Skip to content

Commit

Permalink
Fix for wrong GPIO reg type (issue #397)
Browse files Browse the repository at this point in the history
  • Loading branch information
tprochazka authored and slav-at-attachix committed Jul 31, 2017
1 parent f3fd668 commit 73f38de
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Sming/Libraries/Adafruit_PCD8544/Adafruit_PCD8544.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ All text above, and the splash screen must be included in any redistribution
typedef volatile RwReg PortReg;
typedef uint32_t PortMask;
#else
typedef volatile uint8_t PortReg;
typedef uint8_t PortMask;
typedef volatile GPIO_REG_TYPE PortReg;
typedef GPIO_REG_TYPE PortMask;
#endif

#define BLACK 1
Expand Down
2 changes: 2 additions & 0 deletions Sming/Libraries/Adafruit_SSD1306/Adafruit_SSD1306.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ All text above, and the splash screen must be included in any redistribution
typedef volatile uint32_t PortReg;
typedef uint32_t PortMask;
#elif defined(__AVR__)
typedef volatile uint8_t PortReg;
typedef uint8_t PortMask;
typedef volatile uint8_t PortReg;
typedef uint8_t PortMask;
#define HAVE_PORTREG
Expand Down
2 changes: 1 addition & 1 deletion Sming/Libraries/CapacitiveSensor/CapacitiveSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#define PIN_TO_BASEREG(pin) (portOutputRegister(digitalPinToPort(pin)))
#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin))
#define IO_REG_TYPE uint8_t
#define IO_REG_TYPE GPIO_REG_TYPE
#define IO_REG_ASM
#define DIRECT_READ(base, mask) (((*((base)+GPIO_IN_ADDRESS)) & (mask)) ? 1 : 0)
#define DIRECT_MODE_INPUT(base, mask) ((*((base)+GPIO_ENABLE_ADDRESS)) &= ~(mask))
Expand Down
4 changes: 2 additions & 2 deletions Sming/Libraries/TFT_ILI9163C/TFT_ILI9163C.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ class TFT_ILI9163C : public Adafruit_GFX {

#if defined(__ESP8266_EX__)
void spiwrite(uint8_t);
volatile uint8_t *csport, *rsport;
volatile GPIO_REG_TYPE *csport, *rsport;
uint8_t _cs,_rs,_sid,_sclk,_rst;
uint8_t cspinmask, rspinmask;
GPIO_REG_TYPE cspinmask, rspinmask;
#endif // #ifdef __ESP8266_EX__
};
#endif
8 changes: 4 additions & 4 deletions Sming/SmingCore/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern const unsigned int A0; // Single ESP8266EX analog input pin (TOUT) 10 bit
#define PB 2
#define PC 3

#define GPIO_REG_TYPE uint8_t
#define GPIO_REG_TYPE uint32_t

// We use maximum compatibility to standard Arduino logic.

Expand All @@ -34,9 +34,9 @@ extern const unsigned int A0; // Single ESP8266EX analog input pin (TOUT) 10 bit
#define STD_GPIO_IN (PERIPHS_GPIO_BASEADDR + GPIO_IN_ADDRESS)
#define STD_GPIO_ENABLE (PERIPHS_GPIO_BASEADDR + GPIO_ENABLE_ADDRESS)

#define portOutputRegister(P) ( ((volatile uint8_t*)(P != PC ? STD_GPIO_OUT : RTC_GPIO_OUT)) + ( ( ((int)P) == PB ) ? 1 : 0) )
#define portInputRegister(P) ( ((volatile uint8_t*)(P != PC ? STD_GPIO_IN : RTC_GPIO_IN_DATA)) + ( ( ((int)P) == PB ) ? 1 : 0) )
#define portModeRegister(P) ( ((volatile uint8_t*)(P != PC ? STD_GPIO_ENABLE : RTC_GPIO_ENABLE)) + ( ( ((int)P) == PB ) ? 1 : 0) ) // Stored bits: 0=In, 1=Out
#define portOutputRegister(P) ( ((GPIO_REG_TYPE*)(P != PC ? STD_GPIO_OUT : RTC_GPIO_OUT)) + ( ( ((int)P) == PB ) ? 1 : 0) )
#define portInputRegister(P) ( ((GPIO_REG_TYPE*)(P != PC ? STD_GPIO_IN : RTC_GPIO_IN_DATA)) + ( ( ((int)P) == PB ) ? 1 : 0) )
#define portModeRegister(P) ( ((GPIO_REG_TYPE*)(P != PC ? STD_GPIO_ENABLE : RTC_GPIO_ENABLE)) + ( ( ((int)P) == PB ) ? 1 : 0) ) // Stored bits: 0=In, 1=Out


#endif /* WIRING_PINS_ARDUINO_H_ */

0 comments on commit 73f38de

Please sign in to comment.