Skip to content

Commit 6904921

Browse files
committed
Device/NXP/uart_debug: Added support for SignalEvent
1 parent af38c46 commit 6904921

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Device/NXP/Driver/uart_debug/Driver_USART.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ static const ARM_USART_CAPABILITIES DriverCapabilities = {
6565
0 /* Signal RI change event: \ref ARM_USART_EVENT_RI */
6666
};
6767

68+
static ARM_USART_SignalEvent_t m_SignalEvent;
69+
6870
//
6971
// Functions
7072
//
@@ -77,7 +79,6 @@ ARM_USART_CAPABILITIES ARM_USART_GetCapabilities(void) {
7779
return DriverCapabilities;
7880
}
7981

80-
//TODO: Add support for ARM_USART_SignalEvent_t cb_event
8182
int32_t ARM_USART_Initialize(ARM_USART_SignalEvent_t cb_event) {
8283
Chip_UART_Init(LPC_UART0);
8384
Chip_UART_SetBaud(LPC_UART0, 115200);
@@ -86,6 +87,8 @@ int32_t ARM_USART_Initialize(ARM_USART_SignalEvent_t cb_event) {
8687
// Enable UART Transmit
8788
Chip_UART_TXEnable(LPC_UART0);
8889

90+
m_SignalEvent = cb_event;
91+
8992
return ARM_DRIVER_OK;
9093
}
9194

@@ -106,11 +109,20 @@ int32_t ARM_USART_Send(const void *data, uint32_t num) {
106109
if ((len >= 2) && (ptr[len-1] == '\n') && (ptr[len-2] != '\r')) {
107110
_ttywrch('\r');
108111
}
112+
113+
if (m_SignalEvent) {
114+
m_SignalEvent(ARM_USART_EVENT_SEND_COMPLETE);
115+
}
109116
return sent;
110117
}
111118

112119
int32_t ARM_USART_Receive(void *data, uint32_t num) {
113-
return Chip_UART_Read(LPC_UART0, data, num);
120+
int32_t ret = Chip_UART_Read(LPC_UART0, data, num);
121+
122+
if (m_SignalEvent) {
123+
m_SignalEvent(ARM_USART_EVENT_RECEIVE_COMPLETE);
124+
}
125+
return ret;
114126
}
115127

116128
int32_t ARM_USART_Transfer(const void *data_out, void *data_in, uint32_t num) {

0 commit comments

Comments
 (0)