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

Go to the source code of this file.

Classes

struct  gpio_mux_t
 

Macros

#define PIO_NUM_IO_BITS   5
 
#define GPIO_PIN(x, y)   (((uint32_t) (x << PIO_NUM_IO_BITS)) | y)
 

Typedefs

typedef uint32_t gpio_drv_t
 
typedef uint32_t gpio_t
 

Enumerations

enum  {
  GPIO_INPUT = 0 , GPIO_OUTPUT = 1 , GPIO_PERIPH_MUX2 = 2 , GPIO_PERIPH_MUX3 = 3 ,
  GPIO_PERIPH_MUX4 = 4 , GPIO_PERIPH_MUX5 = 5 , GPIO_PERIPH_MUX6 = 6 , GPIO_PERIPH_MUX7 = 7 ,
  GPIO_PERIPH_MUX8 = 8 , GPIO_PERIPH_MUX14 = 14 , GPIO_DISABLED = 0xf
}
 
enum  { GPIO_LEVEL_LOW = 0 , GPIO_LEVEL_HIGH }
 
enum  {
  GPIO_PORTA = 0 , GPIO_PORTB , GPIO_PORTC , GPIO_PORTD ,
  GPIO_PORTE , GPIO_PORTF , GPIO_PORTG , GPIO_PORTH ,
  GPIO_PORTI , GPIO_PORTJ , GPIO_PORTK , GPIO_PORTL ,
  GPIO_PORTM , GPIO_PORTN
}
 
enum  gpio_pull_t { GPIO_PULL_UP = 0 , GPIO_PULL_DOWN = 1 , GPIO_PULL_NONE = 2 }
 

Functions

void sunxi_gpio_init (gpio_t pin, int cfg)
 Initialize the specified GPIO pin with the given configuration.
 
void sunxi_gpio_set_value (gpio_t pin, int value)
 Set the value of the specified GPIO pin.
 
int sunxi_gpio_read (gpio_t pin)
 Read the value of the specified GPIO pin.
 
void sunxi_gpio_set_pull (gpio_t pin, enum gpio_pull_t pull)
 Set the pull configuration for the specified GPIO pin.
 
void sunxi_gpio_set_drv (gpio_t pin, gpio_drv_t drv)
 Sets the drive strength of a Sunxi GPIO pin.
 

Macro Definition Documentation

◆ GPIO_PIN

#define GPIO_PIN (   x,
 
)    (((uint32_t) (x << PIO_NUM_IO_BITS)) | y)

◆ PIO_NUM_IO_BITS

#define PIO_NUM_IO_BITS   5

Typedef Documentation

◆ gpio_drv_t

◆ gpio_t

typedef uint32_t gpio_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
GPIO_INPUT 
GPIO_OUTPUT 
GPIO_PERIPH_MUX2 
GPIO_PERIPH_MUX3 
GPIO_PERIPH_MUX4 
GPIO_PERIPH_MUX5 
GPIO_PERIPH_MUX6 
GPIO_PERIPH_MUX7 
GPIO_PERIPH_MUX8 
GPIO_PERIPH_MUX14 
GPIO_DISABLED 

◆ anonymous enum

anonymous enum
Enumerator
GPIO_LEVEL_LOW 
GPIO_LEVEL_HIGH 

◆ anonymous enum

anonymous enum
Enumerator
GPIO_PORTA 
GPIO_PORTB 
GPIO_PORTC 
GPIO_PORTD 
GPIO_PORTE 
GPIO_PORTF 
GPIO_PORTG 
GPIO_PORTH 
GPIO_PORTI 
GPIO_PORTJ 
GPIO_PORTK 
GPIO_PORTL 
GPIO_PORTM 
GPIO_PORTN 

◆ gpio_pull_t

Enumerator
GPIO_PULL_UP 
GPIO_PULL_DOWN 
GPIO_PULL_NONE 

Function Documentation

◆ sunxi_gpio_init()

void sunxi_gpio_init ( gpio_t  pin,
int  cfg 
)

Initialize the specified GPIO pin with the given configuration.

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

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)

Read the value of the specified GPIO pin.

Parameters
pinThe GPIO pin to read the value from.
Returns
The value (0 or 1) read from the 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 
)

Set the pull configuration for the specified GPIO pin.

Parameters
pinThe GPIO pin to set the pull configuration for.
pullThe pull configuration to be set for the 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 
)

Set the value of the specified GPIO pin.

Parameters
pinThe GPIO pin to set the value for.
valueThe value to be set (0 or 1) for the 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).