Note

This is the documentation for the latest development branch and may refer to features that are not available in released versions. If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

FPIOA HAL interface documentation#

Hardware introduction#

K230 integrates an FPIOA (Field Programmable IO Array) controller internally to manage the function reuse of chip pins. The controller supports up to 64 pins, and each pin can be configured with a variety of different functions, including but not limited to GPIO, UART, SPI, I2C, PWM and other peripheral functions.


Data structure description#

fpioa_func_t#

Description: Define all available pin functions, including GPIO0~GPIO63 and various peripheral functions (UART, SPI, I2C, PWM, etc.).

fpioa_iomux_cfg_t#

Description: Pin configuration structure, including the following configuration bits:

  • st: Input Schmitt trigger control enable

  • ds: drive current control (4 bits)

  • pd: pull-down enable

  • pu: pull-up enable

  • oe: output enable

  • ie: input enable

  • msc: voltage selection

  • io_sel: multiplex function selection (3 bits)

  • di: Current PAD input data


Function interface description#

int drv_fpioa_get_pin_cfg(int pin, uint32_t* value);#

Function: Get the configuration register value of the specified pin.

parameter:

  • pin: pin number, range [0, 63]

  • value: Pointer used to store configuration values

Return Value:

  • 0: Success

  • -1: failed


int drv_fpioa_set_pin_cfg(int pin, uint32_t value);#

Function: Set the configuration register value of the specified pin.

parameter:

  • pin: pin number, range [0, 63]

  • value: Configuration value to be set

Return Value:

  • 0: Success

  • -1: failed


int drv_fpioa_get_pin_func(int pin, fpioa_func_t* func);#

Function: Get the function of the current configuration of the specified pin.

parameter:

  • pin: pin number, range [0, 63]

  • func: Pointer used to store functional types

Return Value:

  • 0: Success

  • -1: failed


int drv_fpioa_set_pin_func(int pin, fpioa_func_t func);#

Function: Set the function of the specified pin. If this function has been assigned to other pins, the configuration of other pins will be canceled first.

parameter:

  • pin: pin number, range [0, 63]

  • func: Function type to be set

Return Value:

  • 0: Success

  • -1: Failure (the pin does not support this feature)


int drv_fpioa_func_available_pins(fpioa_func_t func, int pins[FPIOA_PIN_FUNC_ALT_NUM]);#

Function: Get all pins that the specified function can be assigned to.

parameter:

  • func: Function type

  • pins: Array used to store pin numbers, up to 4

Return Value:

  • Number of available pins


int drv_fpioa_pin_supported_funcs(int pin, fpioa_func_t funcs[FPIOA_PIN_MAX_FUNCS]);#

Function: Get all functions supported by the specified pin.

parameter:

  • pin: pin number, range [0, 63]

  • funcs: array used to store functional types, up to 5

Return Value:

  • 0: Success

  • -1: failed


int drv_fpioa_get_func_name(fpioa_func_t func, char* buf, size_t buf_size);#

Function: Get the name string of the specified function.

parameter:

  • func: Function type

  • buf: Buffer used to store names

  • buf_size: buffer size

Return Value:

  • 0: Success

  • -1: failed


int drv_fpioa_get_pin_func_name(int pin, char* buf, size_t buf_size);#

Function: Get the name of the current function of the specified pin.

parameter:

  • pin: pin number

  • buf: Buffer used to store names

  • buf_size: buffer size

Return Value:

  • 0: Success

  • -1: failed


int drv_fpioa_get_pin_alt_func_names(int pin, char* buf, size_t buf_size);#

Function: Get the names of all optional functions of the specified pin, separated by “/”.

parameter:

  • pin: pin number

  • buf: Buffer used to store names

  • buf_size: buffer size

Return Value:

  • 0: Success

  • -1: failed


int drv_fpioa_get_func_assigned_pin(fpioa_func_t func);#

Function: Get the pin number currently assigned to the specified function.

parameter:

  • func: Function type

Return Value:

  • >=0: The pin number assigned to this function

  • -1: The function is not assigned or invalid


Pin parameter configuration function#

The following functions are used to configure the electrical characteristics parameters of the pin:

int drv_fpioa_set_pin_st(int pin, int value);#

Function: Set the Schmitt trigger enable of the pin.

int drv_fpioa_get_pin_st(int pin);#

Function: Get the Schmitt trigger enable status of the pin.

int drv_fpioa_set_pin_ds(int pin, int value);#

Function: Set the drive current strength of the pin (0-15).

int drv_fpioa_get_pin_ds(int pin);#

Function: Get the drive current strength of the pin.

int drv_fpioa_set_pin_pd(int pin, int value);#

Function: Set the pull-down resistor enable of the pin.

int drv_fpioa_get_pin_pd(int pin);#

Function: Get the pull-down resistor enable status of the pin.

int drv_fpioa_set_pin_pu(int pin, int value);#

Function: Set the pin’s pull-up resistor enable.

int drv_fpioa_get_pin_pu(int pin);#

Function: Get the pull-up resistor enable status of the pin.

int drv_fpioa_set_pin_oe(int pin, int value);#

Function: Set the output enable of the pin.

int drv_fpioa_get_pin_oe(int pin);#

Function: Get the output enable status of the pin.

int drv_fpioa_set_pin_ie(int pin, int value);#

Function: Set the input enable of the pin.

int drv_fpioa_get_pin_ie(int pin);#

Function: Get the input enable status of the pin.

parameter:

  • pin: pin number, range [0, 63]

  • value: value to set (0 or 1, ds is 0-15)

Return Value:

  • >=0: Success (get function returns the current value)

  • -1: failed


Usage example#

Please refer to src/rtsmart/libs/testcases/rtsmart_hal/test_fpioa.c

Comments list
Comments
Log in