For the Godilocks 20 I tried compiling a sketch with I used with the UNO and got the following error:
receive_j1939_log_Serial.ino: In function 'void setup()':
receive_j1939_log_Serial:302: error: 'INPUT_PULLUP' was not declared in this scope
Isn't INPUT PULLUP supported?
INPUT_PULLUP
Re: INPUT_PULLUP
That's unusual. Haven't seen this issue previously.
Can you add a little more code and background to make it easier to diagnose, please?
Can you add a little more code and background to make it easier to diagnose, please?
Re: INPUT_PULLUP
It's not supported in the current core that Goldilocks is based on. If it was based on the mightyp core then it is older than Arduino IDE v1.0.1. Which is when INPUT_PULLUP support was added.
The support was added to the core file wiring_digital.c file.
Current Goldilocks core wiring_digital.c file:
This is what was added from IDE v1.0.1 and up:
The support was added to the core file wiring_digital.c file.
Current Goldilocks core wiring_digital.c file:
Code: Select all
void pinMode(uint8_t pin, uint8_t mode)
{
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *reg, *out;
if (port == NOT_A_PIN) return;
// JWS: can I let the optimizer do this?
reg = portModeRegister(port);
out = portOutputRegister(port);
if (mode == INPUT) {
uint8_t oldSREG = SREG;
cli();
*reg &= ~bit;
*out &= ~bit;
SREG = oldSREG;
} else if (mode == INPUT_PULLUP) {
uint8_t oldSREG = SREG;
cli();
*reg &= ~bit;
*out |= bit;
SREG = oldSREG;
} else {
uint8_t oldSREG = SREG;
cli();
*reg |= bit;
SREG = oldSREG;
}
}
Code: Select all
void pinMode(uint8_t pin, uint8_t mode)
{
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *reg, *out;
if (port == NOT_A_PIN) return;
// JWS: can I let the optimizer do this?
reg = portModeRegister(port);
out = portOutputRegister(port);
if (mode == INPUT) {
uint8_t oldSREG = SREG;
cli();
*reg &= ~bit;
*out &= ~bit;
SREG = oldSREG;
} else if (mode == INPUT_PULLUP) {
uint8_t oldSREG = SREG;
cli();
*reg &= ~bit;
*out |= bit;
SREG = oldSREG;
} else {
uint8_t oldSREG = SREG;
cli();
*reg |= bit;
SREG = oldSREG;
}
}
Re: INPUT_PULLUP
How do we implement this for the Goldilocks?
Thanks
Bruce
Thanks
Bruce
Re: INPUT_PULLUP
If you are comfortable you can modify the file yourself.
Under where your sketch folder is edit this file ../Arduino/hardware/Goldilocks/cores/arduino/wiring_digital.c
Replace the pinmode() routine with the one I posted in my other message.
Also in the same folder edit this file,../Arduino/hardware/Goldilocks/cores/arduino/Arduino.h
Below these lines.
Add this line in the file.
Under where your sketch folder is edit this file ../Arduino/hardware/Goldilocks/cores/arduino/wiring_digital.c
Replace the pinmode() routine with the one I posted in my other message.
Also in the same folder edit this file,../Arduino/hardware/Goldilocks/cores/arduino/Arduino.h
Below these lines.
Code: Select all
#define INPUT 0x0
#define OUTPUT 0x1
Code: Select all
#define INPUT_PULLUP 0x2