Created
January 31, 2013 17:33
-
-
Save davisford/4684630 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int accel_spi_init() | |
| { | |
| if (bcm2835_init() != 1) | |
| { | |
| perror("Could not initialize BCM2835 library"); | |
| return -1; | |
| } | |
| // enable SPI for accelerometer | |
| bcm2835_spi_begin(); | |
| bcm2835_spi_setDataMode(BCM2835_SPI_MODE0); | |
| bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_128); | |
| bcm2835_spi_chipSelect(BCM2835_SPI_CS0); | |
| bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS0, LOW); | |
| return 0; | |
| } | |
| // other functions here to read/write accelerometer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int power_spi_init() | |
| { | |
| if (bcm2835_init() != 1) | |
| { | |
| perror("Could not initialize BCM2835 library"); | |
| return -1; | |
| } | |
| // enable SPI for accelerometer | |
| bcm2835_spi_begin(); | |
| bcm2835_spi_setDataMode(BCM2835_SPI_MODE1); | |
| bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_8192); | |
| bcm2835_spi_chipSelect(BCM2835_SPI_CS1); | |
| bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS1, HIGH); | |
| return 0; | |
| } | |
| // other functions here to read/write power management |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment