mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-10 11:05:21 +00:00
Many sub-systems might require to set a callback on different pins. Thus enabling it via changing the API. It is also possible to retrieve private-data in the callback handler using CONTAINER_OF() macro (include/misc/util.h). Former API is still available, and is emulated through the new one. Using both should not be a problem as it's using new API calls. However, it's now better to start using the new API. Change-Id: Id16594202905976cc524775d1cd3592b54a84514 Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
94 lines
2.1 KiB
C
94 lines
2.1 KiB
C
/*
|
|
* Copyright (c) 2016 Open-RnD Sp. z o.o.
|
|
*
|
|
* 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 _STM32_GPIO_H_
|
|
#define _STM32_GPIO_H_
|
|
|
|
/**
|
|
* @file header for STM32 GPIO
|
|
*/
|
|
|
|
|
|
#include <clock_control/stm32_clock_control.h>
|
|
#include <pinmux/stm32/pinmux_stm32.h>
|
|
#include <gpio.h>
|
|
|
|
/**
|
|
* @brief configuration of GPIO device
|
|
*/
|
|
struct gpio_stm32_config {
|
|
/* port base address */
|
|
uint32_t *base;
|
|
/* IO port */
|
|
enum stm32_pin_port port;
|
|
/* clock subsystem */
|
|
clock_control_subsys_t clock_subsys;
|
|
};
|
|
|
|
/**
|
|
* @brief driver data
|
|
*/
|
|
struct gpio_stm32_data {
|
|
/* user ISR cb */
|
|
sys_slist_t cb;
|
|
};
|
|
|
|
/**
|
|
* @brief helper for mapping of GPIO flags to SoC specific config
|
|
*
|
|
* @param flags GPIO encoded flags
|
|
* @param out conf SoC specific pin config
|
|
*
|
|
* @return 0 if flags were mapped to SoC pin config
|
|
*/
|
|
int stm32_gpio_flags_to_conf(int flags, int *conf);
|
|
|
|
/**
|
|
* @brief helper for configuration of GPIO pin
|
|
*
|
|
* @param base_addr GPIO port base address
|
|
* @param pin IO pin
|
|
* @param func GPIO mode
|
|
*/
|
|
int stm32_gpio_configure(uint32_t *base_addr, int pin, int func);
|
|
|
|
/**
|
|
* @brief helper for setting of GPIO pin output
|
|
*
|
|
* @param base_addr GPIO port base address
|
|
* @param pin IO pin
|
|
* @param value 1, 0
|
|
*/
|
|
int stm32_gpio_set(uint32_t *base, int pin, int value);
|
|
|
|
/**
|
|
* @brief helper for reading of GPIO pin value
|
|
*
|
|
* @param base_addr GPIO port base address
|
|
* @param pin IO pin
|
|
* @return pin value
|
|
*/
|
|
int stm32_gpio_get(uint32_t *base, int pin);
|
|
|
|
/**
|
|
* @brief enable interrupt source for GPIO pin
|
|
* @param port
|
|
* @param pin
|
|
*/
|
|
int stm32_gpio_enable_int(int port, int pin);
|
|
|
|
#endif /* _STM32_GPIO_H_ */
|