CRpi
A library for rpi with intefaces to: gpio, pwm, dma
Functions
gpio.cpp File Reference

Interface to the GPIO peripheral. More...

#include <stdio.h>
#include <memoryManagement/addressing.h>
#include <memoryManagement/physMemoryManagement.h>
#include <CCRCodingUtils/include/errorManagement.h>
#include <peripherals/gpio.h>
#include "gpio_internal.h"

Functions

int gpio_init ()
 Initializes the interface, to be called before any other function in this file. More...
 
int gpio_isInit ()
 true if gpio_init has been called with success
 
int gpio_setFunction (int bcmPort, int function)
 Sets the function of the specified port. More...
 
int gpio_setOutput (int bcmPort, int value)
 Sets the output at the specified port. The port will output this value if set to the output function. If you use this function with the port not set to output then the port will remember the value until you set it to the output function. More...
 
int gpio_setOutputAll (uint64_t set, uint64_t clear)
 sets all the specified gpios to the specified values More...
 
int gpio_getInput (int bcmPort)
 Gets the detected value of the port in input mode. Obviously you can use this only in input mode, you wold kill your rpi otherwise. More...
 

Detailed Description

Interface to the GPIO peripheral.

If you haven't already, see gpio.h See documentation at "BCM2835 ARM peripherals" page 89

Function Documentation

int gpio_getInput ( int  bcmPort)

Gets the detected value of the port in input mode. Obviously you can use this only in input mode, you wold kill your rpi otherwise.

Parameters
bcmPortThe port.
Returns
The level: 1 or 0.
int gpio_init ( )

Initializes the interface, to be called before any other function in this file.

Returns
negative in case of error
int gpio_setFunction ( int  bcmPort,
int  function 
)

Sets the function of the specified port.

Parameters
bcmPortThe port bcm number
functionThe desired function (PORT_FUNCTION_INPUT, PORT_FUNCTION_OUTPUT, PORT_FUNCTION_ALT_x)
Returns
negative in case of error
int gpio_setOutput ( int  bcmPort,
int  value 
)

Sets the output at the specified port. The port will output this value if set to the output function. If you use this function with the port not set to output then the port will remember the value until you set it to the output function.

Parameters
bcmPortThe port bcm number
value0 means low, any other number means high
Returns
negative in case of error
int gpio_setOutputAll ( uint64_t  set,
uint64_t  clear 
)

sets all the specified gpios to the specified values

Parameters
setThe gpios to set to 1
clearThe values to set to 0
Returns
negative in case of error