Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
862 Views

Quark C1000:How to use UART read_irq?

I need to use UART0 and UART1 read_irq.

I reference Intel example code but that use the qm_uart_irq_read_terminate(STDOUT_UART) function.I want UART FIFO no empty than trigger interrput.

I also reference and try this,but It can't use.

Please help thanks~

code:

# define ERR_STR ("Error: Transmission incomplete.\n")

static qm_uart_transfer_t async_xfer_desc;

int main(void)

{

qm_uart_status_t uart_status __attribute__((unused)) = 0;

int ret __attribute__((unused));

/* Mux out STDOUT_UART tx/rx pins and enable input for rx. */

qm_pmux_select(QM_PIN_ID_18, QM_PMUX_FN_0);

qm_pmux_select(QM_PIN_ID_19, QM_PMUX_FN_0);

qm_pmux_input_en(QM_PIN_ID_18, true);

qm_pmux_select(QM_PIN_ID_16, QM_PMUX_FN_2);

qm_pmux_select(QM_PIN_ID_17, QM_PMUX_FN_2);

qm_pmux_input_en(QM_PIN_ID_17, true);

clk_periph_enable(CLK_PERIPH_CLK | CLK_PERIPH_UARTB_REGISTER);

stdout_uart_setup(QM_UART_CFG_BAUD_DL_PACK(0, 17, 6));

//IRQ

// Register the UART interrupts.

qm_irq_request(QM_IRQ_UART_1, qm_uart_1_isr);

// Used on both TX and RX

//async_xfer_desc.callback_data = (void *)&xfer_irq_data;

/* IRQ based TX. */

async_xfer_desc.data = (uint8_t *)tx_buffer;

async_xfer_desc.data_len = sizeof(tx_buffer);

async_xfer_desc.callback = uart_example_tx_callback;

ret = qm_uart_irq_write(QM_UART_1, &async_xfer_desc);

QM_ASSERT(0 == ret);

clk_sys_udelay(1000);

// IRQ based RX.

rx_callback_invoked = false;

async_xfer_desc.data = (uint8_t *)rx_buffer;

async_xfer_desc.data_len = BIG_NUMBER_RX;

async_xfer_desc.callback = uart_example_rx_callback;

ret = qm_uart_irq_read(QM_UART_1, &async_xfer_desc);

//QM_ASSERT(0 == ret);

while(1)

{

}

QM_PUTS("Finished: AON GPIO\n");

return 0;

}

void uart_example_rx_callback(void *data, int error, qm_uart_status_t status, uint32_t len)

{

if (!error || error == -ECANCELED) {

/* Transfer successful or RX terminated. */

qm_uart_write_buffer(QM_UART_1, &rx_buffer[1], len-1);

rx_callback_invoked = true;

}

else {

qm_uart_write_buffer(QM_UART_1, (uint8_t *)ERR_STR, sizeof(ERR_STR));

}

qm_uart_irq_read(QM_UART_1, &async_xfer_desc);

}

void uart_example_tx_callback(void *data, int error, qm_uart_status_t status, uint32_t len)

{

if (!error || error == -ECANCELED) {

// Transfer successful or RX terminated.

qm_uart_write_buffer(QM_UART_1, &rx_buffer[1], len-1);

rx_callback_invoked = true;

}

else {

qm_uart_write_buffer(QM_UART_1, (uint8_t *)ERR_STR, sizeof(ERR_STR));

}

}

0 Kudos
1 Reply
idata
Community Manager
25 Views

I resolved this issues.thanks~