NAME
HiPi::BCM2835
VERSION
Version 0.01
SYNOPSYS
use HiPi::BCM2835 qw( :registers :memory :function
:pud :pad :pins :spi :pwm);
HiPi::BCM2835::bcm2835_init();
...
...
HiPi::BCM2835::bcm2835_close();
DESCRIPTION
This module is a thin wrapper around the excellent BCM2835 C library by Mike McCauley, <mikem@open.com.au
>
The original library and documentation are available at:
http://www.open.com.au/mikem/bcm2835/
Mike also provides his own wrapper - the CPAN module Device::BCM2835
Normally this module is not used directly in end user code. The modules HiPi::GPIO, HiPi::GPIO::PAD1 and HiPi::GPIO::PAD5 are intended for direct end user use.
EXPORTED CONSTANT TAGS
:registers
BCM2835_PERI_BASE
BCM2835_GPIO_PADS
BCM2835_CLOCK_BASE
BCM2835_GPIO_BASE
BCM2835_SPI0_BASE
BCM2835_GPIO_PWM
:memory
BCM2835_PAGE_SIZE
BCM2835_BLOCK_SIZE
:function
BCM2835_GPFSEL0
BCM2835_GPFSEL1
BCM2835_GPFSEL2
BCM2835_GPFSEL3
BCM2835_GPFSEL4
BCM2835_GPFSEL5
BCM2835_GPSET0
BCM2835_GPSET1
BCM2835_GPCLR0
BCM2835_GPCLR1
BCM2835_GPLEV0
BCM2835_GPLEV1
BCM2835_GPEDS0
BCM2835_GPEDS1
BCM2835_GPREN0
BCM2835_GPREN1
BCM2835_GPFEN0
BCM2835_GPFEN1
BCM2835_GPHEN0
BCM2835_GPHEN1
BCM2835_GPLEN0
BCM2835_GPLEN1
BCM2835_GPAREN0
BCM2835_GPAREN1
BCM2835_GPAFEN0
BCM2835_GPAFEN1
BCM2835_GPPUD
BCM2835_GPPUDCLK0
BCM2835_GPPUDCLK1
BCM2835_GPIO_FSEL_INPT
BCM2835_GPIO_FSEL_OUTP
BCM2835_GPIO_FSEL_ALT0
BCM2835_GPIO_FSEL_ALT1
BCM2835_GPIO_FSEL_ALT2
BCM2835_GPIO_FSEL_ALT3
BCM2835_GPIO_FSEL_ALT4
BCM2835_GPIO_FSEL_ALT5
BCM2835_GPIO_FSEL_MASK
:pud
BCM2835_GPIO_PUD_OFF
BCM2835_GPIO_PUD_DOWN
BCM2835_GPIO_PUD_UP
:pads
BCM2835_PADS_GPIO_0_27
BCM2835_PADS_GPIO_28_45
BCM2835_PADS_GPIO_46_53
BCM2835_PAD_PASSWRD
BCM2835_PAD_SLEW_RATE_UNLIMITED
BCM2835_PAD_HYSTERESIS_ENABLED
BCM2835_PAD_DRIVE_2mA
BCM2835_PAD_DRIVE_4mA
BCM2835_PAD_DRIVE_6mA
BCM2835_PAD_DRIVE_8mA
BCM2835_PAD_DRIVE_10mA
BCM2835_PAD_DRIVE_12mA
BCM2835_PAD_DRIVE_14mA
BCM2835_PAD_DRIVE_16mA
BCM2835_PAD_GROUP_GPIO_0_27
BCM2835_PAD_GROUP_GPIO_28_45
BCM2835_PAD_GROUP_GPIO_46_53
:pins
RPI_GPIO_P1_03
RPI_GPIO_P1_05
RPI_GPIO_P1_07
RPI_GPIO_P1_08
RPI_GPIO_P1_10
RPI_GPIO_P1_11
RPI_GPIO_P1_12
RPI_GPIO_P1_13
RPI_GPIO_P1_15
RPI_GPIO_P1_16
RPI_GPIO_P1_18
RPI_GPIO_P1_19
RPI_GPIO_P1_21
RPI_GPIO_P1_22
RPI_GPIO_P1_23
RPI_GPIO_P1_24
RPI_GPIO_P1_26
RPI_V2_GPIO_P1_03
RPI_V2_GPIO_P1_05
RPI_V2_GPIO_P1_07
RPI_V2_GPIO_P1_08
RPI_V2_GPIO_P1_10
RPI_V2_GPIO_P1_11
RPI_V2_GPIO_P1_12
RPI_V2_GPIO_P1_13
RPI_V2_GPIO_P1_15
RPI_V2_GPIO_P1_16
RPI_V2_GPIO_P1_18
RPI_V2_GPIO_P1_19
RPI_V2_GPIO_P1_21
RPI_V2_GPIO_P1_22
RPI_V2_GPIO_P1_23
RPI_V2_GPIO_P1_24
RPI_V2_GPIO_P1_26
RPI_V2_GPIO_P5_03
RPI_V2_GPIO_P5_04
RPI_V2_GPIO_P5_05
RPI_V2_GPIO_P5_06
:spi
BCM2835_SPI0_CS
BCM2835_SPI0_FIFO
BCM2835_SPI0_CLK
BCM2835_SPI0_DLEN
BCM2835_SPI0_LTOH
BCM2835_SPI0_DC
BCM2835_SPI0_CS_LEN_LONG
BCM2835_SPI0_CS_DMA_LEN
BCM2835_SPI0_CS_CSPOL2
BCM2835_SPI0_CS_CSPOL1
BCM2835_SPI0_CS_CSPOL0
BCM2835_SPI0_CS_RXF
BCM2835_SPI0_CS_RXR
BCM2835_SPI0_CS_TXD
BCM2835_SPI0_CS_RXD
BCM2835_SPI0_CS_DONE
BCM2835_SPI0_CS_TE_EN
BCM2835_SPI0_CS_LMONO
BCM2835_SPI0_CS_LEN
BCM2835_SPI0_CS_REN
BCM2835_SPI0_CS_ADCS
BCM2835_SPI0_CS_INTR
BCM2835_SPI0_CS_INTD
BCM2835_SPI0_CS_DMAEN
BCM2835_SPI0_CS_TA
BCM2835_SPI0_CS_CSPOL
BCM2835_SPI0_CS_CLEAR
BCM2835_SPI0_CS_CLEAR_RX
BCM2835_SPI0_CS_CLEAR_TX
BCM2835_SPI0_CS_CPOL
BCM2835_SPI0_CS_CPHA
BCM2835_SPI0_CS_CS
BCM2835_SPI_BIT_ORDER_LSBFIRST
BCM2835_SPI_BIT_ORDER_MSBFIRST
BCM2835_SPI_MODE0
BCM2835_SPI_MODE1
BCM2835_SPI_MODE2
BCM2835_SPI_MODE3
BCM2835_SPI_CS0
BCM2835_SPI_CS1
BCM2835_SPI_CS2
BCM2835_SPI_CS_NONE
BCM2835_SPI_CLOCK_DIVIDER_65536
BCM2835_SPI_CLOCK_DIVIDER_32768
BCM2835_SPI_CLOCK_DIVIDER_16384
BCM2835_SPI_CLOCK_DIVIDER_8192
BCM2835_SPI_CLOCK_DIVIDER_4096
BCM2835_SPI_CLOCK_DIVIDER_2048
BCM2835_SPI_CLOCK_DIVIDER_1024
BCM2835_SPI_CLOCK_DIVIDER_512
BCM2835_SPI_CLOCK_DIVIDER_256
BCM2835_SPI_CLOCK_DIVIDER_128
BCM2835_SPI_CLOCK_DIVIDER_64
BCM2835_SPI_CLOCK_DIVIDER_32
BCM2835_SPI_CLOCK_DIVIDER_16
BCM2835_SPI_CLOCK_DIVIDER_8
BCM2835_SPI_CLOCK_DIVIDER_4
BCM2835_SPI_CLOCK_DIVIDER_2
BCM2835_SPI_CLOCK_DIVIDER_1
:pwm
BCM2835_PWM_CONTROL
BCM2835_PWM_STATUS
BCM2835_PWM0_RANGE
BCM2835_PWM0_DATA
BCM2835_PWM1_RANGE
BCM2835_PWM1_DATA
BCM2835_PWMCLK_CNTL
BCM2835_PWMCLK_DIV
BCM2835_PWM1_MS_MODE
BCM2835_PWM1_USEFIFO
BCM2835_PWM1_REVPOLAR
BCM2835_PWM1_OFFSTATE
BCM2835_PWM1_REPEATFF
BCM2835_PWM1_SERIAL
BCM2835_PWM1_ENABLE
BCM2835_PWM0_MS_MODE
BCM2835_PWM0_USEFIFO
BCM2835_PWM0_REVPOLAR
BCM2835_PWM0_OFFSTATE
BCM2835_PWM0_REPEATFF
BCM2835_PWM0_SERIAL
BCM2835_PWM0_ENABLE
METHODS
The methods listed at http://www.open.com.au/mikem/bcm2835/modules.html are wrapped.
An example to set Raspberry Pi GPIO Pin 11 mode to output and 'on', then reset RPi pins 3 & 5 for standard I2C use (alt function 0);
use HiPi::BCM2835 qw( :pins :function );
HiPi::BCM2835::bcm2835_gpio_fsel( RPI_V2_GPIO_P1_11 , BCM2835_GPIO_FSEL_OUTP);
HiPi::BCM2835::bcm2835_gpio_set( RPI_V2_GPIO_P1_11);
HiPi::BCM2835::bcm2835_gpio_fsel( RPI_V2_GPIO_P1_03 , BCM2835_GPIO_FSEL_ALT0);
HiPi::BCM2835::bcm2835_gpio_fsel( RPI_V2_GPIO_P1_05 , BCM2835_GPIO_FSEL_ALT0);
Note that the HiPi::BCM2835 functions expect pin numbers to be the Broadcomm BCM 2835 GPIO pin numbers - which are different to the Raspberry Pi Pad 1 pin header layout. Use the constants RPI_V2_GPIO_P1_xx to get BCM GPIO numbers for Raspberry Pi GPIO header pin numbers.
LICENSE
This work is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version.
License Note
I would normally release any Perl code under the Perl Artistic License but this module wraps several GPL / LGPL C libraries and I feel that the licensing of the entire distribution is simpler if the Perl code is under GPL too.
AUTHOR
Mark Dootson, <mdootson at cpan.org>
COPYRIGHT
Copyright (C) 2012-2013 Mark Dootson, all rights reserved.