Skip to content

Commit 4b2938a

Browse files
dhylandsdpgeorge
authored andcommitted
stmhal: Some NETDUINO_PLUS_2 cleanup
- Put the I2C bus on the corect pins - Add the appropriate board_init to power the shield
1 parent 9598f36 commit 4b2938a

4 files changed

Lines changed: 31 additions & 29 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include STM32_HAL_H
2+
3+
void NETDUINO_PLUS_2_board_early_init(void) {
4+
5+
__GPIOB_CLK_ENABLE();
6+
7+
// Turn off the backlight. LCD_BL_CTRL = PK3
8+
GPIO_InitTypeDef GPIO_InitStructure;
9+
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
10+
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
11+
GPIO_InitStructure.Pull = GPIO_PULLUP;
12+
13+
#if MICROPY_HW_HAS_SDCARD
14+
// Turn on the power enable for the sdcard (PB1)
15+
GPIO_InitStructure.Pin = GPIO_PIN_1;
16+
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
17+
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);
18+
#endif
19+
20+
// Turn on the power for the 5V on the expansion header (PB2)
21+
GPIO_InitStructure.Pin = GPIO_PIN_2;
22+
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
23+
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_SET);
24+
}

stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#define NETDUINO_PLUS_2
2-
31
#define MICROPY_HW_BOARD_NAME "NetduinoPlus2"
42
#define MICROPY_HW_MCU_NAME "STM32F405RG"
53

@@ -20,6 +18,9 @@
2018
#define MICROPY_HW_ENABLE_DAC (0)
2119
#define MICROPY_HW_ENABLE_CAN (0)
2220

21+
void NETDUINO_PLUS_2_board_early_init(void);
22+
#define MICROPY_BOARD_EARLY_INIT NETDUINO_PLUS_2_board_early_init
23+
2324
// HSE is 25MHz
2425
#define MICROPY_HW_CLK_PLLM (25)
2526
#define MICROPY_HW_CLK_PLLN (336)
@@ -43,8 +44,8 @@
4344
#define MICROPY_HW_UART6_PINS (GPIO_PIN_6 | GPIO_PIN_7)
4445

4546
// I2C busses
46-
#define MICROPY_HW_I2C2_SCL (pin_B10)
47-
#define MICROPY_HW_I2C2_SDA (pin_B11)
47+
#define MICROPY_HW_I2C1_SCL (pin_B6)
48+
#define MICROPY_HW_I2C1_SDA (pin_B7)
4849

4950
// SPI busses
5051
#define MICROPY_HW_SPI2_NSS (pin_B12)

stmhal/boards/NETDUINO_PLUS_2/pins.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ D10,PB10
1212
D11,PB15
1313
D12,PB14
1414
D13,PB13
15+
SDA,PB6
16+
SCL,PB7
1517
A0,PC0
1618
A1,PC1
1719
A2,PC2

stmhal/main.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -380,31 +380,6 @@ int main(void) {
380380
MICROPY_BOARD_EARLY_INIT();
381381
#endif
382382

383-
//TODO - Move the following to a board_init.c file for the NETDUINO
384-
#if 0
385-
#if defined(NETDUINO_PLUS_2)
386-
{
387-
GPIO_InitTypeDef GPIO_InitStructure;
388-
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
389-
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
390-
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
391-
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
392-
393-
#if MICROPY_HW_HAS_SDCARD
394-
// Turn on the power enable for the sdcard (PB1)
395-
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
396-
GPIO_Init(GPIOB, &GPIO_InitStructure);
397-
GPIO_WriteBit(GPIOB, GPIO_Pin_1, Bit_SET);
398-
#endif
399-
400-
// Turn on the power for the 5V on the expansion header (PB2)
401-
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
402-
GPIO_Init(GPIOB, &GPIO_InitStructure);
403-
GPIO_WriteBit(GPIOB, GPIO_Pin_2, Bit_SET);
404-
}
405-
#endif
406-
#endif
407-
408383
// basic sub-system init
409384
pendsv_init();
410385
led_init();

0 commit comments

Comments
 (0)