Revision 142
changed it so that the cardbox ignores uart rx until it gets a key
trunk/cardbox/serial.c | ||
---|---|---|
55 | 55 |
UCSR0C |= (1<<UCSZ00) | (1<<UCSZ01); |
56 | 56 |
} |
57 | 57 |
|
58 |
// Disables the UART receiver |
|
59 |
void serial_disable_rx (void) { |
|
60 |
UCSR0B &= ~(1<<RXEN0); |
|
61 |
} |
|
62 |
|
|
63 |
// Enables the UART receiver |
|
64 |
void serial_enable_rx(void) { |
|
65 |
UCSR0B |= (1<<RXEN0); |
|
66 |
} |
|
67 |
|
|
58 | 68 |
// uart_putchar - Low-level function which puts a value into the |
59 | 69 |
// Tx buffer for transmission. Automatically injects |
60 | 70 |
// a \r before all \n's |
trunk/cardbox/main.c | ||
---|---|---|
157 | 157 |
start_timer(); |
158 | 158 |
|
159 | 159 |
c = ' '; |
160 |
serial_disable_rx(); |
|
160 | 161 |
while(c ==' ') { |
161 | 162 |
if (seconds > TIMEOUT_SECONDS) { |
162 | 163 |
set_timeout_flag(); |
163 |
serial_putchar(TT_TIMEOUT); |
|
164 |
serial_putchar(TT_TIMEOUT); |
|
165 |
serial_enable_rx(); |
|
164 | 166 |
break; |
165 | 167 |
} |
166 | 168 |
|
167 | 169 |
c = get_button(); |
168 | 170 |
_delay_ms(100); |
169 | 171 |
} |
172 |
serial_enable_rx(); |
|
170 | 173 |
|
171 | 174 |
|
172 | 175 |
if (timeout_flag == 0) { |
... | ... | |
191 | 194 |
case TT_NACK: |
192 | 195 |
PORTC &= ~LED_RED; |
193 | 196 |
break; |
197 |
|
|
198 |
case TT_GET_KEY: |
|
199 |
PORTC &= (~LED_RED & ~LED_YELLOW & ~LED_GREEN); |
|
200 |
break; |
|
194 | 201 |
|
195 | 202 |
default: |
196 | 203 |
PORTC &= (~LED_RED & ~LED_GREEN); |
trunk/cardbox/serial.h | ||
---|---|---|
45 | 45 |
|
46 | 46 |
//serial (serial0) is the ttl serial (wireless) |
47 | 47 |
void serial_init( unsigned int ubrr); |
48 |
void serial_disable_rx(void); |
|
49 |
void serial_enable_rx(void); |
|
48 | 50 |
int serial_putchar(char c); |
49 | 51 |
int serial_getchar(void); |
50 | 52 |
int serial_getchar_nb(void); |
Also available in: Unified diff