HPM SDK
HPMicro Software Development Kit
hpm_gpio_drv.h File Reference
#include "hpm_common.h"
#include "hpm_gpio_regs.h"
#include "hpm_soc_feature.h"

Go to the source code of this file.

Macros

#define PORT_PIN_COUNT   (32U)
 
#define GPIO_GET_PORT_INDEX(x)   (x / PORT_PIN_COUNT)
 
#define GPIO_GET_PIN_INDEX(x)   (x % PORT_PIN_COUNT)
 

Typedefs

typedef enum gpio_interrupt_trigger gpio_interrupt_trigger_t
 Interrupt trigger type. More...
 

Enumerations

enum  gpio_interrupt_trigger { gpio_interrupt_trigger_level_high = 0 , gpio_interrupt_trigger_level_low , gpio_interrupt_trigger_edge_rising , gpio_interrupt_trigger_edge_falling }
 Interrupt trigger type. More...
 

Functions

static uint8_t gpio_read_pin (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Read target pin level. More...
 
static uint32_t gpio_get_pin_output_status (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Read target pin output state. More...
 
static void gpio_toggle_pin (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Toggle pin level. More...
 
static void gpio_write_pin (GPIO_Type *ptr, uint32_t port, uint8_t pin, uint8_t high)
 Write pin level. More...
 
static void gpio_set_pin_input (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Set pin to input mode. More...
 
static void gpio_set_pin_output (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Set pin to output mode. More...
 
void gpio_set_pin_output_with_initial (GPIO_Type *ptr, uint32_t port, uint8_t pin, uint8_t initial)
 Set pin to output mode with initial value. More...
 
static bool gpio_check_pin_interrupt_flag (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Check specific pin interrupt status. More...
 
static void gpio_clear_pin_interrupt_flag (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Clear specific pin interrupt flag. More...
 
static bool gpio_check_pin_interrupt_enabled (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Check if specific pin interrupt is enabled or not. More...
 
static void gpio_enable_pin_interrupt (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Enable interrupt for specific pin. More...
 
static void gpio_disable_pin_interrupt (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Disable interrupt for specific pin. More...
 
static bool gpio_check_clear_interrupt_flag (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Check interrupt flag of specific pin and clear if it is set. More...
 
static uint32_t gpio_read_port (GPIO_Type *ptr, uint32_t port)
 Read all pins level on specific port. More...
 
static void gpio_toggle_port_with_mask (GPIO_Type *ptr, uint32_t port, uint32_t mask)
 Toggle port with specific pin mask. More...
 
static void gpio_write_port (GPIO_Type *ptr, uint32_t port, uint32_t value)
 Write specific port with value. More...
 
static void gpio_set_port_low_with_mask (GPIO_Type *ptr, uint32_t port, uint32_t mask)
 Set spcific port pin high according to the given mask. More...
 
static void gpio_set_port_high_with_mask (GPIO_Type *ptr, uint32_t port, uint32_t mask)
 Set spcific port pin high according to the given mask. More...
 
static void gpio_enable_port_output_with_mask (GPIO_Type *ptr, uint32_t port, uint32_t mask)
 Enable pins output of specific port according to the given mask. More...
 
static void gpio_disable_port_output_with_mask (GPIO_Type *ptr, uint32_t port, uint32_t mask)
 Disable pins output of specific port according to the given mask. More...
 
static uint32_t gpio_get_port_interrupt_flags (GPIO_Type *ptr, uint32_t port)
 Get current interrupt flags on specific port. More...
 
static void gpio_clear_port_interrupt_flags_with_mask (GPIO_Type *ptr, uint32_t port, uint32_t mask)
 Clear interrupt flags with given mask on specific port. More...
 
static void gpio_enable_port_interrupt_with_mask (GPIO_Type *ptr, uint32_t port, uint8_t mask)
 Enable interrupts with given mask on specific port. More...
 
static void gpio_disable_port_interrupt_with_mask (GPIO_Type *ptr, uint32_t port, uint8_t mask)
 Disable interrupts with given mask on specific port. More...
 
void gpio_config_pin_interrupt (GPIO_Type *ptr, uint32_t port, uint8_t pin, gpio_interrupt_trigger_t trigger)
 Config pin interrupt. More...
 
void gpio_toggle_pin_interrupt_trigger_polarity (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Toggle pin interrupt trigger polarity. More...
 
void gpio_toggle_pin_interrupt_trigger_type (GPIO_Type *ptr, uint32_t port, uint8_t pin)
 Toggle pin interrupt trigger type. More...
 

Macro Definition Documentation

◆ GPIO_GET_PIN_INDEX

#define GPIO_GET_PIN_INDEX (   x)    (x % PORT_PIN_COUNT)

◆ GPIO_GET_PORT_INDEX

#define GPIO_GET_PORT_INDEX (   x)    (x / PORT_PIN_COUNT)

◆ PORT_PIN_COUNT

#define PORT_PIN_COUNT   (32U)