From c0b9b494030564455332012d65117d5cdf0ac65d Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Tue, 23 Apr 2019 14:55:27 +0200 Subject: [PATCH 1/2] pinmap: Add a list of restricted GPIO pins Add a `pinmap_restricted_pins_gpio()` that is used to skip pins during the GPIO test. --- .../hal/0002-pinmap-extension.md | 2 ++ hal/mbed_pinmap_default.c | 8 ++++++++ hal/pinmap.h | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/docs/design-documents/hal/0002-pinmap-extension.md b/docs/design-documents/hal/0002-pinmap-extension.md index 5df0eed15f3..51895d3fb4e 100644 --- a/docs/design-documents/hal/0002-pinmap-extension.md +++ b/docs/design-documents/hal/0002-pinmap-extension.md @@ -83,3 +83,5 @@ MBED_WEAK const PinList *pinmap_restricted_pins() return &pin_list; } ``` + +In addition to `pinmap_restricted_pins()`, the `pinmap_restricted_pins_gpio()` is used to skip pins during GPIO testing. By default this function returns an empty list and any target can override it to provide a list of pins that should be skipped. For example, D14 and D15 pins present in the Arduino form factor of FRDM-K64F have fixed pull-up resistors. The `PullDown` `PinMode` is impossible to test. However, other peripherals like the I2C may be successfully tested on these pins. diff --git a/hal/mbed_pinmap_default.c b/hal/mbed_pinmap_default.c index 780bb682520..d0c3a910020 100644 --- a/hal/mbed_pinmap_default.c +++ b/hal/mbed_pinmap_default.c @@ -77,3 +77,11 @@ MBED_WEAK const PinList *pinmap_restricted_pins() return &pin_list; } +//*** Default restricted pins for the GPIO test *** +MBED_WEAK const PinList *pinmap_restricted_pins_gpio() +{ + static const PinName pins[] = {}; + static const PinList pin_list = {0, pins}; + return &pin_list; +} + diff --git a/hal/pinmap.h b/hal/pinmap.h index b61183a169e..1c919f03486 100644 --- a/hal/pinmap.h +++ b/hal/pinmap.h @@ -139,6 +139,25 @@ bool pinmap_list_has_pin(const PinList *list, PinName pin); */ const PinList *pinmap_restricted_pins(void); +/** + * Get the additional list of pins to avoid during GPIO testing + * + * Unlike a list returned by generic pinmap_restricted_pins(), + * that is used by *ALL* tests, this list is used only for GPIO tests. + * This list extends the one returned by pinmap_restricted_pins(). + * + * For example, PTE25 & PTE24 on the FRDM-K64F have fixed pull-ups + * making the PullDown PinMode impossible to test. However, the I2C + * may be successfully tested on these pins. + * + * Targets should override the weak implementation of this + * function if they have additional pins which should be + * skipped during GPIO testing. + * + * @return Pointer to a pin list of pins to avoid + */ +const PinList *pinmap_restricted_pins_gpio(void); + #ifdef TARGET_FF_ARDUINO /** From 1587377585434af398f12037cb3b2636f23c60b9 Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Tue, 23 Apr 2019 15:15:03 +0200 Subject: [PATCH 2/2] K64F: Add a list of restricted pins for GPIO test --- .../TARGET_MCU_K64F/TARGET_FRDM/pinmap.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/pinmap.c diff --git a/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/pinmap.c b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/pinmap.c new file mode 100644 index 00000000000..f8563e42d0a --- /dev/null +++ b/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/pinmap.c @@ -0,0 +1,30 @@ +/* mbed Microcontroller Library + * Copyright (c) 2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed 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. + */ + +#include "hal/pinmap.h" + +const PinList *pinmap_restricted_pins_gpio() +{ + static const PinName pins[] = { + PTE25, PTE24 // fixed pull-ups (for I2C) + }; + static const PinList pin_list = { + sizeof(pins) / sizeof(pins[0]), + pins + }; + return &pin_list; +} \ No newline at end of file