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

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

  • Review code
  • Test on device
  • Add documentation (added to #997)
  • Add to CHANGELOG.md
@technobly

This comment has been minimized.

Copy link
Member

commented Apr 7, 2016

Nice one @avtolstoy !

@m-mcgowan m-mcgowan added this to the 0.6.x milestone Apr 27, 2016

@avtolstoy avtolstoy referenced this pull request May 8, 2016
7 of 7 tasks complete
@m-mcgowan

This comment has been minimized.

Copy link
Contributor

commented Jun 7, 2016

@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

This comment has been minimized.

Copy link
Member Author

commented Jun 7, 2016

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

@technobly technobly force-pushed the feature/usart-lin-config branch from 7d0dbdb to 3f5b9df Jun 10, 2016

@technobly

This comment has been minimized.

Copy link
Member

commented Jun 10, 2016

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

This comment has been minimized.

Copy link
Member

commented Jun 10, 2016

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 the in progress label 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
Projects
None yet
4 participants
You can’t perform that action at this time.