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.

1411 lines
78 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 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.13 2013/12/06 22:24:52 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.36.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 based on work by Arvi Govindaraj.
  302. --/ \version 1.33 Added command line utilities i2c and gpio to examples. Contributed by Shahrooz Shahparnia.
  303. --/ \version 1.34 Added bcm2835_i2c_write_read_rs() which writes an arbitrary number of bytes,
  304. --/ sends a repeat start, and reads from the device. Contributed by Eduardo Steinhorst.
  305. --/ \version 1.35 Fix build errors when compiled under Qt. Also performance improvements with SPI transfers. Contributed by Udo Klaas.
  306. --/ \version 1.36 Make automake's test runner detect that we're skipping tests when not root, the second
  307. --/ one makes us skip the test when using fakeroot (as used when building
  308. --/ Debian packages). Contributed by Guido Günther.
  309. --/
  310. --/ \author Mike McCauley (mikem@airspayce.com) DO NOT CONTACT THE AUTHOR DIRECTLY: USE THE LISTS
  311. -- Defines for BCM2835
  312. --/ \defgroup constants Constants for passing to and from library functions
  313. --/ The values here are designed to be passed to various functions in the bcm2835 library.
  314. --/ @{
  315. --/ This means pin HIGH, true, 3.3volts on a pin.
  316. --/ This means pin LOW, false, 0volts on a pin.
  317. --/ Speed of the core clock core_clk
  318. -- Physical addresses for various peripheral register sets
  319. --/ Base Physical Address of the BCM 2835 peripheral registers
  320. --/ Base Physical Address of the System Timer registers
  321. --/ Base Physical Address of the Pads registers
  322. --/ Base Physical Address of the Clock/timer registers
  323. --/ Base Physical Address of the GPIO registers
  324. --/ Base Physical Address of the SPI0 registers
  325. --/ Base Physical Address of the BSC0 registers
  326. --/ Base Physical Address of the PWM registers
  327. --/ Base Physical Address of the BSC1 registers
  328. -- manual converted
  329. HIGH : constant unsigned := 16#1#;
  330. LOW : constant unsigned := 16#0#;
  331. BCM2835_CORE_CLK_HZ : constant unsigned := 250000000;
  332. BCM2835_PERI_BASE : constant unsigned := 16#20000000#;
  333. BCM2835_ST_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#3000#);
  334. BCM2835_GPIO_PADS : constant unsigned := (BCM2835_PERI_BASE + 16#100000#);
  335. BCM2835_CLOCK_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#101000#);
  336. BCM2835_GPIO_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#200000#);
  337. BCM2835_SPI0_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#204000#);
  338. BCM2835_BSC0_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#205000#);
  339. BCM2835_GPIO_PWM : constant unsigned := (BCM2835_PERI_BASE + 16#20C000#);
  340. BCM2835_BSC1_BASE : constant unsigned := (BCM2835_PERI_BASE + 16#804000#);
  341. BCM2835_PAGE_SIZE : constant unsigned := (4*1024);
  342. BCM2835_BLOCK_SIZE : constant unsigned := (4*1024);
  343. BCM2835_GPFSEL0 : constant unsigned := 16#0000#;
  344. BCM2835_GPFSEL1 : constant unsigned := 16#0004#;
  345. BCM2835_GPFSEL2 : constant unsigned := 16#0008#;
  346. BCM2835_GPFSEL3 : constant unsigned := 16#000c#;
  347. BCM2835_GPFSEL4 : constant unsigned := 16#0010#;
  348. BCM2835_GPFSEL5 : constant unsigned := 16#0014#;
  349. BCM2835_GPSET0 : constant unsigned := 16#001c#;
  350. BCM2835_GPSET1 : constant unsigned := 16#0020#;
  351. BCM2835_GPCLR0 : constant unsigned := 16#0028#;
  352. BCM2835_GPCLR1 : constant unsigned := 16#002c#;
  353. BCM2835_GPLEV0 : constant unsigned := 16#0034#;
  354. BCM2835_GPLEV1 : constant unsigned := 16#0038#;
  355. BCM2835_GPEDS0 : constant unsigned := 16#0040#;
  356. BCM2835_GPEDS1 : constant unsigned := 16#0044#;
  357. BCM2835_GPREN0 : constant unsigned := 16#004c#;
  358. BCM2835_GPREN1 : constant unsigned := 16#0050#;
  359. BCM2835_GPFEN0 : constant unsigned := 16#0058#;
  360. BCM2835_GPFEN1 : constant unsigned := 16#005c#;
  361. BCM2835_GPHEN0 : constant unsigned := 16#0064#;
  362. BCM2835_GPHEN1 : constant unsigned := 16#0068#;
  363. BCM2835_GPLEN0 : constant unsigned := 16#0070#;
  364. BCM2835_GPLEN1 : constant unsigned := 16#0074#;
  365. BCM2835_GPAREN0 : constant unsigned := 16#007c#;
  366. BCM2835_GPAREN1 : constant unsigned := 16#0080#;
  367. BCM2835_GPAFEN0 : constant unsigned := 16#0088#;
  368. BCM2835_GPAFEN1 : constant unsigned := 16#008c#;
  369. BCM2835_GPPUD : constant unsigned := 16#0094#;
  370. BCM2835_GPPUDCLK0 : constant unsigned := 16#0098#;
  371. BCM2835_GPPUDCLK1 : constant unsigned := 16#009c#;
  372. BCM2835_PADS_GPIO_0_27 : constant unsigned := 16#002c#;
  373. BCM2835_PADS_GPIO_28_45 : constant unsigned := 16#0030#;
  374. BCM2835_PADS_GPIO_46_53 : constant unsigned := 16#0034#;
  375. BCM2835_PAD_PASSWRD : constant unsigned := 16#5A000000#;
  376. BCM2835_PAD_SLEW_RATE_UNLIMITED : constant unsigned := 16#10#;
  377. BCM2835_PAD_HYSTERESIS_ENABLED : constant unsigned := 16#08#;
  378. BCM2835_PAD_DRIVE_2mA : constant unsigned := 16#00#;
  379. BCM2835_PAD_DRIVE_4mA : constant unsigned := 16#01#;
  380. BCM2835_PAD_DRIVE_6mA : constant unsigned := 16#02#;
  381. BCM2835_PAD_DRIVE_8mA : constant unsigned := 16#03#;
  382. BCM2835_PAD_DRIVE_10mA : constant unsigned := 16#04#;
  383. BCM2835_PAD_DRIVE_12mA : constant unsigned := 16#05#;
  384. BCM2835_PAD_DRIVE_14mA : constant unsigned := 16#06#;
  385. BCM2835_PAD_DRIVE_16mA : constant unsigned := 16#07#;
  386. BCM2835_SPI0_CS : constant unsigned := 16#0000#;
  387. BCM2835_SPI0_FIFO : constant unsigned := 16#0004#;
  388. BCM2835_SPI0_CLK : constant unsigned := 16#0008#;
  389. BCM2835_SPI0_DLEN : constant unsigned := 16#000c#;
  390. BCM2835_SPI0_LTOH : constant unsigned := 16#0010#;
  391. BCM2835_SPI0_DC : constant unsigned := 16#0014#;
  392. BCM2835_SPI0_CS_LEN_LONG : constant unsigned := 16#02000000#;
  393. BCM2835_SPI0_CS_DMA_LEN : constant unsigned := 16#01000000#;
  394. BCM2835_SPI0_CS_CSPOL2 : constant unsigned := 16#00800000#;
  395. BCM2835_SPI0_CS_CSPOL1 : constant unsigned := 16#00400000#;
  396. BCM2835_SPI0_CS_CSPOL0 : constant unsigned := 16#00200000#;
  397. BCM2835_SPI0_CS_RXF : constant unsigned := 16#00100000#;
  398. BCM2835_SPI0_CS_RXR : constant unsigned := 16#00080000#;
  399. BCM2835_SPI0_CS_TXD : constant unsigned := 16#00040000#;
  400. BCM2835_SPI0_CS_RXD : constant unsigned := 16#00020000#;
  401. BCM2835_SPI0_CS_DONE : constant unsigned := 16#00010000#;
  402. BCM2835_SPI0_CS_TE_EN : constant unsigned := 16#00008000#;
  403. BCM2835_SPI0_CS_LMONO : constant unsigned := 16#00004000#;
  404. BCM2835_SPI0_CS_LEN : constant unsigned := 16#00002000#;
  405. BCM2835_SPI0_CS_REN : constant unsigned := 16#00001000#;
  406. BCM2835_SPI0_CS_ADCS : constant unsigned := 16#00000800#;
  407. BCM2835_SPI0_CS_INTR : constant unsigned := 16#00000400#;
  408. BCM2835_SPI0_CS_INTD : constant unsigned := 16#00000200#;
  409. BCM2835_SPI0_CS_DMAEN : constant unsigned := 16#00000100#;
  410. BCM2835_SPI0_CS_TA : constant unsigned := 16#00000080#;
  411. BCM2835_SPI0_CS_CSPOL : constant unsigned := 16#00000040#;
  412. BCM2835_SPI0_CS_CLEAR : constant unsigned := 16#00000030#;
  413. BCM2835_SPI0_CS_CLEAR_RX : constant unsigned := 16#00000020#;
  414. BCM2835_SPI0_CS_CLEAR_TX : constant unsigned := 16#00000010#;
  415. BCM2835_SPI0_CS_CPOL : constant unsigned := 16#00000008#;
  416. BCM2835_SPI0_CS_CPHA : constant unsigned := 16#00000004#;
  417. BCM2835_SPI0_CS_CS : constant unsigned := 16#00000003#;
  418. BCM2835_BSC_C : constant unsigned := 16#0000#;
  419. BCM2835_BSC_S : constant unsigned := 16#0004#;
  420. BCM2835_BSC_DLEN : constant unsigned := 16#0008#;
  421. BCM2835_BSC_A : constant unsigned := 16#000c#;
  422. BCM2835_BSC_FIFO : constant unsigned := 16#0010#;
  423. BCM2835_BSC_DIV : constant unsigned := 16#0014#;
  424. BCM2835_BSC_DEL : constant unsigned := 16#0018#;
  425. BCM2835_BSC_CLKT : constant unsigned := 16#001c#;
  426. BCM2835_BSC_C_I2CEN : constant unsigned := 16#00008000#;
  427. BCM2835_BSC_C_INTR : constant unsigned := 16#00000400#;
  428. BCM2835_BSC_C_INTT : constant unsigned := 16#00000200#;
  429. BCM2835_BSC_C_INTD : constant unsigned := 16#00000100#;
  430. BCM2835_BSC_C_ST : constant unsigned := 16#00000080#;
  431. BCM2835_BSC_C_CLEAR_1 : constant unsigned := 16#00000020#;
  432. BCM2835_BSC_C_CLEAR_2 : constant unsigned := 16#00000010#;
  433. BCM2835_BSC_C_READ : constant unsigned := 16#00000001#;
  434. BCM2835_BSC_S_CLKT : constant unsigned := 16#00000200#;
  435. BCM2835_BSC_S_ERR : constant unsigned := 16#00000100#;
  436. BCM2835_BSC_S_RXF : constant unsigned := 16#00000080#;
  437. BCM2835_BSC_S_TXE : constant unsigned := 16#00000040#;
  438. BCM2835_BSC_S_RXD : constant unsigned := 16#00000020#;
  439. BCM2835_BSC_S_TXD : constant unsigned := 16#00000010#;
  440. BCM2835_BSC_S_RXR : constant unsigned := 16#00000008#;
  441. BCM2835_BSC_S_TXW : constant unsigned := 16#00000004#;
  442. BCM2835_BSC_S_DONE : constant unsigned := 16#00000002#;
  443. BCM2835_BSC_S_TA : constant unsigned := 16#00000001#;
  444. BCM2835_BSC_FIFO_SIZE : constant unsigned := 16;
  445. BCM2835_ST_CS : constant unsigned := 16#0000#;
  446. BCM2835_ST_CLO : constant unsigned := 16#0004#;
  447. BCM2835_ST_CHI : constant unsigned := 16#0008#;
  448. BCM2835_PWM_CONTROL : constant unsigned := 0;
  449. BCM2835_PWM_STATUS : constant unsigned := 1;
  450. BCM2835_PWM_DMAC : constant unsigned := 2;
  451. BCM2835_PWM0_RANGE : constant unsigned := 4;
  452. BCM2835_PWM0_DATA : constant unsigned := 5;
  453. BCM2835_PWM_FIF1 : constant unsigned := 6;
  454. BCM2835_PWM1_RANGE : constant unsigned := 8;
  455. BCM2835_PWM1_DATA : constant unsigned := 9;
  456. BCM2835_PWMCLK_CNTL : constant unsigned := 40;
  457. BCM2835_PWMCLK_DIV : constant unsigned := 41;
  458. BCM2835_PWM_PASSWRD : constant unsigned := 16#5A000000#;
  459. BCM2835_PWM1_MS_MODE : constant unsigned := 16#8000#;
  460. BCM2835_PWM1_USEFIFO : constant unsigned := 16#2000#;
  461. BCM2835_PWM1_REVPOLAR : constant unsigned := 16#1000#;
  462. BCM2835_PWM1_OFFSTATE : constant unsigned := 16#0800#;
  463. BCM2835_PWM1_REPEATFF : constant unsigned := 16#0400#;
  464. BCM2835_PWM1_SERIAL : constant unsigned := 16#0200#;
  465. BCM2835_PWM1_ENABLE : constant unsigned := 16#0100#;
  466. BCM2835_PWM0_MS_MODE : constant unsigned := 16#0080#;
  467. BCM2835_PWM_CLEAR_FIFO : constant unsigned := 16#0040#;
  468. BCM2835_PWM0_USEFIFO : constant unsigned := 16#0020#;
  469. BCM2835_PWM0_REVPOLAR : constant unsigned := 16#0010#;
  470. BCM2835_PWM0_OFFSTATE : constant unsigned := 16#0008#;
  471. BCM2835_PWM0_REPEATFF : constant unsigned := 16#0004#;
  472. BCM2835_PWM0_SERIAL : constant unsigned := 16#0002#;
  473. BCM2835_PWM0_ENABLE : constant unsigned := 16#0001#;
  474. -- arg-macro: procedure delay (x)
  475. -- bcm2835_delay(x)
  476. -- arg-macro: procedure delayMicroseconds (x)
  477. -- bcm2835_delayMicroseconds(x)
  478. --/ Base of the ST (System Timer) registers.
  479. --/ Available after bcm2835_init has been called
  480. bcm2835_st : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:355
  481. pragma Import (C, bcm2835_st, "bcm2835_st");
  482. --/ Base of the GPIO registers.
  483. --/ Available after bcm2835_init has been called
  484. bcm2835_gpio : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:359
  485. pragma Import (C, bcm2835_gpio, "bcm2835_gpio");
  486. --/ Base of the PWM registers.
  487. --/ Available after bcm2835_init has been called
  488. bcm2835_pwm : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:363
  489. pragma Import (C, bcm2835_pwm, "bcm2835_pwm");
  490. --/ Base of the CLK registers.
  491. --/ Available after bcm2835_init has been called
  492. bcm2835_clk : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:367
  493. pragma Import (C, bcm2835_clk, "bcm2835_clk");
  494. --/ Base of the PADS registers.
  495. --/ Available after bcm2835_init has been called
  496. bcm2835_pads : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:371
  497. pragma Import (C, bcm2835_pads, "bcm2835_pads");
  498. --/ Base of the SPI0 registers.
  499. --/ Available after bcm2835_init has been called
  500. bcm2835_spi0 : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:375
  501. pragma Import (C, bcm2835_spi0, "bcm2835_spi0");
  502. --/ Base of the BSC0 registers.
  503. --/ Available after bcm2835_init has been called
  504. bcm2835_bsc0 : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:379
  505. pragma Import (C, bcm2835_bsc0, "bcm2835_bsc0");
  506. --/ Base of the BSC1 registers.
  507. --/ Available after bcm2835_init has been called
  508. bcm2835_bsc1 : access stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:383
  509. pragma Import (C, bcm2835_bsc1, "bcm2835_bsc1");
  510. --/ Size of memory page on RPi
  511. --/ Size of memory block on RPi
  512. -- Defines for GPIO
  513. -- The BCM2835 has 54 GPIO pins.
  514. -- BCM2835 data sheet, Page 90 onwards.
  515. --/ GPIO register offsets from BCM2835_GPIO_BASE. Offsets into the GPIO Peripheral block in bytes per 6.1 Register View
  516. --/ \brief bcm2835PortFunction
  517. --/ Port function select modes for bcm2835_gpio_fsel()
  518. --/< Input
  519. --/< Output
  520. --/< Alternate function 0
  521. --/< Alternate function 1
  522. --/< Alternate function 2
  523. --/< Alternate function 3
  524. --/< Alternate function 4
  525. --/< Alternate function 5
  526. --/< Function select bits mask
  527. subtype bcm2835FunctionSelect is unsigned;
  528. BCM2835_GPIO_FSEL_INPT : constant bcm2835FunctionSelect := 0;
  529. BCM2835_GPIO_FSEL_OUTP : constant bcm2835FunctionSelect := 1;
  530. BCM2835_GPIO_FSEL_ALT0 : constant bcm2835FunctionSelect := 4;
  531. BCM2835_GPIO_FSEL_ALT1 : constant bcm2835FunctionSelect := 5;
  532. BCM2835_GPIO_FSEL_ALT2 : constant bcm2835FunctionSelect := 6;
  533. BCM2835_GPIO_FSEL_ALT3 : constant bcm2835FunctionSelect := 7;
  534. BCM2835_GPIO_FSEL_ALT4 : constant bcm2835FunctionSelect := 3;
  535. BCM2835_GPIO_FSEL_ALT5 : constant bcm2835FunctionSelect := 2;
  536. BCM2835_GPIO_FSEL_MASK : constant bcm2835FunctionSelect := 7; -- /usr/local/include/bcm2835.h:438
  537. --/ \brief bcm2835PUDControl
  538. --/ Pullup/Pulldown defines for bcm2835_gpio_pud()
  539. --/< Off ? disable pull-up/down
  540. --/< Enable Pull Down control
  541. --/< Enable Pull Up control
  542. type bcm2835PUDControl is
  543. (BCM2835_GPIO_PUD_OFF,
  544. BCM2835_GPIO_PUD_DOWN,
  545. BCM2835_GPIO_PUD_UP);
  546. pragma Convention (C, bcm2835PUDControl); -- /usr/local/include/bcm2835.h:447
  547. --/ Pad control register offsets from BCM2835_GPIO_PADS
  548. --/ Pad Control masks
  549. --/ \brief bcm2835PadGroup
  550. --/ Pad group specification for bcm2835_gpio_pad()
  551. --/< Pad group for GPIO pads 0 to 27
  552. --/< Pad group for GPIO pads 28 to 45
  553. --/< Pad group for GPIO pads 46 to 53
  554. type bcm2835PadGroup is
  555. (BCM2835_PAD_GROUP_GPIO_0_27,
  556. BCM2835_PAD_GROUP_GPIO_28_45,
  557. BCM2835_PAD_GROUP_GPIO_46_53);
  558. pragma Convention (C, bcm2835PadGroup); -- /usr/local/include/bcm2835.h:474
  559. --/ \brief GPIO Pin Numbers
  560. --/
  561. --/ Here we define Raspberry Pin GPIO pins on P1 in terms of the underlying BCM GPIO pin numbers.
  562. --/ These can be passed as a pin number to any function requiring a pin.
  563. --/ Not all pins on the RPi 26 bin IDE plug are connected to GPIO pins
  564. --/ and some can adopt an alternate function.
  565. --/ RPi version 2 has some slightly different pinouts, and these are values RPI_V2_*.
  566. --/ At bootup, pins 8 and 10 are set to UART0_TXD, UART0_RXD (ie the alt0 function) respectively
  567. --/ When SPI0 is in use (ie after bcm2835_spi_begin()), pins 19, 21, 23, 24, 26 are dedicated to SPI
  568. --/ and cant be controlled independently
  569. --/< Version 1, Pin P1-03
  570. --/< Version 1, Pin P1-05
  571. --/< Version 1, Pin P1-07
  572. --/< Version 1, Pin P1-08, defaults to alt function 0 UART0_TXD
  573. --/< Version 1, Pin P1-10, defaults to alt function 0 UART0_RXD
  574. --/< Version 1, Pin P1-11
  575. --/< Version 1, Pin P1-12, can be PWM channel 0 in ALT FUN 5
  576. --/< Version 1, Pin P1-13
  577. --/< Version 1, Pin P1-15
  578. --/< Version 1, Pin P1-16
  579. --/< Version 1, Pin P1-18
  580. --/< Version 1, Pin P1-19, MOSI when SPI0 in use
  581. --/< Version 1, Pin P1-21, MISO when SPI0 in use
  582. --/< Version 1, Pin P1-22
  583. --/< Version 1, Pin P1-23, CLK when SPI0 in use
  584. --/< Version 1, Pin P1-24, CE0 when SPI0 in use
  585. --/< Version 1, Pin P1-26, CE1 when SPI0 in use
  586. -- RPi Version 2
  587. --/< Version 2, Pin P1-03
  588. --/< Version 2, Pin P1-05
  589. --/< Version 2, Pin P1-07
  590. --/< Version 2, Pin P1-08, defaults to alt function 0 UART0_TXD
  591. --/< Version 2, Pin P1-10, defaults to alt function 0 UART0_RXD
  592. --/< Version 2, Pin P1-11
  593. --/< Version 2, Pin P1-12, can be PWM channel 0 in ALT FUN 5
  594. --/< Version 2, Pin P1-13
  595. --/< Version 2, Pin P1-15
  596. --/< Version 2, Pin P1-16
  597. --/< Version 2, Pin P1-18
  598. --/< Version 2, Pin P1-19, MOSI when SPI0 in use
  599. --/< Version 2, Pin P1-21, MISO when SPI0 in use
  600. --/< Version 2, Pin P1-22
  601. --/< Version 2, Pin P1-23, CLK when SPI0 in use
  602. --/< Version 2, Pin P1-24, CE0 when SPI0 in use
  603. --/< Version 2, Pin P1-26, CE1 when SPI0 in use
  604. -- RPi Version 2, new plug P5
  605. --/< Version 2, Pin P5-03
  606. --/< Version 2, Pin P5-04
  607. --/< Version 2, Pin P5-05
  608. --/< Version 2, Pin P5-06
  609. subtype RPiGPIOPin is unsigned;
  610. RPI_GPIO_P1_03 : constant RPiGPIOPin := 0;
  611. RPI_GPIO_P1_05 : constant RPiGPIOPin := 1;
  612. RPI_GPIO_P1_07 : constant RPiGPIOPin := 4;
  613. RPI_GPIO_P1_08 : constant RPiGPIOPin := 14;
  614. RPI_GPIO_P1_10 : constant RPiGPIOPin := 15;
  615. RPI_GPIO_P1_11 : constant RPiGPIOPin := 17;
  616. RPI_GPIO_P1_12 : constant RPiGPIOPin := 18;
  617. RPI_GPIO_P1_13 : constant RPiGPIOPin := 21;
  618. RPI_GPIO_P1_15 : constant RPiGPIOPin := 22;
  619. RPI_GPIO_P1_16 : constant RPiGPIOPin := 23;
  620. RPI_GPIO_P1_18 : constant RPiGPIOPin := 24;
  621. RPI_GPIO_P1_19 : constant RPiGPIOPin := 10;
  622. RPI_GPIO_P1_21 : constant RPiGPIOPin := 9;
  623. RPI_GPIO_P1_22 : constant RPiGPIOPin := 25;
  624. RPI_GPIO_P1_23 : constant RPiGPIOPin := 11;
  625. RPI_GPIO_P1_24 : constant RPiGPIOPin := 8;
  626. RPI_GPIO_P1_26 : constant RPiGPIOPin := 7;
  627. RPI_V2_GPIO_P1_03 : constant RPiGPIOPin := 2;
  628. RPI_V2_GPIO_P1_05 : constant RPiGPIOPin := 3;
  629. RPI_V2_GPIO_P1_07 : constant RPiGPIOPin := 4;
  630. RPI_V2_GPIO_P1_08 : constant RPiGPIOPin := 14;
  631. RPI_V2_GPIO_P1_10 : constant RPiGPIOPin := 15;
  632. RPI_V2_GPIO_P1_11 : constant RPiGPIOPin := 17;
  633. RPI_V2_GPIO_P1_12 : constant RPiGPIOPin := 18;
  634. RPI_V2_GPIO_P1_13 : constant RPiGPIOPin := 27;
  635. RPI_V2_GPIO_P1_15 : constant RPiGPIOPin := 22;
  636. RPI_V2_GPIO_P1_16 : constant RPiGPIOPin := 23;
  637. RPI_V2_GPIO_P1_18 : constant RPiGPIOPin := 24;
  638. RPI_V2_GPIO_P1_19 : constant RPiGPIOPin := 10;
  639. RPI_V2_GPIO_P1_21 : constant RPiGPIOPin := 9;
  640. RPI_V2_GPIO_P1_22 : constant RPiGPIOPin := 25;
  641. RPI_V2_GPIO_P1_23 : constant RPiGPIOPin := 11;
  642. RPI_V2_GPIO_P1_24 : constant RPiGPIOPin := 8;
  643. RPI_V2_GPIO_P1_26 : constant RPiGPIOPin := 7;
  644. RPI_V2_GPIO_P5_03 : constant RPiGPIOPin := 28;
  645. RPI_V2_GPIO_P5_04 : constant RPiGPIOPin := 29;
  646. RPI_V2_GPIO_P5_05 : constant RPiGPIOPin := 30;
  647. RPI_V2_GPIO_P5_06 : constant RPiGPIOPin := 31; -- /usr/local/include/bcm2835.h:531
  648. -- Defines for SPI
  649. -- GPIO register offsets from BCM2835_SPI0_BASE.
  650. -- Offsets into the SPI Peripheral block in bytes per 10.5 SPI Register Map
  651. -- Register masks for SPI0_CS
  652. --/ \brief bcm2835SPIBitOrder SPI Bit order
  653. --/ Specifies the SPI data bit ordering for bcm2835_spi_setBitOrder()
  654. --/< LSB First
  655. --/< MSB First
  656. type bcm2835SPIBitOrder is
  657. (BCM2835_SPI_BIT_ORDER_LSBFIRST,
  658. BCM2835_SPI_BIT_ORDER_MSBFIRST);
  659. pragma Convention (C, bcm2835SPIBitOrder); -- /usr/local/include/bcm2835.h:577
  660. --/ \brief SPI Data mode
  661. --/ Specify the SPI data mode to be passed to bcm2835_spi_setDataMode()
  662. --/< CPOL = 0, CPHA = 0
  663. --/< CPOL = 0, CPHA = 1
  664. --/< CPOL = 1, CPHA = 0
  665. --/< CPOL = 1, CPHA = 1
  666. type bcm2835SPIMode is
  667. (BCM2835_SPI_MODE0,
  668. BCM2835_SPI_MODE1,
  669. BCM2835_SPI_MODE2,
  670. BCM2835_SPI_MODE3);
  671. pragma Convention (C, bcm2835SPIMode); -- /usr/local/include/bcm2835.h:587
  672. --/ \brief bcm2835SPIChipSelect
  673. --/ Specify the SPI chip select pin(s)
  674. --/< Chip Select 0
  675. --/< Chip Select 1
  676. --/< Chip Select 2 (ie pins CS1 and CS2 are asserted)
  677. --/< No CS, control it yourself
  678. type bcm2835SPIChipSelect is
  679. (BCM2835_SPI_CS0,
  680. BCM2835_SPI_CS1,
  681. BCM2835_SPI_CS2,
  682. BCM2835_SPI_CS_NONE);
  683. pragma Convention (C, bcm2835SPIChipSelect); -- /usr/local/include/bcm2835.h:597
  684. --/ \brief bcm2835SPIClockDivider
  685. --/ Specifies the divider used to generate the SPI clock from the system clock.
  686. --/ Figures below give the divider, clock period and clock frequency.
  687. --/ Clock divided is based on nominal base clock rate of 250MHz
  688. --/ It is reported that (contrary to the documentation) any even divider may used.
  689. --/ The frequencies shown for each divider have been confirmed by measurement
  690. --/< 65536 = 262.144us = 3.814697260kHz
  691. --/< 32768 = 131.072us = 7.629394531kHz
  692. --/< 16384 = 65.536us = 15.25878906kHz
  693. --/< 8192 = 32.768us = 30/51757813kHz
  694. --/< 4096 = 16.384us = 61.03515625kHz
  695. --/< 2048 = 8.192us = 122.0703125kHz
  696. --/< 1024 = 4.096us = 244.140625kHz
  697. --/< 512 = 2.048us = 488.28125kHz
  698. --/< 256 = 1.024us = 976.5625MHz
  699. --/< 128 = 512ns = = 1.953125MHz
  700. --/< 64 = 256ns = 3.90625MHz
  701. --/< 32 = 128ns = 7.8125MHz
  702. --/< 16 = 64ns = 15.625MHz
  703. --/< 8 = 32ns = 31.25MHz
  704. --/< 4 = 16ns = 62.5MHz
  705. --/< 2 = 8ns = 125MHz, fastest you can get
  706. --/< 1 = 262.144us = 3.814697260kHz, same as 0/65536
  707. subtype bcm2835SPIClockDivider is unsigned;
  708. BCM2835_SPI_CLOCK_DIVIDER_65536 : constant bcm2835SPIClockDivider := 0;
  709. BCM2835_SPI_CLOCK_DIVIDER_32768 : constant bcm2835SPIClockDivider := 32768;
  710. BCM2835_SPI_CLOCK_DIVIDER_16384 : constant bcm2835SPIClockDivider := 16384;
  711. BCM2835_SPI_CLOCK_DIVIDER_8192 : constant bcm2835SPIClockDivider := 8192;
  712. BCM2835_SPI_CLOCK_DIVIDER_4096 : constant bcm2835SPIClockDivider := 4096;
  713. BCM2835_SPI_CLOCK_DIVIDER_2048 : constant bcm2835SPIClockDivider := 2048;
  714. BCM2835_SPI_CLOCK_DIVIDER_1024 : constant bcm2835SPIClockDivider := 1024;
  715. BCM2835_SPI_CLOCK_DIVIDER_512 : constant bcm2835SPIClockDivider := 512;
  716. BCM2835_SPI_CLOCK_DIVIDER_256 : constant bcm2835SPIClockDivider := 256;
  717. BCM2835_SPI_CLOCK_DIVIDER_128 : constant bcm2835SPIClockDivider := 128;
  718. BCM2835_SPI_CLOCK_DIVIDER_64 : constant bcm2835SPIClockDivider := 64;
  719. BCM2835_SPI_CLOCK_DIVIDER_32 : constant bcm2835SPIClockDivider := 32;
  720. BCM2835_SPI_CLOCK_DIVIDER_16 : constant bcm2835SPIClockDivider := 16;
  721. BCM2835_SPI_CLOCK_DIVIDER_8 : constant bcm2835SPIClockDivider := 8;
  722. BCM2835_SPI_CLOCK_DIVIDER_4 : constant bcm2835SPIClockDivider := 4;
  723. BCM2835_SPI_CLOCK_DIVIDER_2 : constant bcm2835SPIClockDivider := 2;
  724. BCM2835_SPI_CLOCK_DIVIDER_1 : constant bcm2835SPIClockDivider := 1; -- /usr/local/include/bcm2835.h:624
  725. -- Defines for I2C
  726. -- GPIO register offsets from BCM2835_BSC*_BASE.
  727. -- Offsets into the BSC Peripheral block in bytes per 3.1 BSC Register Map
  728. -- Register masks for BSC_C
  729. -- Register masks for BSC_S
  730. --/ \brief bcm2835I2CClockDivider
  731. --/ Specifies the divider used to generate the I2C clock from the system clock.
  732. --/ Clock divided is based on nominal base clock rate of 250MHz
  733. --/< 2500 = 10us = 100 kHz
  734. --/< 622 = 2.504us = 399.3610 kHz
  735. --/< 150 = 60ns = 1.666 MHz (default at reset)
  736. --/< 148 = 59ns = 1.689 MHz
  737. subtype bcm2835I2CClockDivider is unsigned;
  738. BCM2835_I2C_CLOCK_DIVIDER_2500 : constant bcm2835I2CClockDivider := 2500;
  739. BCM2835_I2C_CLOCK_DIVIDER_626 : constant bcm2835I2CClockDivider := 626;
  740. BCM2835_I2C_CLOCK_DIVIDER_150 : constant bcm2835I2CClockDivider := 150;
  741. BCM2835_I2C_CLOCK_DIVIDER_148 : constant bcm2835I2CClockDivider := 148; -- /usr/local/include/bcm2835.h:671
  742. --/ \brief bcm2835I2CReasonCodes
  743. --/ Specifies the reason codes for the bcm2835_i2c_write and bcm2835_i2c_read functions.
  744. --/< Success
  745. --/< Received a NACK
  746. --/< Received Clock Stretch Timeout
  747. --/< Not all data is sent / received
  748. subtype bcm2835I2CReasonCodes is unsigned;
  749. BCM2835_I2C_REASON_OK : constant bcm2835I2CReasonCodes := 0;
  750. BCM2835_I2C_REASON_ERROR_NACK : constant bcm2835I2CReasonCodes := 1;
  751. BCM2835_I2C_REASON_ERROR_CLKT : constant bcm2835I2CReasonCodes := 2;
  752. BCM2835_I2C_REASON_ERROR_DATA : constant bcm2835I2CReasonCodes := 4; -- /usr/local/include/bcm2835.h:681
  753. -- Defines for ST
  754. -- GPIO register offsets from BCM2835_ST_BASE.
  755. -- Offsets into the ST Peripheral block in bytes per 12.1 System Timer Registers
  756. -- The System Timer peripheral provides four 32-bit timer channels and a single 64-bit free running counter.
  757. -- BCM2835_ST_CLO is the System Timer Counter Lower bits register.
  758. -- The system timer free-running counter lower register is a read-only register that returns the current value
  759. -- of the lower 32-bits of the free running counter.
  760. -- BCM2835_ST_CHI is the System Timer Counter Upper bits register.
  761. -- The system timer free-running counter upper register is a read-only register that returns the current value
  762. -- of the upper 32-bits of the free running counter.
  763. --/ @}
  764. -- Defines for PWM, word offsets (ie 4 byte multiples)
  765. -- Defines for PWM Clock, word offsets (ie 4 byte multiples)
  766. --/ \brief bcm2835PWMClockDivider
  767. --/ Specifies the divider used to generate the PWM clock from the system clock.
  768. --/ Figures below give the divider, clock period and clock frequency.
  769. --/ Clock divided is based on nominal PWM base clock rate of 19.2MHz
  770. --/ The frequencies shown for each divider have been confirmed by measurement
  771. --/< 32768 = 585Hz
  772. --/< 16384 = 1171.8Hz
  773. --/< 8192 = 2.34375kHz
  774. --/< 4096 = 4.6875kHz
  775. --/< 2048 = 9.375kHz
  776. --/< 1024 = 18.75kHz
  777. --/< 512 = 37.5kHz
  778. --/< 256 = 75kHz
  779. --/< 128 = 150kHz
  780. --/< 64 = 300kHz
  781. --/< 32 = 600.0kHz
  782. --/< 16 = 1.2MHz
  783. --/< 8 = 2.4MHz
  784. --/< 4 = 4.8MHz
  785. --/< 2 = 9.6MHz, fastest you can get
  786. --/< 1 = 4.6875kHz, same as divider 4096
  787. subtype bcm2835PWMClockDivider is unsigned;
  788. BCM2835_PWM_CLOCK_DIVIDER_32768 : constant bcm2835PWMClockDivider := 32768;
  789. BCM2835_PWM_CLOCK_DIVIDER_16384 : constant bcm2835PWMClockDivider := 16384;
  790. BCM2835_PWM_CLOCK_DIVIDER_8192 : constant bcm2835PWMClockDivider := 8192;
  791. BCM2835_PWM_CLOCK_DIVIDER_4096 : constant bcm2835PWMClockDivider := 4096;
  792. BCM2835_PWM_CLOCK_DIVIDER_2048 : constant bcm2835PWMClockDivider := 2048;
  793. BCM2835_PWM_CLOCK_DIVIDER_1024 : constant bcm2835PWMClockDivider := 1024;
  794. BCM2835_PWM_CLOCK_DIVIDER_512 : constant bcm2835PWMClockDivider := 512;
  795. BCM2835_PWM_CLOCK_DIVIDER_256 : constant bcm2835PWMClockDivider := 256;
  796. BCM2835_PWM_CLOCK_DIVIDER_128 : constant bcm2835PWMClockDivider := 128;
  797. BCM2835_PWM_CLOCK_DIVIDER_64 : constant bcm2835PWMClockDivider := 64;
  798. BCM2835_PWM_CLOCK_DIVIDER_32 : constant bcm2835PWMClockDivider := 32;
  799. BCM2835_PWM_CLOCK_DIVIDER_16 : constant bcm2835PWMClockDivider := 16;
  800. BCM2835_PWM_CLOCK_DIVIDER_8 : constant bcm2835PWMClockDivider := 8;
  801. BCM2835_PWM_CLOCK_DIVIDER_4 : constant bcm2835PWMClockDivider := 4;
  802. BCM2835_PWM_CLOCK_DIVIDER_2 : constant bcm2835PWMClockDivider := 2;
  803. BCM2835_PWM_CLOCK_DIVIDER_1 : constant bcm2835PWMClockDivider := 1; -- /usr/local/include/bcm2835.h:755
  804. -- Historical name compatibility
  805. --/ \defgroup init Library initialisation and management
  806. --/ These functions allow you to intialise and control the bcm2835 library
  807. --/ @{
  808. --/ Initialise the library by opening /dev/mem and getting pointers to the
  809. --/ internal memory for BCM 2835 device registers. You must call this (successfully)
  810. --/ before calling any other
  811. --/ functions in this library (except bcm2835_set_debug).
  812. --/ If bcm2835_init() fails by returning 0,
  813. --/ calling any other function may result in crashes or other failures.
  814. --/ Prints messages to stderr in case of errors.
  815. --/ \return 1 if successful else 0
  816. function bcm2835_init return int; -- /usr/local/include/bcm2835.h:779
  817. pragma Import (C, bcm2835_init, "bcm2835_init");
  818. --/ Close the library, deallocating any allocated memory and closing /dev/mem
  819. --/ \return 1 if successful else 0
  820. function bcm2835_close return int; -- /usr/local/include/bcm2835.h:783
  821. pragma Import (C, bcm2835_close, "bcm2835_close");
  822. --/ Sets the debug level of the library.
  823. --/ A value of 1 prevents mapping to /dev/mem, and makes the library print out
  824. --/ what it would do, rather than accessing the GPIO registers.
  825. --/ A value of 0, the default, causes normal operation.
  826. --/ Call this before calling bcm2835_init();
  827. --/ \param[in] debug The new debug level. 1 means debug
  828. procedure bcm2835_set_debug (debug : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:791
  829. pragma Import (C, bcm2835_set_debug, "bcm2835_set_debug");
  830. --/ @} // end of init
  831. --/ \defgroup lowlevel Low level register access
  832. --/ These functions provide low level register access, and should not generally
  833. --/ need to be used
  834. --/
  835. --/ @{
  836. --/ Reads 32 bit value from a peripheral address
  837. --/ The read is done twice, and is therefore always safe in terms of
  838. --/ manual section 1.3 Peripheral access precautions for correct memory ordering
  839. --/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
  840. --/ \return the value read from the 32 bit register
  841. --/ \sa Physical Addresses
  842. function bcm2835_peri_read (paddr : access stdint_h.uint32_t) return stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:807
  843. pragma Import (C, bcm2835_peri_read, "bcm2835_peri_read");
  844. --/ Reads 32 bit value from a peripheral address without the read barrier
  845. --/ You should only use this when your code has previously called bcm2835_peri_read()
  846. --/ within the same peripheral, and no other peripheral access has occurred since.
  847. --/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
  848. --/ \return the value read from the 32 bit register
  849. --/ \sa Physical Addresses
  850. function bcm2835_peri_read_nb (paddr : access stdint_h.uint32_t) return stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:816
  851. pragma Import (C, bcm2835_peri_read_nb, "bcm2835_peri_read_nb");
  852. --/ Writes 32 bit value from a peripheral address
  853. --/ The write is done twice, and is therefore always safe in terms of
  854. --/ manual section 1.3 Peripheral access precautions for correct memory ordering
  855. --/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
  856. --/ \param[in] value The 32 bit value to write
  857. --/ \sa Physical Addresses
  858. procedure bcm2835_peri_write (paddr : access stdint_h.uint32_t; value : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:825
  859. pragma Import (C, bcm2835_peri_write, "bcm2835_peri_write");
  860. --/ Writes 32 bit value from a peripheral address without the write barrier
  861. --/ You should only use this when your code has previously called bcm2835_peri_write()
  862. --/ within the same peripheral, and no other peripheral access has occurred since.
  863. --/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
  864. --/ \param[in] value The 32 bit value to write
  865. --/ \sa Physical Addresses
  866. procedure bcm2835_peri_write_nb (paddr : access stdint_h.uint32_t; value : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:833
  867. pragma Import (C, bcm2835_peri_write_nb, "bcm2835_peri_write_nb");
  868. --/ Alters a number of bits in a 32 peripheral regsiter.
  869. --/ It reads the current valu and then alters the bits deines as 1 in mask,
  870. --/ according to the bit value in value.
  871. --/ All other bits that are 0 in the mask are unaffected.
  872. --/ Use this to alter a subset of the bits in a register.
  873. --/ The write is done twice, and is therefore always safe in terms of
  874. --/ manual section 1.3 Peripheral access precautions for correct memory ordering
  875. --/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
  876. --/ \param[in] value The 32 bit value to write, masked in by mask.
  877. --/ \param[in] mask Bitmask that defines the bits that will be altered in the register.
  878. --/ \sa Physical Addresses
  879. procedure bcm2835_peri_set_bits
  880. (paddr : access stdint_h.uint32_t;
  881. value : stdint_h.uint32_t;
  882. mask : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:846
  883. pragma Import (C, bcm2835_peri_set_bits, "bcm2835_peri_set_bits");
  884. --/ @} // end of lowlevel
  885. --/ \defgroup gpio GPIO register access
  886. --/ These functions allow you to control the GPIO interface. You can set the
  887. --/ function of each GPIO pin, read the input state and set the output state.
  888. --/ @{
  889. --/ Sets the Function Select register for the given pin, which configures
  890. --/ the pin as Input, Output or one of the 6 alternate functions.
  891. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  892. --/ \param[in] mode Mode to set the pin to, one of BCM2835_GPIO_FSEL_* from \ref bcm2835FunctionSelect
  893. procedure bcm2835_gpio_fsel (pin : stdint_h.uint8_t; mode : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:858
  894. pragma Import (C, bcm2835_gpio_fsel, "bcm2835_gpio_fsel");
  895. --/ Sets the specified pin output to
  896. --/ HIGH.
  897. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  898. --/ \sa bcm2835_gpio_write()
  899. procedure bcm2835_gpio_set (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:864
  900. pragma Import (C, bcm2835_gpio_set, "bcm2835_gpio_set");
  901. --/ Sets the specified pin output to
  902. --/ LOW.
  903. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  904. --/ \sa bcm2835_gpio_write()
  905. procedure bcm2835_gpio_clr (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:870
  906. pragma Import (C, bcm2835_gpio_clr, "bcm2835_gpio_clr");
  907. --/ Sets any of the first 32 GPIO output pins specified in the mask to
  908. --/ HIGH.
  909. --/ \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05)
  910. --/ \sa bcm2835_gpio_write_multi()
  911. procedure bcm2835_gpio_set_multi (mask : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:876
  912. pragma Import (C, bcm2835_gpio_set_multi, "bcm2835_gpio_set_multi");
  913. --/ Sets any of the first 32 GPIO output pins specified in the mask to
  914. --/ LOW.
  915. --/ \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05)
  916. --/ \sa bcm2835_gpio_write_multi()
  917. procedure bcm2835_gpio_clr_multi (mask : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:882
  918. pragma Import (C, bcm2835_gpio_clr_multi, "bcm2835_gpio_clr_multi");
  919. --/ Reads the current level on the specified
  920. --/ pin and returns either HIGH or LOW. Works whether or not the pin
  921. --/ is an input or an output.
  922. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  923. --/ \return the current level either HIGH or LOW
  924. function bcm2835_gpio_lev (pin : stdint_h.uint8_t) return stdint_h.uint8_t; -- /usr/local/include/bcm2835.h:889
  925. pragma Import (C, bcm2835_gpio_lev, "bcm2835_gpio_lev");
  926. --/ Event Detect Status.
  927. --/ Tests whether the specified pin has detected a level or edge
  928. --/ as requested by bcm2835_gpio_ren(), bcm2835_gpio_fen(), bcm2835_gpio_hen(),
  929. --/ bcm2835_gpio_len(), bcm2835_gpio_aren(), bcm2835_gpio_afen().
  930. --/ Clear the flag for a given pin by calling bcm2835_gpio_set_eds(pin);
  931. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  932. --/ \return HIGH if the event detect status for the given pin is true.
  933. function bcm2835_gpio_eds (pin : stdint_h.uint8_t) return stdint_h.uint8_t; -- /usr/local/include/bcm2835.h:898
  934. pragma Import (C, bcm2835_gpio_eds, "bcm2835_gpio_eds");
  935. --/ Sets the Event Detect Status register for a given pin to 1,
  936. --/ which has the effect of clearing the flag. Use this afer seeing
  937. --/ an Event Detect Status on the pin.
  938. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  939. procedure bcm2835_gpio_set_eds (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:904
  940. pragma Import (C, bcm2835_gpio_set_eds, "bcm2835_gpio_set_eds");
  941. --/ Enable Rising Edge Detect Enable for the specified pin.
  942. --/ When a rising edge is detected, sets the appropriate pin in Event Detect Status.
  943. --/ The GPRENn registers use
  944. --/ synchronous edge detection. This means the input signal is sampled using the
  945. --/ system clock and then it is looking for a ?011? pattern on the sampled signal. This
  946. --/ has the effect of suppressing glitches.
  947. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  948. procedure bcm2835_gpio_ren (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:913
  949. pragma Import (C, bcm2835_gpio_ren, "bcm2835_gpio_ren");
  950. --/ Disable Rising Edge Detect Enable for the specified pin.
  951. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  952. procedure bcm2835_gpio_clr_ren (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:917
  953. pragma Import (C, bcm2835_gpio_clr_ren, "bcm2835_gpio_clr_ren");
  954. --/ Enable Falling Edge Detect Enable for the specified pin.
  955. --/ When a falling edge is detected, sets the appropriate pin in Event Detect Status.
  956. --/ The GPRENn registers use
  957. --/ synchronous edge detection. This means the input signal is sampled using the
  958. --/ system clock and then it is looking for a ?100? pattern on the sampled signal. This
  959. --/ has the effect of suppressing glitches.
  960. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  961. procedure bcm2835_gpio_fen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:926
  962. pragma Import (C, bcm2835_gpio_fen, "bcm2835_gpio_fen");
  963. --/ Disable Falling Edge Detect Enable for the specified pin.
  964. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  965. procedure bcm2835_gpio_clr_fen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:930
  966. pragma Import (C, bcm2835_gpio_clr_fen, "bcm2835_gpio_clr_fen");
  967. --/ Enable High Detect Enable for the specified pin.
  968. --/ When a HIGH level is detected on the pin, sets the appropriate pin in Event Detect Status.
  969. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  970. procedure bcm2835_gpio_hen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:935
  971. pragma Import (C, bcm2835_gpio_hen, "bcm2835_gpio_hen");
  972. --/ Disable High 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_hen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:939
  975. pragma Import (C, bcm2835_gpio_clr_hen, "bcm2835_gpio_clr_hen");
  976. --/ Enable Low Detect Enable for the specified pin.
  977. --/ When a LOW 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_len (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:944
  980. pragma Import (C, bcm2835_gpio_len, "bcm2835_gpio_len");
  981. --/ Disable Low 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_len (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:948
  984. pragma Import (C, bcm2835_gpio_clr_len, "bcm2835_gpio_clr_len");
  985. --/ Enable Asynchronous Rising Edge Detect Enable for the specified pin.
  986. --/ When a rising edge is detected, sets the appropriate pin in Event Detect Status.
  987. --/ Asynchronous means the incoming signal is not sampled by the system clock. As such
  988. --/ rising edges of very short duration can be detected.
  989. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  990. procedure bcm2835_gpio_aren (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:955
  991. pragma Import (C, bcm2835_gpio_aren, "bcm2835_gpio_aren");
  992. --/ Disable Asynchronous Rising Edge Detect Enable for the specified pin.
  993. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  994. procedure bcm2835_gpio_clr_aren (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:959
  995. pragma Import (C, bcm2835_gpio_clr_aren, "bcm2835_gpio_clr_aren");
  996. --/ Enable Asynchronous Falling Edge Detect Enable for the specified pin.
  997. --/ When a falling edge is detected, sets the appropriate pin in Event Detect Status.
  998. --/ Asynchronous means the incoming signal is not sampled by the system clock. As such
  999. --/ falling edges of very short duration can be detected.
  1000. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  1001. procedure bcm2835_gpio_afen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:966
  1002. pragma Import (C, bcm2835_gpio_afen, "bcm2835_gpio_afen");
  1003. --/ Disable Asynchronous Falling Edge Detect Enable for the specified pin.
  1004. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  1005. procedure bcm2835_gpio_clr_afen (pin : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:970
  1006. pragma Import (C, bcm2835_gpio_clr_afen, "bcm2835_gpio_clr_afen");
  1007. --/ Sets the Pull-up/down register for the given pin. This is
  1008. --/ used with bcm2835_gpio_pudclk() to set the Pull-up/down resistor for the given pin.
  1009. --/ However, it is usually more convenient to use bcm2835_gpio_set_pud().
  1010. --/ \param[in] pud The desired Pull-up/down mode. One of BCM2835_GPIO_PUD_* from bcm2835PUDControl
  1011. --/ \sa bcm2835_gpio_set_pud()
  1012. procedure bcm2835_gpio_pud (pud : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:977
  1013. pragma Import (C, bcm2835_gpio_pud, "bcm2835_gpio_pud");
  1014. --/ Clocks the Pull-up/down value set earlier by bcm2835_gpio_pud() into the pin.
  1015. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  1016. --/ \param[in] on HIGH to clock the value from bcm2835_gpio_pud() into the pin.
  1017. --/ LOW to remove the clock.
  1018. --/ \sa bcm2835_gpio_set_pud()
  1019. procedure bcm2835_gpio_pudclk (pin : stdint_h.uint8_t; on : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:984
  1020. pragma Import (C, bcm2835_gpio_pudclk, "bcm2835_gpio_pudclk");
  1021. --/ Reads and returns the Pad Control for the given GPIO group.
  1022. --/ \param[in] group The GPIO pad group number, one of BCM2835_PAD_GROUP_GPIO_*
  1023. --/ \return Mask of bits from BCM2835_PAD_* from \ref bcm2835PadGroup
  1024. function bcm2835_gpio_pad (group : stdint_h.uint8_t) return stdint_h.uint32_t; -- /usr/local/include/bcm2835.h:989
  1025. pragma Import (C, bcm2835_gpio_pad, "bcm2835_gpio_pad");
  1026. --/ Sets the Pad Control for the given GPIO group.
  1027. --/ \param[in] group The GPIO pad group number, one of BCM2835_PAD_GROUP_GPIO_*
  1028. --/ \param[in] control Mask of bits from BCM2835_PAD_* from \ref bcm2835PadGroup. Note
  1029. --/ that it is not necessary to include BCM2835_PAD_PASSWRD in the mask as this
  1030. --/ is automatically included.
  1031. procedure bcm2835_gpio_set_pad (group : stdint_h.uint8_t; control : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:996
  1032. pragma Import (C, bcm2835_gpio_set_pad, "bcm2835_gpio_set_pad");
  1033. --/ Delays for the specified number of milliseconds.
  1034. --/ Uses nanosleep(), and therefore does not use CPU until the time is up.
  1035. --/ However, you are at the mercy of nanosleep(). From the manual for nanosleep():
  1036. --/ If the interval specified in req is not an exact multiple of the granularity
  1037. --/ underlying clock (see time(7)), then the interval will be
  1038. --/ rounded up to the next multiple. Furthermore, after the sleep completes,
  1039. --/ there may still be a delay before the CPU becomes free to once
  1040. --/ again execute the calling thread.
  1041. --/ \param[in] millis Delay in milliseconds
  1042. procedure bcm2835_delay (millis : unsigned); -- /usr/local/include/bcm2835.h:1007
  1043. pragma Import (C, bcm2835_delay, "bcm2835_delay");
  1044. --/ Delays for the specified number of microseconds.
  1045. --/ Uses a combination of nanosleep() and a busy wait loop on the BCM2835 system timers,
  1046. --/ However, you are at the mercy of nanosleep(). From the manual for nanosleep():
  1047. --/ If the interval specified in req is not an exact multiple of the granularity
  1048. --/ underlying clock (see time(7)), then the interval will be
  1049. --/ rounded up to the next multiple. Furthermore, after the sleep completes,
  1050. --/ there may still be a delay before the CPU becomes free to once
  1051. --/ again execute the calling thread.
  1052. --/ For times less than about 450 microseconds, uses a busy wait on the System Timer.
  1053. --/ It is reported that a delay of 0 microseconds on RaspberryPi will in fact
  1054. --/ result in a delay of about 80 microseconds. Your mileage may vary.
  1055. --/ \param[in] micros Delay in microseconds
  1056. procedure bcm2835_delayMicroseconds (micros : stdint_h.uint64_t); -- /usr/local/include/bcm2835.h:1021
  1057. pragma Import (C, bcm2835_delayMicroseconds, "bcm2835_delayMicroseconds");
  1058. --/ Sets the output state of the specified pin
  1059. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  1060. --/ \param[in] on HIGH sets the output to HIGH and LOW to LOW.
  1061. procedure bcm2835_gpio_write (pin : stdint_h.uint8_t; on : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1026
  1062. pragma Import (C, bcm2835_gpio_write, "bcm2835_gpio_write");
  1063. --/ Sets any of the first 32 GPIO output pins specified in the mask to the state given by on
  1064. --/ \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05)
  1065. --/ \param[in] on HIGH sets the output to HIGH and LOW to LOW.
  1066. procedure bcm2835_gpio_write_multi (mask : stdint_h.uint32_t; on : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1031
  1067. pragma Import (C, bcm2835_gpio_write_multi, "bcm2835_gpio_write_multi");
  1068. --/ Sets the first 32 GPIO output pins specified in the mask to the value given by value
  1069. --/ \param[in] value values required for each bit masked in by mask, eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05)
  1070. --/ \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05)
  1071. procedure bcm2835_gpio_write_mask (value : stdint_h.uint32_t; mask : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1036
  1072. pragma Import (C, bcm2835_gpio_write_mask, "bcm2835_gpio_write_mask");
  1073. --/ Sets the Pull-up/down mode for the specified pin. This is more convenient than
  1074. --/ clocking the mode in with bcm2835_gpio_pud() and bcm2835_gpio_pudclk().
  1075. --/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
  1076. --/ \param[in] pud The desired Pull-up/down mode. One of BCM2835_GPIO_PUD_* from bcm2835PUDControl
  1077. procedure bcm2835_gpio_set_pud (pin : stdint_h.uint8_t; pud : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1042
  1078. pragma Import (C, bcm2835_gpio_set_pud, "bcm2835_gpio_set_pud");
  1079. --/ @}
  1080. --/ \defgroup spi SPI access
  1081. --/ These functions let you use SPI0 (Serial Peripheral Interface) to
  1082. --/ interface with an external SPI device.
  1083. --/ @{
  1084. --/ Start SPI operations.
  1085. --/ Forces RPi SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1)
  1086. --/ to alternate function ALT0, which enables those pins for SPI interface.
  1087. --/ You should call bcm2835_spi_end() when all SPI funcitons are complete to return the pins to
  1088. --/ their default functions
  1089. --/ \sa bcm2835_spi_end()
  1090. procedure bcm2835_spi_begin; -- /usr/local/include/bcm2835.h:1057
  1091. pragma Import (C, bcm2835_spi_begin, "bcm2835_spi_begin");
  1092. --/ End SPI operations.
  1093. --/ SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1)
  1094. --/ are returned to their default INPUT behaviour.
  1095. procedure bcm2835_spi_end; -- /usr/local/include/bcm2835.h:1062
  1096. pragma Import (C, bcm2835_spi_end, "bcm2835_spi_end");
  1097. --/ Sets the SPI bit order
  1098. --/ NOTE: has no effect. Not supported by SPI0.
  1099. --/ Defaults to
  1100. --/ \param[in] order The desired bit order, one of BCM2835_SPI_BIT_ORDER_*,
  1101. --/ see \ref bcm2835SPIBitOrder
  1102. procedure bcm2835_spi_setBitOrder (order : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1069
  1103. pragma Import (C, bcm2835_spi_setBitOrder, "bcm2835_spi_setBitOrder");
  1104. --/ Sets the SPI clock divider and therefore the
  1105. --/ SPI clock speed.
  1106. --/ \param[in] divider The desired SPI clock divider, one of BCM2835_SPI_CLOCK_DIVIDER_*,
  1107. --/ see \ref bcm2835SPIClockDivider
  1108. procedure bcm2835_spi_setClockDivider (divider : stdint_h.uint16_t); -- /usr/local/include/bcm2835.h:1075
  1109. pragma Import (C, bcm2835_spi_setClockDivider, "bcm2835_spi_setClockDivider");
  1110. --/ Sets the SPI data mode
  1111. --/ Sets the clock polariy and phase
  1112. --/ \param[in] mode The desired data mode, one of BCM2835_SPI_MODE*,
  1113. --/ see \ref bcm2835SPIMode
  1114. procedure bcm2835_spi_setDataMode (mode : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1081
  1115. pragma Import (C, bcm2835_spi_setDataMode, "bcm2835_spi_setDataMode");
  1116. --/ Sets the chip select pin(s)
  1117. --/ When an bcm2835_spi_transfer() is made, the selected pin(s) will be asserted during the
  1118. --/ transfer.
  1119. --/ \param[in] cs Specifies the CS pins(s) that are used to activate the desired slave.
  1120. --/ One of BCM2835_SPI_CS*, see \ref bcm2835SPIChipSelect
  1121. procedure bcm2835_spi_chipSelect (cs : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1088
  1122. pragma Import (C, bcm2835_spi_chipSelect, "bcm2835_spi_chipSelect");
  1123. --/ Sets the chip select pin polarity for a given pin
  1124. --/ When an bcm2835_spi_transfer() occurs, the currently selected chip select pin(s)
  1125. --/ will be asserted to the
  1126. --/ value given by active. When transfers are not happening, the chip select pin(s)
  1127. --/ return to the complement (inactive) value.
  1128. --/ \param[in] cs The chip select pin to affect
  1129. --/ \param[in] active Whether the chip select pin is to be active HIGH
  1130. procedure bcm2835_spi_setChipSelectPolarity (cs : stdint_h.uint8_t; active : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1097
  1131. pragma Import (C, bcm2835_spi_setChipSelectPolarity, "bcm2835_spi_setChipSelectPolarity");
  1132. --/ Transfers one byte to and from the currently selected SPI slave.
  1133. --/ Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect)
  1134. --/ during the transfer.
  1135. --/ Clocks the 8 bit value out on MOSI, and simultaneously clocks in data from MISO.
  1136. --/ Returns the read data byte from the slave.
  1137. --/ Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM Peripherls manual
  1138. --/ \param[in] value The 8 bit data byte to write to MOSI
  1139. --/ \return The 8 bit byte simultaneously read from MISO
  1140. --/ \sa bcm2835_spi_transfern()
  1141. function bcm2835_spi_transfer (value : stdint_h.uint8_t) return stdint_h.uint8_t; -- /usr/local/include/bcm2835.h:1108
  1142. pragma Import (C, bcm2835_spi_transfer, "bcm2835_spi_transfer");
  1143. --/ Transfers any number of bytes to and from the currently selected SPI slave.
  1144. --/ Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect)
  1145. --/ during the transfer.
  1146. --/ Clocks the len 8 bit bytes out on MOSI, and simultaneously clocks in data from MISO.
  1147. --/ The data read read from the slave is placed into rbuf. rbuf must be at least len bytes long
  1148. --/ Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM Peripherls manual
  1149. --/ \param[in] tbuf Buffer of bytes to send.
  1150. --/ \param[out] rbuf Received bytes will by put in this buffer
  1151. --/ \param[in] len Number of bytes in the tbuf buffer, and the number of bytes to send/received
  1152. --/ \sa bcm2835_spi_transfer()
  1153. procedure bcm2835_spi_transfernb
  1154. (tbuf : Interfaces.C.Strings.chars_ptr;
  1155. rbuf : Interfaces.C.Strings.chars_ptr;
  1156. len : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1120
  1157. pragma Import (C, bcm2835_spi_transfernb, "bcm2835_spi_transfernb");
  1158. --/ Transfers any number of bytes to and from the currently selected SPI slave
  1159. --/ using bcm2835_spi_transfernb.
  1160. --/ The returned data from the slave replaces the transmitted data in the buffer.
  1161. --/ \param[in,out] buf Buffer of bytes to send. Received bytes will replace the contents
  1162. --/ \param[in] len Number of bytes int eh buffer, and the number of bytes to send/received
  1163. --/ \sa bcm2835_spi_transfer()
  1164. procedure bcm2835_spi_transfern (buf : Interfaces.C.Strings.chars_ptr; len : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1128
  1165. pragma Import (C, bcm2835_spi_transfern, "bcm2835_spi_transfern");
  1166. --/ Transfers any number of bytes to the currently selected SPI slave.
  1167. --/ Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect)
  1168. --/ during the transfer.
  1169. --/ \param[in] buf Buffer of bytes to send.
  1170. --/ \param[in] len Number of bytes in the tbuf buffer, and the number of bytes to send
  1171. procedure bcm2835_spi_writenb (buf : Interfaces.C.Strings.chars_ptr; len : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1135
  1172. pragma Import (C, bcm2835_spi_writenb, "bcm2835_spi_writenb");
  1173. --/ @}
  1174. --/ \defgroup i2c I2C access
  1175. --/ These functions let you use I2C (The Broadcom Serial Control bus with the Philips
  1176. --/ I2C bus/interface version 2.1 January 2000.) to interface with an external I2C device.
  1177. --/ @{
  1178. --/ Start I2C operations.
  1179. --/ Forces RPi I2C pins P1-03 (SDA) and P1-05 (SCL)
  1180. --/ to alternate function ALT0, which enables those pins for I2C interface.
  1181. --/ You should call bcm2835_i2c_end() when all I2C functions are complete to return the pins to
  1182. --/ their default functions
  1183. --/ \sa bcm2835_i2c_end()
  1184. procedure bcm2835_i2c_begin; -- /usr/local/include/bcm2835.h:1150
  1185. pragma Import (C, bcm2835_i2c_begin, "bcm2835_i2c_begin");
  1186. --/ End I2C operations.
  1187. --/ I2C pins P1-03 (SDA) and P1-05 (SCL)
  1188. --/ are returned to their default INPUT behaviour.
  1189. procedure bcm2835_i2c_end; -- /usr/local/include/bcm2835.h:1155
  1190. pragma Import (C, bcm2835_i2c_end, "bcm2835_i2c_end");
  1191. --/ Sets the I2C slave address.
  1192. --/ \param[in] addr The I2C slave address.
  1193. procedure bcm2835_i2c_setSlaveAddress (addr : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1159
  1194. pragma Import (C, bcm2835_i2c_setSlaveAddress, "bcm2835_i2c_setSlaveAddress");
  1195. --/ Sets the I2C clock divider and therefore the I2C clock speed.
  1196. --/ \param[in] divider The desired I2C clock divider, one of BCM2835_I2C_CLOCK_DIVIDER_*,
  1197. --/ see \ref bcm2835I2CClockDivider
  1198. procedure bcm2835_i2c_setClockDivider (divider : stdint_h.uint16_t); -- /usr/local/include/bcm2835.h:1164
  1199. pragma Import (C, bcm2835_i2c_setClockDivider, "bcm2835_i2c_setClockDivider");
  1200. --/ Sets the I2C clock divider by converting the baudrate parameter to
  1201. --/ the equivalent I2C clock divider. ( see \sa bcm2835_i2c_setClockDivider)
  1202. --/ For the I2C standard 100khz you would set baudrate to 100000
  1203. --/ The use of baudrate corresponds to its use in the I2C kernel device
  1204. --/ driver. (Of course, bcm2835 has nothing to do with the kernel driver)
  1205. procedure bcm2835_i2c_set_baudrate (baudrate : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1171
  1206. pragma Import (C, bcm2835_i2c_set_baudrate, "bcm2835_i2c_set_baudrate");
  1207. --/ Transfers any number of bytes to the currently selected I2C slave.
  1208. --/ (as previously set by \sa bcm2835_i2c_setSlaveAddress)
  1209. --/ \param[in] buf Buffer of bytes to send.
  1210. --/ \param[in] len Number of bytes in the buf buffer, and the number of bytes to send.
  1211. --/ \return reason see \ref bcm2835I2CReasonCodes
  1212. 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:1178
  1213. pragma Import (C, bcm2835_i2c_write, "bcm2835_i2c_write");
  1214. --/ Transfers any number of bytes from the currently selected I2C slave.
  1215. --/ (as previously set by \sa bcm2835_i2c_setSlaveAddress)
  1216. --/ \param[in] buf Buffer of bytes to receive.
  1217. --/ \param[in] len Number of bytes in the buf buffer, and the number of bytes to received.
  1218. --/ \return reason see \ref bcm2835I2CReasonCodes
  1219. 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:1185
  1220. pragma Import (C, bcm2835_i2c_read, "bcm2835_i2c_read");
  1221. --/ Allows reading from I2C slaves that require a repeated start (without any prior stop)
  1222. --/ to read after the required slave register has been set. For example, the popular
  1223. --/ MPL3115A2 pressure and temperature sensor. Note that your device must support or
  1224. --/ require this mode. If your device does not require this mode then the standard
  1225. --/ combined:
  1226. --/ \sa bcm2835_i2c_write
  1227. --/ \sa bcm2835_i2c_read
  1228. --/ are a better choice.
  1229. --/ Will read from the slave previously set by \sa bcm2835_i2c_setSlaveAddress
  1230. --/ \param[in] regaddr Buffer containing the slave register you wish to read from.
  1231. --/ \param[in] buf Buffer of bytes to receive.
  1232. --/ \param[in] len Number of bytes in the buf buffer, and the number of bytes to received.
  1233. --/ \return reason see \ref bcm2835I2CReasonCodes
  1234. function bcm2835_i2c_read_register_rs
  1235. (regaddr : Interfaces.C.Strings.chars_ptr;
  1236. buf : Interfaces.C.Strings.chars_ptr;
  1237. len : stdint_h.uint32_t) return stdint_h.uint8_t; -- /usr/local/include/bcm2835.h:1200
  1238. pragma Import (C, bcm2835_i2c_read_register_rs, "bcm2835_i2c_read_register_rs");
  1239. --/ Allows sending an arbitrary number of bytes to I2C slaves before issuing a repeated
  1240. --/ start (with no prior stop) and reading a response.
  1241. --/ Necessary for devices that require such behavior, such as the MLX90620.
  1242. --/ Will write to and read from the slave previously set by \sa bcm2835_i2c_setSlaveAddress
  1243. --/ \param[in] cmds Buffer containing the bytes to send before the repeated start condition.
  1244. --/ \param[in] cmds_len Number of bytes to send from cmds buffer
  1245. --/ \param[in] buf Buffer of bytes to receive.
  1246. --/ \param[in] buf_len Number of bytes to receive in the buf buffer.
  1247. --/ \return reason see \ref bcm2835I2CReasonCodes
  1248. function bcm2835_i2c_write_read_rs
  1249. (cmds : Interfaces.C.Strings.chars_ptr;
  1250. cmds_len : stdint_h.uint32_t;
  1251. buf : Interfaces.C.Strings.chars_ptr;
  1252. buf_len : stdint_h.uint32_t) return stdint_h.uint8_t; -- /usr/local/include/bcm2835.h:1211
  1253. pragma Import (C, bcm2835_i2c_write_read_rs, "bcm2835_i2c_write_read_rs");
  1254. --/ @}
  1255. --/ \defgroup st System Timer access
  1256. --/ Allows access to and delays using the System Timer Counter.
  1257. --/ @{
  1258. --/ Read the System Timer Counter register.
  1259. --/ \return the value read from the System Timer Counter Lower 32 bits register
  1260. function bcm2835_st_read return stdint_h.uint64_t; -- /usr/local/include/bcm2835.h:1221
  1261. pragma Import (C, bcm2835_st_read, "bcm2835_st_read");
  1262. --/ Delays for the specified number of microseconds with offset.
  1263. --/ \param[in] offset_micros Offset in microseconds
  1264. --/ \param[in] micros Delay in microseconds
  1265. procedure bcm2835_st_delay (offset_micros : stdint_h.uint64_t; micros : stdint_h.uint64_t); -- /usr/local/include/bcm2835.h:1226
  1266. pragma Import (C, bcm2835_st_delay, "bcm2835_st_delay");
  1267. --/ @}
  1268. --/ \defgroup pwm Pulse Width Modulation
  1269. --/ Allows control of 2 independent PWM channels. A limited subset of GPIO pins
  1270. --/ can be connected to one of these 2 channels, allowing PWM control of GPIO pins.
  1271. --/ You have to set the desired pin into a particular Alt Fun to PWM output. See the PWM
  1272. --/ documentation on the Main Page.
  1273. --/ @{
  1274. --/ Sets the PWM clock divisor,
  1275. --/ to control the basic PWM pulse widths.
  1276. --/ \param[in] divisor Divides the basic 19.2MHz PWM clock. You can use one of the common
  1277. --/ values BCM2835_PWM_CLOCK_DIVIDER_* in \ref bcm2835PWMClockDivider
  1278. procedure bcm2835_pwm_set_clock (divisor : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1241
  1279. pragma Import (C, bcm2835_pwm_set_clock, "bcm2835_pwm_set_clock");
  1280. --/ Sets the mode of the given PWM channel,
  1281. --/ allowing you to control the PWM mode and enable/disable that channel
  1282. --/ \param[in] channel The PWM channel. 0 or 1.
  1283. --/ \param[in] markspace Set true if you want Mark-Space mode. 0 for Balanced mode.
  1284. --/ \param[in] enabled Set true to enable this channel and produce PWM pulses.
  1285. procedure bcm2835_pwm_set_mode
  1286. (channel : stdint_h.uint8_t;
  1287. markspace : stdint_h.uint8_t;
  1288. enabled : stdint_h.uint8_t); -- /usr/local/include/bcm2835.h:1248
  1289. pragma Import (C, bcm2835_pwm_set_mode, "bcm2835_pwm_set_mode");
  1290. --/ Sets the maximum range of the PWM output.
  1291. --/ The data value can vary between 0 and this range to control PWM output
  1292. --/ \param[in] channel The PWM channel. 0 or 1.
  1293. --/ \param[in] range The maximum value permitted for DATA.
  1294. procedure bcm2835_pwm_set_range (channel : stdint_h.uint8_t; c_range : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1254
  1295. pragma Import (C, bcm2835_pwm_set_range, "bcm2835_pwm_set_range");
  1296. --/ Sets the PWM pulse ratio to emit to DATA/RANGE,
  1297. --/ where RANGE is set by bcm2835_pwm_set_range().
  1298. --/ \param[in] channel The PWM channel. 0 or 1.
  1299. --/ \param[in] data Controls the PWM output ratio as a fraction of the range.
  1300. --/ Can vary from 0 to RANGE.
  1301. procedure bcm2835_pwm_set_data (channel : stdint_h.uint8_t; data : stdint_h.uint32_t); -- /usr/local/include/bcm2835.h:1261
  1302. pragma Import (C, bcm2835_pwm_set_data, "bcm2835_pwm_set_data");
  1303. --/ @}
  1304. --/ @example blink.c
  1305. --/ Blinks RPi GPIO pin 11 on and off
  1306. --/ @example input.c
  1307. --/ Reads the state of an RPi input pin
  1308. --/ @example event.c
  1309. --/ Shows how to use event detection on an input pin
  1310. --/ @example spi.c
  1311. --/ Shows how to use SPI interface to transfer a byte to and from an SPI device
  1312. --/ @example spin.c
  1313. --/ Shows how to use SPI interface to transfer a number of bytes to and from an SPI device
  1314. --/ @example pwm.c
  1315. --/ Shows how to use PWM to control GPIO pins
  1316. --/ @example i2c.c
  1317. --/ Command line utility for executing i2c commands with the
  1318. --/ Broadcom bcm2835. Contributed by Shahrooz Shahparnia.
  1319. --/ example gpio.c
  1320. --/ Command line utility for executing gpio commands with the
  1321. --/ Broadcom bcm2835. Contributed by Shahrooz Shahparnia.
  1322. end bcm2835_h;