gpio_8258.h File Reference

Go to the source code of this file.

Enumerations

enum  GPIO_PinTypeDef {
  GPIO_GROUPA = 0x000, GPIO_GROUPB = 0x100, GPIO_GROUPC = 0x200, GPIO_GROUPD = 0x300,
  GPIO_GROUPE = 0x400, GPIO_PA0 = GPIO_GROUPA | BIT(0), GPIO_PA1 = GPIO_GROUPA | BIT(1), GPIO_PA2 = GPIO_GROUPA | BIT(2),
  GPIO_PA3 = GPIO_GROUPA | BIT(3), GPIO_PA4 = GPIO_GROUPA | BIT(4), GPIO_PA5 = GPIO_GROUPA | BIT(5), GPIO_DM =GPIO_PA5,
  GPIO_PA6 = GPIO_GROUPA | BIT(6), GPIO_DP =GPIO_PA6, GPIO_PA7 = GPIO_GROUPA | BIT(7), GPIO_SWS =GPIO_PA7,
  GPIOA_ALL = GPIO_GROUPA | 0x00ff, GPIO_PB0 = GPIO_GROUPB | BIT(0), GPIO_PB1 = GPIO_GROUPB | BIT(1), GPIO_PB2 = GPIO_GROUPB | BIT(2),
  GPIO_PB3 = GPIO_GROUPB | BIT(3), GPIO_PB4 = GPIO_GROUPB | BIT(4), GPIO_PB5 = GPIO_GROUPB | BIT(5), GPIO_PB6 = GPIO_GROUPB | BIT(6),
  GPIO_PB7 = GPIO_GROUPB | BIT(7), GPIO_PC0 = GPIO_GROUPC | BIT(0), GPIO_PC1 = GPIO_GROUPC | BIT(1), GPIO_PC2 = GPIO_GROUPC | BIT(2),
  GPIO_PC3 = GPIO_GROUPC | BIT(3), GPIO_PC4 = GPIO_GROUPC | BIT(4), GPIO_PC5 = GPIO_GROUPC | BIT(5), GPIO_PC6 = GPIO_GROUPC | BIT(6),
  GPIO_PC7 = GPIO_GROUPC | BIT(7), GPIO_PD0 = GPIO_GROUPD | BIT(0), GPIO_PD1 = GPIO_GROUPD | BIT(1), GPIO_PD2 = GPIO_GROUPD | BIT(2),
  GPIO_PD3 = GPIO_GROUPD | BIT(3), GPIO_PD4 = GPIO_GROUPD | BIT(4), GPIO_PD5 = GPIO_GROUPD | BIT(5), GPIO_PD6 = GPIO_GROUPD | BIT(6),
  GPIO_PD7 = GPIO_GROUPD | BIT(7), GPIO_PE0 = GPIO_GROUPE | BIT(0), GPIO_MSDO =GPIO_PE0, GPIO_PE1 = GPIO_GROUPE | BIT(1),
  GPIO_MCLK =GPIO_PE1, GPIO_PE2 = GPIO_GROUPE | BIT(2), GPIO_MSCN =GPIO_PE2, GPIO_PE3 = GPIO_GROUPE | BIT(3),
  GPIO_MSDI =GPIO_PE3, GPIO_ALL = 0x500
}
 Define GPIO types. More...
 
enum  GPIO_FuncTypeDef {
  AS_GPIO = 0, AS_MSPI = 1, AS_SWIRE = 2, AS_UART = 3,
  AS_I2C = 4, AS_SPI = 5, AS_I2S = 6, AS_AMIC = 7,
  AS_DMIC = 8, AS_SDM = 9, AS_USB = 10, AS_ADC = 11,
  AS_CMP = 12, AS_ATS = 13, AS_PWM0 = 20, AS_PWM1 = 21,
  AS_PWM2 = 22, AS_PWM3 = 23, AS_PWM4 = 24, AS_PWM5 = 25,
  AS_PWM0_N = 26, AS_PWM1_N = 27, AS_PWM2_N = 28, AS_PWM3_N = 29,
  AS_PWM4_N = 30, AS_PWM5_N = 31
}
 Define GPIO Function types. More...
 
enum  GPIO_LevelTypeDef { Level_Low =0, Level_High =1 }
 
enum  GPIO_PolTypeDef { POL_RISING = 0, pol_rising = 0, POL_FALLING = 1, pol_falling = 1 }
 Define rising/falling types. More...
 
enum  GPIO_PullTypeDef { PM_PIN_UP_DOWN_FLOAT = 0, PM_PIN_PULLUP_1M = 1, PM_PIN_PULLDOWN_100K = 2, PM_PIN_PULLUP_10K = 3 }
 Define pull up or down types. More...
 

Functions

void gpio_init (int anaRes_init_en)
 This function servers to initialization all gpio. More...
 
void gpio_set_func (GPIO_PinTypeDef pin, GPIO_FuncTypeDef func)
 This function servers to set the GPIO's function. More...
 
static void gpio_set_output_en (GPIO_PinTypeDef pin, unsigned int value)
 This function set the output function of a pin. More...
 
void gpio_set_input_en (GPIO_PinTypeDef pin, unsigned int value)
 This function set the input function of a pin. More...
 
static int gpio_is_output_en (GPIO_PinTypeDef pin)
 This function determines whether the output function of a pin is enabled. More...
 
static int gpio_is_input_en (GPIO_PinTypeDef pin)
 This function determines whether the input function of a pin is enabled. More...
 
static void gpio_write (GPIO_PinTypeDef pin, unsigned int value)
 This function set the pin's output level. More...
 
static unsigned int gpio_read (GPIO_PinTypeDef pin)
 This function read the pin's input/output level. More...
 
static unsigned int gpio_read_cache (GPIO_PinTypeDef pin, unsigned char *p)
 This function read a pin's cache from the buffer. More...
 
static void gpio_read_all (unsigned char *p)
 This function read all the pins' input level. More...
 
static void gpio_toggle (GPIO_PinTypeDef pin)
 This function set the pin toggle. More...
 
void gpio_set_data_strength (GPIO_PinTypeDef pin, unsigned int value)
 This function set the pin's driving strength. More...
 
void gpio_setup_up_down_resistor (GPIO_PinTypeDef gpio, GPIO_PullTypeDef up_down)
 This function set a pin's pull-up/down resistor. More...
 
void gpio_shutdown (GPIO_PinTypeDef pin)
 This function servers to set the specified GPIO as high resistor. More...
 
static void gpio_set_interrupt_pol (GPIO_PinTypeDef pin, GPIO_PolTypeDef falling)
 This function set a pin's polarity that trig its IRQ. More...
 
static void gpio_set_interrupt (GPIO_PinTypeDef pin, GPIO_PolTypeDef falling)
 This function set a pin's IRQ. More...
 
static void gpio_en_interrupt (GPIO_PinTypeDef pin, int en)
 This function enables a pin's IRQ function. More...
 
static void gpio_set_interrupt_risc0 (GPIO_PinTypeDef pin, GPIO_PolTypeDef falling)
 This function set a pin's IRQ. More...
 
static void gpio_en_interrupt_risc0 (GPIO_PinTypeDef pin, int en)
 This function enables a pin's IRQ function. More...
 
static void gpio_set_interrupt_risc1 (GPIO_PinTypeDef pin, GPIO_PolTypeDef falling)
 This function set a pin's IRQ. More...
 
static void gpio_en_interrupt_risc1 (GPIO_PinTypeDef pin, int en)
 This function enables a pin's IRQ function. More...
 
static void usb_dp_pullup_en (int en)
 This function enables or disables the internal pull-up resistor of DP pin of USB interface. More...
 
static void usb_power_on (unsigned char en)
 This function serves to power on or down USB module. More...
 
static void usb_set_pin_en (void)
 This function serves to set GPIO MUX function as DP and DM pin of USB. More...
 

Enumeration Type Documentation

◆ GPIO_PinTypeDef

Define GPIO types.

Enumerator
GPIO_GROUPA 
GPIO_GROUPB 
GPIO_GROUPC 
GPIO_GROUPD 
GPIO_GROUPE 
GPIO_PA0 
GPIO_PA1 
GPIO_PA2 
GPIO_PA3 
GPIO_PA4 
GPIO_PA5 
GPIO_DM 
GPIO_PA6 
GPIO_DP 
GPIO_PA7 
GPIO_SWS 
GPIOA_ALL 
GPIO_PB0 
GPIO_PB1 
GPIO_PB2 
GPIO_PB3 
GPIO_PB4 
GPIO_PB5 
GPIO_PB6 
GPIO_PB7 
GPIO_PC0 
GPIO_PC1 
GPIO_PC2 
GPIO_PC3 
GPIO_PC4 
GPIO_PC5 
GPIO_PC6 
GPIO_PC7 
GPIO_PD0 
GPIO_PD1 
GPIO_PD2 
GPIO_PD3 
GPIO_PD4 
GPIO_PD5 
GPIO_PD6 
GPIO_PD7 
GPIO_PE0 
GPIO_MSDO 
GPIO_PE1 
GPIO_MCLK 
GPIO_PE2 
GPIO_MSCN 
GPIO_PE3 
GPIO_MSDI 
GPIO_ALL 

◆ GPIO_FuncTypeDef

Define GPIO Function types.

Enumerator
AS_GPIO 
AS_MSPI 
AS_SWIRE 
AS_UART 
AS_I2C 
AS_SPI 
AS_I2S 
AS_AMIC 
AS_DMIC 
AS_SDM 
AS_USB 
AS_ADC 
AS_CMP 
AS_ATS 
AS_PWM0 
AS_PWM1 
AS_PWM2 
AS_PWM3 
AS_PWM4 
AS_PWM5 
AS_PWM0_N 
AS_PWM1_N 
AS_PWM2_N 
AS_PWM3_N 
AS_PWM4_N 
AS_PWM5_N 

◆ GPIO_LevelTypeDef

Enumerator
Level_Low 
Level_High 

◆ GPIO_PolTypeDef

Define rising/falling types.

Enumerator
POL_RISING 
pol_rising 
POL_FALLING 
pol_falling 

◆ GPIO_PullTypeDef

Define pull up or down types.

Enumerator
PM_PIN_UP_DOWN_FLOAT 
PM_PIN_PULLUP_1M 
PM_PIN_PULLDOWN_100K 
PM_PIN_PULLUP_10K 

Function Documentation

◆ gpio_init()

void gpio_init ( int  anaRes_init_en)

This function servers to initialization all gpio.

Parameters
[in]en- if mcu wake up from deep retention mode, it is NOT necessary to reset analog register
Returns
none.

◆ gpio_set_func()

void gpio_set_func ( GPIO_PinTypeDef  pin,
GPIO_FuncTypeDef  func 
)

This function servers to set the GPIO's function.

Parameters
[in]pin- the special pin.
[in]func- the function of GPIO.
Returns
none.

◆ gpio_set_output_en()

static void gpio_set_output_en ( GPIO_PinTypeDef  pin,
unsigned int  value 
)
inlinestatic

This function set the output function of a pin.

Parameters
[in]pin- the pin needs to set the output function
[in]value- enable or disable the pin's output function(0: disable, 1: enable)
Returns
none

◆ gpio_set_input_en()

void gpio_set_input_en ( GPIO_PinTypeDef  pin,
unsigned int  value 
)

This function set the input function of a pin.

Parameters
[in]pin- the pin needs to set the input function
[in]value- enable or disable the pin's input function(0: disable, 1: enable)
Returns
none

◆ gpio_is_output_en()

static int gpio_is_output_en ( GPIO_PinTypeDef  pin)
inlinestatic

This function determines whether the output function of a pin is enabled.

Parameters
[in]pin- the pin needs to determine whether its output function is enabled.
Returns
1: the pin's output function is enabled ; 0: the pin's output function is disabled

◆ gpio_is_input_en()

static int gpio_is_input_en ( GPIO_PinTypeDef  pin)
inlinestatic

This function determines whether the input function of a pin is enabled.

Parameters
[in]pin- the pin needs to determine whether its input function is enabled.
Returns
1: the pin's input function is enabled ; 0: the pin's input function is disabled

◆ gpio_write()

static void gpio_write ( GPIO_PinTypeDef  pin,
unsigned int  value 
)
inlinestatic

This function set the pin's output level.

Parameters
[in]pin- the pin needs to set its output level
[in]value- value of the output level(1: high 0: low)
Returns
none

◆ gpio_read()

static unsigned int gpio_read ( GPIO_PinTypeDef  pin)
inlinestatic

This function read the pin's input/output level.

Parameters
[in]pin- the pin needs to read its level
Returns
the pin's level(1: high 0: low)

◆ gpio_read_cache()

static unsigned int gpio_read_cache ( GPIO_PinTypeDef  pin,
unsigned char *  p 
)
inlinestatic

This function read a pin's cache from the buffer.

Parameters
[in]pin- the pin needs to read.
[in]p- the buffer from which to read the pin's level.
Returns
the state of the pin.

◆ gpio_read_all()

static void gpio_read_all ( unsigned char *  p)
inlinestatic

This function read all the pins' input level.

Parameters
[out]p- the buffer used to store all the pins' input level
Returns
none

◆ gpio_toggle()

static void gpio_toggle ( GPIO_PinTypeDef  pin)
inlinestatic

This function set the pin toggle.

Parameters
[in]pin- the pin needs to toggle
Returns
none

◆ gpio_set_data_strength()

void gpio_set_data_strength ( GPIO_PinTypeDef  pin,
unsigned int  value 
)

This function set the pin's driving strength.

Parameters
[in]pin- the pin needs to set the driving strength
[in]value- the level of driving strength(1: strong 0: poor)
Returns
none

◆ gpio_setup_up_down_resistor()

void gpio_setup_up_down_resistor ( GPIO_PinTypeDef  gpio,
GPIO_PullTypeDef  up_down 
)

This function set a pin's pull-up/down resistor.

Parameters
[in]gpio- the pin needs to set its pull-up/down resistor
[in]up_down- the type of the pull-up/down resistor
Returns
none

◆ gpio_shutdown()

void gpio_shutdown ( GPIO_PinTypeDef  pin)

This function servers to set the specified GPIO as high resistor.

Parameters
[in]pin- select the specified GPIO
Returns
none.

◆ gpio_set_interrupt_pol()

static void gpio_set_interrupt_pol ( GPIO_PinTypeDef  pin,
GPIO_PolTypeDef  falling 
)
inlinestatic

This function set a pin's polarity that trig its IRQ.

Parameters
[in]pin- the pin needs to set its edge polarity that trig its IRQ
[in]falling- value of the edge polarity(1: falling edge 0: rising edge)
Returns
none

◆ gpio_set_interrupt()

static void gpio_set_interrupt ( GPIO_PinTypeDef  pin,
GPIO_PolTypeDef  falling 
)
inlinestatic

This function set a pin's IRQ.

Parameters
[in]pin- the pin needs to enable its IRQ
[in]falling- value of the edge polarity(1: falling edge 0: rising edge)
Returns
none

◆ gpio_en_interrupt()

static void gpio_en_interrupt ( GPIO_PinTypeDef  pin,
int  en 
)
inlinestatic

This function enables a pin's IRQ function.

Parameters
[in]pin- the pin needs to enables its IRQ function.
[in]en- 1:enable 0:disable.
Returns
none

◆ gpio_set_interrupt_risc0()

static void gpio_set_interrupt_risc0 ( GPIO_PinTypeDef  pin,
GPIO_PolTypeDef  falling 
)
inlinestatic

This function set a pin's IRQ.

Parameters
[in]pin- the pin needs to enable its IRQ
[in]falling- value of the edge polarity(1: falling edge 0: rising edge)
Returns
none

◆ gpio_en_interrupt_risc0()

static void gpio_en_interrupt_risc0 ( GPIO_PinTypeDef  pin,
int  en 
)
inlinestatic

This function enables a pin's IRQ function.

Parameters
[in]pin- the pin needs to enables its IRQ function.
[in]en- 1 enable. 0 disable.
Returns
none

◆ gpio_set_interrupt_risc1()

static void gpio_set_interrupt_risc1 ( GPIO_PinTypeDef  pin,
GPIO_PolTypeDef  falling 
)
inlinestatic

This function set a pin's IRQ.

Parameters
[in]pin- the pin needs to enable its IRQ
[in]falling- value of the edge polarity(1: falling edge 0: rising edge)
Returns
none

◆ gpio_en_interrupt_risc1()

static void gpio_en_interrupt_risc1 ( GPIO_PinTypeDef  pin,
int  en 
)
inlinestatic

This function enables a pin's IRQ function.

Parameters
[in]pin- the pin needs to enables its IRQ function.
[in]en- 1 enable. 0 disable.
Returns
none

◆ usb_dp_pullup_en()

static void usb_dp_pullup_en ( int  en)
inlinestatic

This function enables or disables the internal pull-up resistor of DP pin of USB interface.

Parameters
[in]En- enables or disables the internal pull-up resistor(1: enable 0: disable)
Returns
none

◆ usb_power_on()

static void usb_power_on ( unsigned char  en)
inlinestatic

This function serves to power on or down USB module.

Parameters
[in]En- 1: power on 0: power down
Returns
none

◆ usb_set_pin_en()

static void usb_set_pin_en ( void  )
inlinestatic

This function serves to set GPIO MUX function as DP and DM pin of USB.

Parameters
[in]none.
Returns
none.