1
0
Fork 0
mirror of https://codeberg.org/SiB64/blinkenlights.git synced 2026-06-28 16:19:49 +02:00

Compare commits

...

2 commits

Author SHA1 Message Date
Stephan I. Böttcher
51915670eb kennug: -DWDT_TRIGGERED 2025-05-15 13:50:42 +02:00
Stephan I. Böttcher
9a484ba845 reset_avr: reset via gpio17 2025-05-15 13:49:38 +02:00
3 changed files with 44 additions and 6 deletions

View file

@ -74,7 +74,7 @@ lfuse_blink = 0x7a
# [6]: EESAVE = 0 ! (EEPROM not preserved @ chip erase)
# [5]: WDTON = 0 ! (watchdog disabled)
lfuse_kennung = 0x1a
lfuse_kennung = 0x3a
lfuse_bate = 0x1a
pMCU-attiny13a = t13

View file

@ -124,13 +124,11 @@ static struct kennung EEMEM eeprom;
static uint8_t phase;
ISR(PCINT0_vect)
static inline
void shift_phase()
{
static uint8_t position, index;
if (!GetPORT(OUT_PORT))
return;
if (++position >= kennung.length) {
position = 0;
index = 0;
@ -142,6 +140,21 @@ ISR(PCINT0_vect)
phase >>= 1;
}
ISR(PCINT0_vect)
{
if (!GetPORT(OUT_PORT))
return;
shift_phase();
}
#ifdef WDT_TRIGGERED
ISR(WDT_vect)
{
wdt_reset();
shift_phase();
}
#endif
static inline
void init_trig()
{
@ -257,6 +270,20 @@ void uart()
c |= 0x80;
}
static inline
void init_wdt(uint8_t wdt_period)
{
#ifdef WDT_TRIGGERED
uint8_t cr = Bit(WDTIE) | (wdt_period&7) << WDP0 | (wdt_period&8) << (WDP3-3);
__asm__("STS %[CSR], %[CE]" "\n\t"
"STS %[CSR], %[WE]" "\n"
::[CSR] "n" (&WDTCR),
[CE] "r" (Bit(WDCE) | Bit(WDTIE)),
[WE] "r" (cr)
);
#endif
}
int main()
{
eeprom_read_block(&kennung, &eeprom, sizeof(kennung));
@ -265,14 +292,16 @@ int main()
init_timer();
init_trig();
init_wdt(5);
send('x');
set_sleep_mode(SLEEP_MODE_IDLE);
while (1) {
sei();
sleep_mode();
#ifndef WDT_TRIGGERED
wdt_reset();
#endif
if (!tick)
continue;
tick = 0;

9
src/reset_avr.sh Executable file
View file

@ -0,0 +1,9 @@
#! /bin/bash -v
echo 17 > /sys/class/gpio/export || exit 1
sleep 1
echo out > /sys/class/gpio/gpio17/direction || exit 2
echo 0 > /sys/class/gpio/gpio17/value
sleep 1
echo 1 > /sys/class/gpio/gpio17/value
echo 17 > /sys/class/gpio/unexport