mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Revision:
55:3b765ca737a5
Parent:
52:a51c77007319
Child:
56:99eb381a3269
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/serial_api.c	Sat Dec 07 12:45:04 2013 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/serial_api.c	Mon Dec 09 11:15:04 2013 +0000
@@ -182,30 +182,21 @@
  ******************************************************************************/
 
 // not api
-void uart1_irq(void) {
-    USART_TypeDef *usart = (USART_TypeDef *)UART_1;  
-    if (serial_irq_ids[0] != 0) {
-        if (USART_GetITStatus(usart, USART_IT_TXE) != RESET) {
-            irq_handler(serial_irq_ids[0], TxIrq);
+static void uart_irq(USART_TypeDef* usart, int id) {
+    if (serial_irq_ids[id] != 0) {
+        if (USART_GetITStatus(usart, USART_IT_TC) != RESET) {
+            irq_handler(serial_irq_ids[id], TxIrq);
+            USART_ClearITPendingBit(usart, USART_IT_TC);
         }
         if (USART_GetITStatus(usart, USART_IT_RXNE) != RESET) {
-            irq_handler(serial_irq_ids[0], RxIrq);
+            irq_handler(serial_irq_ids[id], RxIrq);
+            USART_ClearITPendingBit(usart, USART_IT_RXNE);
         }
     }
 }
 
-// not api
-void uart2_irq(void) {
-    USART_TypeDef *usart = (USART_TypeDef *)UART_2;  
-    if (serial_irq_ids[1] != 0) {
-        if (USART_GetITStatus(usart, USART_IT_TXE) != RESET) {
-            irq_handler(serial_irq_ids[1], TxIrq);
-        }
-        if (USART_GetITStatus(usart, USART_IT_RXNE) != RESET) {
-            irq_handler(serial_irq_ids[1], RxIrq);
-        }
-    }
-}
+static void uart1_irq(void) {uart_irq((USART_TypeDef*)UART_1, 0);}
+static void uart2_irq(void) {uart_irq((USART_TypeDef*)UART_2, 1);}
 
 void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) {
     irq_handler = handler;
@@ -233,7 +224,7 @@
             USART_ITConfig(usart, USART_IT_RXNE, ENABLE);
         }
         else { // TxIrq
-            USART_ITConfig(usart, USART_IT_TXE, ENABLE);
+            USART_ITConfig(usart, USART_IT_TC, ENABLE);
         }        
         
         NVIC_SetVector(irq_n, vector);