mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #12477 from fkjagodzinski/hal-gpio-get_capabilities
HAL: Add a get_capabilities() function to GPIO APIpull/12496/head
commit
dc733d8883
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2019 ARM Limited
|
||||
* Copyright (c) 2019-2020 ARM Limited
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -33,6 +33,14 @@ extern "C" {
|
|||
*/
|
||||
void fpga_test_basic_input_output(PinName pin);
|
||||
|
||||
/* Test input pull modes.
|
||||
*
|
||||
* Given a GPIO instance configured with an input pull mode,
|
||||
* when basic input operations are performed,
|
||||
* then all operations succeed.
|
||||
*/
|
||||
void fpga_test_input_pull_modes(PinName pin);
|
||||
|
||||
/* Test explicit input initialization.
|
||||
*
|
||||
* Given a GPIO instance,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited and affiliates.
|
||||
* Copyright (c) 2019-2020, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -56,23 +56,64 @@ void fpga_test_basic_input_output(PinName pin)
|
|||
// Select GPIO0.
|
||||
tester.select_peripheral(MbedTester::PeripheralGPIO);
|
||||
|
||||
// Initialize GPIO pin with a generic init fun.
|
||||
gpio_t gpio;
|
||||
// Test gpio_is_connected() returned value.
|
||||
// Initialize GPIO pin with a generic init fun.
|
||||
gpio_init(&gpio, NC);
|
||||
// Test gpio_is_connected() returned value.
|
||||
TEST_ASSERT_EQUAL_INT(0, gpio_is_connected(&gpio));
|
||||
gpio_free(&gpio);
|
||||
gpio_init(&gpio, pin);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
|
||||
// Some targets don't support input pull mode.
|
||||
#if !defined(TARGET_NANO100) && \
|
||||
!defined(TARGET_NUC472) && \
|
||||
!defined(TARGET_M451)
|
||||
// Test GPIO used as an input.
|
||||
gpio_dir(&gpio, PIN_INPUT);
|
||||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 1, true);
|
||||
TEST_ASSERT_EQUAL_INT(1, gpio_read(&gpio));
|
||||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, true);
|
||||
TEST_ASSERT_EQUAL_INT(0, gpio_read(&gpio));
|
||||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 1, true);
|
||||
TEST_ASSERT_EQUAL_INT(1, gpio_read(&gpio));
|
||||
|
||||
// Test GPIO used as an output.
|
||||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
|
||||
gpio_dir(&gpio, PIN_OUTPUT);
|
||||
gpio_write(&gpio, 0);
|
||||
TEST_ASSERT_EQUAL_INT(0, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
gpio_write(&gpio, 1);
|
||||
TEST_ASSERT_EQUAL_INT(1, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
gpio_write(&gpio, 0);
|
||||
TEST_ASSERT_EQUAL_INT(0, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
|
||||
gpio_free(&gpio);
|
||||
}
|
||||
|
||||
/* Test input pull modes.
|
||||
*
|
||||
* Given a GPIO instance configured with an input pull mode,
|
||||
* when basic input operations are performed,
|
||||
* then all operations succeed.
|
||||
*/
|
||||
void fpga_test_input_pull_modes(PinName pin)
|
||||
{
|
||||
// Reset everything and set all tester pins to hi-Z.
|
||||
tester.reset();
|
||||
|
||||
// Map pins for test.
|
||||
tester.pin_map_set(pin, MbedTester::LogicalPinGPIO0);
|
||||
|
||||
// Select GPIO0.
|
||||
tester.select_peripheral(MbedTester::PeripheralGPIO);
|
||||
|
||||
gpio_t gpio;
|
||||
// Initialize GPIO pin with a generic init fun.
|
||||
gpio_init(&gpio, pin);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
gpio_dir(&gpio, PIN_INPUT);
|
||||
gpio_capabilities_t gcap = {};
|
||||
gpio_get_capabilities(&gpio, &gcap);
|
||||
|
||||
// Test input, pull-up mode.
|
||||
if (gcap.pull_up) {
|
||||
gpio_mode(&gpio, PullUp);
|
||||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
|
||||
wait_us(HI_Z_READ_DELAY_US);
|
||||
|
@ -86,8 +127,12 @@ void fpga_test_basic_input_output(PinName pin)
|
|||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
|
||||
wait_us(HI_Z_READ_DELAY_US);
|
||||
TEST_ASSERT_EQUAL_INT(1, gpio_read(&gpio)); // hi-Z, pulled up
|
||||
} else {
|
||||
utest_printf("skipped PullUp,");
|
||||
}
|
||||
|
||||
// Test input, pull-down mode.
|
||||
if (gcap.pull_down) {
|
||||
gpio_mode(&gpio, PullDown);
|
||||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
|
||||
wait_us(HI_Z_READ_DELAY_US);
|
||||
|
@ -101,8 +146,12 @@ void fpga_test_basic_input_output(PinName pin)
|
|||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
|
||||
wait_us(HI_Z_READ_DELAY_US);
|
||||
TEST_ASSERT_EQUAL_INT(0, gpio_read(&gpio)); // hi-Z, pulled down
|
||||
} else {
|
||||
utest_printf("skipped PullDown,");
|
||||
}
|
||||
|
||||
// Test input, pull-none mode.
|
||||
if (gcap.pull_none) {
|
||||
gpio_mode(&gpio, PullNone);
|
||||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 1, true);
|
||||
TEST_ASSERT_EQUAL_INT(1, gpio_read(&gpio));
|
||||
|
@ -110,17 +159,9 @@ void fpga_test_basic_input_output(PinName pin)
|
|||
TEST_ASSERT_EQUAL_INT(0, gpio_read(&gpio));
|
||||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 1, true);
|
||||
TEST_ASSERT_EQUAL_INT(1, gpio_read(&gpio));
|
||||
#endif
|
||||
|
||||
// Test GPIO used as an output.
|
||||
tester.gpio_write(MbedTester::LogicalPinGPIO0, 0, false);
|
||||
gpio_dir(&gpio, PIN_OUTPUT);
|
||||
gpio_write(&gpio, 0);
|
||||
TEST_ASSERT_EQUAL_INT(0, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
gpio_write(&gpio, 1);
|
||||
TEST_ASSERT_EQUAL_INT(1, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
gpio_write(&gpio, 0);
|
||||
TEST_ASSERT_EQUAL_INT(0, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
} else {
|
||||
utest_printf("skipped PullNone,");
|
||||
}
|
||||
|
||||
gpio_free(&gpio);
|
||||
}
|
||||
|
@ -143,8 +184,13 @@ void fpga_test_explicit_input(PinName pin)
|
|||
tester.select_peripheral(MbedTester::PeripheralGPIO);
|
||||
|
||||
gpio_t gpio;
|
||||
gpio_init(&gpio, pin);
|
||||
gpio_capabilities_t gcap = {};
|
||||
gpio_get_capabilities(&gpio, &gcap);
|
||||
gpio_free(&gpio);
|
||||
|
||||
// Initialize GPIO pin as an input, pull-up mode.
|
||||
if (gcap.pull_up) {
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
gpio_init_in_ex(&gpio, pin, PullUp);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
|
@ -152,8 +198,12 @@ void fpga_test_explicit_input(PinName pin)
|
|||
wait_us(HI_Z_READ_DELAY_US);
|
||||
TEST_ASSERT_EQUAL_INT(1, gpio_read(&gpio)); // hi-Z, pulled up
|
||||
gpio_free(&gpio);
|
||||
} else {
|
||||
utest_printf("skipped PullUp,");
|
||||
}
|
||||
|
||||
// Initialize GPIO pin as an input, pull-down mode.
|
||||
if (gcap.pull_down) {
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
gpio_init_in_ex(&gpio, pin, PullDown);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
|
@ -161,8 +211,12 @@ void fpga_test_explicit_input(PinName pin)
|
|||
wait_us(HI_Z_READ_DELAY_US);
|
||||
TEST_ASSERT_EQUAL_INT(0, gpio_read(&gpio)); // hi-Z, pulled down
|
||||
gpio_free(&gpio);
|
||||
} else {
|
||||
utest_printf("skipped PullDown,");
|
||||
}
|
||||
|
||||
// Initialize GPIO pin as an input, pull-up mode.
|
||||
if (gcap.pull_up) {
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
gpio_init_inout(&gpio, pin, PIN_INPUT, PullUp, 0);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
|
@ -170,8 +224,12 @@ void fpga_test_explicit_input(PinName pin)
|
|||
wait_us(HI_Z_READ_DELAY_US);
|
||||
TEST_ASSERT_EQUAL_INT(1, gpio_read(&gpio)); // hi-Z, pulled up
|
||||
gpio_free(&gpio);
|
||||
} else {
|
||||
utest_printf("skipped PullUp,");
|
||||
}
|
||||
|
||||
// Initialize GPIO pin as an input, pull-down mode.
|
||||
if (gcap.pull_down) {
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
gpio_init_inout(&gpio, pin, PIN_INPUT, PullDown, 0);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
|
@ -179,6 +237,9 @@ void fpga_test_explicit_input(PinName pin)
|
|||
wait_us(HI_Z_READ_DELAY_US);
|
||||
TEST_ASSERT_EQUAL_INT(0, gpio_read(&gpio)); // hi-Z, pulled down
|
||||
gpio_free(&gpio);
|
||||
} else {
|
||||
utest_printf("skipped PullDown,");
|
||||
}
|
||||
}
|
||||
|
||||
/* Test explicit output initialization.
|
||||
|
@ -199,6 +260,10 @@ void fpga_test_explicit_output(PinName pin)
|
|||
tester.select_peripheral(MbedTester::PeripheralGPIO);
|
||||
|
||||
gpio_t gpio;
|
||||
gpio_init(&gpio, pin);
|
||||
gpio_capabilities_t gcap = {};
|
||||
gpio_get_capabilities(&gpio, &gcap);
|
||||
gpio_free(&gpio);
|
||||
|
||||
// Initialize GPIO pin as an output, output value = 0.
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
|
@ -222,6 +287,7 @@ void fpga_test_explicit_output(PinName pin)
|
|||
gpio_free(&gpio);
|
||||
|
||||
// Initialize GPIO pin as an output, output value = 1.
|
||||
if (gcap.pull_none) {
|
||||
memset(&gpio, 0, sizeof gpio);
|
||||
gpio_init_inout(&gpio, pin, PIN_OUTPUT, PullNone, 1);
|
||||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
|
@ -234,16 +300,15 @@ void fpga_test_explicit_output(PinName pin)
|
|||
TEST_ASSERT_NOT_EQUAL(0, gpio_is_connected(&gpio));
|
||||
TEST_ASSERT_EQUAL_INT(0, tester.gpio_read(MbedTester::LogicalPinGPIO0));
|
||||
gpio_free(&gpio);
|
||||
} else {
|
||||
utest_printf("skipped gpio_init_inout,");
|
||||
}
|
||||
}
|
||||
|
||||
Case cases[] = {
|
||||
Case("generic init, input & output", all_ports<GPIOPort, DefaultFormFactor, fpga_test_basic_input_output>),
|
||||
// Some targets don't support input pull mode.
|
||||
#if !defined(TARGET_NANO100) && \
|
||||
!defined(TARGET_NUC472) && \
|
||||
!defined(TARGET_M451)
|
||||
Case("basic input & output", all_ports<GPIOPort, DefaultFormFactor, fpga_test_basic_input_output>),
|
||||
Case("input pull modes", all_ports<GPIOPort, DefaultFormFactor, fpga_test_input_pull_modes>),
|
||||
Case("explicit init, input", all_ports<GPIOPort, DefaultFormFactor, fpga_test_explicit_input>),
|
||||
#endif
|
||||
Case("explicit init, output", all_ports<GPIOPort, DefaultFormFactor, fpga_test_explicit_output>),
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/** \addtogroup hal */
|
||||
/** @{*/
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
* Copyright (c) 2006-2020 ARM Limited
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -46,6 +46,8 @@ extern "C" {
|
|||
* * ::gpio_init_out_ex inits the pin as an output and sets the output value
|
||||
* * ::gpio_init_inout inits the pin to be input/output and set pin mode and value
|
||||
* * The GPIO operations ::gpio_write, ::gpio_read take less than 20us to complete
|
||||
* * The function ::gpio_get_capabilities fills the given
|
||||
* `gpio_capabilities_t` instance according to pin capabilities.
|
||||
*
|
||||
* # Undefined behavior
|
||||
* * Calling any ::gpio_mode, ::gpio_dir, ::gpio_write or ::gpio_read on a gpio_t object that was initialized
|
||||
|
@ -65,6 +67,14 @@ extern "C" {
|
|||
*
|
||||
*/
|
||||
|
||||
/** GPIO capabilities for a given pin
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t pull_none : 1;
|
||||
uint8_t pull_down : 1;
|
||||
uint8_t pull_up : 1;
|
||||
} gpio_capabilities_t;
|
||||
|
||||
/** Set the given pin as GPIO
|
||||
*
|
||||
* @param pin The pin to be set as GPIO
|
||||
|
@ -164,6 +174,10 @@ 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);
|
||||
|
||||
/** Fill the given gpio_capabilities_t instance according to pin capabilities.
|
||||
*/
|
||||
void gpio_get_capabilities(gpio_t *gpio, gpio_capabilities_t *cap);
|
||||
|
||||
/** Get the pins that support all GPIO tests
|
||||
*
|
||||
* Return a PinMap array of pins that support GPIO. The
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
* Copyright (c) 2006-2020 ARM Limited
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -68,6 +68,15 @@ void gpio_init_inout(gpio_t *gpio, PinName pin, PinDirection direction, PinMode
|
|||
}
|
||||
}
|
||||
|
||||
// To be re-implemented in the target layer if required.
|
||||
MBED_WEAK void gpio_get_capabilities(gpio_t *gpio, gpio_capabilities_t *cap)
|
||||
{
|
||||
(void)gpio; // By default, every pin supports all basic input pull modes.
|
||||
cap->pull_none = 1;
|
||||
cap->pull_down = 1;
|
||||
cap->pull_up = 1;
|
||||
}
|
||||
|
||||
#ifdef TARGET_FF_ARDUINO
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
* Copyright (c) 2006-2020 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,10 +22,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
GPIO_X = 0, // dummy peripheral used instead of GPIO_A..GPIO_E
|
||||
} GPIOName;
|
||||
|
||||
typedef enum {
|
||||
OSC32KCLK = 0,
|
||||
} RTCName;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
* Copyright (c) 2006-2020 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,118 +19,6 @@
|
|||
|
||||
#include <mstd_cstddef>
|
||||
|
||||
/************GPIO***************/
|
||||
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_GPIO[] = {
|
||||
{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_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_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_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_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}
|
||||
};
|
||||
|
||||
/************RTC***************/
|
||||
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_RTC[] = {
|
||||
{NC, OSC32KCLK, 0},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
* Copyright (c) 2006-2020 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,8 +16,20 @@
|
|||
|
||||
#include "PeripheralPins.h"
|
||||
#include "PeripheralPinMaps.h"
|
||||
#include "mbed_assert.h"
|
||||
#include "hal/gpio_api.h"
|
||||
|
||||
const PinMap *gpio_pinmap()
|
||||
void gpio_get_capabilities(gpio_t *obj, gpio_capabilities_t *cap)
|
||||
{
|
||||
return PinMap_GPIO;
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
// fixed pull-ups (for I2C)
|
||||
if (obj->pin == PTE24 || obj->pin == PTE25) {
|
||||
cap->pull_none = 0;
|
||||
cap->pull_down = 0;
|
||||
cap->pull_up = 0;
|
||||
} else {
|
||||
cap->pull_none = 1;
|
||||
cap->pull_down = 1;
|
||||
cap->pull_up = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
* Copyright (c) 2006-2020 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,9 +20,6 @@
|
|||
#include "pinmap.h"
|
||||
#include "PeripheralNames.h"
|
||||
|
||||
/************GPIO***************/
|
||||
extern const PinMap PinMap_GPIO[];
|
||||
|
||||
/************RTC***************/
|
||||
extern const PinMap PinMap_RTC[];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2015-2016 Nuvoton
|
||||
* Copyright (c) 2015-2020 Nuvoton
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -140,3 +140,11 @@ void gpio_dir(gpio_t *obj, PinDirection direction)
|
|||
|
||||
pin_mode(obj->pin, obj->mode);
|
||||
}
|
||||
|
||||
void gpio_get_capabilities(gpio_t *obj, gpio_capabilities_t *cap)
|
||||
{
|
||||
// Pull modes not supported.
|
||||
cap->pull_none = 0;
|
||||
cap->pull_down = 0;
|
||||
cap->pull_up = 0;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2015-2017 Nuvoton
|
||||
* Copyright (c) 2015-2020 Nuvoton
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -121,3 +121,11 @@ void gpio_dir(gpio_t *obj, PinDirection direction)
|
|||
|
||||
pin_mode(obj->pin, obj->mode);
|
||||
}
|
||||
|
||||
void gpio_get_capabilities(gpio_t *obj, gpio_capabilities_t *cap)
|
||||
{
|
||||
// Pull modes not supported.
|
||||
cap->pull_none = 0;
|
||||
cap->pull_down = 0;
|
||||
cap->pull_up = 0;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2015-2016 Nuvoton
|
||||
* Copyright (c) 2015-2020 Nuvoton
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -140,3 +140,11 @@ void gpio_dir(gpio_t *obj, PinDirection direction)
|
|||
|
||||
pin_mode(obj->pin, obj->mode);
|
||||
}
|
||||
|
||||
void gpio_get_capabilities(gpio_t *obj, gpio_capabilities_t *cap)
|
||||
{
|
||||
// Pull modes not supported.
|
||||
cap->pull_none = 0;
|
||||
cap->pull_down = 0;
|
||||
cap->pull_up = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue