1 // bcm2835.h
325 #define HIGH 0x1
327 #define LOW 0x0
330 #define BCM2835_CORE_CLK_HZ 250000000
334 #define BCM2835_PERI_BASE 0x20000000
336 #define BCM2835_ST_BASE (BCM2835_PERI_BASE + 0x3000)
338 #define BCM2835_GPIO_PADS (BCM2835_PERI_BASE + 0x100000)
340 #define BCM2835_CLOCK_BASE (BCM2835_PERI_BASE + 0x101000)
342 #define BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000)
344 #define BCM2835_SPI0_BASE (BCM2835_PERI_BASE + 0x204000)
346 #define BCM2835_BSC0_BASE (BCM2835_PERI_BASE + 0x205000)
348 #define BCM2835_GPIO_PWM (BCM2835_PERI_BASE + 0x20C000)
350 #define BCM2835_BSC1_BASE (BCM2835_PERI_BASE + 0x804000)
355 extern volatile uint32_t *bcm2835_st;
359 extern volatile uint32_t *bcm2835_gpio;
363 extern volatile uint32_t *bcm2835_pwm;
367 extern volatile uint32_t *bcm2835_clk;
371 extern volatile uint32_t *bcm2835_pads;
375 extern volatile uint32_t *bcm2835_spi0;
379 extern volatile uint32_t *bcm2835_bsc0;
383 extern volatile uint32_t *bcm2835_bsc1;
386 #define BCM2835_PAGE_SIZE (4*1024)
388 #define BCM2835_BLOCK_SIZE (4*1024)
395 #define BCM2835_GPFSEL0 0x0000
396 #define BCM2835_GPFSEL1 0x0004
397 #define BCM2835_GPFSEL2 0x0008
398 #define BCM2835_GPFSEL3 0x000c
399 #define BCM2835_GPFSEL4 0x0010
400 #define BCM2835_GPFSEL5 0x0014
401 #define BCM2835_GPSET0 0x001c
402 #define BCM2835_GPSET1 0x0020
403 #define BCM2835_GPCLR0 0x0028
404 #define BCM2835_GPCLR1 0x002c
405 #define BCM2835_GPLEV0 0x0034
406 #define BCM2835_GPLEV1 0x0038
407 #define BCM2835_GPEDS0 0x0040
408 #define BCM2835_GPEDS1 0x0044
409 #define BCM2835_GPREN0 0x004c
410 #define BCM2835_GPREN1 0x0050
411 #define BCM2835_GPFEN0 0x0058
412 #define BCM2835_GPFEN1 0x005c
413 #define BCM2835_GPHEN0 0x0064
414 #define BCM2835_GPHEN1 0x0068
415 #define BCM2835_GPLEN0 0x0070
416 #define BCM2835_GPLEN1 0x0074
417 #define BCM2835_GPAREN0 0x007c
418 #define BCM2835_GPAREN1 0x0080
419 #define BCM2835_GPAFEN0 0x0088
420 #define BCM2835_GPAFEN1 0x008c
421 #define BCM2835_GPPUD 0x0094
422 #define BCM2835_GPPUDCLK0 0x0098
423 #define BCM2835_GPPUDCLK1 0x009c
427 typedef enum
429 BCM2835_GPIO_FSEL_INPT = 0b000,
430 BCM2835_GPIO_FSEL_OUTP = 0b001,
431 BCM2835_GPIO_FSEL_ALT0 = 0b100,
432 BCM2835_GPIO_FSEL_ALT1 = 0b101,
433 BCM2835_GPIO_FSEL_ALT2 = 0b110,
434 BCM2835_GPIO_FSEL_ALT3 = 0b111,
435 BCM2835_GPIO_FSEL_ALT4 = 0b011,
436 BCM2835_GPIO_FSEL_ALT5 = 0b010,
437 BCM2835_GPIO_FSEL_MASK = 0b111
438 } bcm2835FunctionSelect;
442 typedef enum
444 BCM2835_GPIO_PUD_OFF = 0b00,
445 BCM2835_GPIO_PUD_DOWN = 0b01,