Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

UART: Moving to fifo implementation and loop back example #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

malikabhi05
Copy link
Contributor

Signed-off-by: Abhishek Malik [email protected]

@malikabhi05
Copy link
Contributor Author

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
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Collaborator

@jontrulson jontrulson left a 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;

Copy link
Collaborator

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");
Copy link
Collaborator

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);
Copy link
Collaborator

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);
Copy link
Collaborator

@jontrulson jontrulson Apr 25, 2017

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants