#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <time.h>
#include <pthread.h>
#include "gpio.h"
#include "cpuinfo.h"
Go to the source code of this file.
Classes | |
struct | tspair |
Macros | |
#define | BCM2708_PERI_BASE 0x20000000 |
#define | BCM2708_GPIO_BASE (BCM2708_PERI_BASE + 0x200000) |
#define | BCM2709_PERI_BASE 0x3F000000 |
#define | BCM2709_GPIO_BASE (BCM2709_PERI_BASE + 0x200000) |
#define | FSEL_OFFSET 0 |
#define | SET_OFFSET 7 |
#define | CLR_OFFSET 10 |
#define | PINLEVEL_OFFSET 13 |
#define | EVENT_DETECT_OFFSET 16 |
#define | RISING_ED_OFFSET 19 |
#define | FALLING_ED_OFFSET 22 |
#define | HIGH_DETECT_OFFSET 25 |
#define | LOW_DETECT_OFFSET 28 |
#define | PULLUPDN_OFFSET 37 |
#define | PULLUPDNCLK_OFFSET 38 |
#define | PAGE_SIZE (4*1024) |
#define | BLOCK_SIZE (4*1024) |
Functions | |
void | short_wait (void) |
int | setup (void) |
void | set_pullupdn (int gpio, int pud) |
void | set_function (int gpio, int function, int pud) |
int | get_function (int gpio) |
int | input (int gpio) |
void | output (int gpio, int value) |
void | outputSequence (int gpio, int period, char *sequence) |
void | resetPWM (int gpio) |
void | pulseTS (int gpio, struct timespec *up, struct timespec *down) |
void | pulseOrSaveTS (int gpio, struct timespec *up, struct timespec *down) |
void | pulseMilli (int gpio, int up, int down) |
void | pulseMilliRatio (int gpio, int width, float ratio) |
void | pulseMicro (int gpio, int up, int down) |
void | pulseMicroRatio (int gpio, int width, float ratio) |
void | pulseAngle (int gpio, float angle) |
void | pulseRatio (int gpio, float ratio) |
struct pulse * | getPulse (int gpio) |
void * | pwmLoop (void *data) |
void | enablePWM (int gpio) |
void | disablePWM (int gpio) |
int | isPWMEnabled (int gpio) |
void | cleanup (void) |
int | number_of_cores (void) |
Variables | |
static volatile uint32_t * | gpio_map |
static struct pulse | gpio_pulses [GPIO_COUNT] |
static struct tspair | gpio_tspairs [GPIO_COUNT] |
static pthread_t * | gpio_threads [GPIO_COUNT] |
#define BCM2708_GPIO_BASE (BCM2708_PERI_BASE + 0x200000) |
#define BCM2709_GPIO_BASE (BCM2709_PERI_BASE + 0x200000) |
#define BLOCK_SIZE (4*1024) |
#define FSEL_OFFSET 0 |
Definition at line 38 of file gpio.c.
Referenced by get_function(), and set_function().
#define PULLUPDN_OFFSET 37 |
Definition at line 47 of file gpio.c.
Referenced by set_pullupdn().
#define PULLUPDNCLK_OFFSET 38 |
Definition at line 48 of file gpio.c.
Referenced by set_pullupdn().
void cleanup | ( | void | ) |
Definition at line 332 of file gpio.c.
References BLOCK_SIZE, and gpio_map.
Referenced by initGPIO().
void disablePWM | ( | int | gpio | ) |
Definition at line 314 of file gpio.c.
References webiopi-client::gpio, gpio_threads, output(), and resetPWM().
Referenced by py_disablePWM(), and set_function().
void enablePWM | ( | int | gpio | ) |
Definition at line 300 of file gpio.c.
References webiopi-client::gpio, gpio_threads, pwmLoop(), and resetPWM().
Referenced by py_enablePWM(), and set_function().
int get_function | ( | int | gpio | ) |
Definition at line 139 of file gpio.c.
References FSEL_OFFSET, gpio_map, isPWMEnabled(), OUT, PWM, and webiopi-client::value.
Referenced by py_get_function(), py_get_function_string(), py_output(), py_output_sequence(), py_pulseAngle(), py_pulseMicro(), py_pulseMicroRatio(), py_pulseMilli(), py_pulseMilliRatio(), and py_pulseRatio().
struct pulse* getPulse | ( | int | gpio | ) |
Definition at line 286 of file gpio.c.
References webiopi-client::gpio, and gpio_pulses.
Referenced by py_getPulse().
int input | ( | int | gpio | ) |
Definition at line 153 of file gpio.c.
References gpio_map, PINLEVEL_OFFSET, and webiopi-client::value.
Referenced by py_input().
int isPWMEnabled | ( | int | gpio | ) |
Definition at line 327 of file gpio.c.
References webiopi-client::gpio, and gpio_threads.
Referenced by get_function(), and py_isPWMEnabled().
void output | ( | int | gpio, |
int | value | ||
) |
Definition at line 163 of file gpio.c.
References CLR_OFFSET, gpio_map, and SET_OFFSET.
Referenced by disablePWM(), outputSequence(), pulseTS(), and py_output().
void outputSequence | ( | int | gpio, |
int | period, | ||
char * | sequence | ||
) |
Definition at line 178 of file gpio.c.
References output(), and webiopi-client::value.
Referenced by py_output_sequence().
void pulseAngle | ( | int | gpio, |
float | angle | ||
) |
Definition at line 269 of file gpio.c.
References ANGLE, webiopi-client::gpio, gpio_pulses, pulseMicro(), pulse::type, and pulse::value.
Referenced by py_pulseAngle().
void pulseMicro | ( | int | gpio, |
int | up, | ||
int | down | ||
) |
Definition at line 250 of file gpio.c.
References pulseOrSaveTS().
Referenced by pulseAngle(), pulseMicroRatio(), pulseRatio(), and py_pulseMicro().
void pulseMicroRatio | ( | int | gpio, |
int | width, | ||
float | ratio | ||
) |
void pulseMilli | ( | int | gpio, |
int | up, | ||
int | down | ||
) |
Definition at line 231 of file gpio.c.
References pulseOrSaveTS().
Referenced by pulseMilliRatio(), and py_pulseMilli().
void pulseMilliRatio | ( | int | gpio, |
int | width, | ||
float | ratio | ||
) |
void pulseOrSaveTS | ( | int | gpio, |
struct timespec * | up, | ||
struct timespec * | down | ||
) |
Definition at line 220 of file gpio.c.
References gpio_threads, gpio_tspairs, and pulseTS().
Referenced by pulseMicro(), and pulseMilli().
void pulseRatio | ( | int | gpio, |
float | ratio | ||
) |
Definition at line 278 of file gpio.c.
References webiopi-client::gpio, gpio_pulses, pulseMicro(), RATIO, pulse::type, and pulse::value.
Referenced by py_pulse(), and py_pulseRatio().
void pulseTS | ( | int | gpio, |
struct timespec * | up, | ||
struct timespec * | down | ||
) |
Definition at line 207 of file gpio.c.
References output().
Referenced by pulseOrSaveTS(), and pwmLoop().
void* pwmLoop | ( | void * | data | ) |
Definition at line 291 of file gpio.c.
References webiopi-client::gpio, gpio_tspairs, and pulseTS().
Referenced by enablePWM().
void resetPWM | ( | int | gpio | ) |
Definition at line 196 of file gpio.c.
References tspair::down, webiopi-client::gpio, gpio_pulses, gpio_tspairs, pulse::type, tspair::up, and pulse::value.
Referenced by disablePWM(), and enablePWM().
void set_function | ( | int | gpio, |
int | function, | ||
int | pud | ||
) |
Definition at line 121 of file gpio.c.
References disablePWM(), enablePWM(), FSEL_OFFSET, gpio_map, OUT, PWM, and set_pullupdn().
Referenced by py_set_function().
void set_pullupdn | ( | int | gpio, |
int | pud | ||
) |
Definition at line 101 of file gpio.c.
References gpio_map, PUD_DOWN, PUD_UP, PULLUPDN_OFFSET, PULLUPDNCLK_OFFSET, and short_wait().
Referenced by set_function().
int setup | ( | void | ) |
Definition at line 74 of file gpio.c.
References BCM2708_GPIO_BASE, BCM2709_GPIO_BASE, BLOCK_SIZE, get_rpi_revision(), gpio_map, number_of_cores(), PAGE_SIZE, cambot::set_speed(), cambot::setup(), SETUP_DEVMEM_FAIL, SETUP_MALLOC_FAIL, SETUP_MMAP_FAIL, SETUP_OK, and cambot::stop().
void short_wait | ( | void | ) |
Definition at line 64 of file gpio.c.
Referenced by set_pullupdn().
|
static |
Definition at line 53 of file gpio.c.
Referenced by cleanup(), get_function(), input(), output(), set_function(), set_pullupdn(), and setup().
|
static |
Definition at line 60 of file gpio.c.
Referenced by getPulse(), pulseAngle(), pulseRatio(), and resetPWM().
|
static |
Definition at line 62 of file gpio.c.
Referenced by disablePWM(), enablePWM(), isPWMEnabled(), and pulseOrSaveTS().
|
static |
Definition at line 61 of file gpio.c.
Referenced by pulseOrSaveTS(), pwmLoop(), and resetPWM().