pihwm
A lightweight C library for Raspberry Pi hardware modules.
 All Data Structures Files Functions Groups Pages
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 
34 // Board information
35 #define MODEL_A 100
36 #define MODEL_B 200
37 #define REV_1 10
38 #define REV_2 20
39 #define MEM_256 1
40 #define MEM_512 2
41 
42 // Useful macros
43 #ifdef DEBUG
44  #define debug(...) printf(__VA_ARGS__)
45 #else
46  #define debug(...) ;
47 #endif
48 
49 #define delay(d) usleep(d*1000); //millisec
50 #define delayMicroseconds(d) usleep(d);
51 #define delaySeconds(d) sleep(d);
52 
53 // http://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html
54 #define a(...) (unsigned char[])__VA_ARGS__
55 
56 #define size(a) (sizeof(a) / sizeof((a)[0]))
57 
58 typedef struct
59 {
60  int model;
61  int rev;
62  int mem;
63 } board_t;
64 
65 // Function prototypes
67 int board_model ();
68 int board_rev ();
69 int board_mem ();
70 int check_kernel_module (char* modulename);
71 
72 #endif