fahad@mqs189:~$ cd /opt/phytec-yogurt/BSP-Yocto-i.MX6UL-PD19.1.0/
fahad@mqs189:/opt/phytec-yogurt/BSP-Yocto-i.MX6UL-PD19.1.0$ . environment-setup-cortexa7hf-neon-vfpv4-phytec-linux-gnueabi
fahad@mqs189:/opt/phytec-yogurt/BSP-Yocto-i.MX6UL-PD19.1.0$ echo $ARCH
arm
fahad@mqs189:/opt/phytec-yogurt/BSP-Yocto-i.MX6UL-PD19.1.0$ cd
fahad@mqs189:~$ ls
button_gpio.c examples.desktop mraa snap
Desktop excl Music techveda
Documents LinuxPro_New perl5
Downloads linux-source-4.15.0 Pictures Templates
EXAMPLE minicom.log Public Videos
fahad@mqs189:~$ echo $ARCH
arm
fahad@mqs189:~$ vi button_gpio.c
fahad@mqs189:~$ $CC button_gpio.c -o button_gpio
button_gpio.c:1:10: fatal error: mraa.h: No such file or directory
#include
^~~~~~~~
compilation terminated.
fahad@mqs189:~$
button_gpio.c program:
#include
#include
#define LED_PIN 49 /**< The pin where the LED is connected */
#define BTN_PIN 52 /**< Button is connected to this pin */
int main(void)
{
mraa_gpio_context ledPin; /* Will be used to represnt the LED pin */
mraa_gpio_context btnPin; /* Will be used to represnt the button pin */
uint32_t status; /* Used to toggle the LED */
uint32_t btnState; /* Used to capture the state of the button */
mraa_init();
ledPin = mraa_gpio_init(LED_PIN);
btnPin = mraa_gpio_init(BTN_PIN);
mraa_gpio_dir(ledPin, MRAA_GPIO_OUT);
mraa_gpio_dir(btnPin, MRAA_GPIO_IN);
while(1)
{
status = mraa_gpio_read(btnPin);
printf("STATUS = %d..\n\n",status);
if(status == 1)
{
mraa_gpio_write(ledPin, 1);
printf("LED ON \n");
}
else
{
printf("LED OFF \n");
mraa_gpio_write(ledPin, 0); // active low 0 is on the led
}
sleep(2);
}
return 0;
}