Skip to content

Commit

Permalink
Merge pull request #160 from manuelbl/issue38
Browse files Browse the repository at this point in the history
Fix #38: Properly initialize NSS, RXTX, RST pins
  • Loading branch information
terrillmoore authored Oct 28, 2018
2 parents aa1b263 + bea7e9e commit 48d154c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/hal/hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,19 @@ static void hal_io_init () {
// Serial.print("dio[1]: "); Serial.println(plmic_pins->dio[1]);
// Serial.print("dio[2]: "); Serial.println(plmic_pins->dio[2]);

// initialize SPI chip select to high (it's active low)
digitalWrite(plmic_pins->nss, HIGH);
pinMode(plmic_pins->nss, OUTPUT);
if (plmic_pins->rxtx != LMIC_UNUSED_PIN)

if (plmic_pins->rxtx != LMIC_UNUSED_PIN) {
// initialize to RX
digitalWrite(plmic_pins->rxtx, LOW != plmic_pins->rxtx_rx_active);
pinMode(plmic_pins->rxtx, OUTPUT);
if (plmic_pins->rst != LMIC_UNUSED_PIN)
pinMode(plmic_pins->rst, OUTPUT);
}
if (plmic_pins->rst != LMIC_UNUSED_PIN) {
// initialize RST to floating
pinMode(plmic_pins->rst, INPUT);
}

hal_interrupt_init();
}
Expand All @@ -54,8 +62,8 @@ void hal_pin_rst (u1_t val) {
return;

if(val == 0 || val == 1) { // drive pin
pinMode(plmic_pins->rst, OUTPUT);
digitalWrite(plmic_pins->rst, val);
pinMode(plmic_pins->rst, OUTPUT);
} else { // keep pin floating
pinMode(plmic_pins->rst, INPUT);
}
Expand Down

0 comments on commit 48d154c

Please sign in to comment.