comparison comm.c @ 0:c59513fd84fb

Initial commit of STM32 test code.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 03 Oct 2011 21:19:15 +1030
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c59513fd84fb
1 /* Martin Thomas 4/2009, 3/2010 */
2 #include "stm32f10x.h"
3 #include "comm.h"
4
5 #define USARTx USART1
6
7 int
8 comm_test(void) {
9 return (USART_GetFlagStatus(USARTx, USART_FLAG_RXNE) == RESET) ? 0 : 1;
10 }
11
12 char
13 comm_get(void) {
14 while (USART_GetFlagStatus(USARTx, USART_FLAG_RXNE) == RESET)
15 ;
16
17 return (char)USART_ReceiveData(USARTx);
18 }
19
20 void
21 comm_put(char d) {
22 while(USART_GetFlagStatus(USARTx, USART_FLAG_TXE) == RESET)
23 ;
24
25 USART_SendData(USARTx, (uint16_t)d);
26 }
27
28 void
29 comm_puts(const char* s) {
30 char c;
31 while ((c = *s++) != '\0') {
32 comm_put(c);
33 }
34 }
35
36 void
37 comm_init (void) {
38 // already done in main.c
39 }
40
41