diff options
author | Jakob Schlyter <jakob@kirei.se> | 2016-07-16 15:10:05 +0200 |
---|---|---|
committer | Jakob Schlyter <jakob@kirei.se> | 2016-07-16 15:10:05 +0200 |
commit | 2b6a62adaaaf0396fd401d2aef6f45ac1a0da23c (patch) | |
tree | ac9da1f36a92bf615a0735025af43dd683801e44 | |
parent | 82418cd46974ce7d011899db89d7bf97d1a6692f (diff) | |
parent | ec079fc63e74e90fe7a159d2e06a7c4cb17fe6b2 (diff) |
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | tamper.c | 21 |
2 files changed, 20 insertions, 3 deletions
@@ -1,5 +1,5 @@ CC = avr-gcc -CFLAGS = -std=gnu99 -Wpedantic -Wall -Werror -mmcu=avr25 -D__AVR_ATtiny828__ +CFLAGS = -std=gnu99 -Wpedantic -Wall -Werror -mmcu=attiny828 -D__AVR_ATtiny828__ OBJCOPY = avr-objcopy all: tamper.hex @@ -213,18 +213,29 @@ mkm_wipe() spi_setup(1); mkm_grab(); + mkm_chip_select(1); spi_set_operation(SPI_OPERATION_SEQUENCE); + mkm_chip_select(0); + + mkm_chip_select(1); spi_write(SPI_WRITE); spi_write(0); /* Address, high byte. */ spi_write(0); /* Address, low byte. */ for (int i = 0; i < 0x1fff; i++) /* 8192 bytes (64Kbit). */ spi_write(0); mkm_chip_select(0); + mkm_release(); spi_setup(0); AVR_LED_PORT &= ~_BV(AVR_LED_RED_BIT); + + /* Flash blue LED three times to indicate wipe is done */ + for (int x = 0; x < 6; x++) { + AVR_LED_PORT ^= _BV(AVR_LED_BLUE_BIT); + for (int i = 0; i < 3200; i++); + } } static inline void @@ -250,13 +261,19 @@ main() for (int i = 0; i < 16000; i++); AVR_LED_PORT &= ~0x0f; + mkm_release(); + while (1) { if (panic_p()) mkm_wipe(); - if (!panic_p()) - sleep(); + /* Sleep is not working right at the moment (the AVR seems to be reset + when brought out of sleep mode by a press on the panic button). + + if (!panic_p()) + sleep(); + */ } return 0; |