Skip to content

Possible typo in Teensy LC SnoozeDigital for INPUT_PULLDOWN #116

Description

@tobywf

Snooze works great, thanks for your work. I did hit a small issue when using a Teensy LC, and trying to use INPUT_PULLDOWN for waking with SnoozeDigital (for waking when a signal goes high, basically the inverse of button_hold_wakeup).

The other HALs implement INPUT, INPUT_PULLUP, and INPUT_PULLDOWN:

if ( pin_mode == INPUT || pin_mode == INPUT_PULLUP || pin_mode == INPUT_PULLDOWN ) {
*portModeRegister( pinNumber ) = 0;
*config = PORT_PCR_MUX( 1 );
if ( pin_mode == INPUT_PULLUP ) *config |= PORT_PCR_PE | PORT_PCR_PS;// pullup
else if ( pin_mode == INPUT_PULLDOWN ) {
*config |= ( PORT_PCR_PE ); // pulldown
*config &= ~( PORT_PCR_PS );
}

if ( pin_mode == INPUT || pin_mode == INPUT_PULLUP || pin_mode == INPUT_PULLDOWN ) {
*portModeRegister( pinNumber ) = 0;
*config = PORT_PCR_MUX( 1 );
if ( pin_mode == INPUT_PULLUP ) *config |= PORT_PCR_PE | PORT_PCR_PS;// pullup
else if ( pin_mode == INPUT_PULLDOWN ) {
*config |= ( PORT_PCR_PE ); // pulldown
*config &= ~( PORT_PCR_PS );
}

if ( pin_mode == INPUT || pin_mode == INPUT_PULLUP || pin_mode == INPUT_PULLDOWN ) {
*portModeRegister( pinNumber ) = 0;
*config = PORT_PCR_MUX( 1 );
if ( pin_mode == INPUT_PULLUP ) *config |= PORT_PCR_PE | PORT_PCR_PS;// pullup
else if ( pin_mode == INPUT_PULLDOWN ) {
*config |= ( PORT_PCR_PE ); // pulldown
*config &= ~( PORT_PCR_PS );
}

It looks like INPUT_PULLDOWN was intended to work with the Teensy LC?

if ( pin_mode == INPUT || pin_mode == INPUT_PULLUP ) {// setup pin mode/type/interrupt
*portModeRegister( pinNumber ) &= ~digitalPinToBitMask( pinNumber );
*config = PORT_PCR_MUX( 1 );
if ( pin_mode == INPUT_PULLUP ) {
*config = PORT_PCR_MUX( 1 ) | PORT_PCR_PE | PORT_PCR_PS;// pullup
}
else if ( pin_mode == INPUT_PULLDOWN ) {
*config |= ( PORT_PCR_PE ); // pulldown
*config &= ~( PORT_PCR_PS );
}

After I modified line 88 to match the other HALs, waking seemed to work fine. So it seems like an omission, especially given the else if on line 94. I also looked in the datasheet and didn't find anything that would indicate INPUT_PULLDOWN is different in any way? If there's a a reason INPUT_PULLDOWN really isn't supported, it would be good to document that. In either case, I can cut a PR if you'd like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions