-
Notifications
You must be signed in to change notification settings - Fork 13
UART: Moving to fifo implementation and loop back example #48
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Abhishek Malik <[email protected]>
I seem to be unable to add reviewers, so I'm just going to tag you guys here: @jontrulson @whbruce @pylbert |
@@ -81,6 +106,10 @@ mraa_uart_init(int uart) | |||
dev->zdev = device_get_binding(UART_DEVICE); | |||
dev->block = 1; | |||
|
|||
#if 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is always necessary, remove the #if
|
||
uart_irq_rx_disable(dev->zdev); | ||
|
||
if(data_arrived == true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
return data_arrived
is simpler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks interesting. I would really like to know how well it does against one of our supported UART devices, like the NMEA ones. These will deliver a steady stream of data (usually at 9600bd) - it will be obvious if you are losing characters.
Also, the global static nature of the two boolean flags means that only one UART could be supported. I would expect that there would be some way to attach the device (mraa) context to this struct in some way, but maybe not?
@@ -51,6 +51,31 @@ | |||
#define PRINT printk | |||
#endif | |||
|
|||
static volatile bool data_transmitted; | |||
static volatile bool data_arrived; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be stored in the context so that multiple uarts on a target could be used?
static volatile bool data_arrived; | ||
|
||
static void uart_interrupt_handler(struct device *dev) { | ||
//printf("coming into interrupt handler\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this is why you made them global statics (data_transmitted/data_arrived)? There is no way to attach the context to this device struct?
if(uart_irq_rx_ready(dev)) { | ||
//printf("rx is ready\n"); | ||
data_arrived = true; | ||
uart_irq_rx_disable(dev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why disable here? Usually what I would think would happen in this intr routine would be that data would be copied out of (RX) the FIFO into a local buffer (a ring buffer would work well), and if there was a TX ring buffer, then data would be sent from it to the FIFO when tx was available (data in tx RB, and uart_irq_tx_ready() == true).
Have you tried this with a device that sends a continuous stream of data like one of the many NMEA GPS devices we support?
|
||
return length; | ||
return uart_fifo_read(dev->zdev, buf, length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not familiar with this FIFO API... How much data can be returned? Does it do it's own local buffering separate from the hardware FIFO?
Signed-off-by: Abhishek Malik [email protected]