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.
targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_uart.c@585:a1ed5b41f74f, 2015-07-08 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Jul 08 14:45:08 2015 +0100
- Revision:
- 585:a1ed5b41f74f
- Parent:
- 558:0880f51c4036
Synchronized with git revision 7a2b57896e0263b82f31ddc5a0ad2443615db184
Full URL: https://github.com/mbedmicro/mbed/commit/7a2b57896e0263b82f31ddc5a0ad2443615db184/
Add rtc_api.c
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 558:0880f51c4036 | 1 | /** |
mbed_official | 558:0880f51c4036 | 2 | ****************************************************************************** |
mbed_official | 558:0880f51c4036 | 3 | * @file W7500x_uart.c |
mbed_official | 558:0880f51c4036 | 4 | * @author |
mbed_official | 558:0880f51c4036 | 5 | * @version |
mbed_official | 558:0880f51c4036 | 6 | * @date |
mbed_official | 558:0880f51c4036 | 7 | * @brief |
mbed_official | 558:0880f51c4036 | 8 | ****************************************************************************** |
mbed_official | 558:0880f51c4036 | 9 | * @attention |
mbed_official | 558:0880f51c4036 | 10 | * |
mbed_official | 558:0880f51c4036 | 11 | * |
mbed_official | 558:0880f51c4036 | 12 | ****************************************************************************** |
mbed_official | 558:0880f51c4036 | 13 | */ |
mbed_official | 558:0880f51c4036 | 14 | |
mbed_official | 558:0880f51c4036 | 15 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 558:0880f51c4036 | 16 | #include "W7500x.h" |
mbed_official | 558:0880f51c4036 | 17 | |
mbed_official | 558:0880f51c4036 | 18 | void UART_StructInit(UART_InitTypeDef* UART_InitStruct) |
mbed_official | 558:0880f51c4036 | 19 | { |
mbed_official | 558:0880f51c4036 | 20 | /* UART_InitStruct members default value */ |
mbed_official | 558:0880f51c4036 | 21 | UART_InitStruct->UART_BaudRate = 115200; |
mbed_official | 558:0880f51c4036 | 22 | UART_InitStruct->UART_WordLength = UART_WordLength_8b ; |
mbed_official | 558:0880f51c4036 | 23 | UART_InitStruct->UART_StopBits = UART_StopBits_1; |
mbed_official | 558:0880f51c4036 | 24 | UART_InitStruct->UART_Parity = UART_Parity_No ; |
mbed_official | 558:0880f51c4036 | 25 | UART_InitStruct->UART_Mode = UART_Mode_Rx | UART_Mode_Tx; |
mbed_official | 558:0880f51c4036 | 26 | UART_InitStruct->UART_HardwareFlowControl = UART_HardwareFlowControl_None ; |
mbed_official | 558:0880f51c4036 | 27 | } |
mbed_official | 558:0880f51c4036 | 28 | |
mbed_official | 558:0880f51c4036 | 29 | void UART_DeInit(UART_TypeDef *UARTx) |
mbed_official | 558:0880f51c4036 | 30 | { |
mbed_official | 558:0880f51c4036 | 31 | |
mbed_official | 558:0880f51c4036 | 32 | } |
mbed_official | 558:0880f51c4036 | 33 | |
mbed_official | 558:0880f51c4036 | 34 | uint32_t UART_Init(UART_TypeDef *UARTx, UART_InitTypeDef* UART_InitStruct) |
mbed_official | 558:0880f51c4036 | 35 | { |
mbed_official | 558:0880f51c4036 | 36 | float baud_divisor; |
mbed_official | 558:0880f51c4036 | 37 | uint32_t tmpreg=0x00, uartclock=0x00; |
mbed_official | 558:0880f51c4036 | 38 | uint32_t integer_baud = 0x00, fractional_baud = 0x00; |
mbed_official | 558:0880f51c4036 | 39 | |
mbed_official | 558:0880f51c4036 | 40 | assert_param(IS_UART_01_PERIPH(UARTx)); |
mbed_official | 558:0880f51c4036 | 41 | assert_param(IS_UART_WORD_LENGTH(UART_InitStruct->UART_WordLength)); |
mbed_official | 558:0880f51c4036 | 42 | assert_param(IS_UART_PARITY(UART_InitStruct->UART_Parity)); |
mbed_official | 558:0880f51c4036 | 43 | assert_param(IS_UART_STOPBITS(UART_InitStruct->UART_StopBits)); |
mbed_official | 558:0880f51c4036 | 44 | assert_param(IS_UART_HARDWARE_FLOW_CONTROL(UART_InitStruct->UART_HardwareFlowControl)); |
mbed_official | 558:0880f51c4036 | 45 | assert_param(IS_UART_MODE(UART_InitStruct->UART_Mode)); |
mbed_official | 558:0880f51c4036 | 46 | |
mbed_official | 558:0880f51c4036 | 47 | |
mbed_official | 558:0880f51c4036 | 48 | UARTx->CR &= ~(UART_CR_UARTEN); |
mbed_official | 558:0880f51c4036 | 49 | |
mbed_official | 558:0880f51c4036 | 50 | // Set baudrate |
mbed_official | 558:0880f51c4036 | 51 | CRG->UARTCLK_SSR = CRG_UARTCLK_SSR_RCLK; // Set UART Clock using internal Oscilator ( 8MHz ) |
mbed_official | 558:0880f51c4036 | 52 | uartclock = (8000000UL) / (1 << CRG->UARTCLK_PVSR); |
mbed_official | 558:0880f51c4036 | 53 | |
mbed_official | 558:0880f51c4036 | 54 | baud_divisor = ((float)uartclock / (16 * UART_InitStruct->UART_BaudRate)); |
mbed_official | 558:0880f51c4036 | 55 | integer_baud = (uint32_t)baud_divisor; |
mbed_official | 558:0880f51c4036 | 56 | fractional_baud = (uint32_t)((baud_divisor - integer_baud) * 64 + 0.5); |
mbed_official | 558:0880f51c4036 | 57 | |
mbed_official | 558:0880f51c4036 | 58 | UARTx->IBRD = integer_baud; |
mbed_official | 558:0880f51c4036 | 59 | UARTx->FBRD = fractional_baud; |
mbed_official | 558:0880f51c4036 | 60 | |
mbed_official | 558:0880f51c4036 | 61 | |
mbed_official | 558:0880f51c4036 | 62 | tmpreg = UARTx->LCR_H; |
mbed_official | 558:0880f51c4036 | 63 | tmpreg &= ~(0x00EE); |
mbed_official | 558:0880f51c4036 | 64 | tmpreg |= (UART_InitStruct->UART_WordLength | UART_InitStruct->UART_StopBits | UART_InitStruct->UART_Parity); |
mbed_official | 558:0880f51c4036 | 65 | UARTx->LCR_H |= tmpreg; |
mbed_official | 558:0880f51c4036 | 66 | |
mbed_official | 558:0880f51c4036 | 67 | tmpreg = UARTx->CR; |
mbed_official | 558:0880f51c4036 | 68 | tmpreg &= ~(UART_CR_CTSEn | UART_CR_RTSEn | UART_CR_RXE | UART_CR_TXE | UART_CR_UARTEN); |
mbed_official | 558:0880f51c4036 | 69 | tmpreg |= (UART_InitStruct->UART_Mode | UART_InitStruct->UART_HardwareFlowControl); |
mbed_official | 558:0880f51c4036 | 70 | UARTx->CR |= tmpreg; |
mbed_official | 558:0880f51c4036 | 71 | |
mbed_official | 558:0880f51c4036 | 72 | UARTx->CR |= UART_CR_UARTEN; |
mbed_official | 558:0880f51c4036 | 73 | |
mbed_official | 558:0880f51c4036 | 74 | return 0; |
mbed_official | 558:0880f51c4036 | 75 | } |
mbed_official | 558:0880f51c4036 | 76 | |
mbed_official | 558:0880f51c4036 | 77 | |
mbed_official | 558:0880f51c4036 | 78 | void UART_SendData(UART_TypeDef* UARTx, uint16_t Data) |
mbed_official | 558:0880f51c4036 | 79 | { |
mbed_official | 558:0880f51c4036 | 80 | assert_param(IS_UART_01_PERIPH(UARTx)); |
mbed_official | 558:0880f51c4036 | 81 | |
mbed_official | 558:0880f51c4036 | 82 | UARTx->DR = Data; |
mbed_official | 558:0880f51c4036 | 83 | } |
mbed_official | 558:0880f51c4036 | 84 | |
mbed_official | 558:0880f51c4036 | 85 | |
mbed_official | 558:0880f51c4036 | 86 | uint16_t UART_ReceiveData(UART_TypeDef* UARTx) |
mbed_official | 558:0880f51c4036 | 87 | { |
mbed_official | 558:0880f51c4036 | 88 | assert_param(IS_UART_01_PERIPH(UARTx)); |
mbed_official | 558:0880f51c4036 | 89 | |
mbed_official | 558:0880f51c4036 | 90 | return (uint16_t)(UARTx->DR); |
mbed_official | 558:0880f51c4036 | 91 | } |
mbed_official | 558:0880f51c4036 | 92 | |
mbed_official | 558:0880f51c4036 | 93 | |
mbed_official | 558:0880f51c4036 | 94 | void UART_SendBreak(UART_TypeDef* UARTx) |
mbed_official | 558:0880f51c4036 | 95 | { |
mbed_official | 558:0880f51c4036 | 96 | assert_param(IS_UART_01_PERIPH(UARTx)); |
mbed_official | 558:0880f51c4036 | 97 | |
mbed_official | 558:0880f51c4036 | 98 | UARTx->LCR_H |= UART_LCR_H_BRK; |
mbed_official | 558:0880f51c4036 | 99 | } |
mbed_official | 558:0880f51c4036 | 100 | |
mbed_official | 558:0880f51c4036 | 101 | |
mbed_official | 558:0880f51c4036 | 102 | FlagStatus UART_GetRecvStatus(UART_TypeDef* UARTx, uint16_t UART_RECV_STATUS) |
mbed_official | 558:0880f51c4036 | 103 | { |
mbed_official | 558:0880f51c4036 | 104 | FlagStatus bitstatus = RESET; |
mbed_official | 558:0880f51c4036 | 105 | |
mbed_official | 558:0880f51c4036 | 106 | assert_param(IS_UART_01_PERIPH(UARTx)); |
mbed_official | 558:0880f51c4036 | 107 | assert_param(IS_UART_RECV_STATUS(UART_RECV_STATUS)); |
mbed_official | 558:0880f51c4036 | 108 | |
mbed_official | 558:0880f51c4036 | 109 | if( (UARTx->STATUS.RSR & UART_RECV_STATUS) != (uint16_t)RESET) |
mbed_official | 558:0880f51c4036 | 110 | { |
mbed_official | 558:0880f51c4036 | 111 | bitstatus = SET; |
mbed_official | 558:0880f51c4036 | 112 | } |
mbed_official | 558:0880f51c4036 | 113 | else |
mbed_official | 558:0880f51c4036 | 114 | { |
mbed_official | 558:0880f51c4036 | 115 | bitstatus = RESET; |
mbed_official | 558:0880f51c4036 | 116 | } |
mbed_official | 558:0880f51c4036 | 117 | |
mbed_official | 558:0880f51c4036 | 118 | return bitstatus; |
mbed_official | 558:0880f51c4036 | 119 | } |
mbed_official | 558:0880f51c4036 | 120 | |
mbed_official | 558:0880f51c4036 | 121 | |
mbed_official | 558:0880f51c4036 | 122 | void UART_ClearRecvStatus(UART_TypeDef* UARTx, uint16_t UART_RECV_STATUS) |
mbed_official | 558:0880f51c4036 | 123 | { |
mbed_official | 558:0880f51c4036 | 124 | assert_param(IS_UART_01_PERIPH(UARTx)); |
mbed_official | 558:0880f51c4036 | 125 | assert_param(IS_UART_RECV_STATUS(UART_RECV_STATUS)); |
mbed_official | 558:0880f51c4036 | 126 | |
mbed_official | 558:0880f51c4036 | 127 | UARTx->STATUS.ECR = (uint16_t)UART_RECV_STATUS; |
mbed_official | 558:0880f51c4036 | 128 | } |
mbed_official | 558:0880f51c4036 | 129 | |
mbed_official | 558:0880f51c4036 | 130 | |
mbed_official | 558:0880f51c4036 | 131 | FlagStatus UART_GetFlagStatus(UART_TypeDef* UARTx, uint16_t UART_FLAG) |
mbed_official | 558:0880f51c4036 | 132 | { |
mbed_official | 558:0880f51c4036 | 133 | FlagStatus bitstatus = RESET; |
mbed_official | 558:0880f51c4036 | 134 | |
mbed_official | 558:0880f51c4036 | 135 | assert_param(IS_UART_01_PERIPH(UARTx)); |
mbed_official | 558:0880f51c4036 | 136 | assert_param(IS_UART_FLAG(UART_FLAG)); |
mbed_official | 558:0880f51c4036 | 137 | |
mbed_official | 558:0880f51c4036 | 138 | if ((UARTx->FR & UART_FLAG) != (uint16_t)RESET) |
mbed_official | 558:0880f51c4036 | 139 | { |
mbed_official | 558:0880f51c4036 | 140 | bitstatus = SET; |
mbed_official | 558:0880f51c4036 | 141 | } |
mbed_official | 558:0880f51c4036 | 142 | else |
mbed_official | 558:0880f51c4036 | 143 | { |
mbed_official | 558:0880f51c4036 | 144 | bitstatus = RESET; |
mbed_official | 558:0880f51c4036 | 145 | } |
mbed_official | 558:0880f51c4036 | 146 | |
mbed_official | 558:0880f51c4036 | 147 | return bitstatus; |
mbed_official | 558:0880f51c4036 | 148 | |
mbed_official | 558:0880f51c4036 | 149 | } |
mbed_official | 558:0880f51c4036 | 150 | |
mbed_official | 558:0880f51c4036 | 151 | /* |
mbed_official | 558:0880f51c4036 | 152 | void UART_ClearFlag(UART_TypeDef* UARTx, uint16_t UART_FLAG) |
mbed_official | 558:0880f51c4036 | 153 | { |
mbed_official | 558:0880f51c4036 | 154 | |
mbed_official | 558:0880f51c4036 | 155 | } |
mbed_official | 558:0880f51c4036 | 156 | */ |
mbed_official | 558:0880f51c4036 | 157 | |
mbed_official | 558:0880f51c4036 | 158 | void UART_ITConfig(UART_TypeDef* UARTx, uint16_t UART_IT, FunctionalState NewState) |
mbed_official | 558:0880f51c4036 | 159 | { |
mbed_official | 558:0880f51c4036 | 160 | assert_param(IS_UART_01_PERIPH(UARTx)); |
mbed_official | 558:0880f51c4036 | 161 | assert_param(IS_UART_IT_FLAG(UART_IT)); |
mbed_official | 558:0880f51c4036 | 162 | |
mbed_official | 558:0880f51c4036 | 163 | if ( NewState != DISABLE ) |
mbed_official | 558:0880f51c4036 | 164 | { |
mbed_official | 558:0880f51c4036 | 165 | UARTx->IMSC |= UART_IT; |
mbed_official | 558:0880f51c4036 | 166 | } |
mbed_official | 558:0880f51c4036 | 167 | else |
mbed_official | 558:0880f51c4036 | 168 | { |
mbed_official | 558:0880f51c4036 | 169 | UARTx->ICR |= UART_IT; |
mbed_official | 558:0880f51c4036 | 170 | } |
mbed_official | 558:0880f51c4036 | 171 | } |
mbed_official | 558:0880f51c4036 | 172 | |
mbed_official | 558:0880f51c4036 | 173 | |
mbed_official | 558:0880f51c4036 | 174 | ITStatus UART_GetITStatus(UART_TypeDef* UARTx, uint16_t UART_IT) |
mbed_official | 558:0880f51c4036 | 175 | { |
mbed_official | 558:0880f51c4036 | 176 | ITStatus bitstatus = RESET; |
mbed_official | 558:0880f51c4036 | 177 | |
mbed_official | 558:0880f51c4036 | 178 | assert_param(IS_UART_01_PERIPH(UARTx)); |
mbed_official | 558:0880f51c4036 | 179 | assert_param(IS_UART_IT_FLAG(UART_IT)); |
mbed_official | 558:0880f51c4036 | 180 | |
mbed_official | 558:0880f51c4036 | 181 | if ((UARTx->MIS & UART_IT) != (uint16_t)RESET) |
mbed_official | 558:0880f51c4036 | 182 | { |
mbed_official | 558:0880f51c4036 | 183 | bitstatus = SET; |
mbed_official | 558:0880f51c4036 | 184 | } |
mbed_official | 558:0880f51c4036 | 185 | else |
mbed_official | 558:0880f51c4036 | 186 | { |
mbed_official | 558:0880f51c4036 | 187 | bitstatus = RESET; |
mbed_official | 558:0880f51c4036 | 188 | } |
mbed_official | 558:0880f51c4036 | 189 | |
mbed_official | 558:0880f51c4036 | 190 | return bitstatus; |
mbed_official | 558:0880f51c4036 | 191 | } |
mbed_official | 558:0880f51c4036 | 192 | |
mbed_official | 558:0880f51c4036 | 193 | void UART_ClearITPendingBit(UART_TypeDef* UARTx, uint16_t UART_IT) |
mbed_official | 558:0880f51c4036 | 194 | { |
mbed_official | 558:0880f51c4036 | 195 | assert_param(IS_UART_01_PERIPH(UARTx)); |
mbed_official | 558:0880f51c4036 | 196 | assert_param(IS_UART_IT_FLAG(UART_IT)); |
mbed_official | 558:0880f51c4036 | 197 | |
mbed_official | 558:0880f51c4036 | 198 | UARTx->ICR |= UART_IT; |
mbed_official | 558:0880f51c4036 | 199 | } |
mbed_official | 558:0880f51c4036 | 200 | |
mbed_official | 558:0880f51c4036 | 201 | |
mbed_official | 558:0880f51c4036 | 202 | void S_UART_DeInit() |
mbed_official | 558:0880f51c4036 | 203 | { |
mbed_official | 558:0880f51c4036 | 204 | |
mbed_official | 558:0880f51c4036 | 205 | } |
mbed_official | 558:0880f51c4036 | 206 | |
mbed_official | 558:0880f51c4036 | 207 | uint32_t S_UART_Init(uint32_t baud) |
mbed_official | 558:0880f51c4036 | 208 | { |
mbed_official | 558:0880f51c4036 | 209 | uint32_t tmpreg=0x00; |
mbed_official | 558:0880f51c4036 | 210 | uint32_t uartclock = 0x00, integer_baud = 0x00; |
mbed_official | 558:0880f51c4036 | 211 | |
mbed_official | 558:0880f51c4036 | 212 | assert_param(IS_UART_MODE(S_UART_InitStruct->UART_Mode)); |
mbed_official | 558:0880f51c4036 | 213 | |
mbed_official | 558:0880f51c4036 | 214 | if(CRG->FCLK_SSR == CRG_FCLK_SSR_RCLK) |
mbed_official | 558:0880f51c4036 | 215 | { |
mbed_official | 558:0880f51c4036 | 216 | uartclock = INTERN_XTAL; |
mbed_official | 558:0880f51c4036 | 217 | } |
mbed_official | 558:0880f51c4036 | 218 | else if(CRG->FCLK_SSR == CRG_FCLK_SSR_OCLK) |
mbed_official | 558:0880f51c4036 | 219 | { |
mbed_official | 558:0880f51c4036 | 220 | uartclock = EXTERN_XTAL; |
mbed_official | 558:0880f51c4036 | 221 | } |
mbed_official | 558:0880f51c4036 | 222 | else |
mbed_official | 558:0880f51c4036 | 223 | { |
mbed_official | 558:0880f51c4036 | 224 | uartclock = GetSystemClock(); |
mbed_official | 558:0880f51c4036 | 225 | } |
mbed_official | 558:0880f51c4036 | 226 | |
mbed_official | 558:0880f51c4036 | 227 | integer_baud = (uint32_t)(uartclock / baud); |
mbed_official | 558:0880f51c4036 | 228 | UART2->BAUDDIV = integer_baud; |
mbed_official | 558:0880f51c4036 | 229 | |
mbed_official | 558:0880f51c4036 | 230 | tmpreg = UART2->CTRL; |
mbed_official | 558:0880f51c4036 | 231 | tmpreg &= ~(S_UART_CTRL_RX_EN | S_UART_CTRL_TX_EN); |
mbed_official | 558:0880f51c4036 | 232 | tmpreg |= (S_UART_CTRL_RX_EN | S_UART_CTRL_TX_EN); |
mbed_official | 558:0880f51c4036 | 233 | UART2->CTRL = tmpreg; |
mbed_official | 558:0880f51c4036 | 234 | |
mbed_official | 558:0880f51c4036 | 235 | return 0; |
mbed_official | 558:0880f51c4036 | 236 | } |
mbed_official | 558:0880f51c4036 | 237 | |
mbed_official | 558:0880f51c4036 | 238 | void S_UART_SendData(uint16_t Data) |
mbed_official | 558:0880f51c4036 | 239 | { |
mbed_official | 558:0880f51c4036 | 240 | while(UART2->STATE & S_UART_STATE_TX_BUF_FULL); |
mbed_official | 558:0880f51c4036 | 241 | UART2->DATA = Data; |
mbed_official | 558:0880f51c4036 | 242 | } |
mbed_official | 558:0880f51c4036 | 243 | |
mbed_official | 558:0880f51c4036 | 244 | uint16_t S_UART_ReceiveData() |
mbed_official | 558:0880f51c4036 | 245 | { |
mbed_official | 558:0880f51c4036 | 246 | return (uint16_t)(UART2->DATA); |
mbed_official | 558:0880f51c4036 | 247 | } |
mbed_official | 558:0880f51c4036 | 248 | |
mbed_official | 558:0880f51c4036 | 249 | |
mbed_official | 558:0880f51c4036 | 250 | FlagStatus S_UART_GetFlagStatus(uint16_t S_UART_FLAG) |
mbed_official | 558:0880f51c4036 | 251 | { |
mbed_official | 558:0880f51c4036 | 252 | FlagStatus bitstatus = RESET; |
mbed_official | 558:0880f51c4036 | 253 | |
mbed_official | 558:0880f51c4036 | 254 | assert_param(IS_S_UART_FLAG(S_UART_FLAG)); |
mbed_official | 558:0880f51c4036 | 255 | |
mbed_official | 558:0880f51c4036 | 256 | if ((UART2->STATE & S_UART_FLAG) != (uint16_t)RESET) |
mbed_official | 558:0880f51c4036 | 257 | { |
mbed_official | 558:0880f51c4036 | 258 | bitstatus = SET; |
mbed_official | 558:0880f51c4036 | 259 | } |
mbed_official | 558:0880f51c4036 | 260 | else |
mbed_official | 558:0880f51c4036 | 261 | { |
mbed_official | 558:0880f51c4036 | 262 | bitstatus = RESET; |
mbed_official | 558:0880f51c4036 | 263 | } |
mbed_official | 558:0880f51c4036 | 264 | |
mbed_official | 558:0880f51c4036 | 265 | return bitstatus; |
mbed_official | 558:0880f51c4036 | 266 | } |
mbed_official | 558:0880f51c4036 | 267 | |
mbed_official | 558:0880f51c4036 | 268 | |
mbed_official | 558:0880f51c4036 | 269 | void S_UART_ITConfig(uint16_t S_UART_IT, FunctionalState NewState) |
mbed_official | 558:0880f51c4036 | 270 | { |
mbed_official | 558:0880f51c4036 | 271 | assert_param(IS_S_UART_IT_FLAG(S_UART_IT)); |
mbed_official | 558:0880f51c4036 | 272 | |
mbed_official | 558:0880f51c4036 | 273 | if ( NewState != DISABLE ) |
mbed_official | 558:0880f51c4036 | 274 | { |
mbed_official | 558:0880f51c4036 | 275 | UART2->CTRL |= S_UART_IT; |
mbed_official | 558:0880f51c4036 | 276 | } |
mbed_official | 558:0880f51c4036 | 277 | else |
mbed_official | 558:0880f51c4036 | 278 | { |
mbed_official | 558:0880f51c4036 | 279 | UART2->CTRL &= ~(S_UART_IT); |
mbed_official | 558:0880f51c4036 | 280 | } |
mbed_official | 558:0880f51c4036 | 281 | } |
mbed_official | 558:0880f51c4036 | 282 | |
mbed_official | 558:0880f51c4036 | 283 | ITStatus S_UART_GetITStatus(uint16_t S_UART_IT) |
mbed_official | 558:0880f51c4036 | 284 | { |
mbed_official | 558:0880f51c4036 | 285 | ITStatus bitstatus = RESET; |
mbed_official | 558:0880f51c4036 | 286 | |
mbed_official | 558:0880f51c4036 | 287 | assert_param(IS_S_UART_IT_FLAG(S_UART_IT)); |
mbed_official | 558:0880f51c4036 | 288 | |
mbed_official | 558:0880f51c4036 | 289 | if ((UART2->INT.STATUS & (S_UART_IT >> 2)) != (uint16_t) RESET) |
mbed_official | 558:0880f51c4036 | 290 | { |
mbed_official | 558:0880f51c4036 | 291 | bitstatus = SET; |
mbed_official | 558:0880f51c4036 | 292 | } |
mbed_official | 558:0880f51c4036 | 293 | else |
mbed_official | 558:0880f51c4036 | 294 | { |
mbed_official | 558:0880f51c4036 | 295 | bitstatus = RESET; |
mbed_official | 558:0880f51c4036 | 296 | } |
mbed_official | 558:0880f51c4036 | 297 | |
mbed_official | 558:0880f51c4036 | 298 | return bitstatus; |
mbed_official | 558:0880f51c4036 | 299 | } |
mbed_official | 558:0880f51c4036 | 300 | |
mbed_official | 558:0880f51c4036 | 301 | void S_UART_ClearITPendingBit(uint16_t S_UART_IT) |
mbed_official | 558:0880f51c4036 | 302 | { |
mbed_official | 558:0880f51c4036 | 303 | assert_param(IS_S_UART_IT_FLAG(S_UART_IT)); |
mbed_official | 558:0880f51c4036 | 304 | |
mbed_official | 558:0880f51c4036 | 305 | UART2->INT.CLEAR |= (S_UART_IT >> 2); |
mbed_official | 558:0880f51c4036 | 306 | } |
mbed_official | 558:0880f51c4036 | 307 | |
mbed_official | 558:0880f51c4036 | 308 | |
mbed_official | 558:0880f51c4036 | 309 | /**************************************************/ |
mbed_official | 558:0880f51c4036 | 310 | // It will be moved to application board's driver */ |
mbed_official | 558:0880f51c4036 | 311 | /**************************************************/ |
mbed_official | 558:0880f51c4036 | 312 | uint8_t UartPutc(UART_TypeDef* UARTx, uint8_t ch) |
mbed_official | 558:0880f51c4036 | 313 | { |
mbed_official | 558:0880f51c4036 | 314 | UART_SendData(UARTx,ch); |
mbed_official | 558:0880f51c4036 | 315 | |
mbed_official | 558:0880f51c4036 | 316 | while(UARTx->FR & UART_FR_BUSY); |
mbed_official | 558:0880f51c4036 | 317 | |
mbed_official | 558:0880f51c4036 | 318 | return (ch); |
mbed_official | 558:0880f51c4036 | 319 | } |
mbed_official | 558:0880f51c4036 | 320 | |
mbed_official | 558:0880f51c4036 | 321 | void UartPuts(UART_TypeDef* UARTx, uint8_t *str) |
mbed_official | 558:0880f51c4036 | 322 | { |
mbed_official | 558:0880f51c4036 | 323 | uint8_t ch; |
mbed_official | 558:0880f51c4036 | 324 | |
mbed_official | 558:0880f51c4036 | 325 | do{ |
mbed_official | 558:0880f51c4036 | 326 | ch = *str; |
mbed_official | 558:0880f51c4036 | 327 | if(ch != (uint8_t)0x0) |
mbed_official | 558:0880f51c4036 | 328 | { |
mbed_official | 558:0880f51c4036 | 329 | UartPutc(UARTx, ch); |
mbed_official | 558:0880f51c4036 | 330 | } |
mbed_official | 558:0880f51c4036 | 331 | *str++; |
mbed_official | 558:0880f51c4036 | 332 | }while(ch != 0); |
mbed_official | 558:0880f51c4036 | 333 | } |
mbed_official | 558:0880f51c4036 | 334 | |
mbed_official | 558:0880f51c4036 | 335 | uint8_t UartGetc(UART_TypeDef* UARTx) |
mbed_official | 558:0880f51c4036 | 336 | { |
mbed_official | 558:0880f51c4036 | 337 | while(UARTx->FR & UART_FR_RXFE); |
mbed_official | 558:0880f51c4036 | 338 | |
mbed_official | 558:0880f51c4036 | 339 | return (UARTx->DR & 0xFF); |
mbed_official | 558:0880f51c4036 | 340 | } |
mbed_official | 558:0880f51c4036 | 341 | |
mbed_official | 558:0880f51c4036 | 342 | |
mbed_official | 558:0880f51c4036 | 343 | uint8_t S_UartPutc(uint8_t ch) |
mbed_official | 558:0880f51c4036 | 344 | { |
mbed_official | 558:0880f51c4036 | 345 | S_UART_SendData(ch); |
mbed_official | 558:0880f51c4036 | 346 | |
mbed_official | 558:0880f51c4036 | 347 | return (ch); |
mbed_official | 558:0880f51c4036 | 348 | } |
mbed_official | 558:0880f51c4036 | 349 | |
mbed_official | 558:0880f51c4036 | 350 | void S_UartPuts(uint8_t *str) |
mbed_official | 558:0880f51c4036 | 351 | { |
mbed_official | 558:0880f51c4036 | 352 | uint8_t ch; |
mbed_official | 558:0880f51c4036 | 353 | |
mbed_official | 558:0880f51c4036 | 354 | do{ |
mbed_official | 558:0880f51c4036 | 355 | ch = *str; |
mbed_official | 558:0880f51c4036 | 356 | if(ch != (uint8_t)0x0) |
mbed_official | 558:0880f51c4036 | 357 | { |
mbed_official | 558:0880f51c4036 | 358 | S_UART_SendData(ch); |
mbed_official | 558:0880f51c4036 | 359 | } |
mbed_official | 558:0880f51c4036 | 360 | *str++; |
mbed_official | 558:0880f51c4036 | 361 | }while(ch != 0); |
mbed_official | 558:0880f51c4036 | 362 | } |
mbed_official | 558:0880f51c4036 | 363 | |
mbed_official | 558:0880f51c4036 | 364 | uint8_t S_UartGetc() |
mbed_official | 558:0880f51c4036 | 365 | { |
mbed_official | 558:0880f51c4036 | 366 | while( (UART2->STATE & S_UART_STATE_RX_BUF_FULL) == 0 ); |
mbed_official | 558:0880f51c4036 | 367 | return (uint8_t)S_UART_ReceiveData(); |
mbed_official | 558:0880f51c4036 | 368 | } |
mbed_official | 558:0880f51c4036 | 369 | |
mbed_official | 558:0880f51c4036 | 370 |