-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created a UART API definition #17
base: linux-descriptors
Are you sure you want to change the base?
Created a UART API definition #17
Conversation
916a82a
to
491be57
Compare
@@ -0,0 +1,94 @@ | |||
/** \file softuart.h |
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 recommend we go with include/uart/api.h
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.
Fixed
491be57
to
e6d4371
Compare
* This function uart0_receive is basically empty for fast_uart. However, in case of | ||
* timer based UART. It reads data from the queue, and returns a single character which | ||
* can then be used by the calling program. | ||
* |
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.
See my comment about blocking verse non-blocking above. I think we probably need some type of function to check if there is a byte to receive.
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.
Fixed
572d7cd
to
9685276
Compare
* \brief initalizes UART. | ||
* This function uartX_init accepts the baud_rate and the mask.Returns 0 if successful. | ||
* The mask indicates where the UART_TX pin must be attached. The rx_mask performs a | ||
* similar function. If FAST_UART is used, only transmit is allowed. |
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.
You are still talking about implementations here.
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.
Fixed
3083e9c
to
075d0ab
Compare
|
||
/** | ||
* \brief initalizes UART. | ||
* This function accepts mask for rx and tx.Returns 0 if successful. |
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.
Always put a space after a full stop.
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.
Fixed
Getting pretty close, I'm wondering if we should have shorter names than |
|
||
/** | ||
* \brief Returns how many more bytes can be loaded | ||
* into the buffer |
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 does this comment wrap? You should be wrapping at 80 characters (or maybe 75).
You are still not putting full stops at the end of all your sentences in the documentation. |
7301453
to
dbba734
Compare
Fixed |
**/ | ||
BOOL uartX_init(enum uart_baud rate, ...); | ||
|
||
/** |
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.
This documentation of this enum still hasn't been fixed.
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.
Not really sure what kind of a doc you want. I just added 2 more line saying less than 0 not valid, greater than 0 valid. Is there something else you want me to add?
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.
Take a look at other examples in the code. Remember consistency is important!
From fx2int.h
/**
* \brief Interrupt numbers for standard FX2 interrupts.
**/
typedef enum {
IE0_ISR=0, ///< External interrupt 0
TF0_ISR, ///< Timer 0 interrupt
IE1_ISR, ///< External interrupt 1
TF1_ISR, ///< Timer 1 interrupt
TI_0_ISR, ///< Serial port 0 transmit or receive interrupt
TF2_ISR, ///< Timer 2 interrupt
RESUME_ISR, ///< Resume interrupt
TI_1_ISR, ///< Serial port 1 transmit or receive interrupt
USBINT_ISR, ///< USB Interrupt. An interrupt handler for this should only be used if not using auto vectored interrupts with INT2
I2CINT_ISR, ///< I2C Bus interrupt
IE4_ISR, ///< External interrupt 4. An interrupt handler for this should only be used if not using auto vectored interrupts with INT4
IE5_ISR, ///< External interrupt 5
IE6_ISR, ///< External interrupt 6
// Better names for the USART interrupts
USART0_ISR = TI_0_ISR, ///< Better name for USART0 interrupt
USART1_ISR = TI_1_ISR, ///< Better name for USART1 interrupt
} FX2_ISR;
From fx2macros.h
/**
* \brief Used for getting and setting the CPU clock speed.
**/
typedef enum { CLK_12M =0, CLK_24M, CLK_48M} CLK_SPD;
Everything else has a \brief
for the short description. You haven't explained what the BAUD_ANY and BAUD_FASTEST should do.
This should probably be a typedef too.
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 generally prefer not to use typedef. I prefer doing enum name. This is part of the Linux coding guidelines given https://www.kernel.org/doc/Documentation/CodingStyle , Chapter 5.
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.
Fixed
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.
Please use the typedefs. This isn't the Linux kernel -- please use style consistent with the rest of the code.
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.
Fixed.
Please fix the pull request description. |
dbba734
to
3342242
Compare
If you fix the enum documentation, this can be merged. |
3342242
to
4be57ba
Compare
* Enum values greater than 0 are supported. | ||
**/ | ||
enum uart_baud { | ||
BAUD_FASTEST = -2, ///< The fastest BAUD available on the system(Currently on 48Mhz,it is 1.71Mbps) |
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.
See commenting is important -- we had different understanding of this value. I think it should be "The fastest baud rate a UART supports".
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.
Again, you shouldn't be referencing real implementations in the API document.
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.
Fixed
4be57ba
to
e5de956
Compare
@@ -20,6 +20,7 @@ | |||
|
|||
#include <lights.h> | |||
#include <delay.h> | |||
#include <uart/api.h> |
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.
Um?
84e7117
to
dadddb1
Compare
* \brief enum Standard available baud rates. | ||
* BAUD_FASTEST will give you the fastest baud rate the UART can operate at. WARNING: | ||
* This is allowed to be a non-standard baud rate. | ||
* Enum values greater than 0 are supported depending on the UART in use.To check |
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.
Space after full stop.
d4322d3
to
b95e144
Compare
…access UART irrespective of the manner in which it is implemented. Updated
b95e144
to
a3c3e01
Compare
I have changed things to the best of my knowledge. |
This defines a robust and flexible UART API which allows the example code to access the UART functionality in a standard manner irrespective of how the device is actually implementing this functionality.