fix LPC812 PWM

Dependents:   IR_LED_Send

Fork of mbed-dev by mbed official

Revision:
124:6a4a5b7d7324
Parent:
0:9b334a45a8ff
--- a/targets/cmsis/TARGET_STM/TARGET_STM32F1/stm32f1xx_hal_uart.c	Thu May 05 21:00:11 2016 +0100
+++ b/targets/cmsis/TARGET_STM/TARGET_STM32F1/stm32f1xx_hal_uart.c	Mon May 09 18:30:12 2016 +0100
@@ -2,8 +2,8 @@
   ******************************************************************************
   * @file    stm32f1xx_hal_uart.c
   * @author  MCD Application Team
-  * @version V1.0.0
-  * @date    15-December-2014
+  * @version V1.0.4
+  * @date    29-April-2016
   * @brief   UART HAL module driver.
   *          This file provides firmware functions to manage the following 
   *          functionalities of the Universal Asynchronous Receiver Transmitter (UART) peripheral:
@@ -127,7 +127,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -209,21 +209,7 @@
         (++) Baud Rate
         (++) Word Length 
         (++) Stop Bit
-        (++) Parity: If the parity is enabled, then the MSB bit of the data written
-             in the data register is transmitted but is changed by the parity bit.
-             Depending on the frame length defined by the M bit (8-bits or 9-bits),
-             the possible UART frame formats are as listed in the following table:
-        (+++)    +-------------------------------------------------------------+     
-        (+++)    |   M bit |  PCE bit  |            UART frame                 |
-        (+++)    |---------------------|---------------------------------------|             
-        (+++)    |    0    |    0      |    | SB | 8 bit data | STB |          |
-        (+++)    |---------|-----------|---------------------------------------|  
-        (+++)    |    0    |    1      |    | SB | 7 bit data | PB | STB |     |
-        (+++)    |---------|-----------|---------------------------------------|  
-        (+++)    |    1    |    0      |    | SB | 9 bit data | STB |          |
-        (+++)    |---------|-----------|---------------------------------------|  
-        (+++)    |    1    |    1      |    | SB | 8 bit data | PB | STB |     |
-        (+++)    +-------------------------------------------------------------+            
+        (++) Parity
         (++) Hardware flow control
         (++) Receiver/transmitter modes
     [..]
@@ -237,6 +223,24 @@
   * @{
   */
 
+/*
+  Additionnal remark: If the parity is enabled, then the MSB bit of the data written
+                      in the data register is transmitted but is changed by the parity bit.
+                      Depending on the frame length defined by the M bit (8-bits or 9-bits),
+                      the possible UART frame formats are as listed in the following table:
+    +-------------------------------------------------------------+
+    |   M bit |  PCE bit  |            UART frame                 |
+    |---------------------|---------------------------------------|
+    |    0    |    0      |    | SB | 8 bit data | STB |          |
+    |---------|-----------|---------------------------------------|
+    |    0    |    1      |    | SB | 7 bit data | PB | STB |     |
+    |---------|-----------|---------------------------------------|
+    |    1    |    0      |    | SB | 9 bit data | STB |          |
+    |---------|-----------|---------------------------------------|
+    |    1    |    1      |    | SB | 8 bit data | PB | STB |     |
+    +-------------------------------------------------------------+
+*/
+
 /**
   * @brief  Initializes the UART mode according to the specified parameters in
   *         the UART_InitTypeDef and create the associated handle.
@@ -269,7 +273,7 @@
   if(huart->State == HAL_UART_STATE_RESET)
   {  
     /* Allocate lock resource and initialize it */
-    huart-> Lock = HAL_UNLOCKED;
+    huart->Lock = HAL_UNLOCKED;
     
     /* Init the low level hardware */
     HAL_UART_MspInit(huart);
@@ -321,6 +325,9 @@
 
   if(huart->State == HAL_UART_STATE_RESET)
   {   
+    /* Allocate lock resource and initialize it */
+    huart->Lock = HAL_UNLOCKED;
+
     /* Init the low level hardware */
     HAL_UART_MspInit(huart);
   }
@@ -380,6 +387,9 @@
   
   if(huart->State == HAL_UART_STATE_RESET)
   {   
+    /* Allocate lock resource and initialize it */
+    huart->Lock = HAL_UNLOCKED;  
+
     /* Init the low level hardware */
     HAL_UART_MspInit(huart);
   }
@@ -445,6 +455,9 @@
 
   if(huart->State == HAL_UART_STATE_RESET)
   {   
+    /* Allocate lock resource and initialize it */
+    huart->Lock = HAL_UNLOCKED;
+
     /* Init the low level hardware */
     HAL_UART_MspInit(huart);
   }
@@ -525,6 +538,8 @@
   */
  __weak void HAL_UART_MspInit(UART_HandleTypeDef *huart)
 {
+  /* Prevent unused argument(s) compilation warning */
+  UNUSED(huart);
   /* NOTE: This function should not be modified, when the callback is needed,
            the HAL_UART_MspInit can be implemented in the user file
    */ 
@@ -538,6 +553,8 @@
   */
  __weak void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
 {
+  /* Prevent unused argument(s) compilation warning */
+  UNUSED(huart);
   /* NOTE: This function should not be modified, when the callback is needed,
            the HAL_UART_MspDeInit can be implemented in the user file
    */ 
@@ -839,9 +856,6 @@
     /* Process Unlocked */
     __HAL_UNLOCK(huart);
 
-    /* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
-    __HAL_UART_ENABLE_IT(huart, UART_IT_ERR);
-
     /* Enable the UART Transmit data register empty Interrupt */
     __HAL_UART_ENABLE_IT(huart, UART_IT_TXE);
     
@@ -1181,8 +1195,6 @@
   /* UART parity error interrupt occurred ------------------------------------*/
   if((tmp_flag != RESET) && (tmp_it_source != RESET))
   { 
-    __HAL_UART_CLEAR_PEFLAG(huart);
-    
     huart->ErrorCode |= HAL_UART_ERROR_PE;
   }
   
@@ -1191,8 +1203,6 @@
   /* UART frame error interrupt occurred -------------------------------------*/
   if((tmp_flag != RESET) && (tmp_it_source != RESET))
   { 
-    __HAL_UART_CLEAR_FEFLAG(huart);
-    
     huart->ErrorCode |= HAL_UART_ERROR_FE;
   }
   
@@ -1200,8 +1210,6 @@
   /* UART noise error interrupt occurred -------------------------------------*/
   if((tmp_flag != RESET) && (tmp_it_source != RESET))
   { 
-    __HAL_UART_CLEAR_NEFLAG(huart);
-    
     huart->ErrorCode |= HAL_UART_ERROR_NE;
   }
   
@@ -1209,8 +1217,6 @@
   /* UART Over-Run interrupt occurred ----------------------------------------*/
   if((tmp_flag != RESET) && (tmp_it_source != RESET))
   { 
-    __HAL_UART_CLEAR_OREFLAG(huart);
-    
     huart->ErrorCode |= HAL_UART_ERROR_ORE;
   }
   
@@ -1240,6 +1246,9 @@
 
   if(huart->ErrorCode != HAL_UART_ERROR_NONE)
   {
+    /* Clear all the error flag at once */
+    __HAL_UART_CLEAR_PEFLAG(huart);
+    
     /* Set the UART state ready to be able to start again the process */
     huart->State = HAL_UART_STATE_READY;
     
@@ -1255,6 +1264,8 @@
   */
  __weak void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
 {
+  /* Prevent unused argument(s) compilation warning */
+  UNUSED(huart);
   /* NOTE: This function should not be modified, when the callback is needed,
            the HAL_UART_TxCpltCallback can be implemented in the user file
    */ 
@@ -1268,6 +1279,8 @@
   */
  __weak void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart)
 {
+  /* Prevent unused argument(s) compilation warning */
+  UNUSED(huart);
   /* NOTE: This function should not be modified, when the callback is needed,
            the HAL_UART_TxHalfCpltCallback can be implemented in the user file
    */ 
@@ -1281,6 +1294,8 @@
   */
 __weak void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
 {
+  /* Prevent unused argument(s) compilation warning */
+  UNUSED(huart);
   /* NOTE: This function should not be modified, when the callback is needed,
            the HAL_UART_RxCpltCallback can be implemented in the user file
    */
@@ -1294,6 +1309,8 @@
   */
 __weak void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart)
 {
+  /* Prevent unused argument(s) compilation warning */
+  UNUSED(huart);
   /* NOTE: This function should not be modified, when the callback is needed,
            the HAL_UART_RxHalfCpltCallback can be implemented in the user file
    */
@@ -1307,6 +1324,8 @@
   */
  __weak void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
 {
+  /* Prevent unused argument(s) compilation warning */
+  UNUSED(huart);
   /* NOTE: This function should not be modified, when the callback is needed,
            the HAL_UART_ErrorCallback can be implemented in the user file
    */ 
@@ -1762,9 +1781,6 @@
   }
   else
   {
-    /* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
-    __HAL_UART_DISABLE_IT(huart, UART_IT_ERR);
-
     huart->State = HAL_UART_STATE_READY;
   }