aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--tamper.c21
2 files changed, 20 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index ec919f8..0bed033 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/tamper.c b/tamper.c
index d1d5c04..477198e 100644
--- a/tamper.c
+++ b/tamper.c
@@ -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;