rc

Dependents:   WizFi250_AP_HelloWorld

Fork of mbed-src by DongEun Koak

Files at this revision

API Documentation at this revision

Comitter:
kaizen
Date:
Mon Aug 24 00:12:39 2015 +0000
Parent:
616:bc40b8d2aec4
Commit message:
Added UART_2 of WIZwiki_W7500 for test

Changed in this revision

targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_uart.c Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_uart.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PeripheralNames.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PeripheralPins.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_WIZNET/TARGET_W7500x/serial_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_uart.c	Thu Aug 20 10:45:13 2015 +0100
+++ b/targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_uart.c	Mon Aug 24 00:12:39 2015 +0000
@@ -14,6 +14,7 @@
 
 /* Includes ------------------------------------------------------------------*/
 #include "W7500x.h"
+#include "W7500x_uart.h"
 
 void UART_StructInit(UART_InitTypeDef* UART_InitStruct)
 {
@@ -151,7 +152,6 @@
 /*
 void UART_ClearFlag(UART_TypeDef* UARTx, uint16_t UART_FLAG)
 {
-
 }
 */
 
@@ -207,13 +207,24 @@
 uint32_t S_UART_Init(uint32_t baud)
 {
     uint32_t tmpreg=0x00;
-    uint32_t uartclock = 0x00, integer_baud = 0x00;
+
+    S_UART_SetBaud(baud);
 
-    assert_param(IS_UART_MODE(S_UART_InitStruct->UART_Mode));
+    tmpreg = UART2->CTRL;
+    tmpreg &= ~(S_UART_CTRL_RX_EN | S_UART_CTRL_TX_EN);
+    tmpreg |= (S_UART_CTRL_RX_EN | S_UART_CTRL_TX_EN);
+    UART2->CTRL = tmpreg;
+
+    return 0;
+}
+
+void S_UART_SetBaud(uint32_t baud)
+{
+    uint32_t uartclock = 0x00, integer_baud = 0x00;
 
     if(CRG->FCLK_SSR == CRG_FCLK_SSR_RCLK)
     {
-        uartclock = INTERN_XTAL;  
+        uartclock = INTERN_XTAL;
     }
     else if(CRG->FCLK_SSR == CRG_FCLK_SSR_OCLK)
     {
@@ -226,18 +237,11 @@
 
     integer_baud = (uint32_t)(uartclock / baud);
     UART2->BAUDDIV = integer_baud;
-
-    tmpreg = UART2->CTRL;
-    tmpreg &= ~(S_UART_CTRL_RX_EN | S_UART_CTRL_TX_EN);
-    tmpreg |= (S_UART_CTRL_RX_EN | S_UART_CTRL_TX_EN);
-    UART2->CTRL = tmpreg;
-
-    return 0;
 }
 
 void S_UART_SendData(uint16_t Data)
 {
-    while(UART2->STATE & S_UART_STATE_TX_BUF_FULL); 
+    while(UART2->STATE & S_UART_STATE_TX_BUF_FULL);
     UART2->DATA = Data;
 }
 
@@ -247,13 +251,13 @@
 }
 
 
-FlagStatus S_UART_GetFlagStatus(uint16_t S_UART_FLAG)
+FlagStatus S_UART_GetFlagStatus(uint16_t S_UART_STATE)
 {
     FlagStatus bitstatus = RESET;
 
-    assert_param(IS_S_UART_FLAG(S_UART_FLAG));
+    assert_param(IS_S_UART_STATE(S_UART_STATE));
 
-    if ((UART2->STATE & S_UART_FLAG) != (uint16_t)RESET)
+    if ((UART2->STATE & S_UART_STATE) != (FlagStatus)RESET)
     {
         bitstatus = SET;
     }
@@ -265,28 +269,40 @@
     return bitstatus;
 }
 
+void S_UART_SetCTRL(uint16_t S_UART_CTRL, FunctionalState NewState)
+{
+	if ( NewState != DISABLE )
+	{
+		UART2->CTRL |= S_UART_CTRL;
+	}
+	else
+	{
+		UART2->CTRL &= ~(S_UART_CTRL);
+	}
+}
 
-void S_UART_ITConfig(uint16_t S_UART_IT, FunctionalState NewState)
+
+void S_UART_ITConfig(uint16_t S_UART_CTRL, FunctionalState NewState)
 {
-    assert_param(IS_S_UART_IT_FLAG(S_UART_IT));
+    assert_param(IS_S_UART_CTRL_FLAG(S_UART_CTRL));
 
     if ( NewState != DISABLE )
     {
-        UART2->CTRL |= S_UART_IT;
+        UART2->CTRL |= S_UART_CTRL;
     }
     else
     {
-        UART2->CTRL &= ~(S_UART_IT);
+        UART2->CTRL &= ~(S_UART_CTRL);
     }
 }
 
-ITStatus S_UART_GetITStatus(uint16_t S_UART_IT)
+ITStatus S_UART_GetITStatus(uint16_t S_UART_INTSTATUS)
 {
     ITStatus bitstatus = RESET;
 
-    assert_param(IS_S_UART_IT_FLAG(S_UART_IT));
+    assert_param(IS_S_UART_INTSATUS(S_UART_INTSTATUS));
 
-    if ((UART2->INT.STATUS & (S_UART_IT >> 2)) != (uint16_t) RESET)
+    if ((UART2->INT.STATUS & (S_UART_INTSTATUS)) != (uint16_t) RESET)
     {
         bitstatus = SET;
     }
@@ -298,11 +314,11 @@
     return bitstatus;
 }
 
-void S_UART_ClearITPendingBit(uint16_t S_UART_IT)
+void S_UART_ClearITPendingBit(uint16_t S_UART_INTSTATUS)
 {
-    assert_param(IS_S_UART_IT_FLAG(S_UART_IT));
+    assert_param(IS_S_UART_INTSATUS(S_UART_INTSTATUS));
 
-    UART2->INT.CLEAR |= (S_UART_IT >> 2);
+    UART2->INT.CLEAR |= (S_UART_INTSTATUS);
 }
 
 
@@ -366,5 +382,3 @@
     while( (UART2->STATE & S_UART_STATE_RX_BUF_FULL) == 0 ); 
     return (uint8_t)S_UART_ReceiveData();
 }
-
-
--- a/targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_uart.h	Thu Aug 20 10:45:13 2015 +0100
+++ b/targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_uart.h	Mon Aug 24 00:12:39 2015 +0000
@@ -224,12 +224,32 @@
 /** @addtogroup S_UART_Flags
   * @{
   */
-#define S_UART_FLAG_RXO        ((uint16_t)0x01UL << 3) /*!< RX buffer Overrun   */
-#define S_UART_FLAG_TXO        ((uint16_t)0x01UL << 2) /*!< TX buffer Overrun   */
-#define S_UART_FLAG_RXF        ((uint16_t)0x01UL << 1) /*!< RX buffer Full      */
-#define S_UART_FLAG_TXF        ((uint16_t)0x01UL << 0) /*!< TX buffer Full      */
-#define IS_S_UART_FLAG(FLAG)   (((FLAG) == S_UART_FLAG_RXO) || ((FLAG) == S_UART_FLAG_TXO) || \
-                                ((FLAG) == S_UART_FLAG_RXF) || ((FLAG) == S_UART_FLAG_TXF))
+#define S_UART_STATE_RXO        ((uint16_t)0x01UL << 3) /*!< RX buffer Overrun   */
+#define S_UART_STATE_TXO        ((uint16_t)0x01UL << 2) /*!< TX buffer Overrun   */
+#define S_UART_STATE_RXF        ((uint16_t)0x01UL << 1) /*!< RX buffer Full      */
+#define S_UART_STATE_TXF        ((uint16_t)0x01UL << 0) /*!< TX buffer Full      */
+#define IS_S_UART_STATE(FLAG)   (((FLAG) == S_UART_STATE_RXO) || ((FLAG) == S_UART_STATE_TXO) || \
+                                ((FLAG) == S_UART_STATE_RXF)  || ((FLAG) == S_UART_STATE_TXF))
+/**
+  * @}
+  */
+
+
+/** @addtogroup S_UART_CTRL_Flags
+  * @{
+  */
+
+#define S_UART_CTRL_RXOI        ((uint16_t)0x01UL << 5) /*!< RX overrun interrupt   */
+#define S_UART_CTRL_TXOI        ((uint16_t)0x01UL << 4) /*!< TX overrun interrupt   */
+#define S_UART_CTRL_RXI         ((uint16_t)0x01UL << 3) /*!< RX interrupt           */
+#define S_UART_CTRL_TXI         ((uint16_t)0x01UL << 2) /*!< TX interrupt           */
+#define S_UART_CTRL_RX          ((uint16_t)0x01UL << 1) /*!< RX                      */
+#define S_UART_CTRL_TX          ((uint16_t)0x01UL << 0) /*!< TX                  */
+
+
+#define IS_S_UART_CTRL_FLAG(FLAG)   (((FLAG) == S_UART_CTRL_FLAG_RXOI)  || ((FLAG) == S_UART_CTRL_FLAG_TXOI) || \
+                                     ((FLAG) == S_UART_CTRL_FLAG_RXI)   || ((FLAG) == S_UART_CTRL_FLAG_TXI) || \
+                                     ((FLAG) == S_UART_CTRL_FLAG_RX)    || ((FLAG) == S_UART_CTRL_FLAG_TX))
 /**
   * @}
   */
@@ -239,13 +259,12 @@
   * @{
   */
 
-#define S_UART_IT_FLAG_RXOI        ((uint16_t)0x01UL << 5) /*!< RX overrun interrupt   */
-#define S_UART_IT_FLAG_TXOI        ((uint16_t)0x01UL << 4) /*!< TX overrun interrupt   */
-#define S_UART_IT_FLAG_RXI         ((uint16_t)0x01UL << 3) /*!< RX interrupt           */
-#define S_UART_IT_FLAG_TXI         ((uint16_t)0x01UL << 2) /*!< TX interrupt           */
-#define IS_S_UART_IT_FLAG(FLAG)   (((FLAG) == S_UART_IT_FLAG_RXOI)  || ((FLAG) == S_UART_IT_FLAG_TXOI) || \
-                                   ((FLAG) == S_UART_IT_FLAG_RXI)   || ((FLAG) == S_UART_IT_FLAG_TXI))
-
+#define S_UART_INTSTATUS_RXOI        ((uint16_t)0x01UL << 3) /*!< RX overrun interrupt   */
+#define S_UART_INTSTATUS_TXOI        ((uint16_t)0x01UL << 2) /*!< TX overrun interrupt   */
+#define S_UART_INTSTATUS_RXI         ((uint16_t)0x01UL << 1) /*!< RX interrupt           */
+#define S_UART_INTSTATUS_TXI         ((uint16_t)0x01UL << 0) /*!< TX interrupt           */
+#define IS_S_UART_INTSTATUS(FLAG)   (((FLAG) == S_UART_INTSTATUS_RXOI)  || ((FLAG) == S_UART_INTSTATUS_TXOI) || \
+                                     ((FLAG) == S_UART_INTSTATUS_RXI)   || ((FLAG) == S_UART_INTSTATUS_TXI))
 /**
   * @}
   */
@@ -263,21 +282,26 @@
 ITStatus    UART_GetITStatus        (UART_TypeDef* UARTx, uint16_t UART_IT);
 void        UART_ClearITPendingBit  (UART_TypeDef* UARTx, uint16_t UART_IT);
 
-
-void S_UART_DeInit(void);
-uint32_t S_UART_Init(uint32_t baud);
-void S_UART_SendData(uint16_t Data);
-uint16_t S_UART_ReceiveData(void);
-
-
-
 uint8_t     UartPutc                (UART_TypeDef* UARTx, uint8_t ch);
 void        UartPuts                (UART_TypeDef* UARTx, uint8_t *str);
 uint8_t     UartGetc                (UART_TypeDef* UARTx);
 
-uint8_t S_UartPutc(uint8_t ch);
-void S_UartPuts(uint8_t *str);
-uint8_t S_UartGetc(void);
+void        S_UART_DeInit   (void);
+uint32_t    S_UART_Init     (uint32_t baud);
+void        S_UART_SetBaud  (uint32_t baud);
+void        S_UART_SetCTRL  (uint16_t S_UART_CTRL, FunctionalState NewState);
+void        S_UART_SendData (uint16_t Data);
+uint16_t    S_UART_ReceiveData(void);
+
+uint8_t     S_UartPutc  (uint8_t ch);
+void        S_UartPuts  (uint8_t *str);
+uint8_t     S_UartGetc  (void);
+
+FlagStatus  S_UART_GetFlagStatus    (uint16_t S_UART_STATE);
+void        S_UART_ITConfig         (uint16_t S_UART_CTRL, FunctionalState NewState);
+
+ITStatus    S_UART_GetITStatus      (uint16_t S_UART_IT);
+void        S_UART_ClearITPendingBit(uint16_t S_UART_IT);
 
 
 #ifdef __cplusplus
@@ -286,4 +310,3 @@
 
 
 #endif // __W7500X_UART_H
-
--- a/targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PeripheralNames.h	Thu Aug 20 10:45:13 2015 +0100
+++ b/targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PeripheralNames.h	Mon Aug 24 00:12:39 2015 +0000
@@ -43,7 +43,8 @@
 
 typedef enum {
     UART_0 = (int)W7500x_UART0_BASE,
-    UART_1 = (int)W7500x_UART1_BASE
+    UART_1 = (int)W7500x_UART1_BASE,
+    UART_2 = (int)W7500x_UART2_BASE
 } UARTName;
 
 #define STDIO_UART_TX  PC_2
--- a/targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PeripheralPins.c	Thu Aug 20 10:45:13 2015 +0100
+++ b/targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PeripheralPins.c	Mon Aug 24 00:12:39 2015 +0000
@@ -39,8 +39,6 @@
     {PC_14, ADC_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF3)}, // ADC0_IN1
     {PC_13, ADC_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF3)}, // ADC0_IN2
     {PC_12, ADC_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF3)}, // ADC0_IN3
-    {PC_11, ADC_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF3)}, // ADC0_IN4
-    {PC_10, ADC_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF3)}, // ADC0_IN5
     {PC_9 , ADC_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF3)}, // ADC0_IN6
     {PC_8 , ADC_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF3)}, // ADC0_IN7
     {NC,   NC,    0}
@@ -50,39 +48,46 @@
 //*** SERIAL ***
 const PinMap PinMap_UART_TX[] = {
     {PA_13, UART_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
+    {PB_2,  UART_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF2)},
     {PC_2,  UART_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
+    {PA_9,  UART_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF2)},
+    {PC_10, UART_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
+    {PC_6,  UART_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF2)},
     {NC,    NC,     0}
 };
 
 const PinMap PinMap_UART_RX[] = {
     {PA_14, UART_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
+    {PB_3,  UART_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF2)},
     {PC_3,  UART_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
+    {PA_10, UART_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF2)},
+    {PC_11, UART_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
+    {PC_7,  UART_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF2)},
     {NC,    NC,     0}
 };
 
 //*** I2C ***
 const PinMap PinMap_I2C_SDA[] = {
     {PA_10, I2C_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
-    {PC_9, I2C_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
-    {PC_5, I2C_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
-    {PA_6, I2C_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
+    {PC_9,  I2C_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
+    {PC_5,  I2C_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
+    {PA_6,  I2C_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},    
     {NC,    NC,    0}
 };
 
 const PinMap PinMap_I2C_SCL[] = {
     {PA_9, I2C_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
-    {PC_8, I2C_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
-    {PC_4, I2C_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
-    {PC_5, I2C_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
+    {PC_8, I2C_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},    
+    {PC_4, I2C_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},    
+    {PA_5, I2C_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},    
     {NC,    NC,    0}
 };
 
 //*** SPI ***
-
 const PinMap PinMap_SPI_SCLK[] = {
     {PA_6 , SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
     {PB_1 , SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
-    {PC_12, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
+    {PC_13, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_12, SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {NC   , NC   , 0}
 };
@@ -90,7 +95,7 @@
 const PinMap PinMap_SPI_MOSI[] = {
     {PA_8 , SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
     {PB_3 , SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
-    {PC_10, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
+    {PC_15, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_14, SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {NC   , NC   , 0}
 };
@@ -98,7 +103,7 @@
 const PinMap PinMap_SPI_MISO[] = {
     {PA_7 , SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
     {PB_2 , SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
-    {PC_11, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
+    {PC_14, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_13, SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {NC   , NC   , 0}
 };
@@ -106,25 +111,25 @@
 const PinMap PinMap_SPI_SSEL[] = {
     {PA_5 , SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
     {PB_0 , SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
-    {PC_13, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
+    {PC_12, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_11, SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {NC   , NC   , 0}
 };
 
 const PinMap PinMap_PWM[] = {
-    {PA_0 , PWM_6, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
-    {PA_1 , PWM_7, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
+    {PC_8 , PWM_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
+    {PC_9 , PWM_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
+    {PC_0 , PWM_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
+    {PC_1 , PWM_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
+    {PC_2 , PWM_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
+    {PC_3 , PWM_3, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
+    {PC_4 , PWM_4, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
+    {PC_5 , PWM_5, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
     {PA_5 , PWM_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
+    {PA_6 , PWM_3, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_7 , PWM_4, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_8 , PWM_5, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_9 , PWM_6, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_10, PWM_7, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
-    {PC_0 , PWM_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
-    {PC_2 , PWM_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
-    {PC_4 , PWM_4, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
-    {PC_5 , PWM_5, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
-    {PC_8 , PWM_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
-    {PC_10, PWM_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
-    {NC   , NC   , WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)}
+    {NC   , NC   , 0}
 };
-
--- a/targets/hal/TARGET_WIZNET/TARGET_W7500x/serial_api.c	Thu Aug 20 10:45:13 2015 +0100
+++ b/targets/hal/TARGET_WIZNET/TARGET_W7500x/serial_api.c	Mon Aug 24 00:12:39 2015 +0000
@@ -37,10 +37,11 @@
 #include "pinmap.h"
 #include <string.h>
 #include "PeripheralPins.h"
+#include "W7500x_uart.h"
 
-#define UART_NUM (2)
+#define UART_NUM (3)
 
-static uint32_t serial_irq_ids[UART_NUM] = {0, 0};
+static uint32_t serial_irq_ids[UART_NUM] = {0, 0, 0};
 
 
 static uart_irq_handler irq_handler;
@@ -54,23 +55,46 @@
 
 static void init_uart(serial_t *obj)
 {
-    UART = (UART_TypeDef *)(obj->uart);
-    UART_InitStructure.UART_BaudRate            = obj->baudrate;
-    UART_InitStructure.UART_WordLength          = obj->databits;
-    UART_InitStructure.UART_StopBits            = obj->stopbits;
-    UART_InitStructure.UART_Parity              = obj->parity;
-    UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;
+    if(obj->index == 2)         // For UART2, It is simple UART.
+    {
+        SystemCoreClockUpdate();
+        //S_UART_Init(obj->baudrate);
+        S_UART_SetCTRL((S_UART_CTRL_RX_EN|S_UART_CTRL_TX_EN), DISABLE);
+        S_UART_SetBaud(obj->baudrate);
+
+        if(obj->pin_rx == NC)
+        {
+            S_UART_SetCTRL(S_UART_CTRL_TX_EN, ENABLE);
+        }
+        else if(obj->pin_tx == NC)
+        {
+            S_UART_SetCTRL(S_UART_CTRL_RX_EN, ENABLE);
+        }
+        else
+        {
+            S_UART_SetCTRL((S_UART_CTRL_TX_EN|S_UART_CTRL_RX_EN),ENABLE);
+        }
+    }
+    else                        // For UART0 and UART1.
+    {
+        UART = (UART_TypeDef *)(obj->uart);
+        UART_InitStructure.UART_BaudRate            = obj->baudrate;
+        UART_InitStructure.UART_WordLength          = obj->databits;
+        UART_InitStructure.UART_StopBits            = obj->stopbits;
+        UART_InitStructure.UART_Parity              = obj->parity;
+        UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;
 
 
-    if (obj->pin_rx == NC) {
-        UART_InitStructure.UART_Mode = UART_Mode_Tx;
-    } else if (obj->pin_tx == NC) {
-        UART_InitStructure.UART_Mode = UART_Mode_Rx;
-    } else {
-        UART_InitStructure.UART_Mode = (UART_Mode_Rx | UART_Mode_Tx);
+        if (obj->pin_rx == NC) {
+            UART_InitStructure.UART_Mode = UART_Mode_Tx;
+        } else if (obj->pin_tx == NC) {
+            UART_InitStructure.UART_Mode = UART_Mode_Rx;
+        } else {
+            UART_InitStructure.UART_Mode = (UART_Mode_Rx | UART_Mode_Tx);
+        }
+
+        UART_Init(UART,&UART_InitStructure);
     }
-
-    UART_Init(UART,&UART_InitStructure);
 }
 
 void serial_init(serial_t *obj, PinName tx, PinName rx)
@@ -93,6 +117,10 @@
         obj->index = 1;
     }
 
+    if (obj->uart == UART_2) {
+        obj->index = 2;
+    }
+
     // Configure the UART pins
     pinmap_pinout(tx, PinMap_UART_TX);
     pinmap_pinout(rx, PinMap_UART_RX);
@@ -130,11 +158,8 @@
 
     if (obj->uart == UART_1) {
     }
-
-
-    // Configure GPIOs
-//    pin_function(obj->pin_tx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
-//    pin_function(obj->pin_rx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
+    if (obj->uart == UART_2) {
+    }
 
     serial_irq_ids[obj->index] = 0;
 }
@@ -194,6 +219,20 @@
     }
 }
 
+static void uart2_irq()
+{
+    if(serial_irq_ids[2] != 0){
+        if( S_UART_GetITStatus(S_UART_INTSTATUS_TXI) != RESET ){
+            S_UART_ClearITPendingBit(S_UART_INTSTATUS_TXI);
+            irq_handler(serial_irq_ids[2], TxIrq);
+        }
+        if( S_UART_GetITStatus(S_UART_INTSTATUS_RXI) != RESET ) {
+            S_UART_ClearITPendingBit(S_UART_INTSTATUS_RXI);
+            irq_handler(serial_irq_ids[2], RxIrq);
+        }
+    }
+}
+
 #ifdef __cplusplus
 extern "C"{
 #endif
@@ -206,6 +245,11 @@
 {
     uart_irq(UART_1, 1);
 }
+
+void UART2_Handler()
+{
+    uart2_irq();
+}
 #ifdef __cplusplus
 }
 #endif
@@ -221,28 +265,49 @@
 {
     IRQn_Type irq_n = (IRQn_Type)0;
 
-    UART = (UART_TypeDef *)(obj->uart);
 
-    if (obj->uart == UART_0) {
-        irq_n = UART0_IRQn;
-    }
+    if (obj->uart == UART_2)
+    {
+        irq_n = UART2_IRQn;
 
-    if (obj->uart == UART_1) {
-        irq_n = UART1_IRQn;
+        if (enable){
+            if (irq == RxIrq){
+                S_UART_ITConfig(S_UART_CTRL_RXI,ENABLE);
+            } else {
+                S_UART_ITConfig(S_UART_CTRL_TXI,ENABLE);
+            }
+            NVIC_ClearPendingIRQ(irq_n);
+            NVIC_EnableIRQ(irq_n);
+        } else { // disable
+            S_UART_ITConfig((S_UART_CTRL_RXI|S_UART_CTRL_TXI),DISABLE);
+            NVIC_DisableIRQ(irq_n);
+        }
     }
+    else
+    {
+        UART = (UART_TypeDef *)(obj->uart);
 
-    if (enable) {
-        if (irq == RxIrq) {
-            UART_ITConfig(UART,UART_IT_FLAG_RXI,ENABLE);
-        } else { // TxIrq
-            UART_ITConfig(UART,UART_IT_FLAG_TXI,ENABLE);
+        if (obj->uart == UART_0) {
+            irq_n = UART0_IRQn;
         }
 
-        NVIC_ClearPendingIRQ(irq_n);
-        NVIC_EnableIRQ(irq_n);
-    } else { // disable
-        UART_ITConfig(UART,(UART_IT_FLAG_RXI|UART_IT_FLAG_TXI),DISABLE);
-        NVIC_DisableIRQ(irq_n);
+        if (obj->uart == UART_1) {
+            irq_n = UART1_IRQn;
+        }
+
+        if (enable) {
+            if (irq == RxIrq) {
+                UART_ITConfig(UART,UART_IT_FLAG_RXI,ENABLE);
+            } else { // TxIrq
+                UART_ITConfig(UART,UART_IT_FLAG_TXI,ENABLE);
+            }
+
+            NVIC_ClearPendingIRQ(irq_n);
+            NVIC_EnableIRQ(irq_n);
+        } else { // disable
+            UART_ITConfig(UART,(UART_IT_FLAG_RXI|UART_IT_FLAG_TXI),DISABLE);
+            NVIC_DisableIRQ(irq_n);
+        }
     }
 }
 
@@ -252,36 +317,74 @@
 
 int serial_getc(serial_t *obj)
 {
-    UART_TypeDef *uart = (UART_TypeDef *)(obj->uart);
-//    while(!serial_readable(obj));
-    while(uart->FR & UART_FR_RXFE);
+    if (obj->uart == UART_2)
+    {
+        S_UART_TypeDef *uart = (S_UART_TypeDef *)(obj->uart);
 
-    return (uart->DR & 0xFF);
+        while( (uart->STATE & S_UART_STATE_RX_BUF_FULL) == 0 );
+        return (uint16_t)(uart->DATA);
+    }
+    else
+    {
+        UART_TypeDef *uart = (UART_TypeDef *)(obj->uart);
+        while(uart->FR & UART_FR_RXFE);
+
+        return (uart->DR & 0xFF);
+    }
 }
 
 void serial_putc(serial_t *obj, int c)
 {
-    UART_TypeDef *uart = (UART_TypeDef *)(obj->uart);
+    if (obj->uart == UART_2)
+    {
+        S_UART_TypeDef *uart = (S_UART_TypeDef *)(obj->uart);
 
-    uart->DR = (uint32_t)(c & (uint16_t)0xFF);
-    while(uart->FR & UART_FR_BUSY);
+        while(uart->STATE & S_UART_STATE_TX_BUF_FULL);
+        uart->DATA = (uint32_t)(c & (uint16_t)0xFF);
+    }
+    else
+    {
+        UART_TypeDef *uart = (UART_TypeDef *)(obj->uart);
+
+        uart->DR = (uint32_t)(c & (uint16_t)0xFF);
+        while(uart->FR & UART_FR_BUSY);
+    }
 }
 
 int serial_readable(serial_t *obj)
 {
     int status;
-    UART_TypeDef *uart = (UART_TypeDef *)(obj->uart);
-    // Check if data is received
-    status = ((uart->FR & UART_FR_RXFE) ? 0: 1);
+
+    if (obj->uart == UART_2)
+    {
+        S_UART_TypeDef *uart = (S_UART_TypeDef *)(obj->uart);
+        status = ((uart->STATE & S_UART_STATE_RX_BUF_FULL) ? 1 : 0);
+    }
+    else
+    {
+        UART_TypeDef *uart = (UART_TypeDef *)(obj->uart);
+        // Check if data is received
+        status = ((uart->FR & UART_FR_RXFE) ? 0: 1);
+    }
+
     return status;
 }
 
 int serial_writable(serial_t *obj)
 {
     int status;
-    UART_TypeDef *uart = (UART_TypeDef *)(obj->uart);
-    // Check if data is transmitted
-    status = ((uart->FR & UART_FR_BUSY) ? 0: 1);
+
+    if (obj->uart == UART_2)
+    {
+        S_UART_TypeDef *uart = (S_UART_TypeDef *)(obj->uart);
+        status = ((uart->STATE & S_UART_STATE_TX_BUF_FULL) ? 0 : 1);
+    }
+    else
+    {
+        UART_TypeDef *uart = (UART_TypeDef *)(obj->uart);
+        // Check if data is transmitted
+        status = ((uart->FR & UART_FR_BUSY) ? 0: 1);
+    }
     return status;
 }
 
@@ -307,4 +410,4 @@
     // [TODO]
 }
 
-#endif
+#endif
\ No newline at end of file