/* UART write finished callback */
static void writeCallback(uint32_t err_code, uint32_t n) {
if (err_code != LPC_OK) {
errorUART();
}
(*tx_done_handler)();
}
/* UART read finished callback */
static void readCallback(uint32_t err_code, uint32_t n) {
if (err_code != LPC_OK) {
errorUART();
}
(*rx_done_handler)();
}
void send_BT_UART(const char *send_data, uint32_t length) {
UART_PARAM_T param;
param.buffer = (uint8_t *) send_data;
param.size = length;
/* Interrupt mode, do not append CR/LF to sent data */
param.transfer_mode = TX_MODE_BUF_EMPTY;
param.driver_mode = DRIVER_MODE_INTERRUPT;
/* Setup the transmit callback, this will get called when the
transfer is complete */
param.callback_func_pt = (UART_CALLBK_T) writeCallback;
if (LPC_UARTND_API->uart_put_line(uartHandle, ¶m)) {
errorUART();
}
}
void recv_BT_UART(char *receive_buffer, uint32_t length) {
UART_PARAM_T param;
param.buffer = (uint8_t *) receive_buffer;
param.size = length;
/* Receive data up to the CR/LF character in polling mode. Will
truncate at length if too long.*/
param.transfer_mode = RX_MODE_BUF_FULL;
param.driver_mode = DRIVER_MODE_INTERRUPT;
/* Setup the receive callback, this will get called when the
transfer is complete */
param.callback_func_pt = (UART_CALLBK_T) readCallback;
if (LPC_UARTND_API->uart_get_line(uartHandle, ¶m)) {
errorUART();
}
} |
send_BT_UART(...) // Do not wait for callback recv_BT_UART(...) |