Various projects using Raspberry Pi
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1408 lines
77 KiB

11 years ago
  1. with Interfaces.C; use Interfaces.C;
  2. with stdint_h;
  3. with Interfaces.C.Strings;
  4. package bcm2835_h is
  5. -- bcm2835.h
  6. -- C and C++ support for Broadcom BCM 2835 as used in Raspberry Pi
  7. -- Author: Mike McCauley
  8. -- Copyright (C) 2011-2013 Mike McCauley
  9. -- $Id: bcm2835.h,v 1.12 2013/10/30 03:09:31 mikem Exp mikem $
  10. --/ \mainpage C library for Broadcom BCM 2835 as used in Raspberry Pi
  11. --/
  12. --/ This is a C library for Raspberry Pi (RPi). It provides access to
  13. --/ GPIO and other IO functions on the Broadcom BCM 2835 chip,
  14. --/ allowing access to the GPIO pins on the
  15. --/ 26 pin IDE plug on the RPi board so you can control and interface with various external devices.
  16. --/
  17. --/ It provides functions for reading digital inputs and setting digital outputs, using SPI and I2C,
  18. --/ and for accessing the system timers.
  19. --/ Pin event detection is supported by polling (interrupts are not supported).
  20. --/
  21. --/ It is C++ compatible, and installs as a header file and non-shared library on
  22. --/ any Linux-based distro (but clearly is no use except on Raspberry Pi or another board with
  23. --/ BCM 2835).
  24. --/
  25. --/ The version of the package that this documentation refers to can be downloaded
  26. --/ from http://www.airspayce.com/mikem/bcm2835/bcm2835-1.32.tar.gz
  27. --/ You can find the latest version at http://www.airspayce.com/mikem/bcm2835
  28. --/
  29. --/ Several example programs are provided.
  30. --/
  31. --/ Based on data in http://elinux.org/RPi_Low-level_peripherals and
  32. --/ http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
  33. --/ and http://www.scribd.com/doc/101830961/GPIO-Pads-Control2
  34. --/
  35. --/ You can also find online help and discussion at http://groups.google.com/group/bcm2835
  36. --/ Please use that group for all questions and discussions on this topic.
  37. --/ Do not contact the author directly, unless it is to discuss commercial licensing.
  38. --/
  39. --/ Tested on debian6-19-04-2012, 2012-07-15-wheezy-raspbian, 2013-07-26-wheezy-raspbian
  40. --/ and Occidentalisv01
  41. --/ CAUTION: it has been observed that when detect enables such as bcm2835_gpio_len()
  42. --/ are used and the pin is pulled LOW
  43. --/ it can cause temporary hangs on 2012-07-15-wheezy-raspbian, 2013-07-26-wheezy-raspbian
  44. --/ and Occidentalisv01.
  45. --/ Reason for this is not yet determined, but we suspect that an interrupt handler is
  46. --/ hitting a hard loop on those OSs.
  47. --/ If you must use bcm2835_gpio_len() and friends, make sure you disable the pins with
  48. --/ bcm2835_gpio_clr_len() and friends after use.
  49. --/
  50. --/ \par Installation
  51. --/
  52. --/ This library consists of a single non-shared library and header file, which will be
  53. --/ installed in the usual places by make install
  54. --/
  55. --/ \code
  56. --/ # download the latest version of the library, say bcm2835-1.xx.tar.gz, then:
  57. --/ tar zxvf bcm2835-1.xx.tar.gz
  58. --/ cd bcm2835-1.xx
  59. --/ ./configure
  60. --/ make
  61. --/ sudo make check
  62. --/ sudo make install
  63. --/ \endcode
  64. --/
  65. --/ \par Physical Addresses
  66. --/
  67. --/ The functions bcm2835_peri_read(), bcm2835_peri_write() and bcm2835_peri_set_bits()
  68. --/ are low level peripheral register access functions. They are designed to use
  69. --/ physical addresses as described in section 1.2.3 ARM physical addresses
  70. --/ of the BCM2835 ARM Peripherals manual.
  71. --/ Physical addresses range from 0x20000000 to 0x20FFFFFF for peripherals. The bus
  72. --/ addresses for peripherals are set up to map onto the peripheral bus address range starting at
  73. --/ 0x7E000000. Thus a peripheral advertised in the manual at bus address 0x7Ennnnnn is available at
  74. --/ physical address 0x20nnnnnn.
  75. --/
  76. --/ The base address of the various peripheral registers are available with the following
  77. --/ externals:
  78. --/ bcm2835_gpio
  79. --/ bcm2835_pwm
  80. --/ bcm2835_clk
  81. --/ bcm2835_pads
  82. --/ bcm2835_spio0
  83. --/ bcm2835_st
  84. --/ bcm2835_bsc0
  85. --/ bcm2835_bsc1
  86. --/
  87. --/ \par Pin Numbering
  88. --/
  89. --/ The GPIO pin numbering as used by RPi is different to and inconsistent with the underlying
  90. --/ BCM 2835 chip pin numbering. http://elinux.org/RPi_BCM2835_GPIOs
  91. --/
  92. --/ RPi has a 26 pin IDE header that provides access to some of the GPIO pins on the BCM 2835,
  93. --/ as well as power and ground pins. Not all GPIO pins on the BCM 2835 are available on the
  94. --/ IDE header.
  95. --/
  96. --/ RPi Version 2 also has a P5 connector with 4 GPIO pins, 5V, 3.3V and Gnd.
  97. --/
  98. --/ The functions in this library are designed to be passed the BCM 2835 GPIO pin number and _not_
  99. --/ the RPi pin number. There are symbolic definitions for each of the available pins
  100. --/ that you should use for convenience. See \ref RPiGPIOPin.
  101. --/
  102. --/ \par SPI Pins
  103. --/
  104. --/ The bcm2835_spi_* functions allow you to control the BCM 2835 SPI0 interface,
  105. --/ allowing you to send and received data by SPI (Serial Peripheral Interface).
  106. --/ For more information about SPI, see http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
  107. --/
  108. --/ When bcm2835_spi_begin() is called it changes the bahaviour of the SPI interface pins from their
  109. --/ default GPIO behaviour in order to support SPI. While SPI is in use, you will not be able
  110. --/ to control the state of the SPI pins through the usual bcm2835_spi_gpio_write().
  111. --/ When bcm2835_spi_end() is called, the SPI pins will all revert to inputs, and can then be
  112. --/ configured and controled with the usual bcm2835_gpio_* calls.
  113. --/
  114. --/ The Raspberry Pi GPIO pins used for SPI are:
  115. --/
  116. --/ - P1-19 (MOSI)
  117. --/ - P1-21 (MISO)
  118. --/ - P1-23 (CLK)
  119. --/ - P1-24 (CE0)
  120. --/ - P1-26 (CE1)
  121. --/
  122. --/ \par I2C Pins
  123. --/
  124. --/ The bcm2835_i2c_* functions allow you to control the BCM 2835 BSC interface,
  125. --/ allowing you to send and received data by I2C ("eye-squared cee"; generically referred to as "two-wire interface") .
  126. --/ For more information about I?C, see http://en.wikipedia.org/wiki/I%C2%B2C
  127. --/
  128. --/ The Raspberry Pi V2 GPIO pins used for I2C are:
  129. --/
  130. --/ - P1-03 (SDA)
  131. --/ - P1-05 (SLC)
  132. --/
  133. --/ \par PWM
  134. --/
  135. --/ The BCM2835 supports hardware PWM on a limited subset of GPIO pins. This bcm2835 library provides
  136. --/ functions for configuring and controlling PWM output on these pins.
  137. --/
  138. --/ The BCM2835 contains 2 independent PWM channels (0 and 1), each of which be connnected to a limited subset of
  139. --/ GPIO pins. The following GPIO pins may be connected to the following PWM channels (from section 9.5):
  140. --/ \code
  141. --/ GPIO PIN RPi pin PWM Channel ALT FUN
  142. --/ 12 0 0
  143. --/ 13 1 0
  144. --/ 18 1-12 0 5
  145. --/ 19 1 5
  146. --/ 40 0 0
  147. --/ 41 1 0
  148. --/ 45 1 0
  149. --/ 52 0 1
  150. --/ 53 1 1
  151. --/ \endcode
  152. --/ In order for a GPIO pin to emit output from its PWM channel, it must be set to the Alt Function given above.
  153. --/ Note carefully that current versions of the Raspberry Pi only expose one of these pins (GPIO 18 = RPi Pin 1-12)
  154. --/ on the IO headers, and therefore this is the only IO pin on the RPi that can be used for PWM.
  155. --/ Further it must be set to ALT FUN 5 to get PWM output.
  156. --/
  157. --/ Both PWM channels are driven by the same PWM clock, whose clock dvider can be varied using
  158. --/ bcm2835_pwm_set_clock(). Each channel can be separately enabled with bcm2835_pwm_set_mode().
  159. --/ The average output of the PWM channel is determined by the ratio of DATA/RANGE for that channel.
  160. --/ Use bcm2835_pwm_set_range() to set the range and bcm2835_pwm_set_data() to set the data in that ratio
  161. --/
  162. --/ Each PWM channel can run in either Balanced or Mark-Space mode. In Balanced mode, the hardware
  163. --/ sends a combination of clock pulses that results in an overall DATA pulses per RANGE pulses.
  164. --/ In Mark-Space mode, the hardware sets the output HIGH for DATA clock pulses wide, followed by
  165. --/ LOW for RANGE-DATA clock pulses.
  166. --/
  167. --/ The PWM clock can be set to control the PWM pulse widths. The PWM clock is derived from
  168. --/ a 19.2MHz clock. You can set any divider, but some common ones are provided by the BCM2835_PWM_CLOCK_DIVIDER_*
  169. --/ values of \ref bcm2835PWMClockDivider.
  170. --/
  171. --/ For example, say you wanted to drive a DC motor with PWM at about 1kHz,
  172. --/ and control the speed in 1/1024 increments from
  173. --/ 0/1024 (stopped) through to 1024/1024 (full on). In that case you might set the
  174. --/ clock divider to be 16, and the RANGE to 1024. The pulse repetition frequency will be
  175. --/ 1.2MHz/1024 = 1171.875Hz.
  176. --/
  177. --/ \par Real Time performance constraints
  178. --/
  179. --/ The bcm2835 is a library for user programs (i.e. they run in 'userland').
  180. --/ Such programs are not part of the kernel and are usually
  181. --/ subject to paging and swapping by the kernel while it does other things besides running your program.
  182. --/ This means that you should not expect to get real-time performance or
  183. --/ real-time timing constraints from such programs. In particular, there is no guarantee that the
  184. --/ bcm2835_delay() and bcm2835_delayMicroseconds() will return after exactly the time requested.
  185. --/ In fact, depending on other activity on the host, IO etc, you might get significantly longer delay times
  186. --/ than the one you asked for. So please dont expect to get exactly the time delay you request.
  187. --/
  188. --/ Arjan reports that you can prevent swapping on Linux with the following code fragment:
  189. --/
  190. --/ \code
  191. --/ struct sched_param sp;
  192. --/ memset(&sp, 0, sizeof(sp));
  193. --/ sp.sched_priority = sched_get_priority_max(SCHED_FIFO);
  194. --/ sched_setscheduler(0, SCHED_FIFO, &sp);
  195. --/ mlockall(MCL_CURRENT | MCL_FUTURE);
  196. --/ \endcode
  197. --/
  198. --/ \par Bindings to other languages
  199. --/
  200. --/ mikem has made Perl bindings available at CPAN:
  201. --/ http://search.cpan.org/~mikem/Device-BCM2835-1.9/lib/Device/BCM2835.pm
  202. --/ Matthew Baker has kindly made Python bindings available at:
  203. --/ https://github.com/mubeta06/py-libbcm2835
  204. --/ Gary Marks has created a Serial Peripheral Interface (SPI) command-line utility
  205. --/ for Raspberry Pi, based on the bcm2835 library. The
  206. --/ utility, spincl, is licensed under Open Source GNU GPLv3 by iP Solutions (http://ipsolutionscorp.com), as a
  207. --/ free download with source included: http://ipsolutionscorp.com/raspberry-pi-spi-utility/
  208. --/
  209. --/ \par Open Source Licensing GPL V2
  210. --/
  211. --/ This is the appropriate option if you want to share the source code of your
  212. --/ application with everyone you distribute it to, and you also want to give them
  213. --/ the right to share who uses it. If you wish to use this software under Open
  214. --/ Source Licensing, you must contribute all your source code to the open source
  215. --/ community in accordance with the GPL Version 2 when your application is
  216. --/ distributed. See http://www.gnu.org/copyleft/gpl.html and COPYING
  217. --/
  218. --/ \par Acknowledgements
  219. --/
  220. --/ Some of this code has been inspired by Dom and Gert.
  221. --/ The I2C code has been inspired by Alan Barr.
  222. --/
  223. --/ \par Revision History
  224. --/
  225. --/ \version 1.0 Initial release
  226. --/ \version 1.1 Minor bug fixes
  227. --/ \version 1.2 Added support for SPI
  228. --/ \version 1.3 Added bcm2835_spi_transfern()
  229. --/ \version 1.4 Fixed a problem that prevented SPI CE1 being used. Reported by David Robinson.
  230. --/ \version 1.5 Added bcm2835_close() to deinit the library. Suggested by C?sar Ortiz
  231. --/ \version 1.6 Document testing on 2012-07-15-wheezy-raspbian and Occidentalisv01
  232. --/ Functions bcm2835_gpio_ren(), bcm2835_gpio_fen(), bcm2835_gpio_hen()
  233. --/ bcm2835_gpio_len(), bcm2835_gpio_aren() and bcm2835_gpio_afen() now
  234. --/ changes only the pin specified. Other pins that were already previously
  235. --/ enabled stay enabled.
  236. --/ Added bcm2835_gpio_clr_ren(), bcm2835_gpio_clr_fen(), bcm2835_gpio_clr_hen()
  237. --/ bcm2835_gpio_clr_len(), bcm2835_gpio_clr_aren(), bcm2835_gpio_clr_afen()
  238. --/ to clear the enable for individual pins, suggested by Andreas Sundstrom.
  239. --/ \version 1.7 Added bcm2835_spi_transfernb to support different buffers for read and write.
  240. --/ \version 1.8 Improvements to read barrier, as suggested by maddin.
  241. --/ \version 1.9 Improvements contributed by mikew:
  242. --/ I noticed that it was mallocing memory for the mmaps on /dev/mem.
  243. --/ It's not necessary to do that, you can just mmap the file directly,
  244. --/ so I've removed the mallocs (and frees).
  245. --/ I've also modified delayMicroseconds() to use nanosleep() for long waits,
  246. --/ and a busy wait on a high resolution timer for the rest. This is because
  247. --/ I've found that calling nanosleep() takes at least 100-200 us.
  248. --/ You need to link using '-lrt' using this version.
  249. --/ I've added some unsigned casts to the debug prints to silence compiler
  250. --/ warnings I was getting, fixed some typos, and changed the value of
  251. --/ BCM2835_PAD_HYSTERESIS_ENABLED to 0x08 as per Gert van Loo's doc at
  252. --/ http://www.scribd.com/doc/101830961/GPIO-Pads-Control2
  253. --/ Also added a define for the passwrd value that Gert says is needed to
  254. --/ change pad control settings.
  255. --/ \version 1.10 Changed the names of the delay functions to bcm2835_delay()
  256. --/ and bcm2835_delayMicroseconds() to prevent collisions with wiringPi.
  257. --/ Macros to map delay()-> bcm2835_delay() and
  258. --/ Macros to map delayMicroseconds()-> bcm2835_delayMicroseconds(), which
  259. --/ can be disabled by defining BCM2835_NO_DELAY_COMPATIBILITY
  260. --/ \version 1.11 Fixed incorrect link to download file
  261. --/ \version 1.12 New GPIO pin definitions for RPi version 2 (which has a different GPIO mapping)
  262. --/ \version 1.13 New GPIO pin definitions for RPi version 2 plug P5
  263. --/ Hardware base pointers are now available (after initialisation) externally as bcm2835_gpio
  264. --/ bcm2835_pwm bcm2835_clk bcm2835_pads bcm2835_spi0.
  265. --/ \version 1.14 Now compiles even if CLOCK_MONOTONIC_RAW is not available, uses CLOCK_MONOTONIC instead.
  266. --/ Fixed errors in documentation of SPI divider frequencies based on 250MHz clock.
  267. --/ Reported by Ben Simpson.
  268. --/ \version 1.15 Added bcm2835_close() to end of examples as suggested by Mark Wolfe.
  269. --/ \version 1.16 Added bcm2835_gpio_set_multi, bcm2835_gpio_clr_multi and bcm2835_gpio_write_multi
  270. --/ to allow a mask of pins to be set all at once. Requested by Sebastian Loncar.
  271. --/ \version 1.17 Added bcm2835_gpio_write_mask. Requested by Sebastian Loncar.
  272. --/ \version 1.18 Added bcm2835_i2c_* functions. Changes to bcm2835_delayMicroseconds:
  273. --/ now uses the RPi system timer counter, instead of clock_gettime, for improved accuracy.
  274. --/ No need to link with -lrt now. Contributed by Arjan van Vught.
  275. --/ \version 1.19 Removed inlines added by previous patch since they don't seem to work everywhere.
  276. --/ Reported by olly.
  277. --/ \version 1.20 Patch from Mark Dootson to close /dev/mem after access to the peripherals has been granted.
  278. --/ \version 1.21 delayMicroseconds is now not susceptible to 32 bit timer overruns.
  279. --/ Patch courtesy Jeremy Mortis.
  280. --/ \version 1.22 Fixed incorrect definition of BCM2835_GPFEN0 which broke the ability to set
  281. --/ falling edge events. Reported by Mark Dootson.
  282. --/ \version 1.23 Added bcm2835_i2c_set_baudrate and bcm2835_i2c_read_register_rs.
  283. --/ Improvements to bcm2835_i2c_read and bcm2835_i2c_write functions
  284. --/ to fix ocasional reads not completing. Patched by Mark Dootson.
  285. --/ \version 1.24 Mark Dootson p[atched a problem with his previously submitted code
  286. --/ under high load from other processes.
  287. --/ \version 1.25 Updated author and distribution location details to airspayce.com
  288. --/ \version 1.26 Added missing unmapmem for pads in bcm2835_close to prevent a memory leak.
  289. --/ Reported by Hartmut Henkel.
  290. --/ \version 1.27 bcm2835_gpio_set_pad() no longer needs BCM2835_PAD_PASSWRD: it is
  291. --/ now automatically included.
  292. --/ Added suport for PWM mode with bcm2835_pwm_* functions.
  293. --/ \version 1.28 Fixed a problem where bcm2835_spi_writenb() would have problems with transfers of more than
  294. --/ 64 bytes dues to read buffer filling. Patched by Peter Würtz.
  295. --/ \version 1.29 Further fix to SPI from Peter Würtz.
  296. --/ \version 1.30 10 microsecond delays from bcm2835_spi_transfer and bcm2835_spi_transfern for
  297. --/ significant performance improvements, Patch by Alan Watson.
  298. --/ \version 1.31 Fix a GCC warning about dummy variable, patched by Alan Watson. Thanks.
  299. --/ \version 1.32 Added option I2C_V1 definition to compile for version 1 RPi.
  300. --/ By default I2C code is generated for the V2 RPi which has SDA1 and SCL1 connected.
  301. --/ Contributed by Malcolm Wiles.
  302. --/
  303. --/ \author Mike McCauley (mikem@airspayce.com) DO NOT CONTACT THE AUTHOR DIRECTLY: USE THE LISTS
  304. -- Defines for BCM2835
  305. --/ \defgroup constants Constants for passing to and from library functions
  306. --/ The values here are designed to be passed to various functions in the bcm2835 library.
  307. --/ @{
  308. --/ This means pin HIGH, true, 3.3volts on a pin.
  309. --/ This means pin LOW, false, 0volts on a pin.
  310. --/ Speed of the core clock core_clk
  311. -- Physical addresses for various peripheral register sets
  312. --/ Base Physical Address of the BCM 2835 peripheral registers
  313. --/ Base Physical Address of the System Timer registers
  314. --/ Base Physical Address of the Pads registers
  315. --/ Base Physical Address of the Clock/timer registers
  316. --/ Base Physical Address of the GPIO registers
  317. --/ Base Physical Address of the SPI0 registers
  318. --/ Base Physical Address of the BSC0 registers
  319. --/ Base Physical Address of the PWM registers
  320. --/ Base Physical Address of the BSC1 registers
  321. -- manual converted
  322. HIGH : constant unsigned := 16#1#;
  323. LOW : constant unsigned := 16#0#;
  324. BCM2835_CORE_CLK_HZ : constant unsigned := 250000000;
  325. BCM2835_PERI_BASE : constant unsigned := 16#20000000#;
  326. BCM2835_ST_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#3000#);
  327. BCM2835_GPIO_PADS : constant unsigned := (BCM2835_PERI_BASE + 16#100000#);
  328. BCM2835_CLOCK_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#101000#);
  329. BCM2835_GPIO_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#200000#);
  330. BCM2835_SPI0_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#204000#);
  331. BCM2835_BSC0_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#205000#);
  332. BCM2835_GPIO_PWM : constant unsigned := (BCM2835_PERI_BASE + 16#20C000#);
  333. BCM2835_BSC1_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#804000#);
  334. BCM2835_PAGE_SIZE : constant unsigned := (4*1024);
  335. BCM2835_BLOCK_SIZE : constant unsigned := (4*1024);
  336. BCM2835_GPFSEL0 : constant unsigned := 16#0000#;
  337. BCM2835_GPFSEL1 : constant unsigned := 16#0004#;
  338. BCM2835_GPFSEL2 : constant unsigned := 16#0008#;
  339. BCM2835_GPFSEL3 : constant unsigned := 16#000c#;
  340. BCM2835_GPFSEL4 : constant unsigned := 16#0010#;
  341. BCM2835_GPFSEL5 : constant unsigned := 16#0014#;
  342. BCM2835_GPSET0 : constant unsigned := 16#001c#;
  343. BCM2835_GPSET1 : constant unsigned := 16#0020#;
  344. BCM2835_GPCLR0 : constant unsigned := 16#0028#;
  345. BCM2835_GPCLR1 : constant unsigned := 16#002c#;
  346. BCM2835_GPLEV0 : constant unsigned := 16#0034#;
  347. BCM2835_GPLEV1 : constant unsigned := 16#0038#;
  348. BCM2835_GPEDS0 : constant unsigned := 16#0040#;
  349. BCM2835_GPEDS1 : constant unsigned := 16#0044#;
  350. BCM2835_GPREN0 : constant unsigned := 16#004c#;
  351. BCM2835_GPREN1 : constant unsigned := 16#0050#;
  352. BCM2835_GPFEN0 : constant unsigned := 16#0058#;
  353. BCM2835_GPFEN1 : constant unsigned := 16#005c#;
  354. BCM2835_GPHEN0 : constant unsigned := 16#0064#;
  355. BCM2835_GPHEN1 : constant unsigned := 16#0068#;
  356. BCM2835_GPLEN0 : constant unsigned := 16#0070#;
  357. BCM2835_GPLEN1 : constant unsigned := 16#0074#;
  358. BCM2835_GPAREN0 : constant unsigned := 16#007c#;
  359. BCM2835_GPAREN1 : constant unsigned := 16#0080#;
  360. BCM2835_GPAFEN0 : constant unsigned := 16#0088#;
  361. BCM2835_GPAFEN1 : constant unsigned := 16#008c#;
  362. BCM2835_GPPUD : constant unsigned := 16#0094#;
  363. BCM2835_GPPUDCLK0 : constant unsigned := 16#0098#;
  364. BCM2835_GPPUDCLK1 : constant unsigned := 16#009c#;
  365. BCM2835_PADS_GPIO_0_27 : constant unsigned := 16#002c#;
  366. BCM2835_PADS_GPIO_28_45 : constant unsigned := 16#0030#;
  367. BCM2835_PADS_GPIO_46_53 : constant unsigned := 16#0034#;
  368. BCM2835_PAD_PASSWRD : constant unsigned := 16#5A000000#;
  369. BCM2835_PAD_SLEW_RATE_UNLIMITED : constant unsigned := 16#10#;
  370. BCM2835_PAD_HYSTERESIS_ENABLED : constant unsigned := 16#08#;
  371. BCM2835_PAD_DRIVE_2mA : constant unsigned := 16#00#;
  372. BCM2835_PAD_DRIVE_4mA : constant unsigned := 16#01#;
  373. BCM2835_PAD_DRIVE_6mA : constant unsigned := 16#02#;
  374. BCM2835_PAD_DRIVE_8mA : constant unsigned := 16#03#;
  375. BCM2835_PAD_DRIVE_10mA : constant unsigned := 16#04#;
  376. BCM2835_PAD_DRIVE_12mA : constant unsigned := 16#05#;
  377. BCM2835_PAD_DRIVE_14mA : constant unsigned := 16#06#;
  378. BCM2835_PAD_DRIVE_16mA : constant unsigned := 16#07#;
  379. BCM2835_SPI0_CS : constant unsigned := 16#0000#;
  380. BCM2835_SPI0_FIFO : constant unsigned := 16#0004#;
  381. BCM2835_SPI0_CLK : constant unsigned := 16#0008#;
  382. BCM2835_SPI0_DLEN : constant unsigned := 16#000c#;
  383. BCM2835_SPI0_LTOH : constant unsigned := 16#0010#;
  384. BCM2835_SPI0_DC : constant unsigned := 16#0014#;
  385. BCM2835_SPI0_CS_LEN_LONG : constant unsigned := 16#02000000#;
  386. BCM2835_SPI0_CS_DMA_LEN : constant unsigned := 16#01000000#;
  387. BCM2835_SPI0_CS_CSPOL2 : constant unsigned := 16#00800000#;
  388. BCM2835_SPI0_CS_CSPOL1 : constant unsigned := 16#00400000#;
  389. BCM2835_SPI0_CS_CSPOL0 : constant unsigned := 16#00200000#;
  390. BCM2835_SPI0_CS_RXF : constant unsigned := 16#00100000#;
  391. BCM2835_SPI0_CS_RXR : constant unsigned := 16#00080000#;
  392. BCM2835_SPI0_CS_TXD : constant unsigned := 16#00040000#;
  393. BCM2835_SPI0_CS_RXD : constant unsigned := 16#00020000#;
  394. BCM2835_SPI0_CS_DONE : constant unsigned := 16#00010000#;
  395. BCM2835_SPI0_CS_TE_EN : constant unsigned := 16#00008000#;
  396. BCM2835_SPI0_CS_LMONO : constant unsigned := 16#00004000#;
  397. BCM2835_SPI0_CS_LEN : constant unsigned := 16#00002000#;
  398. BCM2835_SPI0_CS_REN : constant unsigned := 16#00001000#;
  399. BCM2835_SPI0_CS_ADCS : constant unsigned := 16#00000800#;
  400. BCM2835_SPI0_CS_INTR : constant unsigned := 16#00000400#;
  401. BCM2835_SPI0_CS_INTD : constant unsigned := 16#00000200#;
  402. BCM2835_SPI0_CS_DMAEN : constant unsigned := 16#00000100#;
  403. BCM2835_SPI0_CS_TA : constant unsigned := 16#00000080#;
  404. BCM2835_SPI0_CS_CSPOL : constant unsigned := 16#00000040#;
  405. BCM2835_SPI0_CS_CLEAR : constant unsigned := 16#00000030#;
  406. BCM2835_SPI0_CS_CLEAR_RX : constant unsigned := 16#00000020#;
  407. BCM2835_SPI0_CS_CLEAR_TX : constant unsigned := 16#00000010#;
  408. BCM2835_SPI0_CS_CPOL : constant unsigned := 16#00000008#;
  409. BCM2835_SPI0_CS_CPHA : constant unsigned := 16#00000004#;
  410. BCM2835_SPI0_CS_CS : constant unsigned := 16#00000003#;
  411. BCM2835_BSC_C : constant unsigned := 16#0000#;
  412. BCM2835_BSC_S : constant unsigned := 16#0004#;
  413. BCM2835_BSC_DLEN : constant unsigned := 16#0008#;
  414. BCM2835_BSC_A : constant unsigned := 16#000c#;
  415. BCM2835_BSC_FIFO : constant unsigned := 16#0010#;
  416. BCM2835_BSC_DIV : constant unsigned := 16#0014#;
  417. BCM2835_BSC_DEL : constant unsigned := 16#0018#;
  418. BCM2835_BSC_CLKT : constant unsigned := 16#001c#;
  419. BCM2835_BSC_C_I2CEN : constant unsigned := 16#00008000#;
  420. BCM2835_BSC_C_INTR : constant unsigned := 16#00000400#;
  421. BCM2835_BSC_C_INTT : constant unsigned := 16#00000200#;
  422. BCM2835_BSC_C_INTD : constant unsigned := 16#00000100#;
  423. BCM2835_BSC_C_ST : constant unsigned := 16#00000080#;
  424. BCM2835_BSC_C_CLEAR_1 : constant unsigned := 16#00000020#;
  425. BCM2835_BSC_C_CLEAR_2 : constant unsigned := 16#00000010#;
  426. BCM2835_BSC_C_READ : constant unsigned := 16#00000001#;
  427. BCM2835_BSC_S_CLKT : constant unsigned := 16#00000200#;
  428. BCM2835_BSC_S_ERR : constant unsigned := 16#00000100#;
  429. BCM2835_BSC_S_RXF : constant unsigned := 16#00000080#;
  430. BCM2835_BSC_S_TXE : constant unsigned := 16#00000040#;
  431. BCM2835_BSC_S_RXD : constant unsigned := 16#00000020#;
  432. BCM2835_BSC_S_TXD : constant unsigned := 16#00000010#;
  433. BCM2835_BSC_S_RXR : constant unsigned := 16#00000008#;
  434. BCM2835_BSC_S_TXW : constant unsigned := 16#00000004#;
  435. BCM2835_BSC_S_DONE : constant unsigned := 16#00000002#;
  436. BCM2835_BSC_S_TA : constant unsigned := 16#00000001#;
  437. BCM2835_BSC_FIFO_SIZE : constant unsigned := 16;
  438. BCM2835_ST_CS : constant unsigned := 16#0000#;
  439. BCM2835_ST_CLO : constant unsigned := 16#0004#;
  440. BCM2835_ST_CHI : constant unsigned := 16#0008#;
  441. BCM2835_PWM_CONTROL : constant unsigned := 0;
  442. BCM2835_PWM_STATUS : constant unsigned := 1;
  443. BCM2835_PWM_DMAC : constant unsigned := 2;
  444. BCM2835_PWM0_RANGE : constant unsigned := 4;
  445. BCM2835_PWM0_DATA : constant unsigned := 5;
  446. BCM2835_PWM_FIF1 : constant unsigned := 6;
  447. BCM2835_PWM1_RANGE : constant unsigned := 8;
  448. BCM2835_PWM1_DATA : constant unsigned := 9;
  449. BCM2835_PWMCLK_CNTL : constant unsigned := 40;
  450. BCM2835_PWMCLK_DIV : constant unsigned := 41;
  451. BCM2835_PWM_PASSWRD : constant unsigned := 16#5A000000#;
  452. BCM2835_PWM1_MS_MODE : constant unsigned := 16#8000#;
  453. BCM2835_PWM1_USEFIFO : constant unsigned := 16#2000#;
  454. BCM2835_PWM1_REVPOLAR : constant unsigned := 16#1000#;
  455. BCM2835_PWM1_OFFSTATE : constant unsigned := 16#0800#;
  456. BCM2835_PWM1_REPEATFF : constant unsigned := 16#0400#;
  457. BCM2835_PWM1_SERIAL : constant unsigned := 16#0200#;
  458. BCM2835_PWM1_ENABLE : constant unsigned := 16#0100#;
  459. BCM2835_PWM0_MS_MODE : constant unsigned := 16#0080#;
  460. BCM2835_PWM_CLEAR_FIFO : constant unsigned := 16#0040#;
  461. BCM2835_PWM0_USEFIFO : constant unsigned := 16#0020#;
  462. BCM2835_PWM0_REVPOLAR : constant unsigned := 16#0010#;
  463. BCM2835_PWM0_OFFSTATE : constant unsigned := 16#0008#;
  464. BCM2835_PWM0_REPEATFF : constant unsigned := 16#0004#;
  465. BCM2835_PWM0_SERIAL : constant unsigned := 16#0002#;
  466. BCM2835_PWM0_ENABLE : constant unsigned := 16#0001#;
  467. -- arg-macro: procedure delay (x)
  468. -- bcm2835_delay(x)
  469. -- arg-macro: procedure delayMicroseconds (x)
  470. -- bcm2835_delayMicroseconds(x)
  471. --/ Base of the ST (System Timer) registers.
  472. --/ Available after bcm2835_init has been called
  473. bcm2835_st : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:348
  474. pragma Import (C, bcm2835_st, "bcm2835_st");
  475. --/ Base of the GPIO registers.
  476. --/ Available after bcm2835_init has been called
  477. bcm2835_gpio : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:352
  478. pragma Import (C, bcm2835_gpio, "bcm2835_gpio");
  479. --/ Base of the PWM registers.
  480. --/ Available after bcm2835_init has been called
  481. bcm2835_pwm : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:356
  482. pragma Import (C, bcm2835_pwm, "bcm2835_pwm");
  483. --/ Base of the CLK registers.
  484. --/ Available after bcm2835_init has been called
  485. bcm2835_clk : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:360
  486. pragma Import (C, bcm2835_clk, "bcm2835_clk");
  487. --/ Base of the PADS registers.
  488. --/ Available after bcm2835_init has been called
  489. bcm2835_pads : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:364
  490. pragma Import (C, bcm2835_pads, "bcm2835_pads");
  491. --/ Base of the SPI0 registers.
  492. --/ Available after bcm2835_init has been called
  493. bcm2835_spi0 : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:368
  494. pragma Import (C, bcm2835_spi0, "bcm2835_spi0");
  495. --/ Base of the BSC0 registers.
  496. --/ Available after bcm2835_init has been called
  497. bcm2835_bsc0 : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:372
  498. pragma Import (C, bcm2835_bsc0, "bcm2835_bsc0");
  499. --/ Base of the BSC1 registers.
  500. --/ Available after bcm2835_init has been called
  501. bcm2835_bsc1 : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:376
  502. pragma Import (C, bcm2835_bsc1, "bcm2835_bsc1");
  503. --/ Size of memory page on RPi
  504. --/ Size of memory block on RPi
  505. -- Defines for GPIO
  506. -- The BCM2835 has 54 GPIO pins.
  507. -- BCM2835 data sheet, Page 90 onwards.
  508. --/ GPIO register offsets from BCM2835_GPIO_BASE. Offsets into the GPIO Peripheral block in bytes per 6.1 Register View
  509. --/ \brief bcm2835PortFunction
  510. --/ Port function select modes for bcm2835_gpio_fsel()
  511. --/< Input
  512. --/< Output
  513. --/< Alternate function 0
  514. --/< Alternate function 1
  515. --/< Alternate function 2
  516. --/< Alternate function 3
  517. --/< Alternate function 4
  518. --/< Alternate function 5
  519. --/< Function select bits mask
  520. subtype bcm2835FunctionSelect is unsigned;
  521. BCM2835_GPIO_FSEL_INPT : constant bcm2835FunctionSelect := 0;
  522. BCM2835_GPIO_FSEL_OUTP : constant bcm2835FunctionSelect := 1;
  523. BCM2835_GPIO_FSEL_ALT0 : constant bcm2835FunctionSelect := 4;
  524. BCM2835_GPIO_FSEL_ALT1 : constant bcm2835FunctionSelect := 5;
  525. BCM2835_GPIO_FSEL_ALT2 : constant bcm2835FunctionSelect := 6;
  526. BCM2835_GPIO_FSEL_ALT3 : constant bcm2835FunctionSelect := 7;
  527. BCM2835_GPIO_FSEL_ALT4 : constant bcm2835FunctionSelect := 3;
  528. BCM2835_GPIO_FSEL_ALT5 : constant bcm2835FunctionSelect := 2;
  529. BCM2835_GPIO_FSEL_MASK : constant bcm2835FunctionSelect := 7; -- /usr/local/include/bcm2835.h:431
  530. --/ \brief bcm2835PUDControl
  531. --/ Pullup/Pulldown defines for bcm2835_gpio_pud()
  532. --/< Off ? disable pull-up/down
  533. --/< Enable Pull Down control
  534. --/< Enable Pull Up control
  535. type bcm2835PUDControl is
  536. (BCM2835_GPIO_PUD_OFF,
  537. BCM2835_GPIO_PUD_DOWN,
  538. BCM2835_GPIO_PUD_UP);
  539. pragma Convention (C, bcm2835PUDControl); -- /usr/local/include/bcm2835.h:440
  540. --BCM2835_GPIO_PUD_OFF : constant unsigned := 2#00#;
  541. --BCM2835_GPIO_PUD_DOWN : constant unsigned := 2#01#;
  542. --BCM2835_GPIO_PUD_UP : constant unsigned := 2#10#;
  543. --/ Pad control register offsets from BCM2835_GPIO_PADS
  544. --/ Pad Control masks
  545. --/ \brief bcm2835PadGroup
  546. --/ Pad group specification for bcm2835_gpio_pad()
  547. --/< Pad group for GPIO pads 0 to 27
  548. --/< Pad group for GPIO pads 28 to 45
  549. --/< Pad group for GPIO pads 46 to 53
  550. type bcm2835PadGroup is
  551. (BCM2835_PAD_GROUP_GPIO_0_27,
  552. BCM2835_PAD_GROUP_GPIO_28_45,
  553. BCM2835_PAD_GROUP_GPIO_46_53);
  554. pragma Convention (C, bcm2835PadGroup); -- /usr/local/include/bcm2835.h:467
  555. --BCM2835_PAD_GROUP_GPIO_0_27 : constant unsigned := 0;
  556. --BCM2835_PAD_GROUP_GPIO_28_45 : constant unsigned := 1;
  557. --BCM2835_PAD_GROUP_GPIO_46_53 : constant unsigned := 2;
  558. --/ \brief GPIO Pin Numbers
  559. --/
  560. --/ Here we define Raspberry Pin GPIO pins on P1 in terms of the underlying BCM GPIO pin numbers.
  561. --/ These can be passed as a pin number to any function requiring a pin.
  562. --/ Not all pins on the RPi 26 bin IDE plug are connected to GPIO pins
  563. --/ and some can adopt an alternate function.
  564. --/ RPi version 2 has some slightly different pinouts, and these are values RPI_V2_*.
  565. --/ At bootup, pins 8 and 10 are set to UART0_TXD, UART0_RXD (ie the alt0 function) respectively
  566. --/ When SPI0 is in use (ie after bcm2835_spi_begin()), pins 19, 21, 23, 24, 26 are dedicated to SPI
  567. --/ and cant be controlled independently
  568. --/< Version 1, Pin P1-03
  569. --/< Version 1, Pin P1-05
  570. --/< Version 1, Pin P1-07
  571. --/< Version 1, Pin P1-08, defaults to alt function 0 UART0_TXD
  572. --/< Version 1, Pin P1-10, defaults to alt function 0 UART0_RXD
  573. --/< Version 1, Pin P1-11
  574. --/< Version 1, Pin P1-12, can be PWM channel 0 in ALT FUN 5
  575. --/< Version 1, Pin P1-13
  576. --/< Version 1, Pin P1-15
  577. --/< Version 1, Pin P1-16
  578. --/< Version 1, Pin P1-18
  579. --/< Version 1, Pin P1-19, MOSI when SPI0 in use
  580. --/< Version 1, Pin P1-21, MISO when SPI0 in use
  581. --/< Version 1, Pin P1-22
  582. --/< Version 1, Pin P1-23, CLK when SPI0 in use
  583. --/< Version 1, Pin P1-24, CE0 when SPI0 in use
  584. --/< Version 1, Pin P1-26, CE1 when SPI0 in use
  585. -- RPi Version 2
  586. --/< Version 2, Pin P1-03
  587. --/< Version 2, Pin P1-05
  588. --/< Version 2, Pin P1-07
  589. --/< Version 2, Pin P1-08, defaults to alt function 0 UART0_TXD
  590. --/< Version 2, Pin P1-10, defaults to alt function 0 UART0_RXD
  591. --/< Version 2, Pin P1-11
  592. --/< Version 2, Pin P1-12, can be PWM channel 0 in ALT FUN 5
  593. --/< Version 2, Pin P1-13
  594. --/< Version 2, Pin P1-15
  595. --/< Version 2, Pin P1-16
  596. --/< Version 2, Pin P1-18
  597. --/< Version 2, Pin P1-19, MOSI when SPI0 in use
  598. --/< Version 2, Pin P1-21, MISO when SPI0 in use
  599. --/< Version 2, Pin P1-22
  600. --/< Version 2, Pin P1-23, CLK when SPI0 in use
  601. --/< Version 2, Pin P1-24, CE0 when SPI0 in use
  602. --/< Version 2, Pin P1-26, CE1 when SPI0 in use
  603. -- RPi Version 2, new plug P5
  604. --/< Version 2, Pin P5-03
  605. --/< Version 2, Pin P5-04
  606. --/< Version 2, Pin P5-05
  607. --/< Version 2, Pin P5-06
  608. subtype RPiGPIOPin is unsigned;
  609. RPI_GPIO_P1_03 : constant RPiGPIOPin := 0;
  610. RPI_GPIO_P1_05 : constant RPiGPIOPin := 1;
  611. RPI_GPIO_P1_07 : constant RPiGPIOPin := 4;
  612. RPI_GPIO_P1_08 : constant RPiGPIOPin := 14;
  613. RPI_GPIO_P1_10 : constant RPiGPIOPin := 15;
  614. RPI_GPIO_P1_11 : constant RPiGPIOPin := 17;
  615. RPI_GPIO_P1_12 : constant RPiGPIOPin := 18;
  616. RPI_GPIO_P1_13 : constant RPiGPIOPin := 21;
  617. RPI_GPIO_P1_15 : constant RPiGPIOPin := 22;
  618. RPI_GPIO_P1_16 : constant RPiGPIOPin := 23;
  619. RPI_GPIO_P1_18 : constant RPiGPIOPin := 24;
  620. RPI_GPIO_P1_19 : constant RPiGPIOPin := 10;
  621. RPI_GPIO_P1_21 : constant RPiGPIOPin := 9;
  622. RPI_GPIO_P1_22 : constant RPiGPIOPin := 25;
  623. RPI_GPIO_P1_23 : constant RPiGPIOPin := 11;
  624. RPI_GPIO_P1_24 : constant RPiGPIOPin := 8;
  625. RPI_GPIO_P1_26 : constant RPiGPIOPin := 7;
  626. RPI_V2_GPIO_P1_03 : constant RPiGPIOPin := 2;
  627. RPI_V2_GPIO_P1_05 : constant RPiGPIOPin := 3;
  628. RPI_V2_GPIO_P1_07 : constant RPiGPIOPin := 4;
  629. RPI_V2_GPIO_P1_08 : constant RPiGPIOPin := 14;
  630. RPI_V2_GPIO_P1_10 : constant RPiGPIOPin := 15;
  631. RPI_V2_GPIO_P1_11 : constant RPiGPIOPin := 17;
  632. RPI_V2_GPIO_P1_12 : constant RPiGPIOPin := 18;
  633. RPI_V2_GPIO_P1_13 : constant RPiGPIOPin := 27;
  634. RPI_V2_GPIO_P1_15 : constant RPiGPIOPin := 22;
  635. RPI_V2_GPIO_P1_16 : constant RPiGPIOPin := 23;
  636. RPI_V2_GPIO_P1_18 : constant RPiGPIOPin := 24;
  637. RPI_V2_GPIO_P1_19 : constant RPiGPIOPin := 10;
  638. RPI_V2_GPIO_P1_21 : constant RPiGPIOPin := 9;
  639. RPI_V2_GPIO_P1_22 : constant RPiGPIOPin := 25;
  640. RPI_V2_GPIO_P1_23 : constant RPiGPIOPin := 11;
  641. RPI_V2_GPIO_P1_24 : constant RPiGPIOPin := 8;
  642. RPI_V2_GPIO_P1_26 : constant RPiGPIOPin := 7;
  643. RPI_V2_GPIO_P5_03 : constant RPiGPIOPin := 28;
  644. RPI_V2_GPIO_P5_04 : constant RPiGPIOPin := 29;
  645. RPI_V2_GPIO_P5_05 : constant RPiGPIOPin := 30;
  646. RPI_V2_GPIO_P5_06 : constant RPiGPIOPin := 31; -- /usr/local/include/bcm2835.h:524
  647. -- Defines for SPI
  648. -- GPIO register offsets from BCM2835_SPI0_BASE.
  649. -- Offsets into the SPI Peripheral block in bytes per 10.5 SPI Register Map
  650. -- Register masks for SPI0_CS
  651. --/ \brief bcm2835SPIBitOrder SPI Bit order
  652. --/ Specifies the SPI data bit ordering for bcm2835_spi_setBitOrder()
  653. --/< LSB First
  654. --/< MSB First
  655. type bcm2835SPIBitOrder is
  656. (BCM2835_SPI_BIT_ORDER_LSBFIRST,
  657. BCM2835_SPI_BIT_ORDER_MSBFIRST);
  658. pragma Convention (C, bcm2835SPIBitOrder); -- /usr/local/include/bcm2835.h:570
  659. --BCM2835_SPI_BIT_ORDER_LSBFIRST : constant unsigned := 0;
  660. --BCM2835_SPI_BIT_ORDER_MSBFIRST : constant unsigned := 1;
  661. --/ \brief SPI Data mode
  662. --/ Specify the SPI data mode to be passed to bcm2835_spi_setDataMode()
  663. --/< CPOL = 0, CPHA = 0
  664. --/< CPOL = 0, CPHA = 1
  665. --/< CPOL = 1, CPHA = 0
  666. --/< CPOL = 1, CPHA = 1
  667. type bcm2835SPIMode is
  668. (BCM2835_SPI_MODE0,
  669. BCM2835_SPI_MODE1,
  670. BCM2835_SPI_MODE2,
  671. BCM2835_SPI_MODE3);
  672. pragma Convention (C, bcm2835SPIMode); -- /usr/local/include/bcm2835.h:580
  673. --BCM2835_SPI_MODE0 : constant unsigned := 0;
  674. --BCM2835_SPI_MODE1 : constant unsigned := 1;
  675. --BCM2835_SPI_MODE2 : constant unsigned := 2;
  676. --BCM2835_SPI_MODE3 : constant unsigned := 3;
  677. --/ \brief bcm2835SPIChipSelect
  678. --/ Specify the SPI chip select pin(s)
  679. --/< Chip Select 0
  680. --/< Chip Select 1
  681. --/< Chip Select 2 (ie pins CS1 and CS2 are asserted)
  682. --/< No CS, control it yourself
  683. type bcm2835SPIChipSelect is
  684. (BCM2835_SPI_CS0,
  685. BCM2835_SPI_CS1,
  686. BCM2835_SPI_CS2,
  687. BCM2835_SPI_CS_NONE);
  688. pragma Convention (C, bcm2835SPIChipSelect); -- /usr/local/include/bcm2835.h:590
  689. --BCM2835_SPI_CS0 : constant unsigned := 0;
  690. --BCM2835_SPI_CS1 : constant unsigned := 1;
  691. --BCM2835_SPI_CS2 : constant unsigned := 2;
  692. --BCM2835_SPI_CS_NONE : constant unsigned := 3;
  693. --/ \brief bcm2835SPIClockDivider
  694. --/ Specifies the divider used to generate the SPI clock from the system clock.
  695. --/ Figures below give the divider, clock period and clock frequency.
  696. --/ Clock divided is based on nominal base clock rate of 250MHz
  697. --/ It is reported that (contrary to the documentation) any even divider may used.
  698. --/ The frequencies shown for each divider have been confirmed by measurement
  699. --/< 65536 = 262.144us = 3.814697260kHz
  700. --/< 32768 = 131.072us = 7.629394531kHz
  701. --/< 16384 = 65.536us = 15.25878906kHz
  702. --/< 8192 = 32.768us = 30/51757813kHz
  703. --/< 4096 = 16.384us = 61.03515625kHz
  704. --/< 2048 = 8.192us = 122.0703125kHz
  705. --/< 1024 = 4.096us = 244.140625kHz
  706. --/< 512 = 2.048us = 488.28125kHz
  707. --/< 256 = 1.024us = 976.5625MHz
  708. --/< 128 = 512ns = = 1.953125MHz
  709. --/< 64 = 256ns = 3.90625MHz
  710. --/< 32 = 128ns = 7.8125MHz
  711. --/< 16 = 64ns = 15.625MHz
  712. --/< 8 = 32ns = 31.25MHz
  713. --/< 4 = 16ns = 62.5MHz
  714. --/< 2 = 8ns = 125MHz, fastest you can get
  715. --/< 1 = 262.144us = 3.814697260kHz, same as 0/65536
  716. subtype bcm2835SPIClockDivider is unsigned;
  717. BCM2835_SPI_CLOCK_DIVIDER_65536 : constant bcm2835SPIClockDivider := 0;
  718. BCM2835_SPI_CLOCK_DIVIDER_32768 : constant bcm2835SPIClockDivider := 32768;
  719. BCM2835_SPI_CLOCK_DIVIDER_16384 : constant bcm2835SPIClockDivider := 16384;
  720. BCM2835_SPI_CLOCK_DIVIDER_8192 : constant bcm2835SPIClockDivider := 8192;
  721. BCM2835_SPI_CLOCK_DIVIDER_4096 : constant bcm2835SPIClockDivider := 4096;
  722. BCM2835_SPI_CLOCK_DIVIDER_2048 : constant bcm2835SPIClockDivider := 2048;
  723. BCM2835_SPI_CLOCK_DIVIDER_1024 : constant bcm2835SPIClockDivider := 1024;
  724. BCM2835_SPI_CLOCK_DIVIDER_512 : constant bcm2835SPIClockDivider := 512;
  725. BCM2835_SPI_CLOCK_DIVIDER_256 : constant bcm2835SPIClockDivider := 256;
  726. BCM2835_SPI_CLOCK_DIVIDER_128 : constant bcm2835SPIClockDivider := 128;
  727. BCM2835_SPI_CLOCK_DIVIDER_64 : constant bcm2835SPIClockDivider := 64;
  728. BCM2835_SPI_CLOCK_DIVIDER_32 : constant bcm2835SPIClockDivider := 32;
  729. BCM2835_SPI_CLOCK_DIVIDER_16 : constant bcm2835SPIClockDivider := 16;
  730. BCM2835_SPI_CLOCK_DIVIDER_8 : constant bcm2835SPIClockDivider := 8;
  731. BCM2835_SPI_CLOCK_DIVIDER_4 : constant bcm2835SPIClockDivider := 4;
  732. BCM2835_SPI_CLOCK_DIVIDER_2 : constant bcm2835SPIClockDivider := 2;
  733. BCM2835_SPI_CLOCK_DIVIDER_1 : constant bcm2835SPIClockDivider := 1; -- /usr/local/include/bcm2835.h:617
  734. -- Defines for I2C
  735. -- GPIO register offsets from BCM2835_BSC*_BASE.
  736. -- Offsets into the BSC Peripheral block in bytes per 3.1 BSC Register Map
  737. -- Register masks for BSC_C
  738. -- Register masks for BSC_S
  739. --/ \brief bcm2835I2CClockDivider
  740. --/ Specifies the divider used to generate the I2C clock from the system clock.
  741. --/ Clock divided is based on nominal base clock rate of 250MHz
  742. --/< 2500 = 10us = 100 kHz
  743. --/< 622 = 2.504us = 399.3610 kHz
  744. --/< 150 = 60ns = 1.666 MHz (default at reset)
  745. --/< 148 = 59ns = 1.689 MHz
  746. subtype bcm2835I2CClockDivider is unsigned;
  747. BCM2835_I2C_CLOCK_DIVIDER_2500 : constant bcm2835I2CClockDivider := 2500;
  748. BCM2835_I2C_CLOCK_DIVIDER_626 : constant bcm2835I2CClockDivider := 626;
  749. BCM2835_I2C_CLOCK_DIVIDER_150 : constant bcm2835I2CClockDivider := 150;
  750. BCM2835_I2C_CLOCK_DIVIDER_148 : constant bcm2835I2CClockDivider := 148; -- /usr/local/include/bcm2835.h:664
  751. --/ \brief bcm2835I2CReasonCodes
  752. --/ Specifies the reason codes for the bcm2835_i2c_write and bcm2835_i2c_read functions.
  753. --/< Success
  754. --/< Received a NACK
  755. --/< Received Clock Stretch Timeout
  756. --/< Not all data is sent / received
  757. subtype bcm2835I2CReasonCodes is unsigned;
  758. BCM2835_I2C_REASON_OK : constant bcm2835I2CReasonCodes := 0;
  759. BCM2835_I2C_REASON_ERROR_NACK : constant bcm2835I2CReasonCodes := 1;
  760. BCM2835_I2C_REASON_ERROR_CLKT : constant bcm2835I2CReasonCodes := 2;
  761. BCM2835_I2C_REASON_ERROR_DATA : constant bcm2835I2CReasonCodes := 4; -- /usr/local/include/bcm2835.h:674
  762. -- Defines for ST
  763. -- GPIO register offsets from BCM2835_ST_BASE.
  764. -- Offsets into the ST Peripheral block in bytes per 12.1 System Timer Registers
  765. -- The System Timer peripheral provides four 32-bit timer channels and a single 64-bit free running counter.
  766. -- BCM2835_ST_CLO is the System Timer Counter Lower bits register.
  767. -- The system timer free-running counter lower register is a read-only register that returns the current value
  768. -- of the lower 32-bits of the free running counter.
  769. -- BCM2835_ST_CHI is the System Timer Counter Upper bits register.
  770. -- The system timer free-running counter upper register is a read-only register that returns the current value
  771. -- of the upper 32-bits of the free running counter.
  772. --/ @}
  773. -- Defines for PWM, word offsets (ie 4 byte multiples)
  774. -- Defines for PWM Clock, word offsets (ie 4 byte multiples)
  775. --/ \brief bcm2835PWMClockDivider
  776. --/ Specifies the divider used to generate the PWM clock from the system clock.
  777. --/ Figures below give the divider, clock period and clock frequency.
  778. --/ Clock divided is based on nominal PWM base clock rate of 19.2MHz
  779. --/ The frequencies shown for each divider have been confirmed by measurement
  780. --/< 32768 = 585Hz
  781. --/< 16384 = 1171.8Hz
  782. --/< 8192 = 2.34375kHz
  783. --/< 4096 = 4.6875kHz
  784. --/< 2048 = 9.375kHz
  785. --/< 1024 = 18.75kHz
  786. --/< 512 = 37.5kHz
  787. --/< 256 = 75kHz
  788. --/< 128 = 150kHz
  789. --/< 64 = 300kHz
  790. --/< 32 = 600.0kHz
  791. --/< 16 = 1.2MHz
  792. --/< 8 = 2.4MHz
  793. --/< 4 = 4.8MHz
  794. --/< 2 = 9.6MHz, fastest you can get
  795. --/< 1 = 4.6875kHz, same as divider 4096
  796. subtype bcm2835PWMClockDivider is unsigned;
  797. BCM2835_PWM_CLOCK_DIVIDER_32768 : constant bcm2835PWMClockDivider := 32768;
  798. BCM2835_PWM_CLOCK_DIVIDER_16384 : constant bcm2835PWMClockDivider := 16384;
  799. BCM2835_PWM_CLOCK_DIVIDER_8192 : constant bcm2835PWMClockDivider := 8192;
  800. BCM2835_PWM_CLOCK_DIVIDER_4096 : constant bcm2835PWMClockDivider := 4096;
  801. BCM2835_PWM_CLOCK_DIVIDER_2048 : constant bcm2835PWMClockDivider := 2048;
  802. BCM2835_PWM_CLOCK_DIVIDER_1024 : constant bcm2835PWMClockDivider := 1024;
  803. BCM2835_PWM_CLOCK_DIVIDER_512 : constant bcm2835PWMClockDivider := 512;
  804. BCM2835_PWM_CLOCK_DIVIDER_256 : constant bcm2835PWMClockDivider := 256;
  805. BCM2835_PWM_CLOCK_DIVIDER_128 : constant bcm2835PWMClockDivider := 128;
  806. BCM2835_PWM_CLOCK_DIVIDER_64 : constant bcm2835PWMClockDivider := 64;
  807. BCM2835_PWM_CLOCK_DIVIDER_32 : constant bcm2835PWMClockDivider := 32;
  808. BCM2835_PWM_CLOCK_DIVIDER_16 : constant bcm2835PWMClockDivider := 16;
  809. BCM2835_PWM_CLOCK_DIVIDER_8 : constant bcm2835PWMClockDivider := 8;
  810. BCM2835_PWM_CLOCK_DIVIDER_4 : constant bcm2835PWMClockDivider := 4;
  811. BCM2835_PWM_CLOCK_DIVIDER_2 : constant bcm2835PWMClockDivider := 2;
  812. BCM2835_PWM_CLOCK_DIVIDER_1 : constant bcm2835PWMClockDivider := 1; -- /usr/local/include/bcm2835.h:748
  813. -- Historical name compatibility
  814. --/ \defgroup init Library initialisation and management
  815. --/ These functions allow you to intialise and control the bcm2835 library
  816. --/ @{
  817. --/ Initialise the library by opening /dev/mem and getting pointers to the
  818. --/ internal memory for BCM 2835 device registers. You must call this (successfully)
  819. --/ before calling any other
  820. --/ functions in this library (except bcm2835_set_debug).
  821. --/ If bcm2835_init() fails by returning 0,
  822. --/ calling any other function may result in crashes or other failures.
  823. --/ Prints messages to stderr in case of errors.
  824. --/ \return 1 if successful else 0
  825. function bcm2835_init return int; -- /usr/local/include/bcm2835.h:772
  826. pragma Import (C, bcm2835_init, "bcm2835_init");
  827. --/ Close the library, deallocating any allocated memory and closing /dev/mem
  828. --/ \return 1 if successful else 0
  829. function bcm2835_close return int; -- /usr/local/include/bcm2835.h:776
  830. pragma Import (C, bcm2835_close, "bcm2835_close");
  831. --/ Sets the debug level of the library.
  832. --/ A value of 1 prevents mapping to /dev/mem, and makes the library print out
  833. --/ what it would do, rather than accessing the GPIO registers.
  834. --/ A value of 0, the default, causes normal operation.
  835. --/ Call this before calling bcm2835_init();
  836. --/ \param[in] debug The new debug level. 1 means debug
  837. procedure bcm2835_set_debug (debug : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:784
  838. pragma Import (C, bcm2835_set_debug, "bcm2835_set_debug");
  839. --/ @} // end of init
  840. --/ \defgroup lowlevel Low level register access
  841. --/ These functions provide low level register access, and should not generally
  842. --/ need to be used
  843. --/
  844. --/ @{
  845. --/ Reads 32 bit value from a peripheral address
  846. --/ The read is done twice, and is therefore always safe in terms of
  847. --/ manual section 1.3 Peripheral access precautions for correct memory ordering
  848. --/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
  849. --/ \return the value read from the 32 bit register
  850. --/ \sa Physical Addresses
  851. function bcm2835_peri_read (paddr : access stdint_h.uint32_t) return stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:800
  852. pragma Import (C, bcm2835_peri_read, "bcm2835_peri_read");
  853. --/ Reads 32 bit value from a peripheral address without the read barrier
  854. --/ You should only use this when your code has previously called bcm2835_peri_read()
  855. --/ within the same peripheral, and no other peripheral access has occurred since.
  856. --/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
  857. --/ \return the value read from the 32 bit register
  858. --/ \sa Physical Addresses
  859. function bcm2835_peri_read_nb (paddr : access stdint_h.uint32_t) return stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:809
  860. pragma Import (C, bcm2835_peri_read_nb, "bcm2835_peri_read_nb");
  861. --/ Writes 32 bit value from a peripheral address
  862. --/ The write is done twice, and is therefore always safe in terms of
  863. --/ manual section 1.3 Peripheral access precautions for correct memory ordering
  864. --/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
  865. --/ \param[in] value The 32 bit value to write
  866. --/ \sa Physical Addresses
  867. procedure bcm2835_peri_write (paddr : access stdint_h.uint32_t; value : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:818
  868. pragma Import (C, bcm2835_peri_write, "bcm2835_peri_write");
  869. --/ Writes 32 bit value from a peripheral address without the write barrier
  870. --/ You should only use this when your code has previously called bcm2835_peri_write()
  871. --/ within the same peripheral, and no other peripheral access has occurred since.
  872. --/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
  873. --/ \param[in] value The 32 bit value to write
  874. --/ \sa Physical Addresses
  875. procedure bcm2835_peri_write_nb (paddr : access stdint_h.uint32_t; value : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:826
  876. pragma Import (C, bcm2835_peri_write_nb, "bcm2835_peri_write_nb");
  877. --/ Alters a number of bits in a 32 peripheral regsiter.
  878. --/ It reads the current valu and then alters the bits deines as 1 in mask,
  879. --/ according to the bit value in value.
  880. --/ All other bits that are 0 in the mask are unaffected.
  881. --/ Use this to alter a subset of the bits in a register.
  882. --/ The write is done twice, and is therefore always safe in terms of
  883. --/ manual section 1.3 Peripheral access precautions for correct memory ordering
  884. --/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
  885. --/ \param[in] value The 32 bit value to write, masked in by mask.
  886. --/ \param[in] mask Bitmask that defines the bits that will be altered in the register.
  887. --/ \sa Physical Addresses
  888. procedure bcm2835_peri_set_bits
  889. (paddr : access stdint_h.uint32_t;
  890. value : stdint_h.uint32_t;
  891. mask : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:839
  892. pragma Import (C, bcm2835_peri_set_bits, "bcm2835_peri_set_bits");
  893. --/ @} // end of lowlevel
  894. --/ \defgroup gpio GPIO register access
  895. --/ These functions allow you to control the GPIO interface. You can set the
  896. --/ function of each GPIO pin, read the input state and set the output state.
  897. --/ @{
  898. --/ Sets the Function Select register for the given pin, which configures
  899. --/ the pin as Input, Output or one of the 6 alternate functions.
  900. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  901. --/ \param[in] mode Mode to set the pin to, one of BCM2835_GPIO_FSEL_* from \ref bcm2835FunctionSelect
  902. procedure bcm2835_gpio_fsel (pin : stdint_h.uint8_t; mode : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:851
  903. pragma Import (C, bcm2835_gpio_fsel, "bcm2835_gpio_fsel");
  904. --/ Sets the specified pin output to
  905. --/ HIGH.
  906. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  907. --/ \sa bcm2835_gpio_write()
  908. procedure bcm2835_gpio_set (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:857
  909. pragma Import (C, bcm2835_gpio_set, "bcm2835_gpio_set");
  910. --/ Sets the specified pin output to
  911. --/ LOW.
  912. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  913. --/ \sa bcm2835_gpio_write()
  914. procedure bcm2835_gpio_clr (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:863
  915. pragma Import (C, bcm2835_gpio_clr, "bcm2835_gpio_clr");
  916. --/ Sets any of the first 32 GPIO output pins specified in the mask to
  917. --/ HIGH.
  918. --/ \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05)
  919. --/ \sa bcm2835_gpio_write_multi()
  920. procedure bcm2835_gpio_set_multi (mask : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:869
  921. pragma Import (C, bcm2835_gpio_set_multi, "bcm2835_gpio_set_multi");
  922. --/ Sets any of the first 32 GPIO output pins specified in the mask to
  923. --/ LOW.
  924. --/ \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05)
  925. --/ \sa bcm2835_gpio_write_multi()
  926. procedure bcm2835_gpio_clr_multi (mask : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:875
  927. pragma Import (C, bcm2835_gpio_clr_multi, "bcm2835_gpio_clr_multi");
  928. --/ Reads the current level on the specified
  929. --/ pin and returns either HIGH or LOW. Works whether or not the pin
  930. --/ is an input or an output.
  931. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  932. --/ \return the current level either HIGH or LOW
  933. function bcm2835_gpio_lev (pin : stdint_h.uint8_t) return stdint_h.uint8_t; -- /usr/local/include/bcm2835.h:882
  934. pragma Import (C, bcm2835_gpio_lev, "bcm2835_gpio_lev");
  935. --/ Event Detect Status.
  936. --/ Tests whether the specified pin has detected a level or edge
  937. --/ as requested by bcm2835_gpio_ren(), bcm2835_gpio_fen(), bcm2835_gpio_hen(),
  938. --/ bcm2835_gpio_len(), bcm2835_gpio_aren(), bcm2835_gpio_afen().
  939. --/ Clear the flag for a given pin by calling bcm2835_gpio_set_eds(pin);
  940. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  941. --/ \return HIGH if the event detect status for the given pin is true.
  942. function bcm2835_gpio_eds (pin : stdint_h.uint8_t) return stdint_h.uint8_t; -- /usr/local/include/bcm2835.h:891
  943. pragma Import (C, bcm2835_gpio_eds, "bcm2835_gpio_eds");
  944. --/ Sets the Event Detect Status register for a given pin to 1,
  945. --/ which has the effect of clearing the flag. Use this afer seeing
  946. --/ an Event Detect Status on the pin.
  947. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  948. procedure bcm2835_gpio_set_eds (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:897
  949. pragma Import (C, bcm2835_gpio_set_eds, "bcm2835_gpio_set_eds");
  950. --/ Enable Rising Edge Detect Enable for the specified pin.
  951. --/ When a rising edge is detected, sets the appropriate pin in Event Detect Status.
  952. --/ The GPRENn registers use
  953. --/ synchronous edge detection. This means the input signal is sampled using the
  954. --/ system clock and then it is looking for a ?011? pattern on the sampled signal. This
  955. --/ has the effect of suppressing glitches.
  956. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  957. procedure bcm2835_gpio_ren (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:906
  958. pragma Import (C, bcm2835_gpio_ren, "bcm2835_gpio_ren");
  959. --/ Disable Rising Edge Detect Enable for the specified pin.
  960. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  961. procedure bcm2835_gpio_clr_ren (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:910
  962. pragma Import (C, bcm2835_gpio_clr_ren, "bcm2835_gpio_clr_ren");
  963. --/ Enable Falling Edge Detect Enable for the specified pin.
  964. --/ When a falling edge is detected, sets the appropriate pin in Event Detect Status.
  965. --/ The GPRENn registers use
  966. --/ synchronous edge detection. This means the input signal is sampled using the
  967. --/ system clock and then it is looking for a ?100? pattern on the sampled signal. This
  968. --/ has the effect of suppressing glitches.
  969. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  970. procedure bcm2835_gpio_fen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:919
  971. pragma Import (C, bcm2835_gpio_fen, "bcm2835_gpio_fen");
  972. --/ Disable Falling Edge Detect Enable for the specified pin.
  973. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  974. procedure bcm2835_gpio_clr_fen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:923
  975. pragma Import (C, bcm2835_gpio_clr_fen, "bcm2835_gpio_clr_fen");
  976. --/ Enable High Detect Enable for the specified pin.
  977. --/ When a HIGH level is detected on the pin, sets the appropriate pin in Event Detect Status.
  978. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  979. procedure bcm2835_gpio_hen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:928
  980. pragma Import (C, bcm2835_gpio_hen, "bcm2835_gpio_hen");
  981. --/ Disable High Detect Enable for the specified pin.
  982. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  983. procedure bcm2835_gpio_clr_hen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:932
  984. pragma Import (C, bcm2835_gpio_clr_hen, "bcm2835_gpio_clr_hen");
  985. --/ Enable Low Detect Enable for the specified pin.
  986. --/ When a LOW level is detected on the pin, sets the appropriate pin in Event Detect Status.
  987. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  988. procedure bcm2835_gpio_len (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:937
  989. pragma Import (C, bcm2835_gpio_len, "bcm2835_gpio_len");
  990. --/ Disable Low Detect Enable for the specified pin.
  991. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  992. procedure bcm2835_gpio_clr_len (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:941
  993. pragma Import (C, bcm2835_gpio_clr_len, "bcm2835_gpio_clr_len");
  994. --/ Enable Asynchronous Rising Edge Detect Enable for the specified pin.
  995. --/ When a rising edge is detected, sets the appropriate pin in Event Detect Status.
  996. --/ Asynchronous means the incoming signal is not sampled by the system clock. As such
  997. --/ rising edges of very short duration can be detected.
  998. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  999. procedure bcm2835_gpio_aren (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:948
  1000. pragma Import (C, bcm2835_gpio_aren, "bcm2835_gpio_aren");
  1001. --/ Disable Asynchronous Rising Edge Detect Enable for the specified pin.
  1002. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  1003. procedure bcm2835_gpio_clr_aren (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:952
  1004. pragma Import (C, bcm2835_gpio_clr_aren, "bcm2835_gpio_clr_aren");
  1005. --/ Enable Asynchronous Falling Edge Detect Enable for the specified pin.
  1006. --/ When a falling edge is detected, sets the appropriate pin in Event Detect Status.
  1007. --/ Asynchronous means the incoming signal is not sampled by the system clock. As such
  1008. --/ falling edges of very short duration can be detected.
  1009. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  1010. procedure bcm2835_gpio_afen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:959
  1011. pragma Import (C, bcm2835_gpio_afen, "bcm2835_gpio_afen");
  1012. --/ Disable Asynchronous Falling Edge Detect Enable for the specified pin.
  1013. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  1014. procedure bcm2835_gpio_clr_afen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:963
  1015. pragma Import (C, bcm2835_gpio_clr_afen, "bcm2835_gpio_clr_afen");
  1016. --/ Sets the Pull-up/down register for the given pin. This is
  1017. --/ used with bcm2835_gpio_pudclk() to set the Pull-up/down resistor for the given pin.
  1018. --/ However, it is usually more convenient to use bcm2835_gpio_set_pud().
  1019. --/ \param[in] pud The desired Pull-up/down mode. One of BCM2835_GPIO_PUD_* from bcm2835PUDControl
  1020. --/ \sa bcm2835_gpio_set_pud()
  1021. procedure bcm2835_gpio_pud (pud : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:970
  1022. pragma Import (C, bcm2835_gpio_pud, "bcm2835_gpio_pud");
  1023. --/ Clocks the Pull-up/down value set earlier by bcm2835_gpio_pud() into the pin.
  1024. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  1025. --/ \param[in] on HIGH to clock the value from bcm2835_gpio_pud() into the pin.
  1026. --/ LOW to remove the clock.
  1027. --/ \sa bcm2835_gpio_set_pud()
  1028. procedure bcm2835_gpio_pudclk (pin : stdint_h.uint8_t; on : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:977
  1029. pragma Import (C, bcm2835_gpio_pudclk, "bcm2835_gpio_pudclk");
  1030. --/ Reads and returns the Pad Control for the given GPIO group.
  1031. --/ \param[in] group The GPIO pad group number, one of BCM2835_PAD_GROUP_GPIO_*
  1032. --/ \return Mask of bits from BCM2835_PAD_* from \ref bcm2835PadGroup
  1033. function bcm2835_gpio_pad (group : stdint_h.uint8_t) return stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:982
  1034. pragma Import (C, bcm2835_gpio_pad, "bcm2835_gpio_pad");
  1035. --/ Sets the Pad Control for the given GPIO group.
  1036. --/ \param[in] group The GPIO pad group number, one of BCM2835_PAD_GROUP_GPIO_*
  1037. --/ \param[in] control Mask of bits from BCM2835_PAD_* from \ref bcm2835PadGroup. Note
  1038. --/ that it is not necessary to include BCM2835_PAD_PASSWRD in the mask as this
  1039. --/ is automatically included.
  1040. procedure bcm2835_gpio_set_pad (group : stdint_h.uint8_t; control : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:989
  1041. pragma Import (C, bcm2835_gpio_set_pad, "bcm2835_gpio_set_pad");
  1042. --/ Delays for the specified number of milliseconds.
  1043. --/ Uses nanosleep(), and therefore does not use CPU until the time is up.
  1044. --/ However, you are at the mercy of nanosleep(). From the manual for nanosleep():
  1045. --/ If the interval specified in req is not an exact multiple of the granularity
  1046. --/ underlying clock (see time(7)), then the interval will be
  1047. --/ rounded up to the next multiple. Furthermore, after the sleep completes,
  1048. --/ there may still be a delay before the CPU becomes free to once
  1049. --/ again execute the calling thread.
  1050. --/ \param[in] millis Delay in milliseconds
  1051. procedure bcm2835_delay (millis : unsigned); -- /usr/local/include/bcm2835.h:1000
  1052. pragma Import (C, bcm2835_delay, "bcm2835_delay");
  1053. --/ Delays for the specified number of microseconds.
  1054. --/ Uses a combination of nanosleep() and a busy wait loop on the BCM2835 system timers,
  1055. --/ However, you are at the mercy of nanosleep(). From the manual for nanosleep():
  1056. --/ If the interval specified in req is not an exact multiple of the granularity
  1057. --/ underlying clock (see time(7)), then the interval will be
  1058. --/ rounded up to the next multiple. Furthermore, after the sleep completes,
  1059. --/ there may still be a delay before the CPU becomes free to once
  1060. --/ again execute the calling thread.
  1061. --/ For times less than about 450 microseconds, uses a busy wait on the System Timer.
  1062. --/ It is reported that a delay of 0 microseconds on RaspberryPi will in fact
  1063. --/ result in a delay of about 80 microseconds. Your mileage may vary.
  1064. --/ \param[in] micros Delay in microseconds
  1065. procedure bcm2835_delayMicroseconds (micros : stdint_h.uint64_t); -- /usr/local/include/bcm2835.h:1014
  1066. pragma Import (C, bcm2835_delayMicroseconds, "bcm2835_delayMicroseconds");
  1067. --/ Sets the output state of the specified pin
  1068. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  1069. --/ \param[in] on HIGH sets the output to HIGH and LOW to LOW.
  1070. procedure bcm2835_gpio_write (pin : stdint_h.uint8_t; on : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1019
  1071. pragma Import (C, bcm2835_gpio_write, "bcm2835_gpio_write");
  1072. --/ Sets any of the first 32 GPIO output pins specified in the mask to the state given by on
  1073. --/ \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05)
  1074. --/ \param[in] on HIGH sets the output to HIGH and LOW to LOW.
  1075. procedure bcm2835_gpio_write_multi (mask : stdint_h.uint32_t; on : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1024
  1076. pragma Import (C, bcm2835_gpio_write_multi, "bcm2835_gpio_write_multi");
  1077. --/ Sets the first 32 GPIO output pins specified in the mask to the value given by value
  1078. --/ \param[in] value values required for each bit masked in by mask, eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05)
  1079. --/ \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05)
  1080. procedure bcm2835_gpio_write_mask (value : stdint_h.uint32_t; mask : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1029
  1081. pragma Import (C, bcm2835_gpio_write_mask, "bcm2835_gpio_write_mask");
  1082. --/ Sets the Pull-up/down mode for the specified pin. This is more convenient than
  1083. --/ clocking the mode in with bcm2835_gpio_pud() and bcm2835_gpio_pudclk().
  1084. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  1085. --/ \param[in] pud The desired Pull-up/down mode. One of BCM2835_GPIO_PUD_* from bcm2835PUDControl
  1086. procedure bcm2835_gpio_set_pud (pin : stdint_h.uint8_t; pud : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1035
  1087. pragma Import (C, bcm2835_gpio_set_pud, "bcm2835_gpio_set_pud");
  1088. --/ @}
  1089. --/ \defgroup spi SPI access
  1090. --/ These functions let you use SPI0 (Serial Peripheral Interface) to
  1091. --/ interface with an external SPI device.
  1092. --/ @{
  1093. --/ Start SPI operations.
  1094. --/ Forces RPi SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1)
  1095. --/ to alternate function ALT0, which enables those pins for SPI interface.
  1096. --/ You should call bcm2835_spi_end() when all SPI funcitons are complete to return the pins to
  1097. --/ their default functions
  1098. --/ \sa bcm2835_spi_end()
  1099. procedure bcm2835_spi_begin; -- /usr/local/include/bcm2835.h:1050
  1100. pragma Import (C, bcm2835_spi_begin, "bcm2835_spi_begin");
  1101. --/ End SPI operations.
  1102. --/ SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1)
  1103. --/ are returned to their default INPUT behaviour.
  1104. procedure bcm2835_spi_end; -- /usr/local/include/bcm2835.h:1055
  1105. pragma Import (C, bcm2835_spi_end, "bcm2835_spi_end");
  1106. --/ Sets the SPI bit order
  1107. --/ NOTE: has no effect. Not supported by SPI0.
  1108. --/ Defaults to
  1109. --/ \param[in] order The desired bit order, one of BCM2835_SPI_BIT_ORDER_*,
  1110. --/ see \ref bcm2835SPIBitOrder
  1111. procedure bcm2835_spi_setBitOrder (order : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1062
  1112. pragma Import (C, bcm2835_spi_setBitOrder, "bcm2835_spi_setBitOrder");
  1113. --/ Sets the SPI clock divider and therefore the
  1114. --/ SPI clock speed.
  1115. --/ \param[in] divider The desired SPI clock divider, one of BCM2835_SPI_CLOCK_DIVIDER_*,
  1116. --/ see \ref bcm2835SPIClockDivider
  1117. procedure bcm2835_spi_setClockDivider (divider : stdint_h.uint16_t); -- /usr/local/include/bcm2835.h:1068
  1118. pragma Import (C, bcm2835_spi_setClockDivider, "bcm2835_spi_setClockDivider");
  1119. --/ Sets the SPI data mode
  1120. --/ Sets the clock polariy and phase
  1121. --/ \param[in] mode The desired data mode, one of BCM2835_SPI_MODE*,
  1122. --/ see \ref bcm2835SPIMode
  1123. procedure bcm2835_spi_setDataMode (mode : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1074
  1124. pragma Import (C, bcm2835_spi_setDataMode, "bcm2835_spi_setDataMode");
  1125. --/ Sets the chip select pin(s)
  1126. --/ When an bcm2835_spi_transfer() is made, the selected pin(s) will be asserted during the
  1127. --/ transfer.
  1128. --/ \param[in] cs Specifies the CS pins(s) that are used to activate the desired slave.
  1129. --/ One of BCM2835_SPI_CS*, see \ref bcm2835SPIChipSelect
  1130. procedure bcm2835_spi_chipSelect (cs : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1081
  1131. pragma Import (C, bcm2835_spi_chipSelect, "bcm2835_spi_chipSelect");
  1132. --/ Sets the chip select pin polarity for a given pin
  1133. --/ When an bcm2835_spi_transfer() occurs, the currently selected chip select pin(s)
  1134. --/ will be asserted to the
  1135. --/ value given by active. When transfers are not happening, the chip select pin(s)
  1136. --/ return to the complement (inactive) value.
  1137. --/ \param[in] cs The chip select pin to affect
  1138. --/ \param[in] active Whether the chip select pin is to be active HIGH
  1139. procedure bcm2835_spi_setChipSelectPolarity (cs : stdint_h.uint8_t; active : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1090
  1140. pragma Import (C, bcm2835_spi_setChipSelectPolarity, "bcm2835_spi_setChipSelectPolarity");
  1141. --/ Transfers one byte to and from the currently selected SPI slave.
  1142. --/ Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect)
  1143. --/ during the transfer.
  1144. --/ Clocks the 8 bit value out on MOSI, and simultaneously clocks in data from MISO.
  1145. --/ Returns the read data byte from the slave.
  1146. --/ Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM Peripherls manual
  1147. --/ \param[in] value The 8 bit data byte to write to MOSI
  1148. --/ \return The 8 bit byte simultaneously read from MISO
  1149. --/ \sa bcm2835_spi_transfern()
  1150. function bcm2835_spi_transfer (value : stdint_h.uint8_t) return stdint_h.uint8_t; -- /usr/local/include/bcm2835.h:1101
  1151. pragma Import (C, bcm2835_spi_transfer, "bcm2835_spi_transfer");
  1152. --/ Transfers any number of bytes to and from the currently selected SPI slave.
  1153. --/ Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect)
  1154. --/ during the transfer.
  1155. --/ Clocks the len 8 bit bytes out on MOSI, and simultaneously clocks in data from MISO.
  1156. --/ The data read read from the slave is placed into rbuf. rbuf must be at least len bytes long
  1157. --/ Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM Peripherls manual
  1158. --/ \param[in] tbuf Buffer of bytes to send.
  1159. --/ \param[out] rbuf Received bytes will by put in this buffer
  1160. --/ \param[in] len Number of bytes in the tbuf buffer, and the number of bytes to send/received
  1161. --/ \sa bcm2835_spi_transfer()
  1162. procedure bcm2835_spi_transfernb
  1163. (tbuf : Interfaces.C.Strings.chars_ptr;
  1164. rbuf : Interfaces.C.Strings.chars_ptr;
  1165. len : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1113
  1166. pragma Import (C, bcm2835_spi_transfernb, "bcm2835_spi_transfernb");
  1167. --/ Transfers any number of bytes to and from the currently selected SPI slave
  1168. --/ using bcm2835_spi_transfernb.
  1169. --/ The returned data from the slave replaces the transmitted data in the buffer.
  1170. --/ \param[in,out] buf Buffer of bytes to send. Received bytes will replace the contents
  1171. --/ \param[in] len Number of bytes int eh buffer, and the number of bytes to send/received
  1172. --/ \sa bcm2835_spi_transfer()
  1173. procedure bcm2835_spi_transfern (buf : Interfaces.C.Strings.chars_ptr; len : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1121
  1174. pragma Import (C, bcm2835_spi_transfern, "bcm2835_spi_transfern");
  1175. --/ Transfers any number of bytes to the currently selected SPI slave.
  1176. --/ Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect)
  1177. --/ during the transfer.
  1178. --/ \param[in] buf Buffer of bytes to send.
  1179. --/ \param[in] len Number of bytes in the tbuf buffer, and the number of bytes to send
  1180. procedure bcm2835_spi_writenb (buf : Interfaces.C.Strings.chars_ptr; len : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1128
  1181. pragma Import (C, bcm2835_spi_writenb, "bcm2835_spi_writenb");
  1182. --/ @}
  1183. --/ \defgroup i2c I2C access
  1184. --/ These functions let you use I2C (The Broadcom Serial Control bus with the Philips
  1185. --/ I2C bus/interface version 2.1 January 2000.) to interface with an external I2C device.
  1186. --/ @{
  1187. --/ Start I2C operations.
  1188. --/ Forces RPi I2C pins P1-03 (SDA) and P1-05 (SCL)
  1189. --/ to alternate function ALT0, which enables those pins for I2C interface.
  1190. --/ You should call bcm2835_i2c_end() when all I2C functions are complete to return the pins to
  1191. --/ their default functions
  1192. --/ \sa bcm2835_i2c_end()
  1193. procedure bcm2835_i2c_begin; -- /usr/local/include/bcm2835.h:1143
  1194. pragma Import (C, bcm2835_i2c_begin, "bcm2835_i2c_begin");
  1195. --/ End I2C operations.
  1196. --/ I2C pins P1-03 (SDA) and P1-05 (SCL)
  1197. --/ are returned to their default INPUT behaviour.
  1198. procedure bcm2835_i2c_end; -- /usr/local/include/bcm2835.h:1148
  1199. pragma Import (C, bcm2835_i2c_end, "bcm2835_i2c_end");
  1200. --/ Sets the I2C slave address.
  1201. --/ \param[in] addr The I2C slave address.
  1202. procedure bcm2835_i2c_setSlaveAddress (addr : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1152
  1203. pragma Import (C, bcm2835_i2c_setSlaveAddress, "bcm2835_i2c_setSlaveAddress");
  1204. --/ Sets the I2C clock divider and therefore the I2C clock speed.
  1205. --/ \param[in] divider The desired I2C clock divider, one of BCM2835_I2C_CLOCK_DIVIDER_*,
  1206. --/ see \ref bcm2835I2CClockDivider
  1207. procedure bcm2835_i2c_setClockDivider (divider : stdint_h.uint16_t); -- /usr/local/include/bcm2835.h:1157
  1208. pragma Import (C, bcm2835_i2c_setClockDivider, "bcm2835_i2c_setClockDivider");
  1209. --/ Sets the I2C clock divider by converting the baudrate parameter to
  1210. --/ the equivalent I2C clock divider. ( see \sa bcm2835_i2c_setClockDivider)
  1211. --/ For the I2C standard 100khz you would set baudrate to 100000
  1212. --/ The use of baudrate corresponds to its use in the I2C kernel device
  1213. --/ driver. (Of course, bcm2835 has nothing to do with the kernel driver)
  1214. procedure bcm2835_i2c_set_baudrate (baudrate : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1164
  1215. pragma Import (C, bcm2835_i2c_set_baudrate, "bcm2835_i2c_set_baudrate");
  1216. --/ Transfers any number of bytes to the currently selected I2C slave.
  1217. --/ (as previously set by \sa bcm2835_i2c_setSlaveAddress)
  1218. --/ \param[in] buf Buffer of bytes to send.
  1219. --/ \param[in] len Number of bytes in the buf buffer, and the number of bytes to send.
  1220. --/ \return reason see \ref bcm2835I2CReasonCodes
  1221. function bcm2835_i2c_write (buf : Interfaces.C.Strings.chars_ptr; len : stdint_h.uint32_t) return stdint_h.uint8_t; -- /usr/local/include/bcm2835.h:1171
  1222. pragma Import (C, bcm2835_i2c_write, "bcm2835_i2c_write");
  1223. --/ Transfers any number of bytes from the currently selected I2C slave.
  1224. --/ (as previously set by \sa bcm2835_i2c_setSlaveAddress)
  1225. --/ \param[in] buf Buffer of bytes to receive.
  1226. --/ \param[in] len Number of bytes in the buf buffer, and the number of bytes to received.
  1227. --/ \return reason see \ref bcm2835I2CReasonCodes
  1228. function bcm2835_i2c_read (buf : Interfaces.C.Strings.chars_ptr; len : stdint_h.uint32_t) return stdint_h.uint8_t; -- /usr/local/include/bcm2835.h:1178
  1229. pragma Import (C, bcm2835_i2c_read, "bcm2835_i2c_read");
  1230. --/ Allows reading from I2C slaves that require a repeated start (without any prior stop)
  1231. --/ to read after the required slave register has been set. For example, the popular
  1232. --/ MPL3115A2 pressure and temperature sensor. Note that your device must support or
  1233. --/ require this mode. If your device does not require this mode then the standard
  1234. --/ combined:
  1235. --/ \sa bcm2835_i2c_write
  1236. --/ \sa bcm2835_i2c_read
  1237. --/ are a better choice.
  1238. --/ Will read from the slave previously set by \sa bcm2835_i2c_setSlaveAddress
  1239. --/ \param[in] regaddr Buffer containing the slave register you wish to read from.
  1240. --/ \param[in] buf Buffer of bytes to receive.
  1241. --/ \param[in] len Number of bytes in the buf buffer, and the number of bytes to received.
  1242. --/ \return reason see \ref bcm2835I2CReasonCodes
  1243. function bcm2835_i2c_read_register_rs
  1244. (regaddr : Interfaces.C.Strings.chars_ptr;
  1245. buf : Interfaces.C.Strings.chars_ptr;
  1246. len : stdint_h.uint32_t) return stdint_h.uint8_t; -- /usr/local/include/bcm2835.h:1193
  1247. pragma Import (C, bcm2835_i2c_read_register_rs, "bcm2835_i2c_read_register_rs");
  1248. --/ @}
  1249. --/ \defgroup st System Timer access
  1250. --/ Allows access to and delays using the System Timer Counter.
  1251. --/ @{
  1252. --/ Read the System Timer Counter register.
  1253. --/ \return the value read from the System Timer Counter Lower 32 bits register
  1254. function bcm2835_st_read return stdint_h.uint64_t; -- /usr/local/include/bcm2835.h:1203
  1255. pragma Import (C, bcm2835_st_read, "bcm2835_st_read");
  1256. --/ Delays for the specified number of microseconds with offset.
  1257. --/ \param[in] offset_micros Offset in microseconds
  1258. --/ \param[in] micros Delay in microseconds
  1259. procedure bcm2835_st_delay (offset_micros : stdint_h.uint64_t; micros : stdint_h.uint64_t); -- /usr/local/include/bcm2835.h:1208
  1260. pragma Import (C, bcm2835_st_delay, "bcm2835_st_delay");
  1261. --/ @}
  1262. --/ \defgroup pwm Pulse Width Modulation
  1263. --/ Allows control of 2 independent PWM channels. A limited subset of GPIO pins
  1264. --/ can be connected to one of these 2 channels, allowing PWM control of GPIO pins.
  1265. --/ You have to set the desired pin into a particular Alt Fun to PWM output. See the PWM
  1266. --/ documentation on the Main Page.
  1267. --/ @{
  1268. --/ Sets the PWM clock divisor,
  1269. --/ to control the basic PWM pulse widths.
  1270. --/ \param[in] divisor Divides the basic 19.2MHz PWM clock. You can use one of the common
  1271. --/ values BCM2835_PWM_CLOCK_DIVIDER_* in \ref bcm2835PWMClockDivider.
  1272. procedure bcm2835_pwm_set_clock (divisor : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1223
  1273. pragma Import (C, bcm2835_pwm_set_clock, "bcm2835_pwm_set_clock");
  1274. --/ Sets the mode of the given PWM channel,
  1275. --/ allowing you to control the PWM mode and enable/disable that channel
  1276. --/ \param[in] channel The PWM channel. 0 or 1.
  1277. --/ \param[in] markspace Set true if you want Mark-Space mode. 0 for Balanced mode.
  1278. --/ \param[in] enabled Set true to enable this channel and produce PWM pulses.
  1279. procedure bcm2835_pwm_set_mode
  1280. (channel : stdint_h.uint8_t;
  1281. markspace : stdint_h.uint8_t;
  1282. enabled : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1230
  1283. pragma Import (C, bcm2835_pwm_set_mode, "bcm2835_pwm_set_mode");
  1284. --/ Sets the maximum range of the PWM output.
  1285. --/ The data value can vary between 0 and this range to control PWM output
  1286. --/ \param[in] channel The PWM channel. 0 or 1.
  1287. --/ \param[in] range The maximum value permitted for DATA.
  1288. procedure bcm2835_pwm_set_range (channel : stdint_h.uint8_t; c_range : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1236
  1289. pragma Import (C, bcm2835_pwm_set_range, "bcm2835_pwm_set_range");
  1290. --/ Sets the PWM pulse ratio to emit to DATA/RANGE,
  1291. --/ where RANGE is set by bcm2835_pwm_set_range().
  1292. --/ \param[in] channel The PWM channel. 0 or 1.
  1293. --/ \param[in] data Controls the PWM output ratio as a fraction of the range.
  1294. --/ Can vary from 0 to RANGE.
  1295. procedure bcm2835_pwm_set_data (channel : stdint_h.uint8_t; data : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1243
  1296. pragma Import (C, bcm2835_pwm_set_data, "bcm2835_pwm_set_data");
  1297. --/ @}
  1298. --/ @example blink.c
  1299. --/ Blinks RPi GPIO pin 11 on and off
  1300. --/ @example input.c
  1301. --/ Reads the state of an RPi input pin
  1302. --/ @example event.c
  1303. --/ Shows how to use event detection on an input pin
  1304. --/ @example spi.c
  1305. --/ Shows how to use SPI interface to transfer a byte to and from an SPI device
  1306. --/ @example spin.c
  1307. --/ Shows how to use SPI interface to transfer a number of bytes to and from an SPI device
  1308. --/ @example pwm.c
  1309. --/ Shows how to use PWM to control GPIO pins
  1310. end bcm2835_h;