Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GPIO direct access #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 10 additions & 7 deletions sming/libraries/Adafruit_PCD8544/Adafruit_PCD8544.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ This is a library for our Monochrome Nokia 5110 LCD Displays
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/products/338

These displays use SPI to communicate, 4 or 5 pins are required to
These displays use SPI to communicate, 4 or 5 pins are required to
interface

Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
Expand All @@ -31,6 +31,9 @@ All text above, and the splash screen must be included in any redistribution
#ifdef __SAM3X8E__
typedef volatile RwReg PortReg;
typedef uint32_t PortMask;
#elif defined (__ESP8266_EX__)
typedef volatile GPIO_REG_TYPE PortReg;
typedef GPIO_REG_TYPE PortMask;
#else
typedef volatile uint8_t PortReg;
typedef uint8_t PortMask;
Expand Down Expand Up @@ -79,14 +82,14 @@ class Adafruit_PCD8544 : public Adafruit_GFX {
Adafruit_PCD8544(int8_t DC, int8_t CS, int8_t RST);

void begin(uint8_t contrast = 40, uint8_t bias = 0x04);

void command(uint8_t c);
void data(uint8_t c);

void setContrast(uint8_t val);
void clearDisplay(void);
void display();

void drawPixel(int16_t x, int16_t y, uint16_t color);
uint8_t getPixel(int8_t x, int8_t y);

Expand Down
11 changes: 7 additions & 4 deletions sming/libraries/Adafruit_SSD1306/Adafruit_SSD1306.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ This is a library for our Monochrome OLEDs based on SSD1306 drivers
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/category/63_98

These displays use SPI to communicate, 4 or 5 pins are required to
These displays use SPI to communicate, 4 or 5 pins are required to
interface

Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
Expand All @@ -27,6 +27,9 @@ All text above, and the splash screen must be included in any redistribution
#ifdef __SAM3X8E__
typedef volatile RwReg PortReg;
typedef uint32_t PortMask;
#elif defined (__ESP8266_EX__)
typedef volatile GPIO_REG_TYPE PortReg;
typedef GPIO_REG_TYPE PortMask;
#else
typedef volatile uint8_t PortReg;
typedef uint8_t PortMask;
Expand Down
12 changes: 6 additions & 6 deletions sming/sming/core/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
#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.

// Conversion disabled for now
#define digitalPinToTimer(P) ( NOT_ON_TIMER )

#define digitalPinToPort(P) ( P < 0 ? NOT_A_PIN : ( (int)P < 8 ? PA : ( (int)P < 16 ? PB : ( (int)P == 16 ? PC : NOT_A_PIN ) ) ) )
#define digitalPinToBitMask(P) ( (int)P < 8 ? _BV((int)P) : ( P < 16 ? _BV( (int)P-8 ) : 1) )
#define digitalPinToPort(P) ( P < 0 ? NOT_A_PIN : ( (int)P < 8 ? PA : ( (int)P < 16 ? PB : ( (int)P == 16 ? PC : NOT_A_PORT ) ) ) )
#define digitalPinToBitMask(P) ( (int)P < 16 ? _BV((int)P) : 1 )

#define STD_GPIO_OUT (PERIPHS_GPIO_BASEADDR + GPIO_OUT_ADDRESS)
#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) ((volatile GPIO_REG_TYPE*)(P != PC ? STD_GPIO_OUT : RTC_GPIO_OUT))
#define portInputRegister(P) ((volatile GPIO_REG_TYPE*)(P != PC ? STD_GPIO_IN : RTC_GPIO_IN_DATA))
#define portModeRegister(P) ((volatile GPIO_REG_TYPE*)(P != PC ? STD_GPIO_ENABLE : RTC_GPIO_ENABLE)) // Stored bits: 0=In, 1=Out


#endif /* WIRING_PINS_ARDUINO_H_ */