pihwm  r1
A lightweight C library for Raspberry Pi hardware modules.
pihwm.h
Go to the documentation of this file.
1 
28 #ifndef PIHWM_H
29 #define PIHWM_H
30 
31 #include <stdio.h>
32 #include <unistd.h>
33 #include "pi_gpio.h"
34 #include "pi_pwm.h"
35 #include "pi_spi.h"
36 #include "pi_i2c.h"
37 
38 // Board information
39 #define MODEL_A 100
40 #define MODEL_B 200
41 #define REV_1 10
42 #define REV_2 20
43 #define MEM_256 1
44 #define MEM_512 2
45 
46 // Useful macros
47 #ifdef DEBUG
48  #define debug(...) printf(__VA_ARGS__)
49 #else
50  #define debug(...) ;
51 #endif
52 
53 #define delay(d) usleep(d*1000); //millisec
54 #define delayMicroseconds(d) usleep(d);
55 #define delaySeconds(d) sleep(d);
56 
57 // http://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html
58 #define a(...) (unsigned char[])__VA_ARGS__
59 
60 #define size(a) (sizeof(a) / sizeof((a)[0]))
61 
62 typedef struct
63 {
64  int model;
65  int rev;
66  int mem;
67 } board_t;
68 
69 // Function prototypes
71 int board_model ();
72 int board_rev ();
73 int board_mem ();
74 int check_kernel_module (char* modulename);
75 
76 #endif
int board_mem()
Return the amount of system memory.
Definition: pihwm.c:210
board_t board_info()
Return board information (Model, PCB revision and Memory)
Definition: pihwm.c:111
I2C library headers.
Definition: pihwm.h:62
SPI library headers.
gpio library headers
Pulse width modulation library headers.
int check_kernel_module(char *modulename)
Check if the kernel module specified is loaded.
Definition: pihwm.c:224
int board_rev()
Return board revision.
Definition: pihwm.c:198
int board_model()
Return board model.
Definition: pihwm.c:186