2015-12-09 09:29:47 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Takuo Yonezawa <Yonezawa-T2@mail.dnp.co.jp>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
|
|
|
* Public License v2.1. See the file LICENSE in the top level directory for
|
|
|
|
* more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-06-01 12:17:51 +02:00
|
|
|
* @ingroup cpu_native
|
2017-06-22 15:43:17 +02:00
|
|
|
* @ingroup drivers_periph_gpio
|
2015-12-09 09:29:47 +01:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief empty GPIO implementation
|
|
|
|
*
|
|
|
|
* @author Takuo Yonezawa <Yonezawa-T2@mail.dnp.co.jp>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "periph/gpio.h"
|
|
|
|
|
2024-02-27 00:16:20 +01:00
|
|
|
/**
|
|
|
|
* @brief Mocked GPIO array
|
|
|
|
*/
|
|
|
|
gpio_mock_t gpio_mock[GPIO_PORT_MAX][GPIO_PIN_MAX];
|
|
|
|
|
2024-01-25 01:57:48 +01:00
|
|
|
__attribute__((weak)) int gpio_init(gpio_t pin, gpio_mode_t mode) {
|
2024-01-24 13:13:31 +01:00
|
|
|
(void) pin;
|
|
|
|
(void) mode;
|
2015-12-09 09:29:47 +01:00
|
|
|
|
2024-02-27 00:16:20 +01:00
|
|
|
if (pin) {
|
|
|
|
pin->mode = mode;
|
|
|
|
pin->value = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
2015-12-09 09:29:47 +01:00
|
|
|
}
|
|
|
|
|
2024-01-25 01:57:48 +01:00
|
|
|
__attribute__((weak)) int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
|
2020-07-22 00:40:06 +02:00
|
|
|
gpio_cb_t cb, void *arg)
|
|
|
|
{
|
|
|
|
(void) cb;
|
|
|
|
(void) arg;
|
|
|
|
|
2024-02-27 00:16:20 +01:00
|
|
|
if (pin) {
|
|
|
|
pin->mode = mode;
|
|
|
|
pin->flank = flank;
|
|
|
|
pin->value = 0;
|
|
|
|
pin->cb = cb;
|
|
|
|
pin->arg = arg;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
2020-07-22 00:40:06 +02:00
|
|
|
}
|
|
|
|
|
2024-01-25 01:57:48 +01:00
|
|
|
__attribute__((weak)) void gpio_irq_enable(gpio_t pin)
|
2020-07-22 00:40:06 +02:00
|
|
|
{
|
|
|
|
(void) pin;
|
|
|
|
}
|
|
|
|
|
2024-01-25 01:57:48 +01:00
|
|
|
__attribute__((weak)) void gpio_irq_disable(gpio_t pin)
|
2020-07-22 00:40:06 +02:00
|
|
|
{
|
|
|
|
(void) pin;
|
|
|
|
}
|
|
|
|
|
2024-01-25 01:57:48 +01:00
|
|
|
__attribute__((weak)) int gpio_read(gpio_t pin) {
|
2024-02-27 00:16:20 +01:00
|
|
|
if (pin) {
|
|
|
|
return pin->value;
|
|
|
|
}
|
2015-12-09 09:29:47 +01:00
|
|
|
|
2024-02-27 00:16:20 +01:00
|
|
|
return -1;
|
2015-12-09 09:29:47 +01:00
|
|
|
}
|
|
|
|
|
2024-01-25 01:57:48 +01:00
|
|
|
__attribute__((weak)) void gpio_set(gpio_t pin) {
|
2024-02-27 00:16:20 +01:00
|
|
|
if (pin) {
|
|
|
|
pin->value = 1;
|
|
|
|
}
|
2015-12-09 09:29:47 +01:00
|
|
|
}
|
|
|
|
|
2024-01-25 01:57:48 +01:00
|
|
|
__attribute__((weak)) void gpio_clear(gpio_t pin) {
|
2024-02-27 00:16:20 +01:00
|
|
|
if (pin) {
|
|
|
|
pin->value = 0;
|
|
|
|
}
|
2015-12-09 09:29:47 +01:00
|
|
|
}
|
|
|
|
|
2024-01-25 01:57:48 +01:00
|
|
|
__attribute__((weak)) void gpio_toggle(gpio_t pin) {
|
2024-02-27 00:16:20 +01:00
|
|
|
if (pin) {
|
|
|
|
pin->value ^= 1;
|
|
|
|
}
|
2015-12-09 09:29:47 +01:00
|
|
|
}
|
|
|
|
|
2024-01-25 01:57:48 +01:00
|
|
|
__attribute__((weak)) void gpio_write(gpio_t pin, int value) {
|
2024-02-27 00:16:20 +01:00
|
|
|
if (pin) {
|
|
|
|
pin->value = value;
|
|
|
|
}
|
2015-12-09 09:29:47 +01:00
|
|
|
}
|
2019-10-04 15:48:46 +02:00
|
|
|
|
2015-12-09 09:29:47 +01:00
|
|
|
/** @} */
|