|
@@ -89,25 +89,25 @@ void HardwareSerial::begin(uint32_t baudrate) {
|
89
|
89
|
PINSEL_ConfigPin(&PinCfg);
|
90
|
90
|
}
|
91
|
91
|
|
92
|
|
- /* Initialize UART Configuration parameter structure to default state:
|
93
|
|
- * Baudrate = 9600bps
|
94
|
|
- * 8 data bit
|
95
|
|
- * 1 Stop bit
|
96
|
|
- * None parity
|
97
|
|
- */
|
98
|
|
- UART_ConfigStructInit(&UARTConfigStruct);
|
99
|
|
-
|
100
|
|
- // Re-configure baudrate
|
101
|
|
- UARTConfigStruct.Baud_rate = baudrate;
|
102
|
|
-
|
103
|
|
- // Initialize eripheral with given to corresponding parameter
|
|
92
|
+ /* Initialize UART Configuration parameter structure to default state:
|
|
93
|
+ * Baudrate = 9600bps
|
|
94
|
+ * 8 data bit
|
|
95
|
+ * 1 Stop bit
|
|
96
|
+ * None parity
|
|
97
|
+ */
|
|
98
|
+ UART_ConfigStructInit(&UARTConfigStruct);
|
|
99
|
+
|
|
100
|
+ // Re-configure baudrate
|
|
101
|
+ UARTConfigStruct.Baud_rate = baudrate;
|
|
102
|
+
|
|
103
|
+ // Initialize eripheral with given to corresponding parameter
|
104
|
104
|
UART_Init(UARTx, &UARTConfigStruct);
|
105
|
105
|
|
106
|
106
|
// Enable and reset the TX and RX FIFOs
|
107
|
107
|
UART_FIFOConfigStructInit(&FIFOConfig);
|
108
|
108
|
UART_FIFOConfig(UARTx, &FIFOConfig);
|
109
|
109
|
|
110
|
|
- // Enable UART Transmit
|
|
110
|
+ // Enable UART Transmit
|
111
|
111
|
UART_TxCmd(UARTx, ENABLE);
|
112
|
112
|
|
113
|
113
|
// Configure Interrupts
|
|
@@ -234,9 +234,9 @@ void HardwareSerial::IRQHandler() {
|
234
|
234
|
uint8_t LSRValue, byte;
|
235
|
235
|
|
236
|
236
|
IIRValue = UART_GetIntId(UARTx);
|
237
|
|
- IIRValue &= UART_IIR_INTID_MASK; /* check bit 1~3, interrupt identification */
|
|
237
|
+ IIRValue &= UART_IIR_INTID_MASK; /* check bit 1~3, interrupt identification */
|
238
|
238
|
|
239
|
|
- if ( IIRValue == UART_IIR_INTID_RLS ) /* Receive Line Status */
|
|
239
|
+ if ( IIRValue == UART_IIR_INTID_RLS ) /* Receive Line Status */
|
240
|
240
|
{
|
241
|
241
|
LSRValue = UART_GetLineStatus(UARTx);
|
242
|
242
|
|
|
@@ -246,13 +246,13 @@ void HardwareSerial::IRQHandler() {
|
246
|
246
|
/* There are errors or break interrupt */
|
247
|
247
|
/* Read LSR will clear the interrupt */
|
248
|
248
|
Status = LSRValue;
|
249
|
|
- byte = UART_ReceiveByte(UARTx); /* Dummy read on RX to clear
|
|
249
|
+ byte = UART_ReceiveByte(UARTx); /* Dummy read on RX to clear
|
250
|
250
|
interrupt, then bail out */
|
251
|
251
|
return;
|
252
|
252
|
}
|
253
|
253
|
}
|
254
|
254
|
|
255
|
|
- if ( IIRValue == UART_IIR_INTID_RDA ) /* Receive Data Available */
|
|
255
|
+ if ( IIRValue == UART_IIR_INTID_RDA ) /* Receive Data Available */
|
256
|
256
|
{
|
257
|
257
|
/* Clear the FIFO */
|
258
|
258
|
while ( UART_Receive(UARTx, &byte, 1, NONE_BLOCKING) ) {
|
|
@@ -265,10 +265,10 @@ void HardwareSerial::IRQHandler() {
|
265
|
265
|
break;
|
266
|
266
|
}
|
267
|
267
|
}
|
268
|
|
- else if ( IIRValue == UART_IIR_INTID_CTI ) /* Character timeout indicator */
|
|
268
|
+ else if ( IIRValue == UART_IIR_INTID_CTI ) /* Character timeout indicator */
|
269
|
269
|
{
|
270
|
270
|
/* Character Time-out indicator */
|
271
|
|
- Status |= 0x100; /* Bit 9 as the CTI error */
|
|
271
|
+ Status |= 0x100; /* Bit 9 as the CTI error */
|
272
|
272
|
}
|
273
|
273
|
|
274
|
274
|
#if TX_BUFFER_SIZE > 0
|
|
@@ -302,12 +302,12 @@ extern "C" {
|
302
|
302
|
#endif
|
303
|
303
|
|
304
|
304
|
/*****************************************************************************
|
305
|
|
-** Function name: UART0_IRQHandler
|
|
305
|
+** Function name: UART0_IRQHandler
|
306
|
306
|
**
|
307
|
|
-** Descriptions: UART0 interrupt handler
|
|
307
|
+** Descriptions: UART0 interrupt handler
|
308
|
308
|
**
|
309
|
|
-** parameters: None
|
310
|
|
-** Returned value: None
|
|
309
|
+** parameters: None
|
|
310
|
+** Returned value: None
|
311
|
311
|
**
|
312
|
312
|
*****************************************************************************/
|
313
|
313
|
void UART0_IRQHandler (void)
|
|
@@ -316,12 +316,12 @@ void UART0_IRQHandler (void)
|
316
|
316
|
}
|
317
|
317
|
|
318
|
318
|
/*****************************************************************************
|
319
|
|
-** Function name: UART1_IRQHandler
|
|
319
|
+** Function name: UART1_IRQHandler
|
320
|
320
|
**
|
321
|
|
-** Descriptions: UART1 interrupt handler
|
|
321
|
+** Descriptions: UART1 interrupt handler
|
322
|
322
|
**
|
323
|
|
-** parameters: None
|
324
|
|
-** Returned value: None
|
|
323
|
+** parameters: None
|
|
324
|
+** Returned value: None
|
325
|
325
|
**
|
326
|
326
|
*****************************************************************************/
|
327
|
327
|
void UART1_IRQHandler (void)
|
|
@@ -330,12 +330,12 @@ void UART1_IRQHandler (void)
|
330
|
330
|
}
|
331
|
331
|
|
332
|
332
|
/*****************************************************************************
|
333
|
|
-** Function name: UART2_IRQHandler
|
|
333
|
+** Function name: UART2_IRQHandler
|
334
|
334
|
**
|
335
|
|
-** Descriptions: UART2 interrupt handler
|
|
335
|
+** Descriptions: UART2 interrupt handler
|
336
|
336
|
**
|
337
|
|
-** parameters: None
|
338
|
|
-** Returned value: None
|
|
337
|
+** parameters: None
|
|
338
|
+** Returned value: None
|
339
|
339
|
**
|
340
|
340
|
*****************************************************************************/
|
341
|
341
|
void UART2_IRQHandler (void)
|
|
@@ -344,12 +344,12 @@ void UART2_IRQHandler (void)
|
344
|
344
|
}
|
345
|
345
|
|
346
|
346
|
/*****************************************************************************
|
347
|
|
-** Function name: UART3_IRQHandler
|
|
347
|
+** Function name: UART3_IRQHandler
|
348
|
348
|
**
|
349
|
|
-** Descriptions: UART3 interrupt handler
|
|
349
|
+** Descriptions: UART3 interrupt handler
|
350
|
350
|
**
|
351
|
|
-** parameters: None
|
352
|
|
-** Returned value: None
|
|
351
|
+** parameters: None
|
|
352
|
+** Returned value: None
|
353
|
353
|
**
|
354
|
354
|
*****************************************************************************/
|
355
|
355
|
void UART3_IRQHandler (void)
|