bcm2835  1.53
bcm2835.h
1 /* bcm2835.h
2 
3  C and C++ support for Broadcom BCM 2835 as used in Raspberry Pi
4 
5  Author: Mike McCauley
6  Copyright (C) 2011-2013 Mike McCauley
7  $Id: bcm2835.h,v 1.22 2018/01/16 04:46:01 mikem Exp mikem $
8 */
9 
510 /* Defines for BCM2835 */
511 #ifndef BCM2835_H
512 #define BCM2835_H
513 
514 #include <stdint.h>
515 
516 #define BCM2835_VERSION 10052 /* Version 1.52 */
517 
518 /* RPi 2 is ARM v7, and has DMB instruction for memory barriers.
519  Older RPis are ARM v6 and don't, so a coprocessor instruction must be used instead.
520  However, not all versions of gcc in all distros support the dmb assembler instruction even on conmpatible processors.
521  This test is so any ARMv7 or higher processors with suitable GCC will use DMB.
522 */
523 #if __ARM_ARCH >= 7
524 #define BCM2835_HAVE_DMB
525 #endif
526 
533 #define HIGH 0x1
534 
535 #define LOW 0x0
536 
538 #ifndef MIN
539 #define MIN(a, b) (a < b ? a : b)
540 #endif
541 
543 #define BCM2835_CORE_CLK_HZ 250000000
546 #define BMC2835_RPI2_DT_FILENAME "/proc/device-tree/soc/ranges"
547 
548 #define BMC2835_RPI2_DT_PERI_BASE_ADDRESS_OFFSET 4
549 
550 #define BMC2835_RPI2_DT_PERI_SIZE_OFFSET 8
551 
559 #define BCM2835_PERI_BASE 0x20000000
560 
561 #define BCM2835_PERI_SIZE 0x01000000
562 
566 #define BCM2835_ST_BASE 0x3000
567 
568 #define BCM2835_GPIO_PADS 0x100000
569 
570 #define BCM2835_CLOCK_BASE 0x101000
571 
572 #define BCM2835_GPIO_BASE 0x200000
573 
574 #define BCM2835_SPI0_BASE 0x204000
575 
576 #define BCM2835_BSC0_BASE 0x205000
577 
578 #define BCM2835_GPIO_PWM 0x20C000
579 
580 #define BCM2835_AUX_BASE 0x215000
581 
582 #define BCM2835_SPI1_BASE 0x215080
583 
584 #define BCM2835_SPI2_BASE 0x2150C0
585 
586 #define BCM2835_BSC1_BASE 0x804000
587 
588 
592 extern uint32_t *bcm2835_peripherals_base;
594 extern uint32_t bcm2835_peripherals_size;
595 
597 extern uint32_t *bcm2835_peripherals;
598 
602 extern volatile uint32_t *bcm2835_st;
603 
607 extern volatile uint32_t *bcm2835_gpio;
608 
612 extern volatile uint32_t *bcm2835_pwm;
613 
617 extern volatile uint32_t *bcm2835_clk;
618 
622 extern volatile uint32_t *bcm2835_pads;
623 
627 extern volatile uint32_t *bcm2835_spi0;
628 
632 extern volatile uint32_t *bcm2835_bsc0;
633 
637 extern volatile uint32_t *bcm2835_bsc1;
638 
642 extern volatile uint32_t *bcm2835_aux;
643 
647 extern volatile uint32_t *bcm2835_spi1;
648 
649 
653 typedef enum
654 {
666 
668 #define BCM2835_PAGE_SIZE (4*1024)
669 
670 #define BCM2835_BLOCK_SIZE (4*1024)
671 
672 
673 /* Defines for GPIO
674  The BCM2835 has 54 GPIO pins.
675  BCM2835 data sheet, Page 90 onwards.
676 */
680 #define BCM2835_GPFSEL0 0x0000
681 #define BCM2835_GPFSEL1 0x0004
682 #define BCM2835_GPFSEL2 0x0008
683 #define BCM2835_GPFSEL3 0x000c
684 #define BCM2835_GPFSEL4 0x0010
685 #define BCM2835_GPFSEL5 0x0014
686 #define BCM2835_GPSET0 0x001c
687 #define BCM2835_GPSET1 0x0020
688 #define BCM2835_GPCLR0 0x0028
689 #define BCM2835_GPCLR1 0x002c
690 #define BCM2835_GPLEV0 0x0034
691 #define BCM2835_GPLEV1 0x0038
692 #define BCM2835_GPEDS0 0x0040
693 #define BCM2835_GPEDS1 0x0044
694 #define BCM2835_GPREN0 0x004c
695 #define BCM2835_GPREN1 0x0050
696 #define BCM2835_GPFEN0 0x0058
697 #define BCM2835_GPFEN1 0x005c
698 #define BCM2835_GPHEN0 0x0064
699 #define BCM2835_GPHEN1 0x0068
700 #define BCM2835_GPLEN0 0x0070
701 #define BCM2835_GPLEN1 0x0074
702 #define BCM2835_GPAREN0 0x007c
703 #define BCM2835_GPAREN1 0x0080
704 #define BCM2835_GPAFEN0 0x0088
705 #define BCM2835_GPAFEN1 0x008c
706 #define BCM2835_GPPUD 0x0094
707 #define BCM2835_GPPUDCLK0 0x0098
708 #define BCM2835_GPPUDCLK1 0x009c
713 typedef enum
714 {
725 
729 typedef enum
730 {
735 
737 #define BCM2835_PADS_GPIO_0_27 0x002c
738 #define BCM2835_PADS_GPIO_28_45 0x0030
739 #define BCM2835_PADS_GPIO_46_53 0x0034
742 #define BCM2835_PAD_PASSWRD (0x5A << 24)
743 #define BCM2835_PAD_SLEW_RATE_UNLIMITED 0x10
744 #define BCM2835_PAD_HYSTERESIS_ENABLED 0x08
745 #define BCM2835_PAD_DRIVE_2mA 0x00
746 #define BCM2835_PAD_DRIVE_4mA 0x01
747 #define BCM2835_PAD_DRIVE_6mA 0x02
748 #define BCM2835_PAD_DRIVE_8mA 0x03
749 #define BCM2835_PAD_DRIVE_10mA 0x04
750 #define BCM2835_PAD_DRIVE_12mA 0x05
751 #define BCM2835_PAD_DRIVE_14mA 0x06
752 #define BCM2835_PAD_DRIVE_16mA 0x07
757 typedef enum
758 {
763 
778 typedef enum
779 {
798  /* RPi Version 2 */
826  /* RPi Version 2, new plug P5 */
832  /* RPi B+ J8 header, also RPi 2 40 pin GPIO header */
859 } RPiGPIOPin;
860 
861 /* Defines for AUX
862  GPIO register offsets from BCM2835_AUX_BASE.
863 */
864 #define BCM2835_AUX_IRQ 0x0000
865 #define BCM2835_AUX_ENABLE 0x0004
867 #define BCM2835_AUX_ENABLE_UART1 0x01
868 #define BCM2835_AUX_ENABLE_SPI0 0x02
869 #define BCM2835_AUX_ENABLE_SPI1 0x04
872 #define BCM2835_AUX_SPI_CNTL0 0x0000
873 #define BCM2835_AUX_SPI_CNTL1 0x0004
874 #define BCM2835_AUX_SPI_STAT 0x0008
875 #define BCM2835_AUX_SPI_PEEK 0x000C
876 #define BCM2835_AUX_SPI_IO 0x0020
877 #define BCM2835_AUX_SPI_TXHOLD 0x0030
879 #define BCM2835_AUX_SPI_CLOCK_MIN 30500
880 #define BCM2835_AUX_SPI_CLOCK_MAX 125000000
882 #define BCM2835_AUX_SPI_CNTL0_SPEED 0xFFF00000
883 #define BCM2835_AUX_SPI_CNTL0_SPEED_MAX 0xFFF
884 #define BCM2835_AUX_SPI_CNTL0_SPEED_SHIFT 20
886 #define BCM2835_AUX_SPI_CNTL0_CS0_N 0x000C0000
887 #define BCM2835_AUX_SPI_CNTL0_CS1_N 0x000A0000
888 #define BCM2835_AUX_SPI_CNTL0_CS2_N 0x00060000
890 #define BCM2835_AUX_SPI_CNTL0_POSTINPUT 0x00010000
891 #define BCM2835_AUX_SPI_CNTL0_VAR_CS 0x00008000
892 #define BCM2835_AUX_SPI_CNTL0_VAR_WIDTH 0x00004000
893 #define BCM2835_AUX_SPI_CNTL0_DOUTHOLD 0x00003000
894 #define BCM2835_AUX_SPI_CNTL0_ENABLE 0x00000800
895 #define BCM2835_AUX_SPI_CNTL0_CPHA_IN 0x00000400
896 #define BCM2835_AUX_SPI_CNTL0_CLEARFIFO 0x00000200
897 #define BCM2835_AUX_SPI_CNTL0_CPHA_OUT 0x00000100
898 #define BCM2835_AUX_SPI_CNTL0_CPOL 0x00000080
899 #define BCM2835_AUX_SPI_CNTL0_MSBF_OUT 0x00000040
900 #define BCM2835_AUX_SPI_CNTL0_SHIFTLEN 0x0000003F
902 #define BCM2835_AUX_SPI_CNTL1_CSHIGH 0x00000700
903 #define BCM2835_AUX_SPI_CNTL1_IDLE 0x00000080
904 #define BCM2835_AUX_SPI_CNTL1_TXEMPTY 0x00000040
905 #define BCM2835_AUX_SPI_CNTL1_MSBF_IN 0x00000002
906 #define BCM2835_AUX_SPI_CNTL1_KEEP_IN 0x00000001
908 #define BCM2835_AUX_SPI_STAT_TX_LVL 0xFF000000
909 #define BCM2835_AUX_SPI_STAT_RX_LVL 0x00FF0000
910 #define BCM2835_AUX_SPI_STAT_TX_FULL 0x00000400
911 #define BCM2835_AUX_SPI_STAT_TX_EMPTY 0x00000200
912 #define BCM2835_AUX_SPI_STAT_RX_FULL 0x00000100
913 #define BCM2835_AUX_SPI_STAT_RX_EMPTY 0x00000080
914 #define BCM2835_AUX_SPI_STAT_BUSY 0x00000040
915 #define BCM2835_AUX_SPI_STAT_BITCOUNT 0x0000003F
917 /* Defines for SPI
918  GPIO register offsets from BCM2835_SPI0_BASE.
919  Offsets into the SPI Peripheral block in bytes per 10.5 SPI Register Map
920 */
921 #define BCM2835_SPI0_CS 0x0000
922 #define BCM2835_SPI0_FIFO 0x0004
923 #define BCM2835_SPI0_CLK 0x0008
924 #define BCM2835_SPI0_DLEN 0x000c
925 #define BCM2835_SPI0_LTOH 0x0010
926 #define BCM2835_SPI0_DC 0x0014
928 /* Register masks for SPI0_CS */
929 #define BCM2835_SPI0_CS_LEN_LONG 0x02000000
930 #define BCM2835_SPI0_CS_DMA_LEN 0x01000000
931 #define BCM2835_SPI0_CS_CSPOL2 0x00800000
932 #define BCM2835_SPI0_CS_CSPOL1 0x00400000
933 #define BCM2835_SPI0_CS_CSPOL0 0x00200000
934 #define BCM2835_SPI0_CS_RXF 0x00100000
935 #define BCM2835_SPI0_CS_RXR 0x00080000
936 #define BCM2835_SPI0_CS_TXD 0x00040000
937 #define BCM2835_SPI0_CS_RXD 0x00020000
938 #define BCM2835_SPI0_CS_DONE 0x00010000
939 #define BCM2835_SPI0_CS_TE_EN 0x00008000
940 #define BCM2835_SPI0_CS_LMONO 0x00004000
941 #define BCM2835_SPI0_CS_LEN 0x00002000
942 #define BCM2835_SPI0_CS_REN 0x00001000
943 #define BCM2835_SPI0_CS_ADCS 0x00000800
944 #define BCM2835_SPI0_CS_INTR 0x00000400
945 #define BCM2835_SPI0_CS_INTD 0x00000200
946 #define BCM2835_SPI0_CS_DMAEN 0x00000100
947 #define BCM2835_SPI0_CS_TA 0x00000080
948 #define BCM2835_SPI0_CS_CSPOL 0x00000040
949 #define BCM2835_SPI0_CS_CLEAR 0x00000030
950 #define BCM2835_SPI0_CS_CLEAR_RX 0x00000020
951 #define BCM2835_SPI0_CS_CLEAR_TX 0x00000010
952 #define BCM2835_SPI0_CS_CPOL 0x00000008
953 #define BCM2835_SPI0_CS_CPHA 0x00000004
954 #define BCM2835_SPI0_CS_CS 0x00000003
959 typedef enum
960 {
964 
968 typedef enum
969 {
975 
979 typedef enum
980 {
986 
1001 typedef enum
1002 {
1021 
1022 /* Defines for I2C
1023  GPIO register offsets from BCM2835_BSC*_BASE.
1024  Offsets into the BSC Peripheral block in bytes per 3.1 BSC Register Map
1025 */
1026 #define BCM2835_BSC_C 0x0000
1027 #define BCM2835_BSC_S 0x0004
1028 #define BCM2835_BSC_DLEN 0x0008
1029 #define BCM2835_BSC_A 0x000c
1030 #define BCM2835_BSC_FIFO 0x0010
1031 #define BCM2835_BSC_DIV 0x0014
1032 #define BCM2835_BSC_DEL 0x0018
1033 #define BCM2835_BSC_CLKT 0x001c
1035 /* Register masks for BSC_C */
1036 #define BCM2835_BSC_C_I2CEN 0x00008000
1037 #define BCM2835_BSC_C_INTR 0x00000400
1038 #define BCM2835_BSC_C_INTT 0x00000200
1039 #define BCM2835_BSC_C_INTD 0x00000100
1040 #define BCM2835_BSC_C_ST 0x00000080
1041 #define BCM2835_BSC_C_CLEAR_1 0x00000020
1042 #define BCM2835_BSC_C_CLEAR_2 0x00000010
1043 #define BCM2835_BSC_C_READ 0x00000001
1045 /* Register masks for BSC_S */
1046 #define BCM2835_BSC_S_CLKT 0x00000200
1047 #define BCM2835_BSC_S_ERR 0x00000100
1048 #define BCM2835_BSC_S_RXF 0x00000080
1049 #define BCM2835_BSC_S_TXE 0x00000040
1050 #define BCM2835_BSC_S_RXD 0x00000020
1051 #define BCM2835_BSC_S_TXD 0x00000010
1052 #define BCM2835_BSC_S_RXR 0x00000008
1053 #define BCM2835_BSC_S_TXW 0x00000004
1054 #define BCM2835_BSC_S_DONE 0x00000002
1055 #define BCM2835_BSC_S_TA 0x00000001
1057 #define BCM2835_BSC_FIFO_SIZE 16
1063 typedef enum
1064 {
1070 
1074 typedef enum
1075 {
1081 
1082 /* Defines for ST
1083  GPIO register offsets from BCM2835_ST_BASE.
1084  Offsets into the ST Peripheral block in bytes per 12.1 System Timer Registers
1085  The System Timer peripheral provides four 32-bit timer channels and a single 64-bit free running counter.
1086  BCM2835_ST_CLO is the System Timer Counter Lower bits register.
1087  The system timer free-running counter lower register is a read-only register that returns the current value
1088  of the lower 32-bits of the free running counter.
1089  BCM2835_ST_CHI is the System Timer Counter Upper bits register.
1090  The system timer free-running counter upper register is a read-only register that returns the current value
1091  of the upper 32-bits of the free running counter.
1092 */
1093 #define BCM2835_ST_CS 0x0000
1094 #define BCM2835_ST_CLO 0x0004
1095 #define BCM2835_ST_CHI 0x0008
1100 /* Defines for PWM, word offsets (ie 4 byte multiples) */
1101 #define BCM2835_PWM_CONTROL 0
1102 #define BCM2835_PWM_STATUS 1
1103 #define BCM2835_PWM_DMAC 2
1104 #define BCM2835_PWM0_RANGE 4
1105 #define BCM2835_PWM0_DATA 5
1106 #define BCM2835_PWM_FIF1 6
1107 #define BCM2835_PWM1_RANGE 8
1108 #define BCM2835_PWM1_DATA 9
1109 
1110 /* Defines for PWM Clock, word offsets (ie 4 byte multiples) */
1111 #define BCM2835_PWMCLK_CNTL 40
1112 #define BCM2835_PWMCLK_DIV 41
1113 #define BCM2835_PWM_PASSWRD (0x5A << 24)
1115 #define BCM2835_PWM1_MS_MODE 0x8000
1116 #define BCM2835_PWM1_USEFIFO 0x2000
1117 #define BCM2835_PWM1_REVPOLAR 0x1000
1118 #define BCM2835_PWM1_OFFSTATE 0x0800
1119 #define BCM2835_PWM1_REPEATFF 0x0400
1120 #define BCM2835_PWM1_SERIAL 0x0200
1121 #define BCM2835_PWM1_ENABLE 0x0100
1123 #define BCM2835_PWM0_MS_MODE 0x0080
1124 #define BCM2835_PWM_CLEAR_FIFO 0x0040
1125 #define BCM2835_PWM0_USEFIFO 0x0020
1126 #define BCM2835_PWM0_REVPOLAR 0x0010
1127 #define BCM2835_PWM0_OFFSTATE 0x0008
1128 #define BCM2835_PWM0_REPEATFF 0x0004
1129 #define BCM2835_PWM0_SERIAL 0x0002
1130 #define BCM2835_PWM0_ENABLE 0x0001
1138 typedef enum
1139 {
1140  BCM2835_PWM_CLOCK_DIVIDER_2048 = 2048,
1141  BCM2835_PWM_CLOCK_DIVIDER_1024 = 1024,
1142  BCM2835_PWM_CLOCK_DIVIDER_512 = 512,
1143  BCM2835_PWM_CLOCK_DIVIDER_256 = 256,
1144  BCM2835_PWM_CLOCK_DIVIDER_128 = 128,
1145  BCM2835_PWM_CLOCK_DIVIDER_64 = 64,
1146  BCM2835_PWM_CLOCK_DIVIDER_32 = 32,
1147  BCM2835_PWM_CLOCK_DIVIDER_16 = 16,
1148  BCM2835_PWM_CLOCK_DIVIDER_8 = 8,
1149  BCM2835_PWM_CLOCK_DIVIDER_4 = 4,
1150  BCM2835_PWM_CLOCK_DIVIDER_2 = 2,
1151  BCM2835_PWM_CLOCK_DIVIDER_1 = 1
1152 } bcm2835PWMClockDivider;
1153 
1154 /* Historical name compatibility */
1155 #ifndef BCM2835_NO_DELAY_COMPATIBILITY
1156 #define delay(x) bcm2835_delay(x)
1157 #define delayMicroseconds(x) bcm2835_delayMicroseconds(x)
1158 #endif
1159 
1160 #ifdef __cplusplus
1161 extern "C" {
1162 #endif
1163 
1182  extern int bcm2835_init(void);
1183 
1187  extern int bcm2835_close(void);
1188 
1196  extern void bcm2835_set_debug(uint8_t debug);
1197 
1201  extern unsigned int bcm2835_version(void);
1202 
1218  extern uint32_t* bcm2835_regbase(uint8_t regbase);
1219 
1228  extern uint32_t bcm2835_peri_read(volatile uint32_t* paddr);
1229 
1240  extern uint32_t bcm2835_peri_read_nb(volatile uint32_t* paddr);
1241 
1242 
1254  extern void bcm2835_peri_write(volatile uint32_t* paddr, uint32_t value);
1255 
1268  extern void bcm2835_peri_write_nb(volatile uint32_t* paddr, uint32_t value);
1269 
1282  extern void bcm2835_peri_set_bits(volatile uint32_t* paddr, uint32_t value, uint32_t mask);
1296  extern void bcm2835_gpio_fsel(uint8_t pin, uint8_t mode);
1297 
1303  extern void bcm2835_gpio_set(uint8_t pin);
1304 
1310  extern void bcm2835_gpio_clr(uint8_t pin);
1311 
1317  extern void bcm2835_gpio_set_multi(uint32_t mask);
1318 
1324  extern void bcm2835_gpio_clr_multi(uint32_t mask);
1325 
1332  extern uint8_t bcm2835_gpio_lev(uint8_t pin);
1333 
1342  extern uint8_t bcm2835_gpio_eds(uint8_t pin);
1343 
1349  extern uint32_t bcm2835_gpio_eds_multi(uint32_t mask);
1350 
1356  extern void bcm2835_gpio_set_eds(uint8_t pin);
1357 
1362  extern void bcm2835_gpio_set_eds_multi(uint32_t mask);
1363 
1372  extern void bcm2835_gpio_ren(uint8_t pin);
1373 
1377  extern void bcm2835_gpio_clr_ren(uint8_t pin);
1378 
1387  extern void bcm2835_gpio_fen(uint8_t pin);
1388 
1392  extern void bcm2835_gpio_clr_fen(uint8_t pin);
1393 
1398  extern void bcm2835_gpio_hen(uint8_t pin);
1399 
1403  extern void bcm2835_gpio_clr_hen(uint8_t pin);
1404 
1409  extern void bcm2835_gpio_len(uint8_t pin);
1410 
1414  extern void bcm2835_gpio_clr_len(uint8_t pin);
1415 
1422  extern void bcm2835_gpio_aren(uint8_t pin);
1423 
1427  extern void bcm2835_gpio_clr_aren(uint8_t pin);
1428 
1435  extern void bcm2835_gpio_afen(uint8_t pin);
1436 
1440  extern void bcm2835_gpio_clr_afen(uint8_t pin);
1441 
1448  extern void bcm2835_gpio_pud(uint8_t pud);
1449 
1456  extern void bcm2835_gpio_pudclk(uint8_t pin, uint8_t on);
1457 
1463  extern uint32_t bcm2835_gpio_pad(uint8_t group);
1464 
1472  extern void bcm2835_gpio_set_pad(uint8_t group, uint32_t control);
1473 
1484  extern void bcm2835_delay (unsigned int millis);
1485 
1499  extern void bcm2835_delayMicroseconds (uint64_t micros);
1500 
1505  extern void bcm2835_gpio_write(uint8_t pin, uint8_t on);
1506 
1511  extern void bcm2835_gpio_write_multi(uint32_t mask, uint8_t on);
1512 
1517  extern void bcm2835_gpio_write_mask(uint32_t value, uint32_t mask);
1518 
1524  extern void bcm2835_gpio_set_pud(uint8_t pin, uint8_t pud);
1525 
1542  extern int bcm2835_spi_begin(void);
1543 
1548  extern void bcm2835_spi_end(void);
1549 
1556  extern void bcm2835_spi_setBitOrder(uint8_t order);
1557 
1563  extern void bcm2835_spi_setClockDivider(uint16_t divider);
1564 
1570  extern void bcm2835_spi_setDataMode(uint8_t mode);
1571 
1578  extern void bcm2835_spi_chipSelect(uint8_t cs);
1579 
1588  extern void bcm2835_spi_setChipSelectPolarity(uint8_t cs, uint8_t active);
1589 
1600  extern uint8_t bcm2835_spi_transfer(uint8_t value);
1601 
1613  extern void bcm2835_spi_transfernb(char* tbuf, char* rbuf, uint32_t len);
1614 
1622  extern void bcm2835_spi_transfern(char* buf, uint32_t len);
1623 
1630  extern void bcm2835_spi_writenb(const char* buf, uint32_t len);
1631 
1641  extern void bcm2835_spi_write(uint16_t data);
1642 
1648  extern int bcm2835_aux_spi_begin(void);
1649 
1654  extern void bcm2835_aux_spi_end(void);
1655 
1659  extern void bcm2835_aux_spi_setClockDivider(uint16_t);
1660 
1666  extern uint16_t bcm2835_aux_spi_CalcClockDivider(uint32_t speed_hz);
1667 
1674  extern void bcm2835_aux_spi_write(uint16_t);
1675 
1681  extern void bcm2835_aux_spi_writenb(const char *buf, uint32_t len);
1682 
1690  extern void bcm2835_aux_spi_transfern(char *, uint32_t);
1691 
1700  extern void bcm2835_aux_spi_transfernb(const char *, char *, uint32_t);
1701 
1718  extern int bcm2835_i2c_begin(void);
1719 
1724  extern void bcm2835_i2c_end(void);
1725 
1729  extern void bcm2835_i2c_setSlaveAddress(uint8_t addr);
1730 
1735  extern void bcm2835_i2c_setClockDivider(uint16_t divider);
1736 
1743  extern void bcm2835_i2c_set_baudrate(uint32_t baudrate);
1744 
1751  extern uint8_t bcm2835_i2c_write(const char * buf, uint32_t len);
1752 
1759  extern uint8_t bcm2835_i2c_read(char* buf, uint32_t len);
1760 
1775  extern uint8_t bcm2835_i2c_read_register_rs(char* regaddr, char* buf, uint32_t len);
1776 
1787  extern uint8_t bcm2835_i2c_write_read_rs(char* cmds, uint32_t cmds_len, char* buf, uint32_t buf_len);
1788 
1799  extern uint64_t bcm2835_st_read(void);
1800 
1805  extern void bcm2835_st_delay(uint64_t offset_micros, uint64_t micros);
1806 
1822  extern void bcm2835_pwm_set_clock(uint32_t divisor);
1823 
1830  extern void bcm2835_pwm_set_mode(uint8_t channel, uint8_t markspace, uint8_t enabled);
1831 
1837  extern void bcm2835_pwm_set_range(uint8_t channel, uint32_t range);
1838 
1845  extern void bcm2835_pwm_set_data(uint8_t channel, uint32_t data);
1846 
1848 #ifdef __cplusplus
1849 }
1850 #endif
1851 
1852 #endif /* BCM2835_H */
1853 
Definition: bcm2835.h:803
Definition: bcm2835.h:820
Definition: bcm2835.h:970
Definition: bcm2835.h:808
Definition: bcm2835.h:858
void bcm2835_pwm_set_clock(uint32_t divisor)
Definition: bcm2835.c:1475
Definition: bcm2835.h:806
volatile uint32_t * bcm2835_spi0
Definition: bcm2835.c:54
void bcm2835_gpio_set_multi(uint32_t mask)
Definition: bcm2835.c:245
void bcm2835_gpio_hen(uint8_t pin)
Definition: bcm2835.c:333
Definition: bcm2835.h:823
void bcm2835_aux_spi_setClockDivider(uint16_t)
Definition: bcm2835.c:834
void bcm2835_spi_writenb(const char *buf, uint32_t len)
Definition: bcm2835.c:680
unsigned int bcm2835_version(void)
Definition: bcm2835.c:111
uint8_t bcm2835_gpio_lev(uint8_t pin)
Definition: bcm2835.c:259
Definition: bcm2835.h:788
Definition: bcm2835.h:1017
volatile uint32_t * bcm2835_aux
Definition: bcm2835.c:58
Definition: bcm2835.h:1067
Definition: bcm2835.h:982
void bcm2835_i2c_setSlaveAddress(uint8_t addr)
Definition: bcm2835.c:1052
Definition: bcm2835.h:663
Definition: bcm2835.h:817
Definition: bcm2835.h:983
Definition: bcm2835.h:807
uint64_t bcm2835_st_read(void)
Definition: bcm2835.c:1431
Definition: bcm2835.h:810
Definition: bcm2835.h:1077
Definition: bcm2835.h:1019
Definition: bcm2835.h:715
Definition: bcm2835.h:718
Definition: bcm2835.h:837
void bcm2835_gpio_fen(uint8_t pin)
Definition: bcm2835.c:317
Definition: bcm2835.h:961
volatile uint32_t * bcm2835_st
Definition: bcm2835.c:57
bcm2835SPIChipSelect
bcm2835SPIChipSelect Specify the SPI chip select pin(s)
Definition: bcm2835.h:979
Definition: bcm2835.h:657
int bcm2835_i2c_begin(void)
Definition: bcm2835.c:1008
Definition: bcm2835.h:850
Definition: bcm2835.h:805
Definition: bcm2835.h:848
Definition: bcm2835.h:1007
Definition: bcm2835.h:801
Definition: bcm2835.h:1015
int bcm2835_spi_begin(void)
Definition: bcm2835.c:542
Definition: bcm2835.h:842
Definition: bcm2835.h:811
bcm2835PUDControl
bcm2835PUDControl Pullup/Pulldown defines for bcm2835_gpio_pud()
Definition: bcm2835.h:729
uint8_t bcm2835_i2c_write_read_rs(char *cmds, uint32_t cmds_len, char *buf, uint32_t buf_len)
Definition: bcm2835.c:1329
void bcm2835_spi_end(void)
Definition: bcm2835.c:566
void bcm2835_gpio_clr_hen(uint8_t pin)
Definition: bcm2835.c:340
void bcm2835_gpio_set(uint8_t pin)
Definition: bcm2835.c:229
Definition: bcm2835.h:721
Definition: bcm2835.h:1006
volatile uint32_t * bcm2835_clk
Definition: bcm2835.c:52
Definition: bcm2835.h:818
void bcm2835_gpio_aren(uint8_t pin)
Definition: bcm2835.c:365
uint8_t bcm2835_i2c_read_register_rs(char *regaddr, char *buf, uint32_t len)
Definition: bcm2835.c:1238
Definition: bcm2835.h:843
Definition: bcm2835.h:794
Definition: bcm2835.h:787
uint8_t bcm2835_gpio_eds(uint8_t pin)
Definition: bcm2835.c:270
uint32_t bcm2835_peri_read_nb(volatile uint32_t *paddr)
Definition: bcm2835.c:142
uint16_t bcm2835_aux_spi_CalcClockDivider(uint32_t speed_hz)
Definition: bcm2835.c:814
Definition: bcm2835.h:834
uint8_t bcm2835_i2c_write(const char *buf, uint32_t len)
Definition: bcm2835.c:1092
Definition: bcm2835.h:656
void bcm2835_gpio_fsel(uint8_t pin, uint8_t mode)
Definition: bcm2835.c:218
Definition: bcm2835.h:835
Definition: bcm2835.h:1065
RPiGPIOPin
GPIO Pin Numbers.
Definition: bcm2835.h:778
int bcm2835_init(void)
Definition: bcm2835.c:1583
void bcm2835_gpio_set_eds(uint8_t pin)
Definition: bcm2835.c:286
Definition: bcm2835.h:855
void bcm2835_i2c_end(void)
Definition: bcm2835.c:1039
Definition: bcm2835.h:1005
Definition: bcm2835.h:796
int bcm2835_close(void)
Definition: bcm2835.c:1691
Definition: bcm2835.h:732
void bcm2835_spi_transfernb(char *tbuf, char *rbuf, uint32_t len)
Definition: bcm2835.c:637
Definition: bcm2835.h:1066
uint32_t bcm2835_peri_read(volatile uint32_t *paddr)
Definition: bcm2835.c:119
Definition: bcm2835.h:719
void bcm2835_gpio_afen(uint8_t pin)
Definition: bcm2835.c:381
void bcm2835_spi_setDataMode(uint8_t mode)
Definition: bcm2835.c:592
Definition: bcm2835.h:844
Definition: bcm2835.h:846
void bcm2835_peri_write_nb(volatile uint32_t *paddr, uint32_t value)
Definition: bcm2835.c:173
Definition: bcm2835.h:815
void bcm2835_aux_spi_writenb(const char *buf, uint32_t len)
Definition: bcm2835.c:859
Definition: bcm2835.h:809
bcm2835I2CReasonCodes
bcm2835I2CReasonCodes Specifies the reason codes for the bcm2835_i2c_write and bcm2835_i2c_read funct...
Definition: bcm2835.h:1074
Definition: bcm2835.h:655
Definition: bcm2835.h:1078
Definition: bcm2835.h:851
Definition: bcm2835.h:659
Definition: bcm2835.h:816
Definition: bcm2835.h:1076
Definition: bcm2835.h:760
Definition: bcm2835.h:1009
Definition: bcm2835.h:845
volatile uint32_t * bcm2835_spi1
Definition: bcm2835.c:59
Definition: bcm2835.h:800
int bcm2835_aux_spi_begin(void)
Definition: bcm2835.c:781
uint32_t bcm2835_gpio_pad(uint8_t group)
Definition: bcm2835.c:414
Definition: bcm2835.h:658
uint8_t bcm2835_spi_transfer(uint8_t value)
Definition: bcm2835.c:600
void bcm2835_gpio_pudclk(uint8_t pin, uint8_t on)
Definition: bcm2835.c:406
Definition: bcm2835.h:733
Definition: bcm2835.h:814
Definition: bcm2835.h:661
Definition: bcm2835.h:838
uint32_t bcm2835_gpio_eds_multi(uint32_t mask)
Definition: bcm2835.c:278
Definition: bcm2835.h:1018
Definition: bcm2835.h:984
uint32_t * bcm2835_regbase(uint8_t regbase)
Definition: bcm2835.c:77
Definition: bcm2835.h:781
Definition: bcm2835.h:717
uint32_t * bcm2835_peripherals
Definition: bcm2835.c:46
Definition: bcm2835.h:813
Definition: bcm2835.h:731
Definition: bcm2835.h:847
volatile uint32_t * bcm2835_gpio
Definition: bcm2835.c:50
Definition: bcm2835.h:791
Definition: bcm2835.h:1079
Definition: bcm2835.h:759
Definition: bcm2835.h:1016
Definition: bcm2835.h:828
void bcm2835_i2c_set_baudrate(uint32_t baudrate)
Definition: bcm2835.c:1083
Definition: bcm2835.h:1003
void bcm2835_pwm_set_data(uint8_t channel, uint32_t data)
Definition: bcm2835.c:1543
void bcm2835_delayMicroseconds(uint64_t micros)
Definition: bcm2835.c:449
void bcm2835_gpio_clr_ren(uint8_t pin)
Definition: bcm2835.c:308
volatile uint32_t * bcm2835_pads
Definition: bcm2835.c:53
void bcm2835_spi_write(uint16_t data)
Definition: bcm2835.c:745
bcm2835FunctionSelect
bcm2835PortFunction Port function select modes for bcm2835_gpio_fsel()
Definition: bcm2835.h:713
void bcm2835_set_debug(uint8_t debug)
Definition: bcm2835.c:106
void bcm2835_aux_spi_end(void)
Definition: bcm2835.c:804
Definition: bcm2835.h:761
Definition: bcm2835.h:782
uint8_t bcm2835_i2c_read(char *buf, uint32_t len)
Definition: bcm2835.c:1163
Definition: bcm2835.h:854
Definition: bcm2835.h:971
volatile uint32_t * bcm2835_bsc0
Definition: bcm2835.c:55
Definition: bcm2835.h:839
Definition: bcm2835.h:857
void bcm2835_aux_spi_write(uint16_t)
Definition: bcm2835.c:838
Definition: bcm2835.h:786
Definition: bcm2835.h:664
Definition: bcm2835.h:1013
void bcm2835_spi_setBitOrder(uint8_t order)
void bcm2835_gpio_set_pad(uint8_t group, uint32_t control)
Definition: bcm2835.c:427
Definition: bcm2835.h:821
Definition: bcm2835.h:790
void bcm2835_peri_set_bits(volatile uint32_t *paddr, uint32_t value, uint32_t mask)
Definition: bcm2835.c:189
void bcm2835_st_delay(uint64_t offset_micros, uint64_t micros)
Definition: bcm2835.c:1465
Definition: bcm2835.h:1010
Definition: bcm2835.h:792
uint32_t * bcm2835_peripherals_base
Definition: bcm2835.c:41
Definition: bcm2835.h:660
Definition: bcm2835.h:836
void bcm2835_gpio_len(uint8_t pin)
Definition: bcm2835.c:349
bcm2835SPIBitOrder
bcm2835SPIBitOrder SPI Bit order Specifies the SPI data bit ordering for bcm2835_spi_setBitOrder() ...
Definition: bcm2835.h:959
void bcm2835_gpio_clr_len(uint8_t pin)
Definition: bcm2835.c:356
Definition: bcm2835.h:1011
volatile uint32_t * bcm2835_pwm
Definition: bcm2835.c:51
Definition: bcm2835.h:795
void bcm2835_aux_spi_transfernb(const char *, char *, uint32_t)
Definition: bcm2835.c:911
Definition: bcm2835.h:856
uint32_t bcm2835_peripherals_size
Definition: bcm2835.c:42
void bcm2835_gpio_ren(uint8_t pin)
Definition: bcm2835.c:301
Definition: bcm2835.h:720
Definition: bcm2835.h:841
void bcm2835_aux_spi_transfern(char *, uint32_t)
Definition: bcm2835.c:1004
void bcm2835_gpio_clr(uint8_t pin)
Definition: bcm2835.c:237
Definition: bcm2835.h:785
Definition: bcm2835.h:804
Definition: bcm2835.h:849
Definition: bcm2835.h:829
void bcm2835_spi_transfern(char *buf, uint32_t len)
Definition: bcm2835.c:725
Definition: bcm2835.h:1014
Definition: bcm2835.h:784
Definition: bcm2835.h:722
void bcm2835_gpio_set_eds_multi(uint32_t mask)
Definition: bcm2835.c:294
Definition: bcm2835.h:723
void bcm2835_spi_chipSelect(uint8_t cs)
Definition: bcm2835.c:730
Definition: bcm2835.h:1012
Definition: bcm2835.h:972
Definition: bcm2835.h:833
Definition: bcm2835.h:840
Definition: bcm2835.h:830
void bcm2835_gpio_clr_aren(uint8_t pin)
Definition: bcm2835.c:372
volatile uint32_t * bcm2835_bsc1
Definition: bcm2835.c:56
Definition: bcm2835.h:1004
Definition: bcm2835.h:789
Definition: bcm2835.h:783
Definition: bcm2835.h:824
Definition: bcm2835.h:1008
Definition: bcm2835.h:662
void bcm2835_gpio_write_multi(uint32_t mask, uint8_t on)
Definition: bcm2835.c:499
void bcm2835_gpio_clr_afen(uint8_t pin)
Definition: bcm2835.c:388
void bcm2835_gpio_clr_fen(uint8_t pin)
Definition: bcm2835.c:324
void bcm2835_pwm_set_range(uint8_t channel, uint32_t range)
Definition: bcm2835.c:1531
void bcm2835_gpio_write_mask(uint32_t value, uint32_t mask)
Definition: bcm2835.c:508
Definition: bcm2835.h:827
bcm2835PadGroup
bcm2835PadGroup Pad group specification for bcm2835_gpio_pad()
Definition: bcm2835.h:757
Definition: bcm2835.h:780
void bcm2835_gpio_clr_multi(uint32_t mask)
Definition: bcm2835.c:252
void bcm2835_gpio_pud(uint8_t pud)
Definition: bcm2835.c:397
Definition: bcm2835.h:981
Definition: bcm2835.h:822
Definition: bcm2835.h:852
bcm2835I2CClockDivider
bcm2835I2CClockDivider Specifies the divider used to generate the I2C clock from the system clock...
Definition: bcm2835.h:1063
Definition: bcm2835.h:802
Definition: bcm2835.h:819
void bcm2835_gpio_set_pud(uint8_t pin, uint8_t pud)
Definition: bcm2835.c:532
Definition: bcm2835.h:962
void bcm2835_peri_write(volatile uint32_t *paddr, uint32_t value)
Definition: bcm2835.c:158
void bcm2835_pwm_set_mode(uint8_t channel, uint8_t markspace, uint8_t enabled)
Definition: bcm2835.c:1494
bcm2835SPIClockDivider
bcm2835SPIClockDivider Specifies the divider used to generate the SPI clock from the system clock...
Definition: bcm2835.h:1001
Definition: bcm2835.h:1068
bcm2835SPIMode
SPI Data mode Specify the SPI data mode to be passed to bcm2835_spi_setDataMode() ...
Definition: bcm2835.h:968
void bcm2835_spi_setChipSelectPolarity(uint8_t cs, uint8_t active)
Definition: bcm2835.c:737
Definition: bcm2835.h:716
void bcm2835_i2c_setClockDivider(uint16_t divider)
Definition: bcm2835.c:1067
void bcm2835_spi_setClockDivider(uint16_t divider)
Definition: bcm2835.c:586
Definition: bcm2835.h:793
Definition: bcm2835.h:973
Definition: bcm2835.h:853
bcm2835RegisterBase
bcm2835RegisterBase Register bases for bcm2835_regbase()
Definition: bcm2835.h:653
void bcm2835_gpio_write(uint8_t pin, uint8_t on)
Definition: bcm2835.c:490
Definition: bcm2835.h:812
void bcm2835_delay(unsigned int millis)
Definition: bcm2835.c:439
Definition: bcm2835.h:799