Skip to content

Commit

Permalink
Merge pull request #14381 from ARMmbed/feature-std-pin-name
Browse files Browse the repository at this point in the history
Standard Pin Names
  • Loading branch information
0xc0170 authored Mar 22, 2021
2 parents c734138 + 21194f5 commit 4ab347c
Show file tree
Hide file tree
Showing 359 changed files with 3,795 additions and 133,210 deletions.
1 change: 1 addition & 0 deletions .codecheckignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
^hal/storage_abstraction
^hal/tests/TESTS/mbed_hal/trng/pithy
^hal/tests/TESTS/mbed_hal/trng/pithy
^hal/tests/pinvalidate
^platform/cxxsupport
^platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV
^platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM
Expand Down
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,25 @@ matrix:
CFLAGS+="-DLFS_NO_ASSERT -DLFS_NO_DEBUG -DLFS_NO_WARN -DLFS_NO_ERROR"
| tee sizes
- ccache -s
- <<: extended-pinvalidate
stage: "Extended"
name: "pinvalidate"
env: NAME=pinvalidate
language: python
python: 3.7
install:
# Install python modules
- python -m pip install --upgrade pip==18.1
- python -m pip install --upgrade setuptools==40.4.3
- pip install tabulate argparse
- pip list --verbose
# Fetch remaining information needed for branch comparison
- git fetch --all --unshallow --tags
- git fetch origin "${TRAVIS_BRANCH}"
script:
- >-
git diff --name-only --diff-filter=d FETCH_HEAD..HEAD \
| ( grep '.*[\\|\/]PinNames.h$' || true ) \
| while read file; do python ./hal/tests/pinvalidate/pinvalidate.py -vfp "${file}"; done
- git diff --exit-code --diff-filter=d --color

56 changes: 28 additions & 28 deletions TESTS/integration/COMMON/target_extended.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"target_overrides": {
"NUCLEO_F412ZG": {
"target.components_add" : ["SD", "WIFI_WIZFI310"],
"sd.SPI_MOSI" : "D11",
"sd.SPI_MISO" : "D12",
"sd.SPI_CLK" : "D13",
"sd.SPI_CS" : "D10",
"sd.SPI_MOSI" : "ARDUINO_UNO_SPI_MOSI",
"sd.SPI_MISO" : "ARDUINO_UNO_SPI_MISO",
"sd.SPI_CLK" : "ARDUINO_UNO_SPI_SCK",
"sd.SPI_CS" : "ARDUINO_UNO_SPI_CS",
"target.network-default-interface-type" : "WIFI",
"wizfi310.tx" : "PD_5",
"wizfi310.rx" : "PD_6",
Expand Down Expand Up @@ -47,15 +47,15 @@
"NUCLEO_L476RG": {
"target.macros_remove" : ["MBED_TICKLESS"],
"target.components_add" : ["SD", "WIFI_WIZFI310"],
"sd.SPI_MOSI" : "D11",
"sd.SPI_MISO" : "D12",
"sd.SPI_CLK" : "D13",
"sd.SPI_CS" : "D10",
"sd.SPI_MOSI" : "ARDUINO_UNO_SPI_MOSI",
"sd.SPI_MISO" : "ARDUINO_UNO_SPI_MIS0",
"sd.SPI_CLK" : "ARDUINO_UNO_SPI_SCK",
"sd.SPI_CS" : "ARDUINO_UNO_SPI_CS",
"target.network-default-interface-type" : "WIFI",
"wizfi310.tx" : "D8",
"wizfi310.rx" : "D2",
"wizfi310.rts" : "D3",
"wizfi310.cts" : "D5",
"wizfi310.tx" : "ARDUINO_UNO_D8",
"wizfi310.rx" : "ARDUINO_UNO_D2",
"wizfi310.rts" : "ARDUINO_UNO_D3",
"wizfi310.cts" : "ARDUINO_UNO_D5",
"wizfi310.rx-buffer-size" : 64,
"wizfi310.stacksize" : 1536,
"wizfi310.event-queue-size" : 256,
Expand All @@ -65,13 +65,13 @@
"NUCLEO_L4R5ZI": {
"target.macros_remove" : ["MBED_TICKLESS"],
"target.components_add" : ["SD", "WIFI_WIZFI310"],
"sd.SPI_MOSI" : "D11",
"sd.SPI_MISO" : "D12",
"sd.SPI_CLK" : "D13",
"sd.SPI_CS" : "D10",
"sd.SPI_MOSI" : "ARDUINO_UNO_SPI_MOSI",
"sd.SPI_MISO" : "ARDUINO_UNO_SPI_MIS0",
"sd.SPI_CLK" : "ARDUINO_UNO_SPI_SCK",
"sd.SPI_CS" : "ARDUINO_UNO_SPI_CS",
"target.network-default-interface-type" : "WIFI",
"wizfi310.tx" : "D1",
"wizfi310.rx" : "D0",
"wizfi310.tx" : "ARDUINO_UNO_UART_TX",
"wizfi310.rx" : "ARDUINO_UNO_UART_RX",
"wizfi310.rts" : "PB_1",
"wizfi310.cts" : "PB_13",
"wizfi310.rx-buffer-size" : 512,
Expand All @@ -82,13 +82,13 @@
"NUCLEO_L496ZG": {
"target.macros_remove" : ["MBED_TICKLESS"],
"target.components_add" : ["SD", "WIFI_WIZFI310"],
"sd.SPI_MOSI" : "D11",
"sd.SPI_MISO" : "D12",
"sd.SPI_CLK" : "D13",
"sd.SPI_CS" : "D10",
"sd.SPI_MOSI" : "ARDUINO_UNO_SPI_MOSI",
"sd.SPI_MISO" : "ARDUINO_UNO_SPI_MIS0",
"sd.SPI_CLK" : "ARDUINO_UNO_SPI_SCK",
"sd.SPI_CS" : "ARDUINO_UNO_SPI_CS",
"target.network-default-interface-type" : "WIFI",
"wizfi310.tx" : "D1",
"wizfi310.rx" : "D0",
"wizfi310.tx" : "ARDUINO_UNO_UART_TX",
"wizfi310.rx" : "ARDUINO_UNO_UART_RX",
"wizfi310.rts" : "PB_1",
"wizfi310.cts" : "PB_13",
"wizfi310.rx-buffer-size" : 512,
Expand Down Expand Up @@ -121,10 +121,10 @@
"DISCO_F469NI": {
"target.components_add" : ["WIFI_WIZFI310"],
"target.network-default-interface-type" : "WIFI",
"wizfi310.tx" : "D1",
"wizfi310.rx" : "D0",
"wizfi310.rts" : "D4",
"wizfi310.cts" : "D2",
"wizfi310.tx" : "ARDUINO_UNO_UART_TX",
"wizfi310.rx" : "ARDUINO_UNO_UART_RX",
"wizfi310.rts" : "ARDUINO_UNO_D4",
"wizfi310.cts" : "ARDUINO_UNO_D2",
"wizfi310.rx-buffer-size" : 512,
"wizfi310.stacksize" : 1536,
"wizfi310.event-queue-size" : 1024,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "bluenrg_ms",
"config": {
"SPI_MOSI": "D11",
"SPI_MISO": "D12",
"SPI_nCS": "A1",
"SPI_RESET": "D7",
"SPI_IRQ": "A0",
"SPI_SCK": "D3",
"SPI_MOSI": "ARDUINO_UNO_SPI_MOSI",
"SPI_MISO": "ARDUINO_UNO_SPI_MISO",
"SPI_nCS": "ARDUINO_UNO_A1",
"SPI_RESET": "ARDUINO_UNO_D7",
"SPI_IRQ": "ARDUINO_UNO_A0",
"SPI_SCK": "ARDUINO_UNO_D3",
"valid-public-bd-address": {
"help": "Read the BD public address at startup",
"value": false
}
},
"target_overrides": {
"K64F": {
"SPI_SCK": "D13"
"SPI_SCK": "ARDUINO_UNO_SPI_SCK"
},
"DISCO_L475VG_IOT01A": {
"SPI_MOSI": "PC_12",
Expand Down
108 changes: 108 additions & 0 deletions hal/include/hal/PinNameAliases.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@

/** \addtogroup hal */
/** @{*/
/* mbed Microcontroller Library
* Copyright (c) 2020 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.
*/
#ifndef MBED_PIN_NAME_ALIASES_H
#define MBED_PIN_NAME_ALIASES_H

/* Aliases for legacy reasons. To be removed in the next Mbed OS version */
#if defined (CONSOLE_TX) && (CONSOLE_RX)
#define USBTX CONSOLE_TX
#define USBRX CONSOLE_RX
#else
#define CONSOLE_TX USBTX
#define CONSOLE_RX USBRX
#endif

#if defined (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)

#ifdef TARGET_FF_ARDUINO_UNO

#define A0 ARDUINO_UNO_A0
#define A1 ARDUINO_UNO_A1
#define A2 ARDUINO_UNO_A2
#define A3 ARDUINO_UNO_A3
#define A4 ARDUINO_UNO_A4
#define A5 ARDUINO_UNO_A5
#define D0 ARDUINO_UNO_D0
#define D1 ARDUINO_UNO_D1
#define D2 ARDUINO_UNO_D2
#define D3 ARDUINO_UNO_D3
#define D4 ARDUINO_UNO_D4
#define D5 ARDUINO_UNO_D5
#define D6 ARDUINO_UNO_D6
#define D7 ARDUINO_UNO_D7
#define D8 ARDUINO_UNO_D8
#define D9 ARDUINO_UNO_D9
#define D10 ARDUINO_UNO_D10
#define D11 ARDUINO_UNO_D11
#define D12 ARDUINO_UNO_D12
#define D13 ARDUINO_UNO_D13
#define D14 ARDUINO_UNO_D14
#define D15 ARDUINO_UNO_D15

#endif // TARGET_FF_ARDUINO_UNO

#ifdef TARGET_FF_ARDUINO

#warning ARDUINO form factor should not be used any more => use ARDUINO_UNO

#define ARDUINO_UNO_A0 A0
#define ARDUINO_UNO_A1 A1
#define ARDUINO_UNO_A2 A2
#define ARDUINO_UNO_A3 A3
#define ARDUINO_UNO_A4 A4
#define ARDUINO_UNO_A5 A5
#define ARDUINO_UNO_D0 D0
#define ARDUINO_UNO_D1 D1
#define ARDUINO_UNO_D2 D2
#define ARDUINO_UNO_D3 D3
#define ARDUINO_UNO_D4 D4
#define ARDUINO_UNO_D5 D5
#define ARDUINO_UNO_D6 D6
#define ARDUINO_UNO_D7 D7
#define ARDUINO_UNO_D8 D8
#define ARDUINO_UNO_D9 D9
#define ARDUINO_UNO_D10 D10
#define ARDUINO_UNO_D11 D11
#define ARDUINO_UNO_D12 D12
#define ARDUINO_UNO_D13 D13
#define ARDUINO_UNO_D14 D14
#define ARDUINO_UNO_D15 D15

#endif // TARGET_FF_ARDUINO

// Arduino Uno I2C signals aliases
#define ARDUINO_UNO_I2C_SDA ARDUINO_UNO_D14
#define ARDUINO_UNO_I2C_SCL ARDUINO_UNO_D15

// Arduino Uno SPI signals aliases
#define ARDUINO_UNO_SPI_CS ARDUINO_UNO_D10
#define ARDUINO_UNO_SPI_MOSI ARDUINO_UNO_D11
#define ARDUINO_UNO_SPI_MISO ARDUINO_UNO_D12
#define ARDUINO_UNO_SPI_SCK ARDUINO_UNO_D13

// Arduino Uno UART signals aliases
#define ARDUINO_UNO_UART_TX ARDUINO_UNO_D1
#define ARDUINO_UNO_UART_RX ARDUINO_UNO_D0

#endif // (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)

#endif // MBED_PIN_NAME_ALIASES_H

/** @}*/
8 changes: 4 additions & 4 deletions hal/include/hal/pinmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,26 +195,26 @@ const PeripheralList *pinmap_uart_restricted_peripherals(void);
*/
const PinList *pinmap_gpio_restricted_pins(void);

#ifdef TARGET_FF_ARDUINO
#if defined (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)

/**
* Get the pin list of the Arduino form factor
*
* @return Pointer to the Arduino pin list
*/
const PinList *pinmap_ff_arduino_pins(void);
const PinList *pinmap_ff_arduino_uno_pins(void);

/**
* Get the string representation of a form factor pin
*
* @param pin Pin to get a string for
* @return String representing the form factor pin
*/
const char *pinmap_ff_arduino_pin_to_string(PinName pin);
const char *pinmap_ff_arduino_uno_pin_to_string(PinName pin);

/* Default to arduino form factor if unspecified */
#ifndef MBED_CONF_TARGET_DEFAULT_FORM_FACTOR
#define MBED_CONF_TARGET_DEFAULT_FORM_FACTOR arduino
#define MBED_CONF_TARGET_DEFAULT_FORM_FACTOR arduino_uno
#endif

#endif
Expand Down
3 changes: 2 additions & 1 deletion hal/include/hal/static_pinmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef STATIC_PINMAP_H
#define STATIC_PINMAP_H

#include "hal/PinNameAliases.h"
#include "PinNames.h"
#include "spi_api.h"
#include "pwmout_api.h"
Expand Down Expand Up @@ -128,7 +129,7 @@ MSTD_CONSTEXPR_FN_14 serial_pinmap_t get_uart_pinmap(const PinName tx, const Pin
return {(int) NC, NC, (int) NC, NC, (int) NC, false};
}

if (tx_map->pin == STDIO_UART_TX && rx_map->pin == STDIO_UART_RX) {
if (tx_map->pin == CONSOLE_TX && rx_map->pin == CONSOLE_RX) {
return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, true};
} else {
return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, false};
Expand Down
62 changes: 25 additions & 37 deletions hal/source/mbed_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
#include "hal/gpio_api.h"
#include "platform/mbed_toolchain.h"
#include "hal/PinNameAliases.h"

static inline void _gpio_init_in(gpio_t *gpio, PinName pin, PinMode mode)
{
Expand Down Expand Up @@ -77,8 +78,6 @@ MBED_WEAK void gpio_get_capabilities(gpio_t *gpio, gpio_capabilities_t *cap)
cap->pull_up = 1;
}

#ifdef TARGET_FF_ARDUINO

typedef enum {
DEFAULT_GPIO = 0,
} DefaultGPIOPeripheralName;
Expand All @@ -87,42 +86,31 @@ 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[] = {
#if defined (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)
{ARDUINO_UNO_D0, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D1, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D2, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D3, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D4, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D5, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D6, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D7, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D8, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D9, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D10, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D11, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D12, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D13, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D14, DEFAULT_GPIO, 0},
{ARDUINO_UNO_D15, DEFAULT_GPIO, 0},
{ARDUINO_UNO_A0, DEFAULT_GPIO, 0},
{ARDUINO_UNO_A1, DEFAULT_GPIO, 0},
{ARDUINO_UNO_A2, DEFAULT_GPIO, 0},
{ARDUINO_UNO_A3, DEFAULT_GPIO, 0},
{ARDUINO_UNO_A4, DEFAULT_GPIO, 0},
{ARDUINO_UNO_A5, DEFAULT_GPIO, 0},
#endif
{NC, NC, 0},
};
return empty_gpio_pinmap;
}

#endif
Loading

0 comments on commit 4ab347c

Please sign in to comment.