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.

1432 lines
79 KiB

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