Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions Sming/Libraries/Adafruit_SSD1306/Adafruit_SSD1306.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,14 +517,18 @@ void Adafruit_SSD1306::display(void) {
if (sid != -1)
{
// SPI
//digitalWrite(cs, HIGH);
*csport |= cspinmask;
//digitalWrite(dc, HIGH);
*dcport |= dcpinmask;
//digitalWrite(cs, LOW);
*csport &= ~cspinmask;

for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
fastSPIwrite(buffer[i]);
//ssd1306_data(buffer[i]);
}
//digitalWrite(cs, HIGH);
*csport |= cspinmask;
}
else
Expand Down
4 changes: 2 additions & 2 deletions Sming/Libraries/Adafruit_SSD1306/Adafruit_SSD1306.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,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

#include "../../SmingCore/SPI.h"
Expand Down
2 changes: 1 addition & 1 deletion Sming/Libraries/Adafruit_ST7735/Adafruit_ST7735.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class Adafruit_ST7735 : public Adafruit_GFX {
boolean hwSPI;

#if defined(__AVR__) || defined(CORE_TEENSY) || defined (__ESP8266_EX__)
volatile uint8_t *dataport, *clkport, *csport, *rsport;
GPIO_REG_TYPE *dataport, *clkport, *csport, *rsport;
uint8_t _cs, _rs, _rst, _sid, _sclk,
datapinmask, clkpinmask, cspinmask, rspinmask,
colstart, rowstart; // some displays need this changed
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) )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what it's right correction. (uint32_t* + 1) will go out of register range.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not sure. I just changed uint8_t to uint32_t according Arduino/ESP8266 project to solve my problem #397 which works.

#define portInputRegister(P) ( ((GPIO_REG_TYPE*)(P != PC ? STD_GPIO_IN : RTC_GPIO_IN_DATA)) + ( ( ((int)P) == PB ) ? 1 : 0) )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

volatile uint8_t* was changed to GPIO_REG_TYPE* which is wrong. Without the volatile keyword the compiler may optimize-out the code. Please, bring back the volatile keyword.

#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_ */