Features/rs485 - #6
Conversation
|
Broadly I think we should trade against three options - want @jacobh460's input.
I would lean towards option 3 with a comment pointing back to this HAL function because it lets us re-use more existing code, but not sure, and there might be a fourth clever way to do this that I'm missing. |
|
I would consider something like: |
|
I'm fine to merge before testing this, but IMO #2 priority on EC bringup (after core bringup like basic UART printing) is probing the DE pin and confirming that this logic works as expected. |
|
Here are my comments:
(note: we should probably enable a pull up resistor on the UART_RX pin so that the line doesn't float when there is no mux selected!)
In setBaud(), you are calling a HAL function instead of using Arduino's Uart::begin() (which can be called repeatedly to change the baud rate). Probably best to use the arduino function to change the baud rate so there isn't a mismatch between what Arduino thinks the baud rate is currently set to and what it is actually set to. Then do minimal work to enable DE as well.
|
Previously I was passing the DE pin into the RTS pin param of the constructor - if we fix like in option 3 above that won't be an issue. |
|
Ok got it disregard what I said about gpio init, was wrong about that. Just make sure the alternate function matches |
48879a6 to
2536ab3
Compare
| bus6.begin(kEncBaud); | ||
| bus2.begin(kEncBaud); | ||
| if (!bus6.ready()){ | ||
| CommsSerial.println("ERROR: RS485 bus6 (USART6) init failed"); |
There was a problem hiding this comment.
Done. My only concern is that here if we return false immediately, then in the case that both bus6 and bus2 fail, we don't know the latter fails until we fix bus6. Whereas if we have a flag, and let both conditionals evaluate then return false, we will know if both busses or just one of them is broken at the same time.
There was a problem hiding this comment.
Ah - I would be fine with a flag as well - issue was that previously we weren't failing on bus2 status at all.
Fixed ec_main.cpp merge conflict
…efore read attempt
…etBaud() critical section
…y set hardware flow control using HAl instead of letting HAL init method configure it
9709f35 to
3ba0099
Compare
RobertJN64
left a comment
There was a problem hiding this comment.
LGTM - let's merge after testing on Saturday!
…o our begin() method.
This PR Implements
lib/RS485the integration of the RS485 transceivers for the Toad Engine Controller. The code allows for the baud rates to be dynamically switched as needed, and uses the hardware's core to mux the RS485s on the UART Busses, allowing for single-digit microsecond switching between sending and receiving.