RTno is communicating library and framework which allows you to make your embedded device capable of communicating with RT-middleware world. RT-middleware is a platform software to realize Robotic system. In RTM, robots are developed by constructing robotics technologies\' elements (components) named RT-component. Therefore, the RTno helps you to create your own RT-component with your mbed and arduino. To know how to use your RTno device, visit here: http://ysuga.net/robot_e/rtm_e/rtc_e/1065?lang=en To know about RT-middleware and RT-component, visit http://www.openrtm.org
Dependencies: EthernetInterface mbed-rtos
Diff: UART.cpp
- Revision:
- 1:f74116b37bc9
- Parent:
- 0:5f7bc45bc2e8
--- a/UART.cpp Mon Jun 24 06:42:11 2013 +0000 +++ b/UART.cpp Mon Jul 08 07:14:30 2013 +0000 @@ -3,7 +3,7 @@ #include "mbed.h" #include "UART.h" -#define UART_RX_BUFFER_SIZE 128 +#define UART_RX_BUFFER_SIZE 64 static Serial *m_pSerial; unsigned char uart_rx_buffer[UART_RX_BUFFER_SIZE]; @@ -14,8 +14,8 @@ /** * Push data to ring buffer. */ -int uart_rx_buffer_push(unsigned char c) { - uart_rx_buffer[uart_rx_buffer_pointer_tail] = c; +int uart_rx_buffer_push(unsigned char* c) { + uart_rx_buffer[uart_rx_buffer_pointer_tail] = *c; uart_rx_buffer_pointer_tail++; if(uart_rx_buffer_pointer_tail >= UART_RX_BUFFER_SIZE) { uart_rx_buffer_pointer_tail = 0; @@ -23,6 +23,8 @@ return 0; } + + /** * Pop data fron ring buffer */ @@ -44,7 +46,8 @@ } void rx_isr(void) { - uart_rx_buffer_push(m_pSerial->getc()); + int8_t c = m_pSerial->getc(); + uart_rx_buffer_push((uint8_t*)&c); } @@ -77,6 +80,9 @@ } void UART_putc(const char c) { + while(!m_pSerial->writeable()) { + wait_us(100); + } m_pSerial->putc(c); } @@ -86,7 +92,7 @@ } -char UART_getc() +uint8_t UART_getc() { unsigned char c; uart_rx_buffer_pop(&c);