SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Enumerations | Functions
sys-gpio-v3.c File Reference
#include <io.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include <log.h>
#include <reg-ncat.h>
#include <sys-gpio.h>
Include dependency graph for sys-gpio-v3.c:

Enumerations

enum  {
  GPIO_CFG0 = 0x80 , GPIO_CFG1 = 0x84 , GPIO_CFG2 = 0x88 , GPIO_CFG3 = 0x8c ,
  GPIO_DAT = 0x90 , GPIO_DAT_SET = 0x94 , GPIO_DAT_CLR = 0x98 , GPIO_DRV0 = 0xa0 ,
  GPIO_DRV1 = 0xa4 , GPIO_DRV2 = 0xa8 , GPIO_DRV3 = 0xac , GPIO_PUL0 = 0xb0 ,
  GPIO_PUL1 = 0xb4 , GPIO_OFFSET = 0x80 , GPIO_CFG_MASK = 0xf , GPIO_DRV_MASK = 0x3 ,
  R_GPIO_CFG0 = 0x00 , R_GPIO_CFG1 = 0x04 , R_GPIO_CFG2 = 0x08 , R_GPIO_CFG3 = 0x0c ,
  R_GPIO_DAT = 0x500 , R_GPIO_DAT_SET = 0x504 , R_GPIO_DAT_CLR = 0x508 , R_GPIO_DRV0 = 0x14 ,
  R_GPIO_DRV1 = 0x18 , R_GPIO_DRV2 = 0x1c , R_GPIO_DRV3 = 0x20 , R_GPIO_PUL0 = 0x24 ,
  R_GPIO_PUL1 = 0x28 , R_GPIO_OFFSET = 0x30 , R_GPIO_CFG_MASK = 0xf , R_GPIO_DRV_MASK = 0x3
}
 

Functions

static uint32_t _port_num (gpio_t pin)
 Extracts the port number from a GPIO pin.
 
static uint32_t _port_base_get (gpio_t pin)
 Gets the base address of the port register for a GPIO pin.
 
static uint32_t _pin_num (gpio_t pin)
 Extracts the pin number within a port from a GPIO pin.
 
void sunxi_gpio_init (gpio_t pin, int cfg)
 Initializes a Sunxi GPIO pin with the specified configuration.
 
void sunxi_gpio_set_value (gpio_t pin, int value)
 Sets the value of a Sunxi GPIO pin.
 
int sunxi_gpio_read (gpio_t pin)
 Reads the value of a Sunxi GPIO pin.
 
void sunxi_gpio_set_pull (gpio_t pin, enum gpio_pull_t pull)
 Sets the pull configuration of a Sunxi GPIO pin.
 
void sunxi_gpio_set_drv (gpio_t pin, gpio_drv_t drv)
 Sets the drive strength of a Sunxi GPIO pin.
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
GPIO_CFG0 
GPIO_CFG1 
GPIO_CFG2 
GPIO_CFG3 
GPIO_DAT 
GPIO_DAT_SET 
GPIO_DAT_CLR 
GPIO_DRV0 
GPIO_DRV1 
GPIO_DRV2 
GPIO_DRV3 
GPIO_PUL0 
GPIO_PUL1 
GPIO_OFFSET 
GPIO_CFG_MASK 
GPIO_DRV_MASK 
R_GPIO_CFG0 
R_GPIO_CFG1 
R_GPIO_CFG2 
R_GPIO_CFG3 
R_GPIO_DAT 
R_GPIO_DAT_SET 
R_GPIO_DAT_CLR 
R_GPIO_DRV0 
R_GPIO_DRV1 
R_GPIO_DRV2 
R_GPIO_DRV3 
R_GPIO_PUL0 
R_GPIO_PUL1 
R_GPIO_OFFSET 
R_GPIO_CFG_MASK 
R_GPIO_DRV_MASK 

Function Documentation

◆ _pin_num()

static uint32_t _pin_num ( gpio_t  pin)
inlinestatic

Extracts the pin number within a port from a GPIO pin.

This inline function extracts the pin number within a port from the given GPIO pin number.

Parameters
pinThe GPIO pin number.
Returns
The pin number within a port.

◆ _port_base_get()

static uint32_t _port_base_get ( gpio_t  pin)
static

Gets the base address of the port register for a GPIO pin.

This function calculates and returns the base address of the port register for the specified GPIO pin.

Parameters
pinThe GPIO pin number.
Returns
The base address of the port register.

◆ _port_num()

static uint32_t _port_num ( gpio_t  pin)
inlinestatic

Extracts the port number from a GPIO pin.

This inline function extracts the port number from the given GPIO pin number.

Parameters
pinThe GPIO pin number.
Returns
The port number.

◆ sunxi_gpio_init()

void sunxi_gpio_init ( gpio_t  pin,
int  cfg 
)

Initializes a Sunxi GPIO pin with the specified configuration.

Initialize the specified GPIO pin with the given configuration.

This function initializes a Sunxi GPIO pin with the specified configuration. It sets the pin's configuration based on the provided parameters.

Parameters
pinThe GPIO pin to initialize.
cfgThe configuration value for the GPIO pin.

◆ sunxi_gpio_read()

int sunxi_gpio_read ( gpio_t  pin)

Reads the value of a Sunxi GPIO pin.

Read the value of the specified GPIO pin.

This function reads the current value of a Sunxi GPIO pin and returns it.

Parameters
pinThe GPIO pin to read the value from.
Returns
The value of the GPIO pin (0 or 1).

◆ sunxi_gpio_set_drv()

void sunxi_gpio_set_drv ( gpio_t  pin,
gpio_drv_t  drv 
)

Sets the drive strength of a Sunxi GPIO pin.

This function sets the drive strength for the specified GPIO pin.

Parameters
pinThe GPIO pin to set the drive strength for.
drvThe drive strength value to set (GPIO_DRV_LOW, GPIO_DRV_MEDIUM, or GPIO_DRV_HIGH).

◆ sunxi_gpio_set_pull()

void sunxi_gpio_set_pull ( gpio_t  pin,
enum gpio_pull_t  pull 
)

Sets the pull configuration of a Sunxi GPIO pin.

Set the pull configuration for the specified GPIO pin.

This function sets the pull-up, pull-down, or no pull configuration for the specified GPIO pin.

Parameters
pinThe GPIO pin to set the pull configuration for.
pullThe pull configuration to set (GPIO_PULL_UP, GPIO_PULL_DOWN, or GPIO_PULL_NONE).

◆ sunxi_gpio_set_value()

void sunxi_gpio_set_value ( gpio_t  pin,
int  value 
)

Sets the value of a Sunxi GPIO pin.

Set the value of the specified GPIO pin.

This function sets the value of a Sunxi GPIO pin to the specified value (0 or 1).

Parameters
pinThe GPIO pin to set the value for.
valueThe value to set (0 or 1).