SysIo  1.9.0
Embedded Library and tools
rpi.h
1 
8 #ifndef _SYSIO_RPI_H_
9 #define _SYSIO_RPI_H_
10 #include <sysio/defs.h>
11 #ifdef __cplusplus
12  extern "C" {
13 #endif
14 /* ========================================================================== */
15 
91 typedef enum {
92  eRpiModelA,
93  eRpiModelB,
94  eRpiModelAPlus,
95  eRpiModelBPlus,
96  eRpiModelComputeModule,
97  eRpiModel2B,
98  eRpiModelZero,
99  eRpiModel3B,
100  eRpiModelZeroW,
101  eRpiModelComputeModule3,
102  eRpiModelUnknown = -1
103 } eRpiModel;
104 
108 typedef enum {
109  eRpiMcuBcm2708,
110  eRpiMcuBcm2709,
111  eRpiMcuBcm2710,
112  eRpiMcuUnknown = -1
113 } eRpiMcu;
114 
118 typedef struct xRpi {
119  int iRev;
121  int iGpioRev;
123  int iMemMB;
124  int iPcbMajor;
125  int iPcbMinor;
126  const char * sManufacturer;
127 } xRpi;
128 
129 /* internal public functions ================================================ */
130 
136 int iRpiRev (void);
137 
181 const xRpi * pxRpiInfo (void);
182 /*
183  */
190 const char * sRpiModelToStr (eRpiModel eModel);
191 
198 const char * sRpiMcuToStr (eRpiMcu eMcu);
199 
200 
201 /* constants ================================================================ */
202 #define GPIO_GEN0 0
203 #define GPIO_GEN1 1
204 #define GPIO_GEN2 2
205 #define GPIO_GEN3 3
206 #define GPIO_GEN4 4
207 #define GPIO_GEN5 5
208 #define GPIO_GEN6 6
209 #define GPIO_GCLK 7
210 
211 #define I2C_SDA 8
212 #define I2C_SCL 9
213 #define I2C_SDA1 8
214 #define I2C_SCL1 9
215 #define I2C_SDA0 30
216 #define I2C_SCL0 31
217 
218 #define SPI_CE0_N 10
219 #define SPI_CE1_N 11
220 #define SPI_MOSI 12
221 #define SPI_MISO 13
222 #define SPI_SCLK 14
223 
224 #define UART_TXD 15
225 #define UART_RXD 16
226 #define UART_TXD0 15
227 #define UART_RXD0 16
228 
229 // Models A & B PCB V 2.0 only
230 #define GPIO_GEN7 17
231 #define GPIO_GEN8 18
232 #define GPIO_GEN9 19
233 #define GPIO_GEN10 20
234 
235 // Models A+, B+, 2B, 3B, Zero only
236 #define GPIO_GEN11 21
237 #define LAN_RUN 22
238 #define GPIO_GEN12 23
239 #define GPIO_GEN13 24
240 #define GPIO_GEN14 25
241 #define GPIO_GEN15 26
242 #define STATUS_LED 27
243 #define GPIO_GEN17 28
244 #define GPIO_GEN18 29
245 
246 #define GPIO17 0
247 #define GPIO18 1
248 #define GPIO27 2 // Models A & B PCB V2.0, A+, B+, 2B, 3B, Zero
249 #define GPIO22 3
250 #define GPIO23 4
251 #define GPIO24 5
252 #define GPIO25 6
253 #define GPIO4 7
254 
255 #define GPIO2 8 // Models A & B PCB V2.0, A+, B+, 2B, 3B, Zero
256 #define GPIO3 9 // Models A & B PCB V2.0, A+, B+, 2B, 3B, Zero
257 #define GPIO0 30
258 #define GPIO1 31
259 
260 #define GPIO8 10
261 #define GPIO7 11
262 #define GPIO10 12
263 #define GPIO9 13
264 #define GPIO11 14
265 
266 #define GPIO14 15
267 #define GPIO15 16
268 
269 // Models A & B PCB V 2.0 only
270 #define GPIO28 17
271 #define GPIO29 18
272 #define GPIO30 19
273 #define GPIO31 20
274 
275 // Models A+, B+, 2B, 3B, Zero only
276 #define GPIO5 21
277 #define GPIO6 22
278 #define GPIO13 23
279 #define GPIO19 24
280 #define GPIO26 25
281 #define GPIO12 26
282 #define GPIO16 27
283 #define GPIO20 28
284 #define GPIO21 29
285 
290 #if defined(__DOXYGEN__)
291 
294 static inline unsigned long ulRpiIoBase(void);
295 
300 #else /* ! defined(__DOXYGEN__) */
301 // -----------------------------------------------------------------------------
302 /*
303  GPIO_PADS = RASPBERRY_PI_PERI_BASE + 0x00100000 ;
304  GPIO_TIMER = RASPBERRY_PI_PERI_BASE + 0x0000B000 ;
305  */
306 /* bcm2708 internals ======================================================== */
307 #define BCM2708_IO_BASE (0x20000000)
308 #define BCM2709_IO_BASE (0x3F000000)
309 #define BCM270X_PAGE_SIZE (4*1024)
310 #define BCM270X_BLOCK_SIZE (4*1024)
311 
312 // -----------------------------------------------------------------------------
313 INLINE unsigned long
314 ulRpiIoBase(void) {
315 
316  return (pxRpiInfo()->eMcu == eRpiMcuBcm2708) ? BCM2708_IO_BASE : BCM2709_IO_BASE;
317 }
318 #endif /* !defined(__DOXYGEN__) */
319 
320 /* ========================================================================== */
321 #ifdef __cplusplus
322  }
323 #endif
324 #endif /*_SYSIO_RPI_H_ defined */
const char * sRpiMcuToStr(eRpiMcu eMcu)
Chaîne de caractères correspondant à un mcu.
int iPcbMinor
Definition: rpi.h:125
eRpiMcu
Type de MCU SoC.
Definition: rpi.h:108
int iGpioRev
Definition: rpi.h:121
eRpiMcu eMcu
Definition: rpi.h:122
int iRev
Definition: rpi.h:119
const char * sManufacturer
Definition: rpi.h:126
const char * sRpiModelToStr(eRpiModel eModel)
Chaîne de caractères correspondant à un modèle.
struct xRpi xRpi
Information sur le Raspberry Pi.
int iRpiRev(void)
Retourne la revision du raspberry.
const xRpi * pxRpiInfo(void)
Lecture des informations sur le Raspberry Pi.
eRpiModel eModel
Definition: rpi.h:120
Information sur le Raspberry Pi.
Definition: rpi.h:118
int iMemMB
Definition: rpi.h:123
eRpiModel
Modèle de Raspberry Pi.
Definition: rpi.h:91
int iPcbMajor
Definition: rpi.h:124