Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By kriss_fr
#34539 Hi,

First of all Thank you very much to add the ESP8266 board to the arduino IDE, it's soo good ! :D

I'm trying to add the compatibility of the ESP8266 to a sketch design for arduino Mega board.
Thanks to your work on the IDE, almost all is working out of the box.

But unfortunately a small part of the code use register and port (with digitalpintoport() ) and i guess the esp8266 doesn't have port like the Mega board.

here is the part of the code :
Code: Select alluint8_t Fbit=0;
uint8_t Fport=0;
uint8_t FstateMask=0;

boolean FetchSignal(byte DataPin, boolean StateSignal) {
   uint8_t Fbit = digitalPinToBitMask(DataPin);
   uint8_t Fport = digitalPinToPort(DataPin);
   uint8_t FstateMask = (StateSignal ? Fbit : 0);

   if ((*portInputRegister(Fport) & Fbit) == FstateMask) {
  // do some stuff, but for the moment the program never go here :(
  }
}

// the function above is call like that :
// FetchSignal(PIN_RF_RX_DATA,HIGH)
// the PIN_RF_RX_DATA is define at 19 for the Mega board
// the PIN_RF_RX_DATA is define at D6 for the esp8266 board



If i print the value of Fport, it display 0 . Is it the cause of the issue ?
How to make the portInputRegister() working ?

ps: the program compile fine
Last edited by kriss_fr on Wed Nov 25, 2015 4:03 am, edited 1 time in total.
User avatar
By martinayotte
#34887 Why don't you simply use digitalRead() instead ?
In Arduino.h, the following defines are there, but since nobody is using it, maybe there are bugs that never been flagged :
Code: Select all#define digitalPinToPort(pin)       (0)
#define digitalPinToBitMask(pin)    (1UL << (pin))
#define digitalPinToTimer(pin)      (0)
#define portOutputRegister(port)    ((volatile uint32_t*) GPO)
#define portInputRegister(port)     ((volatile uint32_t*) GPI)
#define portModeRegister(port)      ((volatile uint32_t*) GPE)
User avatar
By kriss_fr
#34899 Hi martinayotte, thanks for your reply :)

The original sketch for the arduino Mega is not from me, but i know that they use port register because DigitalRead() is too slow for reading input from a 433 MHz receiver. As i don't know if the DigitalRead function is quick enought, i'm currently trying to use an equivalent of the port register reading method.

Currently i try to use the GPIP(DataPin) function, but i never enter inside the if condition (i also tryed with DigitalRead() function without succes).

Do you have any advices ?