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

Add support for holding a button on boot to wait for programmer. #352

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
5 changes: 5 additions & 0 deletions optiboot/bootloaders/optiboot/optiboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,11 @@ int main(void) {
#endif
#endif

#ifdef HOLD_TO_PROG
if (HOLD_TO_PROG_ON)
watchdogConfig(WATCHDOG_OFF);
else
#endif
// Set up watchdog to trigger after desired timeout
watchdogConfig(WDTPERIOD);

Expand Down
23 changes: 23 additions & 0 deletions optiboot/bootloaders/optiboot/pin_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1628,3 +1628,26 @@
#if SOFT_UART && defined(SOFTTX) && defined(SOFTRX)
#include "pins_softuart.h"
#endif

#ifdef HOLD_TO_PROG

#if HOLD_TO_PROG == D0
#undef HOLD_TO_PROG
#define HOLD_TO_PROG_PIN PIND
#define HOLD_TO_PROG PIND0

#else
#error -------------------------------------------
#error Unrecognized LED name. Should be like "B5"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is incorrect wording probably an effect of cut&paste. Can you re-word please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll change it (and yeah, it's cut and paste).

#error -------------------------------------------
#endif

#endif

#ifdef BUTTON_ON_HIGH
// A pin is 1 when the button is down
#define HOLD_TO_PROG_ON ((HOLD_TO_PROG_PIN & HOLD_TO_PROG) == 1)
#else
// A pin is 0 when the button is down
#define HOLD_TO_PROG_ON ((HOLD_TO_PROG_PIN & HOLD_TO_PROG) == 0)
#endif