pihwm  r1
A lightweight C library for Raspberry Pi hardware modules.
 All Data Structures Files Functions Modules 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
int board_mem()
Return the amount of system memory.
Definition: pihwm.c:209
board_t board_info()
Return board information (Model, PCB revision and Memory)
Definition: pihwm.c:110
Definition: pihwm.h:58
int check_kernel_module(char *modulename)
Check if the kernel module specified is loaded.
Definition: pihwm.c:223
int board_rev()
Return board revision.
Definition: pihwm.c:197
int board_model()
Return board model.
Definition: pihwm.c:185