Skip to content

Commit 45e02a9

Browse files
committed
Fix pins.
Former-commit-id: 6b69e30
1 parent a811c9f commit 45e02a9

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

cores/nRF5/wiring_digital.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ void pinMode( uint32_t ulPin, uint32_t ulMode )
3131
return;
3232
}
3333

34+
ulPin = g_ADigitalPinMap[ulPin];
35+
3436
// Set pin mode according to chapter '22.6.3 I/O Pin Configuration'
3537
switch ( ulMode )
3638
{
@@ -66,6 +68,8 @@ void digitalWrite( uint32_t ulPin, uint32_t ulVal )
6668
return;
6769
}
6870

71+
ulPin = g_ADigitalPinMap[ulPin];
72+
6973
if (ulVal == LOW) {
7074
nrf_gpio_pin_clear(ulPin);
7175
} else {
@@ -81,16 +85,23 @@ int digitalRead( uint32_t ulPin )
8185
return 0;
8286
}
8387

88+
ulPin = g_ADigitalPinMap[ulPin];
89+
8490
if (nrf_gpio_pin_dir_get(ulPin) == NRF_GPIO_PIN_DIR_INPUT) {
8591
return nrf_gpio_pin_read(ulPin);
8692
} else {
8793
return nrf_gpio_pin_out_read(ulPin);
8894
}
8995
}
9096

91-
void digitalToggle( uint32_t pin )
97+
void digitalToggle( uint32_t ulPin )
9298
{
93-
nrf_gpio_pin_toggle(pin);
99+
if (ulPin >= PINS_COUNT) {
100+
return;
101+
}
102+
103+
ulPin = g_ADigitalPinMap[ulPin];
104+
nrf_gpio_pin_toggle(ulPin);
94105
}
95106

96107
#ifdef LED_STATE_ON

libraries/SPI/SPI.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ SPIClass::SPIClass(NRF_SPI_Type *p_spi, uint8_t uc_pinMISO, uint8_t uc_pinSCK, u
4646
_bitOrder = SPI_CONFIG_ORDER_MsbFirst;
4747
}
4848

49-
#ifdef ARDUINO_GENERIC
5049
void SPIClass::setPins(uint8_t uc_pinMISO, uint8_t uc_pinSCK, uint8_t uc_pinMOSI)
5150
{
5251
_uc_pinMiso = g_ADigitalPinMap[uc_pinMISO];
5352
_uc_pinSCK = g_ADigitalPinMap[uc_pinSCK];
5453
_uc_pinMosi = g_ADigitalPinMap[uc_pinMOSI];
5554
}
56-
#endif // ARDUINO_GENERIC
5755

5856
void SPIClass::begin()
5957
{

libraries/SPI/SPI.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ class SPIClass {
100100
void attachInterrupt();
101101
void detachInterrupt();
102102

103-
#ifdef ARDUINO_GENERIC
104103
void setPins(uint8_t uc_pinMISO, uint8_t uc_pinSCK, uint8_t uc_pinMOSI);
105-
#endif // ARDUINO_GENERIC
104+
106105
void begin();
107106
void end();
108107

libraries/Wire/Wire.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ class TwoWire : public Stream
3939
#else
4040
TwoWire(NRF_TWI_Type * p_twi, uint8_t pinSDA, uint8_t pinSCL);
4141
#endif
42-
#ifdef ARDUINO_GENERIC
4342
void setPins(uint8_t pinSDA, uint8_t pinSCL);
44-
#endif // ARDUINO_GENERIC
4543
void begin();
4644
#if defined(NRF52_SERIES)
4745
void begin(uint8_t);

libraries/Wire/Wire_nRF51.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,11 @@ TwoWire::TwoWire(NRF_TWI_Type * p_twi, uint8_t pinSDA, uint8_t pinSCL)
4141
this->suspended = false;
4242
}
4343

44-
#ifdef ARDUINO_GENERIC
4544
void TwoWire::setPins(uint8_t pinSDA, uint8_t pinSCL)
4645
{
4746
this->_uc_pinSDA = pinSDA;
4847
this->_uc_pinSCL = pinSCL;
4948
}
50-
#endif // ARDUINO_GENERIC
5149

5250
void TwoWire::begin(void) {
5351
//Master Mode

libraries/Wire/Wire_nRF52.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,11 @@ TwoWire::TwoWire(NRF_TWIM_Type * p_twim, NRF_TWIS_Type * p_twis, IRQn_Type IRQn,
4141
transmissionBegun = false;
4242
}
4343

44-
#ifdef ARDUINO_GENERIC
4544
void TwoWire::setPins(uint8_t pinSDA, uint8_t pinSCL)
4645
{
4746
this->_uc_pinSDA = pinSDA;
4847
this->_uc_pinSCL = pinSCL;
4948
}
50-
#endif // ARDUINO_GENERIC
5149

5250
void TwoWire::begin(void) {
5351
//Master Mode

0 commit comments

Comments
 (0)