Skip to content

When using portOutputRegister will throw an exception. #1110

@svaygame

Description

@svaygame

When using portOutputRegister will throw an exception.

Example project: adafruit-ssd1331

I found some issue at address operations

//Incorrect !! ,  the return value is not a valid address. Type of GPO is uint32_t , not an address pointer
#define portOutputRegister(port)    ((volatile uint32_t*) GPO)
//Correct , return the address of GPO  ,  
#define portOutputRegister(port)    ((volatile uint32_t*) &GPO)

reference:

https://github.com/esp8266/Arduino/blob/master/cores/esp8266/esp8266_peri.h

#define ESP8266_REG(addr) *((volatile uint32_t *)(0x60000000+(addr)))
...
#define GPO    ESP8266_REG(0x300) //GPIO_OUT R/W (Output Level)
#define GPE    ESP8266_REG(0x30C) //GPIO_ENABLE R/W (Enable)
#define GPI    ESP8266_REG(0x318) //GPIO_IN RO (Read Input Level)

https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Arduino.h

#define portOutputRegister(port)    ((volatile uint32_t*) GPO)
#define portInputRegister(port)     ((volatile uint32_t*) GPI)
#define portModeRegister(port)      ((volatile uint32_t*) GPE)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions