Permalink
Browse files

tweak LEDs; lock both halves after a factory reset

  • Loading branch information...
1 parent 5effa08 commit a61813ba68598a711dcc22abe8ae7e03ae145fb1 @phooky committed Feb 26, 2014
Showing with 11 additions and 3 deletions.
  1. +2 −2 code/SnapPadv1/leds.c
  2. +8 −1 code/SnapPadv1/main.c
  3. +1 −0 code/SnapPadv1/uarts.c
@@ -34,7 +34,7 @@ void leds_init() {
P6OUT |= 1<<3; // pull resistor is high
P6REN |= 1<<3; // turn on pull up
// Set up blink timer
- TA0CCR0 = 31250; // Count up to 1/4 second
+ TA0CCR0 = 15625; // Count up to 1/8 second
TA0CCTL0 = 0x10; // Enable counter interrupts, bit 4=1
TA0EX0 = 0x07; // Additional /8
TA0CTL = TASSEL_1 | MC_1 | ID1 | ID0; // Clock SMCLK, /8, upcount mode
@@ -81,7 +81,7 @@ void wait_for_confirm() {
}
inline bool is_on(uint8_t mode, uint8_t phase) {
- return (mode & phase) != 0;
+ return (mode & (1<<phase)) != 0;
}
#pragma vector=TIMER0_A0_VECTOR
@@ -88,14 +88,21 @@ void main (void)
if (button_pressed) {
// Don't bother entering the main loop; go directly to reset confirmation mode
uint8_t i;
+ // Alternating side slow blink: confirm reset
for (i = 0; i < LED_COUNT; i++) leds_set_led(i,LED_SLOW_0);
uart_factory_reset_confirm();
+ // Alternating leds on board: reset in process
for (i = 0; i < LED_COUNT; i++) leds_set_led(i,(i%2 == 0)?LED_FAST_0:LED_FAST_1);
otp_factory_reset();
+ // Lights off: reset done
for (i = 0; i < LED_COUNT; i++) leds_set_led(i,LED_OFF);
- } else {
+ while (1){} // Loop forever
}
}
+ if (cs != CS_NOT_CONNECTED) {
+ // Go ahead to attract mode
+ leds_set_larson();
+ }
while (1) // main loop
{
@@ -188,6 +188,7 @@ void uart_process() {
for (i = 0; i < LED_COUNT; i++) leds_set_led(i,(i%2 == 0)?LED_FAST_1:LED_FAST_0);
otp_factory_reset();
for (i = 0; i < LED_COUNT; i++) leds_set_led(i,LED_OFF);
+ while(1){} // Loop forever
}
}
}

0 comments on commit a61813b

Please sign in to comment.