Herzog Library 00.00.01  rel_libdev.herzog.00.00.01.10606
Data Structures | Macros | Typedefs | Functions
gpio_device.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "hdf.h"
#include "errno.h"

Go to the source code of this file.

Data Structures

struct  GPIO_Device_t
 A structure to represent GPIO device. More...
 

Macros

#define GPIO_MODE_INPUT   1 << 0
 
#define GPIO_MODE_OUTPUT   1 << 1
 
#define GPIO_MODE_PULLUP   1 << 2
 
#define GPIO_MODE_PULLDOWN   1 << 3
 
#define GPIO_MODE_INTERRUPT   1 << 4
 

Typedefs

typedef const struct GPIO_Device_t GPIO_Device_t
 A structure to represent GPIO device. More...
 

Functions

GPIO_Device_tGPIO_devRequest (const char *name)
 Request a GPIO Device. More...
 
int32_t GPIO_devRegisterIRQ (GPIO_Device_t *dev, void *cb)
 Register a callback function to GPIO interrupt handler. More...
 
int32_t GPIO_devUnregisterIRQ (GPIO_Device_t *dev, void *cb)
 Unregister a callback function to GPIO interrupt handler. More...
 
int32_t GPIO_devInit (GPIO_Device_t *dev, uint8_t pos, uint32_t mode)
 Initialize a GPIO pin. More...
 
int32_t GPIO_devSet (GPIO_Device_t *dev, uint8_t pos, uint8_t state)
 Set GPIO pin state. More...
 
int32_t GPIO_devRead (GPIO_Device_t *dev, uint8_t pos)
 Read GPIO pin state. More...
 
int32_t GPIO_devInitPort (GPIO_Device_t *dev, uint8_t mask, uint32_t mode)
 Initialize a GPIO port. More...
 
int32_t GPIO_devPortSet (GPIO_Device_t *dev, uint8_t mask, uint8_t val)
 Set GPIO port. More...
 
int32_t GPIO_devPortRead (GPIO_Device_t *dev, uint8_t mask)
 Read GPIO pin state. More...
 

Detailed Description

This file is proprietary to Indie Semiconductor. All rights reserved. Reproduction or distribution, in whole or in part, is forbidden except by express written permission of Indie Semiconductor.

Macro Definition Documentation

#define GPIO_MODE_INPUT   1 << 0

Bit mask for GPIO input enable

#define GPIO_MODE_INTERRUPT   1 << 4

Bit mask for GPIO interrupt enable

#define GPIO_MODE_OUTPUT   1 << 1

Bit mask for GPIO output enable

#define GPIO_MODE_PULLDOWN   1 << 3

Bit mask for GPIO pull down enable

#define GPIO_MODE_PULLUP   1 << 2

Bit mask for GPIO pull up enable

Typedef Documentation

typedef const struct GPIO_Device_t GPIO_Device_t

A structure to represent GPIO device.

Function Documentation

int32_t GPIO_devInit ( GPIO_Device_t dev,
uint8_t  pos,
uint32_t  mode 
)

Initialize a GPIO pin.

Parameters
devPointer to the GPIO device
posPin position to the GPIO device.
modeBit mask indicating the combination of the mode for this pin.
Returns
0 for success or error code upon a failure.
int32_t GPIO_devInitPort ( GPIO_Device_t dev,
uint8_t  mask,
uint32_t  mode 
)

Initialize a GPIO port.

Parameters
devPointer to the GPIO device
maskThe bit mask in the GPIO port to be configured.
modeThe bit mask indicating the combination of the mode for this port.
Returns
0 for success or error code upon a failure.
int32_t GPIO_devPortRead ( GPIO_Device_t dev,
uint8_t  mask 
)

Read GPIO pin state.

Parameters
devPointer to the GPIO device.
maskThe bit mask in the GPIO port to be read.
Returns
The masked value of the GPIO port or error code upon a failure.
int32_t GPIO_devPortSet ( GPIO_Device_t dev,
uint8_t  mask,
uint8_t  val 
)

Set GPIO port.

Parameters
devPointer to the GPIO device.
maskThe bit mask in the GPIO port to be set.
valThe value to be programmed to the GPIO port.
Returns
0 for success or error code upon a failure.
int32_t GPIO_devRead ( GPIO_Device_t dev,
uint8_t  pos 
)

Read GPIO pin state.

Parameters
devPointer to the GPIO device.
posPin position to the GPIO device.
Returns
The state of the GPIO pin or error code upon a failure.
int32_t GPIO_devRegisterIRQ ( GPIO_Device_t dev,
void *  cb 
)

Register a callback function to GPIO interrupt handler.

Parameters
devPointer to the GPIO device.
cbThe callback function to be registered.
Returns
0 for success or error code upon a failure.
GPIO_Device_t* GPIO_devRequest ( const char *  name)

Request a GPIO Device.

Parameters
nameThe name string of GPIO device.
Returns
The pointer to the GPIO device instance.
int32_t GPIO_devSet ( GPIO_Device_t dev,
uint8_t  pos,
uint8_t  state 
)

Set GPIO pin state.

Parameters
devPointer to the GPIO device.
posPin position to the GPIO device.
statePin state, 0 for low level, none zone for high level.
Returns
0 for success or error code upon a failure.
int32_t GPIO_devUnregisterIRQ ( GPIO_Device_t dev,
void *  cb 
)

Unregister a callback function to GPIO interrupt handler.

Parameters
devPointer to the GPIO device.
cbThe callback function to be unregistered.
Returns
0 for success or error code upon a failure.