Init power outputs to zero on startup

This commit is contained in:
Gregor Riepl 2021-01-25 20:58:15 +01:00
parent 3d40582b39
commit a2cccbde71

View file

@ -8,11 +8,21 @@
static bool report_change = false;
uint16_t bang(uint16_t data);
void strobe();
void uart_bang(uint8_t data);
static void init() {
// Enable GPIO: PB2, PB3, PB4 output, low; PB5 input, pull-up on
PORTB = (PORTB & ~(_BV(PB2) | _BV(PB3) | _BV(PB4))) | _BV(PB5);
PORTB = (PORTB & ~(_BV(PB2) | _BV(PB3) | _BV(PB4))) | _BV(PB5);
DDRB = (DDRB & ~_BV(PB5)) | (_BV(PB2) | _BV(PB3) | _BV(PB4));
// Important: Before we do anything else, reset all outputs
// The shift registers have an undefined state at startup,
// and there are no pull-downs on the outputs.
bang(0x0000);
strobe();
// Initialize CAN interface
can_init(BITRATE_125_KBPS);
// Regular receive/transmit mode