From a6eb48c2de28be784ba6b79b889eb6391e768ec5 Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Thu, 23 May 2019 13:27:41 +0200 Subject: [PATCH 1/7] Add HAL API for GPIO pinmap --- hal/gpio_api.h | 13 +++++++++++++ hal/mbed_gpio.c | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/hal/gpio_api.h b/hal/gpio_api.h index 503e682a6f5..48f2d316531 100644 --- a/hal/gpio_api.h +++ b/hal/gpio_api.h @@ -22,6 +22,7 @@ #include #include "device.h" +#include "pinmap.h" #ifdef __cplusplus extern "C" { @@ -135,6 +136,18 @@ void gpio_init_out_ex(gpio_t *gpio, PinName pin, int value); */ void gpio_init_inout(gpio_t *gpio, PinName pin, PinDirection direction, PinMode mode, int value); +/** Get the pins that support all GPIO tests + * + * Return a PinMap array of pins that support GPIO. The + * array is terminated with {NC, NC, 0}. + * + * Targets should override the weak implementation of this + * function to provide the actual pinmap for GPIO testing. + * + * @return PinMap array + */ +const PinMap *gpio_pinmap(void); + /**@}*/ #ifdef __cplusplus diff --git a/hal/mbed_gpio.c b/hal/mbed_gpio.c index b58a6ca61a6..ff750b6c848 100644 --- a/hal/mbed_gpio.c +++ b/hal/mbed_gpio.c @@ -15,6 +15,7 @@ * limitations under the License. */ #include "hal/gpio_api.h" +#include "platform/mbed_toolchain.h" static inline void _gpio_init_in(gpio_t *gpio, PinName pin, PinMode mode) { @@ -66,3 +67,11 @@ void gpio_init_inout(gpio_t *gpio, PinName pin, PinDirection direction, PinMode _gpio_init_out(gpio, pin, mode, value); } } + +MBED_WEAK const PinMap *gpio_pinmap() +{ + static const PinMap empty_gpio_pinmap[] = { + {NC, NC, 0}, + }; + return empty_gpio_pinmap; +} From 6e405463ae2c528dab22fbba40ceace53f201318 Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Thu, 23 May 2019 14:20:24 +0200 Subject: [PATCH 2/7] Add a sanity check for the GPIO pinmap --- TESTS/mbed_hal/pinmap/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TESTS/mbed_hal/pinmap/main.cpp b/TESTS/mbed_hal/pinmap/main.cpp index d5ca3f2305f..103902be4a0 100644 --- a/TESTS/mbed_hal/pinmap/main.cpp +++ b/TESTS/mbed_hal/pinmap/main.cpp @@ -20,6 +20,7 @@ using namespace utest::v1; +#include "gpio_api.h" #include "analogin_api.h" #include "analogout_api.h" #include "can_api.h" @@ -38,6 +39,7 @@ typedef struct { } pinmap_info_t; const pinmap_info_t pinmap_functions[] = { + PINMAP_TEST_ENTRY(gpio_pinmap), #if DEVICE_ANALOGIN PINMAP_TEST_ENTRY(analogin_pinmap), #endif From 5bc873239e266a3e04aeaad9e0a77ae302d6c8a0 Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Thu, 23 May 2019 14:21:13 +0200 Subject: [PATCH 3/7] K64F: Add a GPIO pinmap for testing --- .../TARGET_FRDM/PeripheralNames.h | 8 ++ .../TARGET_FRDM/PeripheralPins.c | 117 ++++++++++++++++++ .../api/PeripheralPins.h | 3 + 3 files changed, 128 insertions(+) diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralNames.h b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralNames.h index 66aee9d7b14..caac7bd0f77 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralNames.h +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralNames.h @@ -22,6 +22,14 @@ extern "C" { #endif +typedef enum { + GPIO_A = 0, + GPIO_B = 1, + GPIO_C = 2, + GPIO_D = 3, + GPIO_E = 4, +} GPIOName; + typedef enum { OSC32KCLK = 0, } RTCName; diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralPins.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralPins.c index c2bb8f627e2..7fdaa547f82 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralPins.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralPins.c @@ -16,6 +16,123 @@ #include "PeripheralPins.h" +/************GPIO***************/ +const PinMap PinMap_GPIO[] = { + {PTA0, GPIO_A, 1}, + {PTA1, GPIO_A, 1}, + {PTA2, GPIO_A, 1}, + {PTA3, GPIO_A, 1}, + {PTA4, GPIO_A, 1}, + {PTA5, GPIO_A, 1}, + {PTA6, GPIO_A, 1}, + {PTA7, GPIO_A, 1}, + {PTA8, GPIO_A, 1}, + {PTA9, GPIO_A, 1}, + {PTA10, GPIO_A, 1}, + {PTA11, GPIO_A, 1}, + {PTA12, GPIO_A, 1}, + {PTA13, GPIO_A, 1}, + {PTA14, GPIO_A, 1}, + {PTA15, GPIO_A, 1}, + {PTA16, GPIO_A, 1}, + {PTA17, GPIO_A, 1}, + {PTA18, GPIO_A, 1}, + {PTA19, GPIO_A, 1}, + {PTA24, GPIO_A, 1}, + {PTA25, GPIO_A, 1}, + {PTA26, GPIO_A, 1}, + {PTA27, GPIO_A, 1}, + {PTA28, GPIO_A, 1}, + {PTA29, GPIO_A, 1}, + + {PTB0, GPIO_B, 1}, + {PTB1, GPIO_B, 1}, + {PTB2, GPIO_B, 1}, + {PTB3, GPIO_B, 1}, + {PTB4, GPIO_B, 1}, + {PTB5, GPIO_B, 1}, + {PTB6, GPIO_B, 1}, + {PTB7, GPIO_B, 1}, + {PTB8, GPIO_B, 1}, + {PTB9, GPIO_B, 1}, + {PTB10, GPIO_B, 1}, + {PTB11, GPIO_B, 1}, + {PTB12, GPIO_B, 1}, + {PTB13, GPIO_B, 1}, + {PTB16, GPIO_B, 1}, + {PTB17, GPIO_B, 1}, + {PTB18, GPIO_B, 1}, + {PTB19, GPIO_B, 1}, + {PTB20, GPIO_B, 1}, + {PTB21, GPIO_B, 1}, + {PTB22, GPIO_B, 1}, + {PTB23, GPIO_B, 1}, + + {PTC0, GPIO_C, 1}, + {PTC1, GPIO_C, 1}, + {PTC2, GPIO_C, 1}, + {PTC3, GPIO_C, 1}, + {PTC4, GPIO_C, 1}, + {PTC5, GPIO_C, 1}, + {PTC6, GPIO_C, 1}, + {PTC7, GPIO_C, 1}, + {PTC8, GPIO_C, 1}, + {PTC9, GPIO_C, 1}, + {PTC10, GPIO_C, 1}, + {PTC11, GPIO_C, 1}, + {PTC12, GPIO_C, 1}, + {PTC13, GPIO_C, 1}, + {PTC14, GPIO_C, 1}, + {PTC15, GPIO_C, 1}, + {PTC16, GPIO_C, 1}, + {PTC17, GPIO_C, 1}, + {PTC18, GPIO_C, 1}, + {PTC19, GPIO_C, 1}, + + {PTD0, GPIO_D, 1}, + {PTD1, GPIO_D, 1}, + {PTD2, GPIO_D, 1}, + {PTD3, GPIO_D, 1}, + {PTD4, GPIO_D, 1}, + {PTD5, GPIO_D, 1}, + {PTD6, GPIO_D, 1}, + {PTD7, GPIO_D, 1}, + {PTD8, GPIO_D, 1}, + {PTD9, GPIO_D, 1}, + {PTD10, GPIO_D, 1}, + {PTD11, GPIO_D, 1}, + {PTD12, GPIO_D, 1}, + {PTD13, GPIO_D, 1}, + {PTD14, GPIO_D, 1}, + {PTD15, GPIO_D, 1}, + + {PTE0, GPIO_E, 1}, + {PTE1, GPIO_E, 1}, + {PTE2, GPIO_E, 1}, + {PTE3, GPIO_E, 1}, + {PTE4, GPIO_E, 1}, + {PTE5, GPIO_E, 1}, + {PTE6, GPIO_E, 1}, + {PTE7, GPIO_E, 1}, + {PTE8, GPIO_E, 1}, + {PTE9, GPIO_E, 1}, + {PTE10, GPIO_E, 1}, + {PTE11, GPIO_E, 1}, + {PTE12, GPIO_E, 1}, + // {PTE24, GPIO_E, 1}, // fixed pull-up (for I2C) + // {PTE25, GPIO_E, 1}, // fixed pull-up (for I2C) + {PTE26, GPIO_E, 1}, + {PTE27, GPIO_E, 1}, + {PTE28, GPIO_E, 1}, + + {NC , NC , 0} +}; + +const PinMap *gpio_pinmap() +{ + return PinMap_GPIO; +} + /************RTC***************/ const PinMap PinMap_RTC[] = { {NC, OSC32KCLK, 0}, diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/PeripheralPins.h b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/PeripheralPins.h index 36627417f85..0720a43d126 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/PeripheralPins.h +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/PeripheralPins.h @@ -20,6 +20,9 @@ #include "pinmap.h" #include "PeripheralNames.h" +/************GPIO***************/ +extern const PinMap PinMap_GPIO[]; + /************RTC***************/ extern const PinMap PinMap_RTC[]; From a326db8b77687769b267cfaddcb4e8f6679738c2 Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Thu, 23 May 2019 17:20:14 +0200 Subject: [PATCH 4/7] K64F: Use a common peripheral name in GPIO pinmap This was unnecessary since all the pins may be used independently. --- .../TARGET_FRDM/PeripheralNames.h | 6 +- .../TARGET_FRDM/PeripheralPins.c | 204 +++++++++--------- 2 files changed, 103 insertions(+), 107 deletions(-) diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralNames.h b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralNames.h index caac7bd0f77..c5005d473ce 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralNames.h +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralNames.h @@ -23,11 +23,7 @@ extern "C" { #endif typedef enum { - GPIO_A = 0, - GPIO_B = 1, - GPIO_C = 2, - GPIO_D = 3, - GPIO_E = 4, + GPIO_X = 0, // dummy peripheral used instead of GPIO_A..GPIO_E } GPIOName; typedef enum { diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralPins.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralPins.c index 7fdaa547f82..f9d4a90863d 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralPins.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralPins.c @@ -18,112 +18,112 @@ /************GPIO***************/ const PinMap PinMap_GPIO[] = { - {PTA0, GPIO_A, 1}, - {PTA1, GPIO_A, 1}, - {PTA2, GPIO_A, 1}, - {PTA3, GPIO_A, 1}, - {PTA4, GPIO_A, 1}, - {PTA5, GPIO_A, 1}, - {PTA6, GPIO_A, 1}, - {PTA7, GPIO_A, 1}, - {PTA8, GPIO_A, 1}, - {PTA9, GPIO_A, 1}, - {PTA10, GPIO_A, 1}, - {PTA11, GPIO_A, 1}, - {PTA12, GPIO_A, 1}, - {PTA13, GPIO_A, 1}, - {PTA14, GPIO_A, 1}, - {PTA15, GPIO_A, 1}, - {PTA16, GPIO_A, 1}, - {PTA17, GPIO_A, 1}, - {PTA18, GPIO_A, 1}, - {PTA19, GPIO_A, 1}, - {PTA24, GPIO_A, 1}, - {PTA25, GPIO_A, 1}, - {PTA26, GPIO_A, 1}, - {PTA27, GPIO_A, 1}, - {PTA28, GPIO_A, 1}, - {PTA29, GPIO_A, 1}, + {PTA0, GPIO_X, 1}, + {PTA1, GPIO_X, 1}, + {PTA2, GPIO_X, 1}, + {PTA3, GPIO_X, 1}, + {PTA4, GPIO_X, 1}, + {PTA5, GPIO_X, 1}, + {PTA6, GPIO_X, 1}, + {PTA7, GPIO_X, 1}, + {PTA8, GPIO_X, 1}, + {PTA9, GPIO_X, 1}, + {PTA10, GPIO_X, 1}, + {PTA11, GPIO_X, 1}, + {PTA12, GPIO_X, 1}, + {PTA13, GPIO_X, 1}, + {PTA14, GPIO_X, 1}, + {PTA15, GPIO_X, 1}, + {PTA16, GPIO_X, 1}, + {PTA17, GPIO_X, 1}, + {PTA18, GPIO_X, 1}, + {PTA19, GPIO_X, 1}, + {PTA24, GPIO_X, 1}, + {PTA25, GPIO_X, 1}, + {PTA26, GPIO_X, 1}, + {PTA27, GPIO_X, 1}, + {PTA28, GPIO_X, 1}, + {PTA29, GPIO_X, 1}, - {PTB0, GPIO_B, 1}, - {PTB1, GPIO_B, 1}, - {PTB2, GPIO_B, 1}, - {PTB3, GPIO_B, 1}, - {PTB4, GPIO_B, 1}, - {PTB5, GPIO_B, 1}, - {PTB6, GPIO_B, 1}, - {PTB7, GPIO_B, 1}, - {PTB8, GPIO_B, 1}, - {PTB9, GPIO_B, 1}, - {PTB10, GPIO_B, 1}, - {PTB11, GPIO_B, 1}, - {PTB12, GPIO_B, 1}, - {PTB13, GPIO_B, 1}, - {PTB16, GPIO_B, 1}, - {PTB17, GPIO_B, 1}, - {PTB18, GPIO_B, 1}, - {PTB19, GPIO_B, 1}, - {PTB20, GPIO_B, 1}, - {PTB21, GPIO_B, 1}, - {PTB22, GPIO_B, 1}, - {PTB23, GPIO_B, 1}, + {PTB0, GPIO_X, 1}, + {PTB1, GPIO_X, 1}, + {PTB2, GPIO_X, 1}, + {PTB3, GPIO_X, 1}, + {PTB4, GPIO_X, 1}, + {PTB5, GPIO_X, 1}, + {PTB6, GPIO_X, 1}, + {PTB7, GPIO_X, 1}, + {PTB8, GPIO_X, 1}, + {PTB9, GPIO_X, 1}, + {PTB10, GPIO_X, 1}, + {PTB11, GPIO_X, 1}, + {PTB12, GPIO_X, 1}, + {PTB13, GPIO_X, 1}, + {PTB16, GPIO_X, 1}, + {PTB17, GPIO_X, 1}, + {PTB18, GPIO_X, 1}, + {PTB19, GPIO_X, 1}, + {PTB20, GPIO_X, 1}, + {PTB21, GPIO_X, 1}, + {PTB22, GPIO_X, 1}, + {PTB23, GPIO_X, 1}, - {PTC0, GPIO_C, 1}, - {PTC1, GPIO_C, 1}, - {PTC2, GPIO_C, 1}, - {PTC3, GPIO_C, 1}, - {PTC4, GPIO_C, 1}, - {PTC5, GPIO_C, 1}, - {PTC6, GPIO_C, 1}, - {PTC7, GPIO_C, 1}, - {PTC8, GPIO_C, 1}, - {PTC9, GPIO_C, 1}, - {PTC10, GPIO_C, 1}, - {PTC11, GPIO_C, 1}, - {PTC12, GPIO_C, 1}, - {PTC13, GPIO_C, 1}, - {PTC14, GPIO_C, 1}, - {PTC15, GPIO_C, 1}, - {PTC16, GPIO_C, 1}, - {PTC17, GPIO_C, 1}, - {PTC18, GPIO_C, 1}, - {PTC19, GPIO_C, 1}, + {PTC0, GPIO_X, 1}, + {PTC1, GPIO_X, 1}, + {PTC2, GPIO_X, 1}, + {PTC3, GPIO_X, 1}, + {PTC4, GPIO_X, 1}, + {PTC5, GPIO_X, 1}, + {PTC6, GPIO_X, 1}, + {PTC7, GPIO_X, 1}, + {PTC8, GPIO_X, 1}, + {PTC9, GPIO_X, 1}, + {PTC10, GPIO_X, 1}, + {PTC11, GPIO_X, 1}, + {PTC12, GPIO_X, 1}, + {PTC13, GPIO_X, 1}, + {PTC14, GPIO_X, 1}, + {PTC15, GPIO_X, 1}, + {PTC16, GPIO_X, 1}, + {PTC17, GPIO_X, 1}, + {PTC18, GPIO_X, 1}, + {PTC19, GPIO_X, 1}, - {PTD0, GPIO_D, 1}, - {PTD1, GPIO_D, 1}, - {PTD2, GPIO_D, 1}, - {PTD3, GPIO_D, 1}, - {PTD4, GPIO_D, 1}, - {PTD5, GPIO_D, 1}, - {PTD6, GPIO_D, 1}, - {PTD7, GPIO_D, 1}, - {PTD8, GPIO_D, 1}, - {PTD9, GPIO_D, 1}, - {PTD10, GPIO_D, 1}, - {PTD11, GPIO_D, 1}, - {PTD12, GPIO_D, 1}, - {PTD13, GPIO_D, 1}, - {PTD14, GPIO_D, 1}, - {PTD15, GPIO_D, 1}, + {PTD0, GPIO_X, 1}, + {PTD1, GPIO_X, 1}, + {PTD2, GPIO_X, 1}, + {PTD3, GPIO_X, 1}, + {PTD4, GPIO_X, 1}, + {PTD5, GPIO_X, 1}, + {PTD6, GPIO_X, 1}, + {PTD7, GPIO_X, 1}, + {PTD8, GPIO_X, 1}, + {PTD9, GPIO_X, 1}, + {PTD10, GPIO_X, 1}, + {PTD11, GPIO_X, 1}, + {PTD12, GPIO_X, 1}, + {PTD13, GPIO_X, 1}, + {PTD14, GPIO_X, 1}, + {PTD15, GPIO_X, 1}, - {PTE0, GPIO_E, 1}, - {PTE1, GPIO_E, 1}, - {PTE2, GPIO_E, 1}, - {PTE3, GPIO_E, 1}, - {PTE4, GPIO_E, 1}, - {PTE5, GPIO_E, 1}, - {PTE6, GPIO_E, 1}, - {PTE7, GPIO_E, 1}, - {PTE8, GPIO_E, 1}, - {PTE9, GPIO_E, 1}, - {PTE10, GPIO_E, 1}, - {PTE11, GPIO_E, 1}, - {PTE12, GPIO_E, 1}, - // {PTE24, GPIO_E, 1}, // fixed pull-up (for I2C) - // {PTE25, GPIO_E, 1}, // fixed pull-up (for I2C) - {PTE26, GPIO_E, 1}, - {PTE27, GPIO_E, 1}, - {PTE28, GPIO_E, 1}, + {PTE0, GPIO_X, 1}, + {PTE1, GPIO_X, 1}, + {PTE2, GPIO_X, 1}, + {PTE3, GPIO_X, 1}, + {PTE4, GPIO_X, 1}, + {PTE5, GPIO_X, 1}, + {PTE6, GPIO_X, 1}, + {PTE7, GPIO_X, 1}, + {PTE8, GPIO_X, 1}, + {PTE9, GPIO_X, 1}, + {PTE10, GPIO_X, 1}, + {PTE11, GPIO_X, 1}, + {PTE12, GPIO_X, 1}, + // {PTE24, GPIO_X, 1}, // fixed pull-up (for I2C) + // {PTE25, GPIO_X, 1}, // fixed pull-up (for I2C) + {PTE26, GPIO_X, 1}, + {PTE27, GPIO_X, 1}, + {PTE28, GPIO_X, 1}, {NC , NC , 0} }; From 63fd9f9488677fb4b28aeda31ad215adc1f98f27 Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Fri, 24 May 2019 11:02:15 +0200 Subject: [PATCH 5/7] Provide a default gpio_pinmap() for arduino_ff --- hal/mbed_gpio.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/hal/mbed_gpio.c b/hal/mbed_gpio.c index ff750b6c848..0579a02f2e0 100644 --- a/hal/mbed_gpio.c +++ b/hal/mbed_gpio.c @@ -68,10 +68,52 @@ void gpio_init_inout(gpio_t *gpio, PinName pin, PinDirection direction, PinMode } } +#ifdef TARGET_FF_ARDUINO + +typedef enum { + DEFAULT_GPIO = 0, +} DefaultGPIOPeripheralName; + MBED_WEAK const PinMap *gpio_pinmap() { + // Targets should override this weak implementation to provide correct data. static const PinMap empty_gpio_pinmap[] = { + {D0, DEFAULT_GPIO, 0}, + {D1, DEFAULT_GPIO, 0}, + {D2, DEFAULT_GPIO, 0}, + {D3, DEFAULT_GPIO, 0}, + {D4, DEFAULT_GPIO, 0}, + {D5, DEFAULT_GPIO, 0}, + {D6, DEFAULT_GPIO, 0}, + {D7, DEFAULT_GPIO, 0}, + {D8, DEFAULT_GPIO, 0}, + {D9, DEFAULT_GPIO, 0}, + {D10, DEFAULT_GPIO, 0}, + {D11, DEFAULT_GPIO, 0}, + {D12, DEFAULT_GPIO, 0}, + {D13, DEFAULT_GPIO, 0}, + {D14, DEFAULT_GPIO, 0}, + {D15, DEFAULT_GPIO, 0}, + {A0, DEFAULT_GPIO, 0}, + {A1, DEFAULT_GPIO, 0}, + {A2, DEFAULT_GPIO, 0}, + {A3, DEFAULT_GPIO, 0}, + {A4, DEFAULT_GPIO, 0}, + {A5, DEFAULT_GPIO, 0}, + {NC, NC, 0}, }; return empty_gpio_pinmap; } + +#else + +MBED_WEAK const PinMap *gpio_pinmap() +{ + static const PinMap empty_gpio_pinmap[] = { + {NC, NC, 0}, + }; + return empty_gpio_pinmap; +} + +#endif From 1a9b635e7d7ef1866c5b30fcf0d6fe3d8adb179a Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Mon, 27 May 2019 13:21:43 +0200 Subject: [PATCH 6/7] KW24D: Add a GPIO pinmap for testing --- .../TARGET_FRDM/PeripheralNames.h | 4 ++ .../TARGET_KW24D/TARGET_FRDM/PeripheralPins.c | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/TARGET_FRDM/PeripheralNames.h b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/TARGET_FRDM/PeripheralNames.h index 1a8445e1ce3..ddda19b9350 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/TARGET_FRDM/PeripheralNames.h +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/TARGET_FRDM/PeripheralNames.h @@ -22,6 +22,10 @@ extern "C" { #endif +typedef enum { + GPIO_X = 0, // dummy peripheral used instead of GPIO_A..GPIO_E +} GPIOName; + typedef enum { OSC32KCLK = 0, } RTCName; diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/TARGET_FRDM/PeripheralPins.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/TARGET_FRDM/PeripheralPins.c index 4347b556f6c..a8c86694f81 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/TARGET_FRDM/PeripheralPins.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/TARGET_FRDM/PeripheralPins.c @@ -16,6 +16,47 @@ #include "PeripheralPins.h" +/************GPIO***************/ +const PinMap PinMap_GPIO[] = { + {PTA0, GPIO_X, 1}, + {PTA1, GPIO_X, 1}, + {PTA2, GPIO_X, 1}, + {PTA3, GPIO_X, 1}, + {PTA4, GPIO_X, 1}, + {PTA18, GPIO_X, 1}, + {PTA19, GPIO_X, 1}, + + {PTC4, GPIO_X, 1}, + {PTC5, GPIO_X, 1}, + {PTC6, GPIO_X, 1}, + {PTC7, GPIO_X, 1}, + + {PTD1, GPIO_X, 1}, + {PTD2, GPIO_X, 1}, + {PTD3, GPIO_X, 1}, + {PTD4, GPIO_X, 1}, + {PTD5, GPIO_X, 1}, + {PTD6, GPIO_X, 1}, + {PTD7, GPIO_X, 1}, + + {PTE0, GPIO_X, 1}, + {PTE1, GPIO_X, 1}, + {PTE2, GPIO_X, 1}, + {PTE3, GPIO_X, 1}, + {PTE4, GPIO_X, 1}, + {PTE16, GPIO_X, 1}, + {PTE17, GPIO_X, 1}, + {PTE18, GPIO_X, 1}, + {PTE19, GPIO_X, 1}, + + {NC , NC , 0} +}; + +const PinMap *gpio_pinmap() +{ + return PinMap_GPIO; +} + /************RTC***************/ const PinMap PinMap_RTC[] = { {NC, OSC32KCLK, 0}, From 61f9a1c362399209ae38f2cfdb611b55e52c4c84 Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Mon, 27 May 2019 13:22:10 +0200 Subject: [PATCH 7/7] KW41Z: Add a GPIO pinmap for testing --- .../TARGET_FRDM/PeripheralNames.h | 4 ++ .../TARGET_KW41Z/TARGET_FRDM/PeripheralPins.c | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/TARGET_FRDM/PeripheralNames.h b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/TARGET_FRDM/PeripheralNames.h index 2cee79bba73..16c516e05cc 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/TARGET_FRDM/PeripheralNames.h +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/TARGET_FRDM/PeripheralNames.h @@ -22,6 +22,10 @@ extern "C" { #endif +typedef enum { + GPIO_X = 0, // dummy peripheral used instead of GPIO_A..GPIO_C +} GPIOName; + typedef enum { OSC32KCLK = 0 } RTCName; diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/TARGET_FRDM/PeripheralPins.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/TARGET_FRDM/PeripheralPins.c index 3363bda072a..e1fe4d8d3aa 100644 --- a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/TARGET_FRDM/PeripheralPins.c +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/TARGET_FRDM/PeripheralPins.c @@ -16,6 +16,45 @@ #include "PeripheralPins.h" +/************GPIO***************/ +const PinMap PinMap_GPIO[] = { + {PTA0, GPIO_X, 1}, + {PTA1, GPIO_X, 1}, + {PTA2, GPIO_X, 1}, + {PTA16, GPIO_X, 1}, + {PTA17, GPIO_X, 1}, + {PTA18, GPIO_X, 1}, + {PTA19, GPIO_X, 1}, + + {PTB0, GPIO_X, 1}, + {PTB1, GPIO_X, 1}, + {PTB2, GPIO_X, 1}, + {PTB3, GPIO_X, 1}, + {PTB16, GPIO_X, 1}, + {PTB17, GPIO_X, 1}, + {PTB18, GPIO_X, 1}, + + // {PTC0, GPIO_X, 1}, // PTC0 is not available on the 48-pin Laminate QFN package. + {PTC1, GPIO_X, 1}, + {PTC2, GPIO_X, 1}, + {PTC3, GPIO_X, 1}, + {PTC4, GPIO_X, 1}, + {PTC5, GPIO_X, 1}, + {PTC6, GPIO_X, 1}, + {PTC7, GPIO_X, 1}, + {PTC16, GPIO_X, 1}, + {PTC17, GPIO_X, 1}, + {PTC18, GPIO_X, 1}, + {PTC19, GPIO_X, 1}, + + {NC , NC , 0} +}; + +const PinMap *gpio_pinmap() +{ + return PinMap_GPIO; +} + /************RTC***************/ const PinMap PinMap_RTC[] = { {NC, OSC32KCLK, 0},