You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/10/21 01:39:18 UTC
incubator-mynewt-core git commit: MYNEWT-424;
MCU specific define mapping port/pin to a single number.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop 598cd4b4c -> dbb78037e
MYNEWT-424; MCU specific define mapping port/pin to a single number.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/dbb78037
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/dbb78037
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/dbb78037
Branch: refs/heads/develop
Commit: dbb78037e27c532b91078d51dd327bf92a8c9f50
Parents: 598cd4b
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Oct 20 18:28:51 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Oct 20 18:28:51 2016 -0700
----------------------------------------------------------------------
hw/bsp/frdm-k64f/include/bsp/bsp.h | 3 +-
hw/bsp/nucleo-f401re/include/bsp/bsp.h | 3 +-
hw/bsp/nucleo-f401re/src/hal_bsp.c | 23 +++++-----
.../include/bsp/bsp.h | 3 +-
hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c | 8 ++--
hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c | 14 +++----
hw/mcu/native/include/mcu/mcu.h | 36 ++++++++++++++++
hw/mcu/nordic/nrf51xxx/include/mcu/mcu.h | 36 ++++++++++++++++
hw/mcu/nordic/nrf52xxx/include/mcu/mcu.h | 36 ++++++++++++++++
hw/mcu/nxp/MK64F12/include/mcu/mcu.h | 40 ++++++++++++++++++
hw/mcu/stm/stm32f4xx/include/mcu/mcu.h | 44 ++++++++++++++++++++
11 files changed, 221 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb78037/hw/bsp/frdm-k64f/include/bsp/bsp.h
----------------------------------------------------------------------
diff --git a/hw/bsp/frdm-k64f/include/bsp/bsp.h b/hw/bsp/frdm-k64f/include/bsp/bsp.h
index e70a21d..be2af2c 100644
--- a/hw/bsp/frdm-k64f/include/bsp/bsp.h
+++ b/hw/bsp/frdm-k64f/include/bsp/bsp.h
@@ -20,6 +20,7 @@
#define H_BSP_H
#include <stdint.h>
+#include <mcu/mcu.h>
#ifdef __cplusplus
extern "C" {
@@ -29,7 +30,7 @@ extern uint8_t __DATA_ROM;
#define RAM_SIZE 0x40000
/* LED pins */
-#define LED_BLINK_PIN (54)
+#define LED_BLINK_PIN MCU_GPIO_PORTB(22)
/* UART info */
#define CONSOLE_UART "uart0"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb78037/hw/bsp/nucleo-f401re/include/bsp/bsp.h
----------------------------------------------------------------------
diff --git a/hw/bsp/nucleo-f401re/include/bsp/bsp.h b/hw/bsp/nucleo-f401re/include/bsp/bsp.h
index 0f5cbd5..4b9c9a6 100644
--- a/hw/bsp/nucleo-f401re/include/bsp/bsp.h
+++ b/hw/bsp/nucleo-f401re/include/bsp/bsp.h
@@ -20,6 +20,7 @@
#define H_BSP_H
#include <inttypes.h>
+#include <mcu/mcu.h>
#ifdef __cplusplus
extern "C" {
@@ -38,7 +39,7 @@ extern uint8_t _ram_start;
#define RAM_SIZE (96 * 1024)
/* LED pins */
-#define LED_BLINK_PIN (5)
+#define LED_BLINK_PIN MCU_GPIO_PORTA(5)
/* UART */
#define UART_CNT 1
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb78037/hw/bsp/nucleo-f401re/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nucleo-f401re/src/hal_bsp.c b/hw/bsp/nucleo-f401re/src/hal_bsp.c
index 4958ec4..8940388 100644
--- a/hw/bsp/nucleo-f401re/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f401re/src/hal_bsp.c
@@ -31,6 +31,7 @@
#endif
#include <stm32f401xe.h>
#include <stm32f4xx_hal_gpio_ex.h>
+#include <mcu/mcu.h>
#include <mcu/stm32f4_bsp.h>
#include <mcu/stm32f4xx_mynewt_hal.h>
#include "bsp/bsp.h"
@@ -44,10 +45,10 @@ static const struct stm32f4_uart_cfg uart_cfg[UART_CNT] = {
.suc_uart = USART2,
.suc_rcc_reg = &RCC->APB1ENR,
.suc_rcc_dev = RCC_APB1ENR_USART2EN,
- .suc_pin_tx = 2,
- .suc_pin_rx = 3,
- .suc_pin_rts = 1,
- .suc_pin_cts = 0,
+ .suc_pin_tx = MCU_GPIO_PORTA(2), /* PA2 */
+ .suc_pin_rx = MCU_GPIO_PORTA(3), /* PA3 */
+ .suc_pin_rts = MCU_GPIO_PORTA(1), /* PA1 */
+ .suc_pin_cts = MCU_GPIO_PORTA(0), /* PA0 */
.suc_pin_af = GPIO_AF7_USART2,
.suc_irqn = USART2_IRQn
}
@@ -66,20 +67,20 @@ static struct stm32f4_hal_i2c_cfg i2c_cfg0 = {
.hic_i2c = I2C1,
.hic_rcc_reg = &RCC->APB1ENR,
.hic_rcc_dev = RCC_APB1ENR_I2C1EN,
- .hic_pin_sda = 16 + 9, /* PB9 */
- .hic_pin_scl = 16 + 8, /* PB8 */
+ .hic_pin_sda = MCU_GPIO_PORTB(9), /* PB9 */
+ .hic_pin_scl = MCU_GPIO_PORTB(8), /* PB8 */
.hic_pin_af = GPIO_AF4_I2C1,
.hic_10bit = 0,
- .hic_speed = 100000 /* 100kHz */
+ .hic_speed = 100000 /* 100kHz */
};
#endif
#if MYNEWT_VAL(SPI_0_SLAVE) || MYNEWT_VAL(SPI_0_MASTER)
struct stm32f4_hal_spi_cfg spi0_cfg = {
- .ss_pin = 4,
- .sck_pin = 5,
- .miso_pin = 6,
- .mosi_pin = 21,
+ .ss_pin = MCU_GPIO_PORTA(4), /* PA4 */
+ .sck_pin = MCU_GPIO_PORTA(5), /* PA5 */
+ .miso_pin = MCU_GPIO_PORTA(6), /* PA6 */
+ .mosi_pin = MCU_GPIO_PORTB(5), /* PB5 */
.irq_prio = 2
};
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb78037/hw/bsp/olimex_stm32-e407_devboard/include/bsp/bsp.h
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/include/bsp/bsp.h b/hw/bsp/olimex_stm32-e407_devboard/include/bsp/bsp.h
index c124bf4..f67040b 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/include/bsp/bsp.h
+++ b/hw/bsp/olimex_stm32-e407_devboard/include/bsp/bsp.h
@@ -20,6 +20,7 @@
#define H_BSP_H
#include <inttypes.h>
+#include <mcu/mcu.h>
#ifdef __cplusplus
extern "C" {
@@ -40,7 +41,7 @@ extern uint8_t _ccram_start;
#define CCRAM_SIZE (64 * 1024)
/* LED pins */
-#define LED_BLINK_PIN (45)
+#define LED_BLINK_PIN MCU_GPIO_PORTC(13)
/* UART */
#define UART_CNT 1
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb78037/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c b/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c
index 4fdaad2..9608994 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c
+++ b/hw/bsp/olimex_stm32-e407_devboard/src/hal_bsp.c
@@ -30,10 +30,10 @@ static const struct stm32f4_uart_cfg uart_cfg[UART_CNT] = {
.suc_uart = USART6,
.suc_rcc_reg = &RCC->APB2ENR,
.suc_rcc_dev = RCC_APB2ENR_USART6EN,
- .suc_pin_tx = 38,
- .suc_pin_rx = 39,
- .suc_pin_rts = 34,
- .suc_pin_cts = 35,
+ .suc_pin_tx = MCU_GPIO_PORTC(6), /* PC6 */
+ .suc_pin_rx = MCU_GPIO_PORTC(7), /* PC7 */
+ .suc_pin_rts = -1,
+ .suc_pin_cts = -1,
.suc_pin_af = GPIO_AF8_USART6,
.suc_irqn = USART6_IRQn
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb78037/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
index 49fe20a..c6b7081 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
+++ b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
@@ -258,20 +258,20 @@ static struct stm32f4_hal_i2c_cfg i2c_cfg0 = {
.hic_i2c = I2C1,
.hic_rcc_reg = &RCC->APB1ENR,
.hic_rcc_dev = RCC_APB1ENR_I2C1EN,
- .hic_pin_sda = 16 + 9, /* PB9 */
- .hic_pin_scl = 16 + 8, /* PB8 */
+ .hic_pin_sda = MCU_GPIO_PORTB(9), /* PB9 */
+ .hic_pin_scl = MCU_GPIO_PORTB(8), /* PB8 */
.hic_pin_af = GPIO_AF4_I2C1,
.hic_10bit = 0,
- .hic_speed = 100000 /* 100kHz */
+ .hic_speed = 100000 /* 100kHz */
};
#endif
#if MYNEWT_VAL(SPI_0_SLAVE) || MYNEWT_VAL(SPI_0_MASTER)
struct stm32f4_hal_spi_cfg spi0_cfg = {
- .ss_pin = 4,
- .sck_pin = 5,
- .miso_pin = 6,
- .mosi_pin = 21,
+ .ss_pin = MCU_GPIO_PORTA(4), /* PA4 */
+ .sck_pin = MCU_GPIO_PORTA(5), /* PA5 */
+ .miso_pin = MCU_GPIO_PORTA(6), /* PA6 */
+ .mosi_pin = MCU_GPIO_PORTB(5), /* PB5 */
.irq_prio = 2
};
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb78037/hw/mcu/native/include/mcu/mcu.h
----------------------------------------------------------------------
diff --git a/hw/mcu/native/include/mcu/mcu.h b/hw/mcu/native/include/mcu/mcu.h
new file mode 100644
index 0000000..e417a0f
--- /dev/null
+++ b/hw/mcu/native/include/mcu/mcu.h
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __MCU_MCU_H_
+#define __MCU_MCU_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Defines for naming GPIOs.
+ */
+#define MCU_GPIO_PORTA(pin) ((0 * 16) + (pin))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MCU_MCU_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb78037/hw/mcu/nordic/nrf51xxx/include/mcu/mcu.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/include/mcu/mcu.h b/hw/mcu/nordic/nrf51xxx/include/mcu/mcu.h
new file mode 100644
index 0000000..e417a0f
--- /dev/null
+++ b/hw/mcu/nordic/nrf51xxx/include/mcu/mcu.h
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __MCU_MCU_H_
+#define __MCU_MCU_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Defines for naming GPIOs.
+ */
+#define MCU_GPIO_PORTA(pin) ((0 * 16) + (pin))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MCU_MCU_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb78037/hw/mcu/nordic/nrf52xxx/include/mcu/mcu.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/include/mcu/mcu.h b/hw/mcu/nordic/nrf52xxx/include/mcu/mcu.h
new file mode 100644
index 0000000..e417a0f
--- /dev/null
+++ b/hw/mcu/nordic/nrf52xxx/include/mcu/mcu.h
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __MCU_MCU_H_
+#define __MCU_MCU_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Defines for naming GPIOs.
+ */
+#define MCU_GPIO_PORTA(pin) ((0 * 16) + (pin))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MCU_MCU_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb78037/hw/mcu/nxp/MK64F12/include/mcu/mcu.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nxp/MK64F12/include/mcu/mcu.h b/hw/mcu/nxp/MK64F12/include/mcu/mcu.h
new file mode 100644
index 0000000..baa4eb8
--- /dev/null
+++ b/hw/mcu/nxp/MK64F12/include/mcu/mcu.h
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __MCU_MCU_H_
+#define __MCU_MCU_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Defines for naming GPIOs.
+ */
+#define MCU_GPIO_PORTA(pin) ((0 * 32) + (pin))
+#define MCU_GPIO_PORTB(pin) ((1 * 32) + (pin))
+#define MCU_GPIO_PORTC(pin) ((2 * 32) + (pin))
+#define MCU_GPIO_PORTD(pin) ((3 * 32) + (pin))
+#define MCU_GPIO_PORTE(pin) ((4 * 32) + (pin))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MCU_MCU_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb78037/hw/mcu/stm/stm32f4xx/include/mcu/mcu.h
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/include/mcu/mcu.h b/hw/mcu/stm/stm32f4xx/include/mcu/mcu.h
new file mode 100644
index 0000000..4d87753
--- /dev/null
+++ b/hw/mcu/stm/stm32f4xx/include/mcu/mcu.h
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __MCU_MCU_H_
+#define __MCU_MCU_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Defines for naming GPIOs.
+ */
+#define MCU_GPIO_PORTA(pin) ((0 * 16) + (pin))
+#define MCU_GPIO_PORTB(pin) ((1 * 16) + (pin))
+#define MCU_GPIO_PORTC(pin) ((2 * 16) + (pin))
+#define MCU_GPIO_PORTD(pin) ((3 * 16) + (pin))
+#define MCU_GPIO_PORTE(pin) ((4 * 16) + (pin))
+#define MCU_GPIO_PORTF(pin) ((5 * 16) + (pin))
+#define MCU_GPIO_PORTG(pin) ((6 * 16) + (pin))
+#define MCU_GPIO_PORTH(pin) ((7 * 16) + (pin))
+#define MCU_GPIO_PORTI(pin) ((8 * 16) + (pin))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MCU_MCU_H_ */