/**
******************************************************************************
* File Name : gpio.h
* Description : This file contains all the functions prototypes for
* the gpio
******************************************************************************
* @attention
*
*
© Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __gpio_H
#define __gpio_H
#ifdef __cplusplus
extern "C" {
#endif
#include
#include "pinName-board.h"
#include "pinName-ioe.h"
/* Includes ------------------------------------------------------------------*/
#include "main.h"
typedef void( GpioIrqHandler )( void );
#define RCC_GPIO_CLK_ENABLE( __GPIO_PORT__ ) \
do { \
switch( __GPIO_PORT__) \
{ \
case GPIOA_BASE: __HAL_RCC_GPIOA_CLK_ENABLE(); break; \
case GPIOB_BASE: __HAL_RCC_GPIOB_CLK_ENABLE(); break; \
case GPIOC_BASE: __HAL_RCC_GPIOC_CLK_ENABLE(); break; \
case GPIOD_BASE: __HAL_RCC_GPIOD_CLK_ENABLE(); break; \
} \
} while(0)
#define RCC_GPIO_CLK_DISABLE( __GPIO_PORT__ ) \
do { \
switch( __GPIO_PORT__) \
{ \
case GPIOA_BASE: __HAL_RCC_GPIOA_CLK_DISABLE(); break; \
case GPIOB_BASE: __HAL_RCC_GPIOB_CLK_DISABLE(); break; \
case GPIOC_BASE: __HAL_RCC_GPIOC_CLK_DISABLE(); break; \
case GPIOD_BASE: __HAL_RCC_GPIOD_CLK_DISABLE(); break; \
} \
} while(0)
void Board_GPIOInit(void);
/*!
* @brief Initializes the given GPIO object
*
* @param GPIOx: where x can be (A..E and H)
* @param GPIO_Pin: specifies the port bit to be written.
* This parameter can be one of GPIO_PIN_x where x can be (0..15).
* All port bits are not necessarily available on all GPIOs.
* @param [IN] initStruct GPIO_InitTypeDef intit structure
* @retval none
*/
void HW_GPIO_Init( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_InitTypeDef* initStruct);
void HW_GPIO_DeInit( GPIO_TypeDef* port, uint16_t GPIO_Pin);
/*!
* @brief Records the interrupt handler for the GPIO object
*
* @param GPIOx: where x can be (A..E and H)
* @param GPIO_Pin: specifies the port bit to be written.
* This parameter can be one of GPIO_PIN_x where x can be (0..15).
* All port bits are not necessarily available on all GPIOs.
* @param [IN] prio NVIC priority (0 is highest)
* @param [IN] irqHandler points to the function to execute
* @retval none
*/
void HW_GPIO_SetIrq( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, uint32_t prio, GpioIrqHandler *irqHandler );
/*!
* @brief Execute the interrupt from the object
*
* @param GPIOx: where x can be (A..E and H)
* @param GPIO_Pin: specifies the port bit to be written.
* This parameter can be one of GPIO_PIN_x where x can be (0..15).
* All port bits are not necessarily available on all GPIOs.
* @retval none
*/
void HW_GPIO_IrqHandler( uint16_t GPIO_Pin );
/*!
* @brief Writes the given value to the GPIO output
*
* @param GPIO_Pin: specifies the port bit to be written.
* This parameter can be one of GPIO_PIN_x where x can be (0..15).
* All port bits are not necessarily available on all GPIOs.
* @param [IN] value New GPIO output value
* @retval none
*/
void HW_GPIO_Write( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, uint32_t value );
/*!
* @brief Reads the current GPIO input value
*
* @param GPIOx: where x can be (A..E and H)
* @param GPIO_Pin: specifies the port bit to be written.
* This parameter can be one of GPIO_PIN_x where x can be (0..15).
* All port bits are not necessarily available on all GPIOs.
* @retval value Current GPIO input value
*/
uint32_t HW_GPIO_Read( GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin );
#ifdef __cplusplus
}
#endif
#endif /*__ pinoutConfig_H */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/