| BlueNRG-1 Peripherals drivers APIs

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

BlueNRG1_uart.h
Go to the documentation of this file.
1
23 /* Define to prevent recursive inclusion -------------------------------------*/
24 #ifndef BLUENRG1_UART_H
25 #define BLUENRG1_UART_H
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /* Includes ------------------------------------------------------------------*/
32 #include "BlueNRG1.h"
33
49 typedef struct
50 {
51 uint32_t UART_BaudRate;
53 uint8_t UART_WordLengthTransmit;
56 uint8_t UART_WordLengthReceive;
59 uint8_t UART_StopBits;
62 uint8_t UART_Parity;
65 uint8_t UART_Mode;
68 uint8_t UART_HardwareFlowControl;
72 FunctionalState UART_FifoEnable;
74 } UART_InitType;
75
76
89 #define UART_WordLength_5b ((uint8_t)0)
90 #define UART_WordLength_6b ((uint8_t)1)
91 #define UART_WordLength_7b ((uint8_t)2)
92 #define UART_WordLength_8b ((uint8_t)3)
94 /* This macro checks if LENGTH is a valid UART word length value */
95 #define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WordLength_5b) || \
96 ((LENGTH) == UART_WordLength_6b) || \
97 ((LENGTH) == UART_WordLength_7b) || \
98 ((LENGTH) == UART_WordLength_8b))
99
107 #define UART_StopBits_1 ((uint8_t)0)
108 #define UART_StopBits_2 ((uint8_t)1)
110 /* This macro checks if STOPBITS is a valid UART stop bits value */
111 #define IS_UART_STOPBITS(STOPBITS) (((STOPBITS) == UART_StopBits_1) || \
112 ((STOPBITS) == UART_StopBits_2))
113
121 #define UART_Parity_No ((uint8_t)0)
122 #define UART_Parity_Even ((uint8_t)1)
123 #define UART_Parity_Odd ((uint8_t)2)
125 /* This macro checks if PARITY is a valid UART parity value */
126 #define IS_UART_PARITY(PARITY) (((PARITY) == UART_Parity_No) || \
127 ((PARITY) == UART_Parity_Even) || \
128 ((PARITY) == UART_Parity_Odd))
129
137 #define UART_Mode_Rx ((uint8_t)0x01)
138 #define UART_Mode_Tx ((uint8_t)0x02)
140 /* This macro checks if MODE is a valid UART mode value */
141 #define IS_UART_MODE(MODE) ( (MODE)<= 3)
142
150 #define UART_HardwareFlowControl_None ((uint8_t)0x00)
151 #define UART_HardwareFlowControl_RTS ((uint8_t)0x01)
152 #define UART_HardwareFlowControl_CTS ((uint8_t)0x02)
153 #define UART_HardwareFlowControl_RTS_CTS ((uint8_t)0x03)
155 /* This macro checks if CONTROL is a valid UART hardware flow control value */
156 #define IS_UART_HW_FLOW_CONTROL(CONTROL) ( (CONTROL) <= 3 )
157
167 #define UART_IT_TXFE ((uint16_t)0x1000)
168 #define UART_IT_XO ((uint16_t)0x0800)
169 #define UART_IT_OE ((uint16_t)0x0400)
170 #define UART_IT_BE ((uint16_t)0x0200)
171 #define UART_IT_PE ((uint16_t)0x0100)
172 #define UART_IT_FE ((uint16_t)0x0080)
173 #define UART_IT_RT ((uint16_t)0x0040)
174 #define UART_IT_TX ((uint16_t)0x0020)
175 #define UART_IT_RX ((uint16_t)0x0010)
176 #define UART_IT_CTS ((uint16_t)0x0002)
178 /* This macro checks if IT is a valid combination of UART interrupt value */
179 #define IS_UART_CONFIG_IT(IT) ((((IT) & (uint16_t)~0x1FF2) == 0x00) && ((IT) != (uint16_t)0x0000))
180
181
182
192 #define UART_FLAG_CTS ((uint32_t)0x00000001)
193 #define UART_FLAG_BUSY ((uint32_t)0x00000008)
194 #define UART_FLAG_RXFE ((uint32_t)0x00000010)
195 #define UART_FLAG_TXFF ((uint32_t)0x00000020)
196 #define UART_FLAG_RXFF ((uint32_t)0x00000040)
197 #define UART_FLAG_TXFE ((uint32_t)0x00000080)
199 #define UART_FLAG_FE ((uint32_t)0x80000001)
200 #define UART_FLAG_PE ((uint32_t)0x80000002)
201 #define UART_FLAG_BE ((uint32_t)0x80000004)
202 #define UART_FLAG_OE ((uint32_t)0x80000008)
204 /* This macro checks if FLAG is a valid UART flag */
205 #define IS_UART_FLAG(FLAG) (((FLAG) == UART_FLAG_CTS) || ((FLAG) == UART_FLAG_BUSY) || \
206 ((FLAG) == UART_FLAG_RXFE) || ((FLAG) == UART_FLAG_TXFF) || \
207 ((FLAG) == UART_FLAG_RXFF) || ((FLAG) == UART_FLAG_TXFE) || \
208 ((FLAG) == UART_FLAG_OE) || ((FLAG) == UART_FLAG_FE) || \
209 ((FLAG) == UART_FLAG_PE) || ((FLAG) == UART_FLAG_BE) )
210
211 /* This macro checks if FLAG is a valid UART clearable flag */
212 #define IS_UART_CLEAR_FLAG(FLAG) (((FLAG) == UART_FLAG_FE) || ((FLAG) == UART_FLAG_PE) || \
213 ((FLAG) == UART_FLAG_BE) || ((FLAG) == UART_FLAG_OE))
214
215 /* This macro checks if BAUDRATE is a valid UART baudrate */
216 #define IS_UART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) <= 1000000))
217
218 /* This macro checks if DATA is a valid UART data */
219 #define IS_UART_DATA(DATA) ((DATA) <= 0x1FF)
220
229 #define FIFO_LEV_1_8 ((uint8_t)0)
230 #define FIFO_LEV_1_4 ((uint8_t)1)
231 #define FIFO_LEV_1_2 ((uint8_t)2)
232 #define FIFO_LEV_3_4 ((uint8_t)3)
233 #define FIFO_LEV_7_8 ((uint8_t)4)
235 /* This macro checks if TX_FIFO_LEV is a valid Tx FIFO level */
236 #define IS_FIFO_LEV(FIFO_LEV) ( ((FIFO_LEV) == FIFO_LEV_1_8) || \
237 ((FIFO_LEV) == FIFO_LEV_1_4) || \
238 ((FIFO_LEV) == FIFO_LEV_1_2) || \
239 ((FIFO_LEV) == FIFO_LEV_3_4) || \
240 ((FIFO_LEV) == FIFO_LEV_7_8))
241
249 #define NO_SW_FLOW_CTRL ((uint8_t)0)
250 #define SW_FLOW_CTRL_XON1_XOFF1 ((uint8_t)1)
251 #define SW_FLOW_CTRL_XON2_XOFF2 ((uint8_t)2)
252 #define SW_FLOW_CTRL_ALL_CHARS ((uint8_t)3)
254 /* This macro checks if SW_FLOW_CTRL is a valid software flow control value */
255 #define IS_SW_FLOW_CTRL(SW_FLOW_CTRL) ( ((SW_FLOW_CTRL) == NO_SW_FLOW_CTRL) || \
256 ((SW_FLOW_CTRL) == SW_FLOW_CTRL_XON1_XOFF1) || \
257 ((SW_FLOW_CTRL) == SW_FLOW_CTRL_XON2_XOFF2) || \
258 ((SW_FLOW_CTRL) == SW_FLOW_CTRL_ALL_CHARS))
259
267 #define UART_DMAReq_Tx ((uint8_t)0x02)
268 #define UART_DMAReq_Rx ((uint8_t)0x01)
269
270 /* This macro checks if DMAREQ is a valid DMA request value */
271 #define IS_UART_DMAREQ(DMAREQ) (DMAREQ<(uint8_t)4 && DMAREQ!=(uint8_t)0 )
272
281 /* This macro checks if VAL is a valid timeout value */
282 #define IS_UART_TIMEOUT(VAL) ((VAL) < 0x400000 )
283
304 void UART_DeInit(void);
305 void UART_Init(UART_InitType* UART_InitStruct);
306 void UART_StructInit(UART_InitType* UART_InitStruct);
307 void UART_Cmd(FunctionalState NewState);
308 void UART_ITConfig(uint16_t UART_IT, FunctionalState NewState);
309 void UART_SendData(uint16_t Data);
310 uint16_t UART_ReceiveData(void);
311 void UART_BreakCmd(FunctionalState NewState);
312 void UART_RequestToSendCmd(FunctionalState NewState);
313 FlagStatus UART_GetFlagStatus(uint32_t UART_FLAG);
314 void UART_ClearFlag(uint32_t UART_FLAG);
315 ITStatus UART_GetITStatus(uint16_t UART_IT);
316 void UART_ClearITPendingBit(uint16_t UART_IT);
317 void UART_TxFifoIrqLevelConfig(uint8_t UART_TxFifo_Level);
318 void UART_RxFifoIrqLevelConfig(uint8_t UART_RxFifo_Level);
319 void UART_TimeoutConfig(uint32_t UART_Timeout);
320 void UART_SwFlowControl(FunctionalState NewState);
321 void UART_RxSwFlowControlMode(uint8_t UART_RxSwFlowCtrlMode);
322 void UART_TxSwFlowControlMode(uint8_t UART_TxSwFlowCtrlMode);
323 void UART_XonAnyBit(FunctionalState NewState);
324 void UART_SpecialCharDetect(FunctionalState NewState);
325 void UART_Xon1Char(uint8_t UART_XonChar);
326 void UART_Xon2Char(uint8_t UART_XonChar);
327 void UART_Xoff1Char(uint8_t UART_XoffChar);
328 void UART_Xoff2Char(uint8_t UART_XoffChar);
329
330 void UART_DMACmd(uint8_t UART_DMAReq, FunctionalState NewState);
331
344 #ifdef __cplusplus
345 }
346 #endif
347
348 #endif /* BLUENRG1_UART_H */
349
350 /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
UART_DeInit
void UART_DeInit(void)
Deinitializes the UART peripheral registers to their default reset values.
Definition: BlueNRG1_uart.c:107
UART_RxFifoIrqLevelConfig
void UART_RxFifoIrqLevelConfig(uint8_t UART_RxFifo_Level)
Sets the UART interrupt FIFO level.
Definition: BlueNRG1_uart.c:456
UART_ITConfig
void UART_ITConfig(uint16_t UART_IT, FunctionalState NewState)
Enables or disables the specified UART interrupts.
Definition: BlueNRG1_uart.c:239
UART_ClearFlag
void UART_ClearFlag(uint32_t UART_FLAG)
Clears the UART pending flags.
Definition: BlueNRG1_uart.c:362
UART_InitType::UART_Parity
uint8_t UART_Parity
Definition: BlueNRG1_uart.h:62
UART_RxSwFlowControlMode
void UART_RxSwFlowControlMode(uint8_t UART_RxSwFlowCtrlMode)
Sets the UART flow control mode for reception.
Definition: BlueNRG1_uart.c:549
UART_InitType::UART_BaudRate
uint32_t UART_BaudRate
Definition: BlueNRG1_uart.h:51
UART_XonAnyBit
void UART_XonAnyBit(FunctionalState NewState)
Enables or disables the UART XON any bit.
Definition: BlueNRG1_uart.c:582
UART_SendData
void UART_SendData(uint16_t Data)
Transmits single data through the UART peripheral.
Definition: BlueNRG1_uart.c:260
UART_InitType::UART_WordLengthReceive
uint8_t UART_WordLengthReceive
Definition: BlueNRG1_uart.h:56
UART_Init
void UART_Init(UART_InitType *UART_InitStruct)
Initializes the UART peripheral according to the specified parameters in the UART_InitStruct.
Definition: BlueNRG1_uart.c:134
UART_ClearITPendingBit
void UART_ClearITPendingBit(uint16_t UART_IT)
Clears the UART interrupt pending bits.
Definition: BlueNRG1_uart.c:417
UART_DMACmd
void UART_DMACmd(uint8_t UART_DMAReq, FunctionalState NewState)
Enables or disables the UART DMA interface.
Definition: BlueNRG1_uart.c:495
UART_InitType::UART_StopBits
uint8_t UART_StopBits
Definition: BlueNRG1_uart.h:59
UART_SwFlowControl
void UART_SwFlowControl(FunctionalState NewState)
Enables or disables the UART software flow control.
Definition: BlueNRG1_uart.c:523
UART_Cmd
void UART_Cmd(FunctionalState NewState)
Enables or disables the UART peripheral.
Definition: BlueNRG1_uart.c:85
UART_SpecialCharDetect
void UART_SpecialCharDetect(FunctionalState NewState)
Enables or disables the UART special character detection.
Definition: BlueNRG1_uart.c:604
UART_TimeoutConfig
void UART_TimeoutConfig(uint32_t UART_Timeout)
UART timeout value for the interrupt. The receive timeout interrupt is asserted when the RX FIFO is n...
Definition: BlueNRG1_uart.c:474
UART_StructInit
void UART_StructInit(UART_InitType *UART_InitStruct)
Fills each UART_InitStruct member with its default value.
Definition: BlueNRG1_uart.c:208
UART_RequestToSendCmd
void UART_RequestToSendCmd(FunctionalState NewState)
Enables or disables the request to send command.
Definition: BlueNRG1_uart.c:302
UART_InitType::UART_HardwareFlowControl
uint8_t UART_HardwareFlowControl
Definition: BlueNRG1_uart.h:68
UART_GetFlagStatus
FlagStatus UART_GetFlagStatus(uint32_t UART_FLAG)
Checks whether the specified UART flag is set or not.
Definition: BlueNRG1_uart.c:328
UART_BreakCmd
void UART_BreakCmd(FunctionalState NewState)
Enables or disables the break command.
Definition: BlueNRG1_uart.c:288
UART_InitType
Structure definition of UART initialization.
Definition: BlueNRG1_uart.h:49
UART_InitType::UART_FifoEnable
FunctionalState UART_FifoEnable
Definition: BlueNRG1_uart.h:72
UART_TxFifoIrqLevelConfig
void UART_TxFifoIrqLevelConfig(uint8_t UART_TxFifo_Level)
Sets the UART interrupt FIFO level.
Definition: BlueNRG1_uart.c:437
UART_TxSwFlowControlMode
void UART_TxSwFlowControlMode(uint8_t UART_TxSwFlowCtrlMode)
Sets the UART flow control mode for transmission.
Definition: BlueNRG1_uart.c:567
UART_Xon1Char
void UART_Xon1Char(uint8_t UART_XonChar)
Sets the UART flow control mode for transmission.
Definition: BlueNRG1_uart.c:625
UART_InitType::UART_WordLengthTransmit
uint8_t UART_WordLengthTransmit
Definition: BlueNRG1_uart.h:53
UART_Xon2Char
void UART_Xon2Char(uint8_t UART_XonChar)
Sets the UART flow control mode for transmission.
Definition: BlueNRG1_uart.c:638
UART_GetITStatus
ITStatus UART_GetITStatus(uint16_t UART_IT)
Checks whether the specified UART interrupt has occurred or not.
Definition: BlueNRG1_uart.c:387
UART_Xoff1Char
void UART_Xoff1Char(uint8_t UART_XoffChar)
Sets the UART flow control mode for transmission.
Definition: BlueNRG1_uart.c:651
UART_InitType::UART_Mode
uint8_t UART_Mode
Definition: BlueNRG1_uart.h:65
UART_ReceiveData
uint16_t UART_ReceiveData(void)
Returns the most recent received data by the UART peripheral.
Definition: BlueNRG1_uart.c:274
UART_Xoff2Char
void UART_Xoff2Char(uint8_t UART_XoffChar)
Sets the UART flow control mode for transmission.
Definition: BlueNRG1_uart.c:664