Skip to content

Commit a16ff8e

Browse files
Changes so that generic_pc13 version uses Boot1 jump link as the button pin so that the bootloader holds in DFU mode. Also rebuilt and tested generic_pa1 to check no side effects of these changes
1 parent dfb77c5 commit a16ff8e

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

binaries/generic_boot20_pa1.bin

0 Bytes
Binary file not shown.

binaries/generic_boot20_pc13.bin

0 Bytes
Binary file not shown.
-28 Bytes
Binary file not shown.
-28 Bytes
Binary file not shown.

config.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,16 @@
147147

148148
#elif defined TARGET_GENERIC_F103_PC13
149149

150+
150151
#define LED_BANK GPIOC
151152
#define LED_PIN 13
152153
#define LED_ON_STATE 0
153154

154-
// Button (if you have one)
155-
156-
#define BUTTON_BANK GPIOC
157-
#define BUTTON_PIN 14
155+
// Use Boot1 PB2 as the button, as hardly anyone uses this pin as GPIO
156+
// Need to set the button input mode to just CR_INPUT and not CR_INPUT_PU_PD because the external pullup on the jumplink is very weak
157+
#define BUTTON_INPUT_MODE CR_INPUT
158+
#define BUTTON_BANK GPIOB
159+
#define BUTTON_PIN 2
158160
#define BUTTON_PRESSED_STATE 1
159161

160162

@@ -362,6 +364,13 @@
362364
#error "No config for this target"
363365
#endif
364366

367+
// Check if button pulldown should be enabled
368+
// Default to True as this was the default prior to needing to disable it
369+
// in order to use the boot1 pin on the Blue Pill which has a very week pullup
370+
#ifndef BUTTON_INPUT_MODE
371+
#define BUTTON_INPUT_MODE CR_INPUT_PU_PD
372+
#endif
373+
365374
#define STARTUP_BLINKS 5
366375
#ifndef BOOTLOADER_WAIT
367376
#ifdef BUTTON_BANK

hardware.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void setupLEDAndButton (void) {
152152
// SET_REG(AFIO_MAPR,(GET_REG(AFIO_MAPR) & ~AFIO_MAPR_SWJ_CFG) | AFIO_MAPR_SWJ_CFG_NO_JTAG_NO_SW);// Try to disable SWD AND JTAG so we can use those pins (not sure if this works).
153153

154154
#if defined(BUTTON_BANK) && defined (BUTTON_PIN) && defined (BUTTON_PRESSED_STATE)
155-
SET_REG(GPIO_CR(BUTTON_BANK,BUTTON_PIN),(GPIO_CR(BUTTON_BANK,BUTTON_PIN) & crMask(BUTTON_PIN)) | CR_INPUT_PU_PD << CR_SHITF(BUTTON_PIN));
155+
SET_REG(GPIO_CR(BUTTON_BANK,BUTTON_PIN),(GPIO_CR(BUTTON_BANK,BUTTON_PIN) & crMask(BUTTON_PIN)) | BUTTON_INPUT_MODE << CR_SHITF(BUTTON_PIN));
156156

157157
gpio_write_bit(BUTTON_BANK, BUTTON_PIN,1-BUTTON_PRESSED_STATE);// set pulldown resistor in case there is no button.
158158
#endif

0 commit comments

Comments
 (0)