BV global: put RS-485 and CAN transceivers in safe mode
This commit is contained in:
parent
912509925e
commit
ee5e5cf244
|
@ -151,19 +151,27 @@ void busvoodoo_safe_state(void)
|
|||
}
|
||||
|
||||
if (busvoodoo_full) {
|
||||
// disable all RS-232 and some RS-485 signals (put back to input floating)
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS232_TX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS232_TX_PIN));
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS232_RX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS232_RX_PIN));
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS232_RTS_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS232_RTS_PIN));
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS232_CTS_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS232_CTS_PIN));
|
||||
// disable RS-232 signals
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS232_TX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS232_TX_PIN)); // set pin to floating
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS232_RX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS232_RX_PIN)); // set pin to floating
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS232_RTS_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS232_RTS_PIN)); // set pin to floating
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS232_CTS_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS232_CTS_PIN)); // set pin to floating
|
||||
gpio_set(GPIO(BUSVOODOO_RS232_EN_PORT), GPIO(BUSVOODOO_RS232_EN_PIN)); // set high to disable receiver
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS232_EN_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO(BUSVOODOO_RS232_EN_PIN)); // use external pull-up resistor to set high by default
|
||||
gpio_clear(GPIO(BUSVOODOO_RS232_SHDN_PORT), GPIO(BUSVOODOO_RS232_SHDN_PIN)); // set low to disable transmitter
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS232_SHDN_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(BUSVOODOO_RS232_SHDN_PIN)); // there is also an external pull-down resistor to disable per default
|
||||
|
||||
// disable RS-485 signals (RS and TX are shared with RS-232)
|
||||
gpio_set(GPIO(BUSVOODOO_RS485_RE_PORT), GPIO(BUSVOODOO_RS485_RE_PIN)); // set high to disable receiver
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS485_RE_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO(BUSVOODOO_RS485_RE_PIN)); // use external pull-up resistor to set high by default
|
||||
gpio_clear(GPIO(BUSVOODOO_RS485_DE_PORT), GPIO(BUSVOODOO_RS485_DE_PIN)); // set low to disable transmitter
|
||||
gpio_set_mode(GPIO(BUSVOODOO_RS485_DE_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(BUSVOODOO_RS485_DE_PIN)); // there is also an external pull-down resistor to disable per default
|
||||
|
||||
// disable all CAN and some RS-458 signals (put back to input floating)
|
||||
gpio_set_mode(GPIO(BUSVOODOO_CAN_TX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_CAN_TX_PIN));
|
||||
gpio_set_mode(GPIO(BUSVOODOO_CAN_RX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_CAN_RX_PIN));
|
||||
gpio_set_mode(GPIO(BUSVOODOO_CAN_EN_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_CAN_EN_PIN));
|
||||
gpio_set_mode(GPIO(BUSVOODOO_CAN_S_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_CAN_S_PIN));
|
||||
gpio_set_mode(GPIO(BUSVOODOO_CAN_TX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_CAN_TX_PIN)); // set pin to floating
|
||||
gpio_set_mode(GPIO(BUSVOODOO_CAN_RX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_CAN_RX_PIN)); // set pin to floating
|
||||
gpio_set(GPIO(BUSVOODOO_CAN_EN_PORT), GPIO(BUSVOODOO_CAN_EN_PIN)); // set high to power off transceiver
|
||||
gpio_set_mode(GPIO(BUSVOODOO_CAN_EN_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO(BUSVOODOO_CAN_EN_PIN)); // use external pull-up resistor to set high by default
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,13 +73,24 @@
|
|||
#define BUSVOODOO_RS232_RX_PIN 3 /**< RS-232 Receive input pin */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup busvoodoo_rs485 RS-485 (and RS-422) transceiver connection definition
|
||||
* @{
|
||||
*/
|
||||
#define BUSVOODOO_RS485_RE_PORT C /**< RS-232 pin to enable receiver (active low, pulled up) */
|
||||
#define BUSVOODOO_RS485_RE_PIN 13 /**< RS-232 pin to enable receiver (active low, pulled up) */
|
||||
#define BUSVOODOO_RS485_DE_PORT C /**< RS-232 pin to enable transmitter (active high, pulled low) */
|
||||
#define BUSVOODOO_RS485_DE_PIN 14 /**< RS-232 pin to enable transmitter (active high, pulled low) */
|
||||
#define BUSVOODOO_RS485_TX_PORT A /**< RS-485 Transmit output pin */
|
||||
#define BUSVOODOO_RS485_TX_PIN 2 /**< RS-485 Transmit output pin */
|
||||
#define BUSVOODOO_RS485_RX_PORT A /**< RS-485 Receive input pin */
|
||||
#define BUSVOODOO_RS485_RX_PIN 3 /**< RS-485 Receive input pin */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup busvoodoo_can CAN transceiver connection definition
|
||||
* @{
|
||||
*/
|
||||
#define BUSVOODOO_CAN_EN_PORT C /**< CAN pin to enable transceiver (active high, pulled low) */
|
||||
#define BUSVOODOO_CAN_EN_PIN 14 /**< CAN pin to enable transceiver (active high, pulled low) */
|
||||
#define BUSVOODOO_CAN_S_PORT C /**< CAN pin to set to silent mode (active low, pulled high) */
|
||||
#define BUSVOODOO_CAN_S_PIN 13 /**< CAN pin to set to silent mode (active low, pulled high) */
|
||||
#define BUSVOODOO_CAN_EN_PORT C /**< signal to power CAN transceiver (active high, pulled low) */
|
||||
#define BUSVOODOO_CAN_EN_PIN 7 /**< signal to power CAN transceiver (active high, pulled low) */
|
||||
#define BUSVOODOO_CAN_TX_PORT B /**< CAN Transmit output pin */
|
||||
#define BUSVOODOO_CAN_TX_PIN 9 /**< CAN Transmit output pin */
|
||||
#define BUSVOODOO_CAN_RX_PORT B /**< CAN Receive input pin */
|
||||
|
|
Loading…
Reference in New Issue