2019-01-21 23:26:53 +00:00
|
|
|
/* 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 <stdlib.h>
|
|
|
|
#include "hal/pinmap.h"
|
|
|
|
#include "platform/mbed_toolchain.h"
|
|
|
|
#include "platform/mbed_assert.h"
|
|
|
|
#include "device.h"
|
Add STDIO UART as restricted for FPGA testing for all targets
Substantiation for this is that the STDIO UART peripheral is used by Mbed, so it should never be tested.
Also solve the potential problem with accidenty skipped peripherals in FPGA testing. Currently, we have a one `pinmap_restricted_peripherals()` function for all interfaces (UART, I2C, SPI, etc.).
The problem can be encountered if different interfaces have the same peripheral ids (e.g. `UART_0` = 0, `SPI_0` = 0). In this case, if `UART_0` is on the restricted list, then SPI tests will be also skipped for `SPI_0`.
The good news is that usually, the peripheral ids are the base addresses of the peripheral's register set, but we can't rely on this. It is also good that `pinmap_restricted_peripherals()` at this moment is only required for STDIO UART (Nuvoton and STM).
To solve this issue we will change name of `pinmap_restricted_peripherals()` to `pinmap_uart_restricted_peripherals()`, make STDIO UART restricted by default for all targets and update FPGA test utilily functions to use `pinmap_uart_restricted_peripherals()` to skip only uart peripherals.
In the future if needed we can consider to add support to restrict peripherals of other interfaces(SPI, I2C, etc).
2020-02-05 13:31:53 +00:00
|
|
|
#include "hal/serial_api.h"
|
2019-01-21 23:26:53 +00:00
|
|
|
|
|
|
|
//*** Common form factors ***
|
|
|
|
#ifdef TARGET_FF_ARDUINO
|
|
|
|
|
|
|
|
static const PinName ff_arduino_pins[] = {
|
|
|
|
D0, D1, D2, D3, D4, D5, D6, D7,
|
|
|
|
D8, D9, D10, D11, D12, D13, D14, D15,
|
|
|
|
A0, A1, A2, A3, A4, A5
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *ff_arduino_names[] = {
|
|
|
|
"D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
|
|
|
|
"D8", "D9", "D10", "D11", "D12", "D13", "D14", "D15",
|
|
|
|
"A0", "A1", "A2", "A3", "A4", "A5"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const PinList ff_arduino_list = {
|
|
|
|
sizeof(ff_arduino_pins) / sizeof(ff_arduino_pins[0]),
|
|
|
|
ff_arduino_pins
|
|
|
|
};
|
|
|
|
|
|
|
|
MBED_STATIC_ASSERT(sizeof(ff_arduino_pins) / sizeof(ff_arduino_pins[0]) == sizeof(ff_arduino_names) / sizeof(ff_arduino_names[0]),
|
|
|
|
"Arrays must have the same length");
|
|
|
|
|
|
|
|
const PinList *pinmap_ff_arduino_pins()
|
|
|
|
{
|
|
|
|
return &ff_arduino_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *pinmap_ff_arduino_pin_to_string(PinName pin)
|
|
|
|
{
|
|
|
|
if (pin == NC) {
|
|
|
|
return "NC";
|
|
|
|
}
|
|
|
|
for (size_t i = 0; i < ff_arduino_list.count; i++) {
|
|
|
|
if (ff_arduino_list.pins[i] == pin) {
|
|
|
|
return ff_arduino_names[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//*** Default restricted pins ***
|
|
|
|
MBED_WEAK const PinList *pinmap_restricted_pins()
|
|
|
|
{
|
|
|
|
static const PinName pins[] = {
|
|
|
|
USBTX, USBRX
|
|
|
|
};
|
|
|
|
static const PinList pin_list = {
|
|
|
|
sizeof(pins) / sizeof(pins[0]),
|
|
|
|
pins
|
|
|
|
};
|
|
|
|
return &pin_list;
|
|
|
|
}
|
|
|
|
|
2020-02-07 09:30:59 +00:00
|
|
|
//*** Default restricted gpio pins ***
|
|
|
|
// GPIO pins are special case because there are no pin-maps for GPIO
|
|
|
|
MBED_WEAK const PinList *pinmap_gpio_restricted_pins()
|
|
|
|
{
|
|
|
|
static const PinList pin_list = {
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
return &pin_list;
|
|
|
|
}
|
|
|
|
|
2019-07-11 14:24:08 +00:00
|
|
|
//*** Default restricted peripherals ***
|
2020-02-10 07:17:55 +00:00
|
|
|
#if DEVICE_SERIAL
|
Add STDIO UART as restricted for FPGA testing for all targets
Substantiation for this is that the STDIO UART peripheral is used by Mbed, so it should never be tested.
Also solve the potential problem with accidenty skipped peripherals in FPGA testing. Currently, we have a one `pinmap_restricted_peripherals()` function for all interfaces (UART, I2C, SPI, etc.).
The problem can be encountered if different interfaces have the same peripheral ids (e.g. `UART_0` = 0, `SPI_0` = 0). In this case, if `UART_0` is on the restricted list, then SPI tests will be also skipped for `SPI_0`.
The good news is that usually, the peripheral ids are the base addresses of the peripheral's register set, but we can't rely on this. It is also good that `pinmap_restricted_peripherals()` at this moment is only required for STDIO UART (Nuvoton and STM).
To solve this issue we will change name of `pinmap_restricted_peripherals()` to `pinmap_uart_restricted_peripherals()`, make STDIO UART restricted by default for all targets and update FPGA test utilily functions to use `pinmap_uart_restricted_peripherals()` to skip only uart peripherals.
In the future if needed we can consider to add support to restrict peripherals of other interfaces(SPI, I2C, etc).
2020-02-05 13:31:53 +00:00
|
|
|
MBED_WEAK const PeripheralList *pinmap_uart_restricted_peripherals()
|
2019-07-11 14:24:08 +00:00
|
|
|
{
|
Add STDIO UART as restricted for FPGA testing for all targets
Substantiation for this is that the STDIO UART peripheral is used by Mbed, so it should never be tested.
Also solve the potential problem with accidenty skipped peripherals in FPGA testing. Currently, we have a one `pinmap_restricted_peripherals()` function for all interfaces (UART, I2C, SPI, etc.).
The problem can be encountered if different interfaces have the same peripheral ids (e.g. `UART_0` = 0, `SPI_0` = 0). In this case, if `UART_0` is on the restricted list, then SPI tests will be also skipped for `SPI_0`.
The good news is that usually, the peripheral ids are the base addresses of the peripheral's register set, but we can't rely on this. It is also good that `pinmap_restricted_peripherals()` at this moment is only required for STDIO UART (Nuvoton and STM).
To solve this issue we will change name of `pinmap_restricted_peripherals()` to `pinmap_uart_restricted_peripherals()`, make STDIO UART restricted by default for all targets and update FPGA test utilily functions to use `pinmap_uart_restricted_peripherals()` to skip only uart peripherals.
In the future if needed we can consider to add support to restrict peripherals of other interfaces(SPI, I2C, etc).
2020-02-05 13:31:53 +00:00
|
|
|
static const int stdio_uart = pinmap_peripheral(STDIO_UART_TX, serial_tx_pinmap());
|
|
|
|
|
|
|
|
static const int peripherals[] = {
|
|
|
|
stdio_uart
|
|
|
|
};
|
|
|
|
|
2019-07-11 14:24:08 +00:00
|
|
|
static const PeripheralList peripheral_list = {
|
Add STDIO UART as restricted for FPGA testing for all targets
Substantiation for this is that the STDIO UART peripheral is used by Mbed, so it should never be tested.
Also solve the potential problem with accidenty skipped peripherals in FPGA testing. Currently, we have a one `pinmap_restricted_peripherals()` function for all interfaces (UART, I2C, SPI, etc.).
The problem can be encountered if different interfaces have the same peripheral ids (e.g. `UART_0` = 0, `SPI_0` = 0). In this case, if `UART_0` is on the restricted list, then SPI tests will be also skipped for `SPI_0`.
The good news is that usually, the peripheral ids are the base addresses of the peripheral's register set, but we can't rely on this. It is also good that `pinmap_restricted_peripherals()` at this moment is only required for STDIO UART (Nuvoton and STM).
To solve this issue we will change name of `pinmap_restricted_peripherals()` to `pinmap_uart_restricted_peripherals()`, make STDIO UART restricted by default for all targets and update FPGA test utilily functions to use `pinmap_uart_restricted_peripherals()` to skip only uart peripherals.
In the future if needed we can consider to add support to restrict peripherals of other interfaces(SPI, I2C, etc).
2020-02-05 13:31:53 +00:00
|
|
|
sizeof peripherals / sizeof peripherals[0],
|
|
|
|
peripherals
|
2019-07-11 14:24:08 +00:00
|
|
|
};
|
|
|
|
return &peripheral_list;
|
|
|
|
}
|
2020-02-10 07:17:55 +00:00
|
|
|
#endif
|