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.

1429 lines
78 KiB

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