nopnop2002 / Raspberry-ili9340spi

ILI9340 SPI TFT Library & XPT2046 Touch Screen Library for Raspberry
MIT License
39 stars 16 forks source link

Direct control of the LED pin 8 #25

Closed Aquidneck closed 1 year ago

Aquidneck commented 2 years ago

Objective is to control the LED to on/off. I used the following code additions, with the appropriate additions to the .h file:

define LED 18 // GPIO pin 12

void LED_on(void) { bcm2835_gpio_fsel(LED,BCM2835_GPIO_FSEL_OUTP); // LED bcm2835_gpio_write(LED, HIGH); }

void LED_off(void) { bcm2835_gpio_fsel(LED,BCM2835_GPIO_FSEL_OUTP); // LED bcm2835_gpio_write(LED, LOW); }

Those changes compile successfully, along with the addition of the calls to turn the LED on at the start of the main segment in demo.c and at the end to turn the LED off. I plead guilty to little or no knowledge of the BCM2834, so I just used your existing code for the RES function. The result is now a segmentation fault with those changes in place, whereas it runs normally with the original code.

Any suggestions??

nopnop2002 commented 2 years ago

I plead guilty to little or no knowledge of the BCM2834

Read this when using BCM2835.

https://www.airspayce.com/mikem/bcm2835/group__gpio.html