LPC11U6x UART Rom API Full Duplex safe?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC11U6x UART Rom API Full Duplex safe?

1,171件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Belias on Wed Jul 02 07:05:49 MST 2014
When using the LPC11U6X ROM API for U(S)ART, is it possible and allowed to do the following (having two different callback functions for rx and tx):

/* 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, &param)) {
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, &param)) {
errorUART();
}
}


And calling send_BT_UART() and recv_BT_UART() before the callback strikes?

send_BT_UART(...)
// Do not wait for callback
recv_BT_UART(...)


I think that it might be possible that when calling LPC_UARTND_API->uart_get_line that the callback which send_BT_UART() sets gets overwritten by recv_BT_UART().
Is this true? Is there a workaround, that when using a single callback I can find out if it originates from an rx or an tx operation?

Thanks alot!
ラベル(1)
0 件の賞賛
返信
2 返答(返信)

1,096件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bob_walker on Wed Jun 10 22:26:38 MST 2015
Did this ever get answered?

0 件の賞賛
返信

1,096件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xianghuiwang on Thu Jul 03 15:59:41 MST 2014
Hi, Belias,

Can you check is HDEN bit is set?
We will confirm and clarify the API usage as well.

regards,
0 件の賞賛
返信