Skip to content

Commit

Permalink
Gen2: conditionally initialize SWD/JTAG pins.
Browse files Browse the repository at this point in the history
  • Loading branch information
XuGuohui committed Apr 21, 2020
1 parent faf75fc commit 87ac2e0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 4 additions & 0 deletions hal/src/electron/pinmap_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#define TOTAL_DAC_PINS 2
#define TOTAL_ANALOG_PINS 12
#define FIRST_ANALOG_PIN 10
#define TOTAL_ESSENTIAL_PINS 20
#define HAS_EXTRA_PINS 1
#define FIRST_EXTRA_PIN 24
#define LAST_EXTRA_PIN 35

#define D0 0
#define D1 1
Expand Down
6 changes: 6 additions & 0 deletions hal/src/photon/pinmap_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#define TOTAL_DAC_PINS 2
#define TOTAL_ANALOG_PINS 8
#define FIRST_ANALOG_PIN 10
#define TOTAL_ESSENTIAL_PINS 20
#define HAS_EXTRA_PINS 0

// Digital pins
#define D0 0
Expand Down Expand Up @@ -93,6 +95,10 @@
#define TOTAL_DAC_PINS 2
#define TOTAL_ANALOG_PINS 13
#define FIRST_ANALOG_PIN 10
#define TOTAL_ESSENTIAL_PINS 20
#define HAS_EXTRA_PINS 1
#define FIRST_EXTRA_PIN 24
#define LAST_EXTRA_PIN 29

// Digital pins
#define D0 0
Expand Down
17 changes: 8 additions & 9 deletions hal/src/stm32f2xx/core_hal_stm32f2xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,27 +345,26 @@ void HAL_Core_Config(void)
PWR_WakeUpPinCmd(DISABLE);

//Wiring pins default to inputs
for (pin_t pin = 0; pin <= 19; pin++) {
for (pin_t pin = 0; pin < TOTAL_ESSENTIAL_PINS; pin++) {
#if defined(USE_SWD_JTAG) || defined(USE_SWD)
if (pin >= 3 && pin <= 7) {
if (pin >= D3 && pin <= D7) { // JTAG pins
continue;
}
#endif
HAL_Pin_Mode(pin, INPUT);
}
#if PLATFORM_ID==8 // Additional pins for P1
for (pin_t pin = 24; pin <= 29; pin++) {

#if HAS_EXTRA_PINS
for (pin_t pin = FIRST_EXTRA_PIN; pin <= LAST_EXTRA_PIN; pin++) {
HAL_Pin_Mode(pin, INPUT);
}
#endif

#if PLATFORM_ID==8
if (isWiFiPowersaveClockDisabled()) {
HAL_Pin_Mode(30, INPUT); // Wi-Fi Powersave clock is disabled, default to INPUT
}
#endif
#if PLATFORM_ID==10 // Additional pins for Electron
for (pin_t pin = 24; pin <= 35; pin++) {
HAL_Pin_Mode(pin, INPUT);
}
#endif

HAL_Core_Config_systick_configuration();

Expand Down
2 changes: 0 additions & 2 deletions hal/src/stm32f2xx/i2c_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ int HAL_I2C_Init(HAL_I2C_Interface i2c, const HAL_I2C_Config* config)
if(i2c == HAL_I2C_INTERFACE1)
{
i2cMap[i2c] = &I2C_MAP[I2C1_D0_D1];
HAL_Pin_Mode(i2cMap[i2c]->I2C_SDA_Pin, INPUT);
HAL_Pin_Mode(i2cMap[i2c]->I2C_SCL_Pin, INPUT);
}
#if PLATFORM_ID == PLATFORM_ELECTRON_PRODUCTION // Electron
if(i2c == HAL_I2C_INTERFACE2 || i2c == HAL_I2C_INTERFACE1)
Expand Down

0 comments on commit 87ac2e0

Please sign in to comment.