2020-04-28 02:18 AM
hello,
I am using the SPC582b and SPC5stdio.
I want to have interrupts run whenever I receive data.
But This function is difficult because it waits until input is received
(sd_lld_read, &lcd_data[bit], 1)
How can I implement an uart interrupt?
I need your help.
Thank you.
Solved! Go to Solution.
2020-05-04 05:45 AM
Hello ,
You can use a thread by using a RTOS like Chibios or FreeRTOS
or you can adapt the driver presents in this followin g file
**
* @brief Serial read without DMA
*
* @param[in] sdp pointer to a @p SerialDriver object
* @param[out] buffer data buffer receiver
* @param[out] len number of bytes received
*
* @return The number of bytes effectively read.
*
* @notapi
*/
static uint16_t sd_rx(SerialDriver* sdp, uint8_t* buffer, uint16_t len) {
if (len > 0UL) {
if(sdp->config->api_mode == SPC5_LIN_API_MODE_BUFFERED_IO) {
uint16_t l = len;
sdp->linflexlp->LINIER.B.DRIE = 0;
while (l != 0U) {
if (sdp->rx_read_ptr != sdp->rx_write_ptr) {
sdp->linflexlp->LINIER.B.DRIE = 0;
*buffer++ = *sdp->rx_read_ptr++;
if (sdp->rx_read_ptr == sdp->rx_end_ptr) {
sdp->rx_read_ptr = sdp->rx_buffered_io;
}
l--;
} else {
sdp->linflexlp->LINIER.B.DRIE = 1;
}
}
sdp->linflexlp->LINIER.B.DRIE = 1;
} else {
sdp->rx_buf = buffer;
sdp->rx_len = len;
sdp->linflexlp->LINIER.R |= (uint16_t)(SPC5_LINIER_DRIE | SPC5_LIN_INTERRUPTS); /* Interrupts enabled. */
sdp->linflexlp->UARTCR.B.RXEN = 1;
}
}
return len;
}
Best Regards
Erwan
2020-05-04 05:45 AM
Hello ,
You can use a thread by using a RTOS like Chibios or FreeRTOS
or you can adapt the driver presents in this followin g file
**
* @brief Serial read without DMA
*
* @param[in] sdp pointer to a @p SerialDriver object
* @param[out] buffer data buffer receiver
* @param[out] len number of bytes received
*
* @return The number of bytes effectively read.
*
* @notapi
*/
static uint16_t sd_rx(SerialDriver* sdp, uint8_t* buffer, uint16_t len) {
if (len > 0UL) {
if(sdp->config->api_mode == SPC5_LIN_API_MODE_BUFFERED_IO) {
uint16_t l = len;
sdp->linflexlp->LINIER.B.DRIE = 0;
while (l != 0U) {
if (sdp->rx_read_ptr != sdp->rx_write_ptr) {
sdp->linflexlp->LINIER.B.DRIE = 0;
*buffer++ = *sdp->rx_read_ptr++;
if (sdp->rx_read_ptr == sdp->rx_end_ptr) {
sdp->rx_read_ptr = sdp->rx_buffered_io;
}
l--;
} else {
sdp->linflexlp->LINIER.B.DRIE = 1;
}
}
sdp->linflexlp->LINIER.B.DRIE = 1;
} else {
sdp->rx_buf = buffer;
sdp->rx_len = len;
sdp->linflexlp->LINIER.R |= (uint16_t)(SPC5_LINIER_DRIE | SPC5_LIN_INTERRUPTS); /* Interrupts enabled. */
sdp->linflexlp->UARTCR.B.RXEN = 1;
}
}
return len;
}
Best Regards
Erwan