CN / EN
Doc Feedback
Thanks for your interest, welcome to contact us.
Thanks for your feedback
No matches were found 114page(s) matching the search query
Documentation > GR5xx APP Driver User Manual/ Overview/ Initialization Parameter Structure Copy URL

Initialization Parameter Structure

Initialization parameters of an APP driver mainly include

  • app_xxx_id_t: Specify peripheral ID. For example, it can define the ID of I2C as ID0/ID1/ID2.
  • app_xxx_role_t: Specify peripheral roles. For example, it can define the role of I2C as APP_I2C_ROLE_MASTER/APP_I2C_ROLE_SLAVE.
  • app_xxx_dma_cfg_t: Configure peripheral DMA transmission. For example, it can configure the DMA instances/channels needed for DMA read/write operations for I2C.
  • app_xxx_pin_cfg_t: Initialize GPIOs for peripherals, such as initializing GPIO pull-up/pull-down settings, input/output configurations, and MUX selection.
  • xxx_init_t: Define the transmission parameters of a peripheral. For example, it can define the data size, clock polarity, clock phase, and sampling frequency of an SPI transmission.

Take I2C as an example. Structures of the initialization parameters are defined below:

/**
  * @brief I2C parameters structure definition
  */
typedef struct
{
    app_i2c_id_t        id;              /**< specified I2C module ID.      */
    app_i2c_role_t      role;            /**< specified the role of I2C.    */
    app_i2c_pin_cfg_t   pin_cfg;         /**< the pin configuration information for 
                                              the specified I2C module.     */
    app_i2c_dma_cfg_t   dma_cfg;         /**< I2C operate mode.             */
    i2c_init_t          init;            /**< I2C communication parameters. */
    i2c_env_t           i2c_dev;
} app_i2c_params_t;

app_peripheral_id_t

This structure member is used when a peripheral has more than one instance, such as I2C and UART of GR5526, both of which have six instances. In this case, the IDs are numbers from 0 to 5, with each indicating a peripheral instance. For peripherals with only one instance such as DSPI, OSPI, GPU, and DC, there is no such structure member.

app_xxx_pin_cfg_t

This structure member is used for peripherals that require operation on I/O pins, such as UART, SPI, and I2C. The member is composed of the following four sub-members:

  • Pin type: such as GPIOA/GPIOB/GPIOC/NORMAL, AON_GPIO, and MSIOA. NORMAL I/Os are only available for GR551x, and can be replaced by GPIOA/GPIOB which are recommended for GR551x.
  • Pin multiplexing: Multiplex I/Os for the functions as needed by configuring app_io_mux_t according to the Pin Mux tables in the corresponding datasheet. Taking GR5526 as an example, users can multiplex GPIOA4 for UART3 transmission by choosing MUX3.
  • Pin number: a number from 0 to 15. For NORMAL pins, it is a number from 0 to 31.
  • Pin mode: Configure a pin as pull-up/pull-down/floating.

For peripherals (such as TIMER and DUAL_TIMER) that do not require setting GPIOs, there is no need to define this member.

Take UART as an example. The member “app_uart_pin_cfg_t” is defined as below:

typedef struct
{
    app_io_type_t      type;           /**< Specifies the type of UART IO. */
    app_io_mux_t       mux;            /**< Specifies the Peripheral to be 
                                            connected to the selected pins. */
    uint32_t           pin;            /**< Specifies the IO pins to be configured.
                                            This parameter can be any value of 
                                            @ref GR55xx_pins. */
    app_io_pull_t      pull;           /**< Specifies the Pull-up or Pull-Down 
                                            activation for the selected pins. */

}app_uart_pin_t;

/**
  * @brief UART pins config Structures
  */
typedef struct
{
    app_uart_pin_t    tx;              /**< Set the configuration of UART TX pin.  */
    app_uart_pin_t    rx;              /**< Set the configuration of UART RX pin.  */
    app_uart_pin_t    cts;             /**< Set the configuration of UART CTS pin. */
    app_uart_pin_t    rts;             /**< Set the configuration of UART RTS pin. */
}app_uart_pin_cfg_t;

xxx_init_t

This structure member is used to set the unique parameters of each peripheral. For the PWM module as an example, the member “pwm_init_t” is defined below:

typedef struct
{
    uint32_t mode;                      /**< Specifies the PWM output mode state.
                                             This parameter can be a value of 
                                             @ref PWM_Mode */
    uint32_t align;                     /**< Specifies the PWM alignment mode with 
                                             three channels
                                             This parameter can be a value 
                                             of @ref PWM_Alignment_Mode */
    uint32_t freq;                      /**< Specifies the PWM frequency.
                                             This parameter must be a number between 
                                             0 ~ SystemFreq/2 (max = 32Mhz).*/
    uint32_t bperiod;                   /**< Specifies the PWM breath period in breath mode. 
                                             Unit: ms.
                                             This parameter must be a number between 
                                             0 ~ 0xFFFFFFFF/SystemFreq*1000. */
    uint32_t hperiod;                   /**< Specifies the PWM hold period in breath mode. 
                                             Unit: ms.
                                             This parameter must be a number between 
                                             0 ~ 0xFFFFFF/SystemFreq*1000. */
    uint32_t bstoplvl;                   /**< Specifies the PWM io level when stop.
                                             This parameter can be a value 
                                             of @ref PWM_STOP_LVL */
    pwm_channel_init_t channel_a;       /**< Specifies the configuration parameters 
                                             of channel A. */
    pwm_channel_init_t channel_b;       /**< Specifies the configuration parameters 
                                             of channel B. */
    pwm_channel_init_t channel_c;       /**< Specifies the configuration parameters 
                                             of channel C. */

} pwm_init_t;

Scan to follow

Open WeChat, use "Scan" to follow.