@@ -65,6 +65,8 @@ static const ARM_USART_CAPABILITIES DriverCapabilities = {
65
65
0 /* Signal RI change event: \ref ARM_USART_EVENT_RI */
66
66
};
67
67
68
+ static ARM_USART_SignalEvent_t m_SignalEvent ;
69
+
68
70
//
69
71
// Functions
70
72
//
@@ -77,7 +79,6 @@ ARM_USART_CAPABILITIES ARM_USART_GetCapabilities(void) {
77
79
return DriverCapabilities ;
78
80
}
79
81
80
- //TODO: Add support for ARM_USART_SignalEvent_t cb_event
81
82
int32_t ARM_USART_Initialize (ARM_USART_SignalEvent_t cb_event ) {
82
83
Chip_UART_Init (LPC_UART0 );
83
84
Chip_UART_SetBaud (LPC_UART0 , 115200 );
@@ -86,6 +87,8 @@ int32_t ARM_USART_Initialize(ARM_USART_SignalEvent_t cb_event) {
86
87
// Enable UART Transmit
87
88
Chip_UART_TXEnable (LPC_UART0 );
88
89
90
+ m_SignalEvent = cb_event ;
91
+
89
92
return ARM_DRIVER_OK ;
90
93
}
91
94
@@ -106,11 +109,20 @@ int32_t ARM_USART_Send(const void *data, uint32_t num) {
106
109
if ((len >= 2 ) && (ptr [len - 1 ] == '\n' ) && (ptr [len - 2 ] != '\r' )) {
107
110
_ttywrch ('\r' );
108
111
}
112
+
113
+ if (m_SignalEvent ) {
114
+ m_SignalEvent (ARM_USART_EVENT_SEND_COMPLETE );
115
+ }
109
116
return sent ;
110
117
}
111
118
112
119
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 ;
114
126
}
115
127
116
128
int32_t ARM_USART_Transfer (const void * data_out , void * data_in , uint32_t num ) {
0 commit comments