Skip to content

Instantly share code, notes, and snippets.

@amaork
Created July 27, 2017 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amaork/e20ffe04172586479f7e539408eb7149 to your computer and use it in GitHub Desktop.
Save amaork/e20ffe04172586479f7e539408eb7149 to your computer and use it in GitHub Desktop.
Raspberry pi restore spi alt0 function
#include <stdio.h>
#include <bcm2835.h>
int main(int argc, char **argv)
{
if (!bcm2835_init()) {
fprintf(stderr, "bcm2835_init failed!\n");
return -1;
}
bcm2835_gpio_fsel(RPI_GPIO_P1_21, BCM2835_GPIO_FSEL_ALT0); /* MISO BCM 9 */
bcm2835_gpio_fsel(RPI_GPIO_P1_19, BCM2835_GPIO_FSEL_ALT0); /* MOSI BCM 10 */
bcm2835_gpio_fsel(RPI_GPIO_P1_23, BCM2835_GPIO_FSEL_ALT0); /* CLK BCM 11 */
bcm2835_close();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment