summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDave Hylands <dhylands@gmail.com>2016-02-12 21:25:00 -0800
committerDamien George <damien.p.george@gmail.com>2016-02-15 10:07:27 +0000
commit4b2938a4b0ec6b31691509003cb1eda9458fa2d7 (patch)
tree4fb51ef7ae1c066050ef0b7aba719b93317d9cf8
parent9598f36a84e19045e2978ab902e2367dc2fa12d4 (diff)
downloadmicropython-4b2938a4b0ec6b31691509003cb1eda9458fa2d7.tar.gz
micropython-4b2938a4b0ec6b31691509003cb1eda9458fa2d7.zip
stmhal: Some NETDUINO_PLUS_2 cleanup
- Put the I2C bus on the corect pins - Add the appropriate board_init to power the shield
-rw-r--r--stmhal/boards/NETDUINO_PLUS_2/board_init.c24
-rw-r--r--stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h9
-rw-r--r--stmhal/boards/NETDUINO_PLUS_2/pins.csv2
-rw-r--r--stmhal/main.c25
4 files changed, 31 insertions, 29 deletions
diff --git a/stmhal/boards/NETDUINO_PLUS_2/board_init.c b/stmhal/boards/NETDUINO_PLUS_2/board_init.c
new file mode 100644
index 0000000000..085034b2d8
--- /dev/null
+++ b/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);
+}
diff --git a/stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h b/stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h
index 872e285ae2..8ec8df645f 100644
--- a/stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h
+++ b/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"
@@ -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)
diff --git a/stmhal/boards/NETDUINO_PLUS_2/pins.csv b/stmhal/boards/NETDUINO_PLUS_2/pins.csv
index f9b94a6c87..7857f4e870 100644
--- a/stmhal/boards/NETDUINO_PLUS_2/pins.csv
+++ b/stmhal/boards/NETDUINO_PLUS_2/pins.csv
@@ -12,6 +12,8 @@ D10,PB10
D11,PB15
D12,PB14
D13,PB13
+SDA,PB6
+SCL,PB7
A0,PC0
A1,PC1
A2,PC2
diff --git a/stmhal/main.c b/stmhal/main.c
index 02dcc76174..329109cd3d 100644
--- a/stmhal/main.c
+++ b/stmhal/main.c
@@ -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();