Stefan Schuermans commited on 2012-02-20 16:03:28
Showing 3 changed files, with 25 additions and 2 deletions.
... | ... |
@@ -54,6 +54,7 @@ void delay(void) |
54 | 54 |
int main() |
55 | 55 |
{ |
56 | 56 |
unsigned int i; |
57 |
+ unsigned short chr; |
|
57 | 58 |
unsigned char leds; |
58 | 59 |
|
59 | 60 |
for (i = 0; i < sizeof(data) / sizeof(data[0]); ++i) |
... | ... |
@@ -92,8 +93,13 @@ int main() |
92 | 93 |
leds = 0x11; |
93 | 94 |
while (1) { |
94 | 95 |
#ifdef CFG_UART |
95 |
- if (uart_can_rx()) |
|
96 |
- leds = uart_rx(); |
|
96 |
+ if (uart_can_rx()) { |
|
97 |
+ chr = uart_rx(); |
|
98 |
+ if (uart_is_err(chr)) |
|
99 |
+ leds = 0; |
|
100 |
+ else |
|
101 |
+ leds = chr; |
|
102 |
+ } |
|
97 | 103 |
#endif |
98 | 104 |
leds_set_state(leds); |
99 | 105 |
leds = leds << 1 | leds >> 7; |
... | ... |
@@ -70,3 +70,13 @@ unsigned short uart_rx(void) |
70 | 70 |
return chr; |
71 | 71 |
} |
72 | 72 |
|
73 |
+/** |
|
74 |
+ * @brief determine if character is an error character |
|
75 |
+ * @param[in] chr character to check |
|
76 |
+ * @return if error |
|
77 |
+ */ |
|
78 |
+int uart_is_err(unsigned short chr) |
|
79 |
+{ |
|
80 |
+ return chr >> 15; |
|
81 |
+} |
|
82 |
+ |
... | ... |
@@ -43,5 +43,12 @@ int uart_can_rx(void); |
43 | 43 |
*/ |
44 | 44 |
unsigned short uart_rx(void); |
45 | 45 |
|
46 |
+/** |
|
47 |
+ * @brief determine if character is an error character |
|
48 |
+ * @param[in] chr character to check |
|
49 |
+ * @return if error |
|
50 |
+ */ |
|
51 |
+int uart_is_err(unsigned short chr); |
|
52 |
+ |
|
46 | 53 |
#endif /* #ifndef UART_H */ |
47 | 54 |
|
48 | 55 |