Commit 4b2938a4 authored by Dave Hylands's avatar Dave Hylands Committed by Damien George
Browse files

stmhal: Some NETDUINO_PLUS_2 cleanup

- Put the I2C bus on the corect pins
- Add the appropriate board_init to power the shield
parent 9598f36a
#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);
}
#define NETDUINO_PLUS_2
#define MICROPY_HW_BOARD_NAME "NetduinoPlus2"
#define MICROPY_HW_MCU_NAME "STM32F405RG"
......@@ -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)
......@@ -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)
......
......@@ -12,6 +12,8 @@ D10,PB10
D11,PB15
D12,PB14
D13,PB13
SDA,PB6
SCL,PB7
A0,PC0
A1,PC1
A2,PC2
......
......@@ -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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment