Skip to content

Commit

Permalink
stmhal: Some NETDUINO_PLUS_2 cleanup
Browse files Browse the repository at this point in the history
- Put the I2C bus on the corect pins
- Add the appropriate board_init to power the shield
  • Loading branch information
dhylands authored and dpgeorge committed Feb 15, 2016
1 parent 9598f36 commit 4b2938a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
24 changes: 24 additions & 0 deletions stmhal/boards/NETDUINO_PLUS_2/board_init.c
@@ -0,0 +1,24 @@
#include STM32_HAL_H

void NETDUINO_PLUS_2_board_early_init(void) {

__GPIOB_CLK_ENABLE();

// Turn off the backlight. LCD_BL_CTRL = PK3
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pull = GPIO_PULLUP;

#if MICROPY_HW_HAS_SDCARD
// Turn on the power enable for the sdcard (PB1)
GPIO_InitStructure.Pin = GPIO_PIN_1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);
#endif

// Turn on the power for the 5V on the expansion header (PB2)
GPIO_InitStructure.Pin = GPIO_PIN_2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_SET);
}
9 changes: 5 additions & 4 deletions stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h
@@ -1,5 +1,3 @@
#define NETDUINO_PLUS_2

#define MICROPY_HW_BOARD_NAME "NetduinoPlus2"
#define MICROPY_HW_MCU_NAME "STM32F405RG"

Expand All @@ -20,6 +18,9 @@
#define MICROPY_HW_ENABLE_DAC (0)
#define MICROPY_HW_ENABLE_CAN (0)

void NETDUINO_PLUS_2_board_early_init(void);
#define MICROPY_BOARD_EARLY_INIT NETDUINO_PLUS_2_board_early_init

// HSE is 25MHz
#define MICROPY_HW_CLK_PLLM (25)
#define MICROPY_HW_CLK_PLLN (336)
Expand All @@ -43,8 +44,8 @@
#define MICROPY_HW_UART6_PINS (GPIO_PIN_6 | GPIO_PIN_7)

// I2C busses
#define MICROPY_HW_I2C2_SCL (pin_B10)
#define MICROPY_HW_I2C2_SDA (pin_B11)
#define MICROPY_HW_I2C1_SCL (pin_B6)
#define MICROPY_HW_I2C1_SDA (pin_B7)

// SPI busses
#define MICROPY_HW_SPI2_NSS (pin_B12)
Expand Down
2 changes: 2 additions & 0 deletions stmhal/boards/NETDUINO_PLUS_2/pins.csv
Expand Up @@ -12,6 +12,8 @@ D10,PB10
D11,PB15
D12,PB14
D13,PB13
SDA,PB6
SCL,PB7
A0,PC0
A1,PC1
A2,PC2
Expand Down
25 changes: 0 additions & 25 deletions stmhal/main.c
Expand Up @@ -380,31 +380,6 @@ int main(void) {
MICROPY_BOARD_EARLY_INIT();
#endif

//TODO - Move the following to a board_init.c file for the NETDUINO
#if 0
#if defined(NETDUINO_PLUS_2)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

#if MICROPY_HW_HAS_SDCARD
// Turn on the power enable for the sdcard (PB1)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_WriteBit(GPIOB, GPIO_Pin_1, Bit_SET);
#endif

// Turn on the power for the 5V on the expansion header (PB2)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_WriteBit(GPIOB, GPIO_Pin_2, Bit_SET);
}
#endif
#endif

// basic sub-system init
pendsv_init();
led_init();
Expand Down

0 comments on commit 4b2938a

Please sign in to comment.