Created a UART API definition#17
Created a UART API definition#17RacingTornado wants to merge 1 commit intomithro:linux-descriptorsfrom
Conversation
916a82a to
491be57
Compare
include/softuart.h
Outdated
| @@ -0,0 +1,94 @@ | |||
| /** \file softuart.h | |||
There was a problem hiding this comment.
I recommend we go with include/uart/api.h
491be57 to
e6d4371
Compare
include/softuart.h
Outdated
| * 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.
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.
572d7cd to
9685276
Compare
include/uart/api.h
Outdated
| * \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.
You are still talking about implementations here.
3083e9c to
075d0ab
Compare
include/uart/api.h
Outdated
|
|
||
| /** | ||
| * \brief initalizes UART. | ||
| * This function accepts mask for rx and tx.Returns 0 if successful. |
There was a problem hiding this comment.
Always put a space after a full stop.
|
Getting pretty close, I'm wondering if we should have shorter names than |
include/uart/api.h
Outdated
|
|
||
| /** | ||
| * \brief Returns how many more bytes can be loaded | ||
| * into the buffer |
There was a problem hiding this comment.
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.
This documentation of this enum still hasn't been fixed.
There was a problem hiding this comment.
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.
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.
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.
Please use the typedefs. This isn't the Linux kernel -- please use style consistent with the rest of the code.
|
Please fix the pull request description. |
dbba734 to
3342242
Compare
|
If you fix the enum documentation, this can be merged. |
3342242 to
4be57ba
Compare
include/uart/api.h
Outdated
| * 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.
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.
Again, you shouldn't be referencing real implementations in the API document.
4be57ba to
e5de956
Compare
examples/lights/lights.c
Outdated
|
|
||
| #include <lights.h> | ||
| #include <delay.h> | ||
| #include <uart/api.h> |
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 |
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.