Skip to content
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

Open
wants to merge 1 commit into
base: linux-descriptors
Choose a base branch
from

Conversation

RacingTornado
Copy link

@RacingTornado RacingTornado commented Jun 24, 2016

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.

@@ -0,0 +1,94 @@
/** \file softuart.h
Copy link
Owner

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

* 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.
*
Copy link
Owner

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@RacingTornado RacingTornado force-pushed the merge_uart_api branch 2 times, most recently from 572d7cd to 9685276 Compare June 24, 2016 04:46
* \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.
Copy link
Owner

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@RacingTornado RacingTornado force-pushed the merge_uart_api branch 3 times, most recently from 3083e9c to 075d0ab Compare June 24, 2016 05:29

/**
* \brief initalizes UART.
* This function accepts mask for rx and tx.Returns 0 if successful.
Copy link
Owner

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@mithro
Copy link
Owner

mithro commented Jun 24, 2016

Getting pretty close, I'm wondering if we should have shorter names than transmit and receive. Maybe rx and tx?


/**
* \brief Returns how many more bytes can be loaded
* into the buffer
Copy link
Owner

@mithro mithro Jun 25, 2016

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).

@mithro
Copy link
Owner

mithro commented Jun 25, 2016

You are still not putting full stops at the end of all your sentences in the documentation.

@RacingTornado
Copy link
Author

You are still not putting full stops at the end of all your sentences in the documentation.

Fixed

@mithro mithro changed the title Created a UART API definition for allowing proper abstraction Created a UART API definition Jun 27, 2016
**/
BOOL uartX_init(enum uart_baud rate, ...);

/**
Copy link
Owner

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.

Copy link
Author

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?

Copy link
Owner

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.

Copy link
Author

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Owner

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@mithro
Copy link
Owner

mithro commented Jun 27, 2016

Please fix the pull request description.

@mithro
Copy link
Owner

mithro commented Jul 3, 2016

If you fix the enum documentation, this can be merged.

* 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)
Copy link
Owner

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".

Copy link
Owner

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -20,6 +20,7 @@

#include <lights.h>
#include <delay.h>
#include <uart/api.h>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um?

@RacingTornado RacingTornado force-pushed the merge_uart_api branch 2 times, most recently from 84e7117 to dadddb1 Compare July 5, 2016 13:19
* \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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after full stop.

@RacingTornado RacingTornado force-pushed the merge_uart_api branch 3 times, most recently from d4322d3 to b95e144 Compare July 20, 2016 06:13
…access UART irrespective of the manner in which it is implemented.

Updated
@RacingTornado
Copy link
Author

I have changed things to the best of my knowledge.

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

Successfully merging this pull request may close these issues.

3 participants