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

LIN Bus support, USART hardware flow control configuration support #930

Closed
wants to merge 7 commits into from

Conversation

avtolstoy
Copy link
Member

@avtolstoy avtolstoy commented Mar 31, 2016

This PR implements #697

Hardware USART serials can be configured in one of the following LIN modes:

  • LIN_MASTER_13B - LIN Master mode with ability to send 13 bit breaks
  • LIN_SLAVE_10B - LIN Slave mode with 10 bit break detection
  • LIN_SLAVE_11B - LIN Slave mode with 11 bit break detection

Example: Serial1.begin(9600, LIN_MASTER_13B);

These are just convenient pre-defined configurations:

// Pre-defined LIN configurations
#define LIN_MASTER_13B (uint32_t)(((uint32_t)SERIAL_8N1) | LIN_MODE_MASTER | LIN_BREAK_13B)
#define LIN_SLAVE_10B  (uint32_t)(((uint32_t)SERIAL_8N1) | LIN_MODE_SLAVE  | LIN_BREAK_10B)
#define LIN_SLAVE_11B  (uint32_t)(((uint32_t)SERIAL_8N1) | LIN_MODE_SLAVE  | LIN_BREAK_11B)

LIN break detection can also be manually enabled in Master mode (this is a supported configuration in LIN, when Master can act as a Slave as well and respond to its own messages). This configuration was used in serial_loopback test SERIAL1_LINMasterReadWriteBreakSucceedsInLoopbackWithTxRxShorted.
Serial1.begin(9600, LIN_MASTER_13B | LIN_BREAK_10B);

New Wiring methods:

  • void USARTSerial::breakTx(void); - send break
  • bool USARTSerial::breakRx(void); - checks if break was detected

This PR also includes support for hardware flow control settings on USARTs:

// Flow control settings
#define SERIAL_FLOW_CONTROL_NONE ((uint8_t)0b00000000)
#define SERIAL_FLOW_CONTROL_RTS ((uint8_t)0b00100000)
#define SERIAL_FLOW_CONTROL_CTS ((uint8_t)0b01000000)
#define SERIAL_FLOW_CONTROL_RTS_CTS ((uint8_t)0b01100000)

Hardware flow control is available on:

  • Core: Serial1 (CTS - A0, RTS - A1)
  • Photon/Electron: Serial2 (CTS - A7, RTS - RGBR (which will require some tinkering to access))

@technobly
Copy link
Member

Nice one @avtolstoy !

@m-mcgowan
Copy link
Contributor

@avtolstoy - our serial peripherals are shaping up so well! Please rebase on develop so you can add some docs to the firmware reference for the new features. Thanks!

@avtolstoy
Copy link
Member Author

@m-mcgowan the docs are already in PR #997, which is based on this branch :)

@technobly
Copy link
Member

  • rebased against develop and force pushed to feature/serial-config

@technobly
Copy link
Member

Closing this due to all of it's changes were merged into develop with #997

@technobly technobly closed this Jun 10, 2016
@technobly technobly removed their assignment Jun 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants