Hello,
This is my 1st RAK project. I am altering the PT100_Pressure example. My project has three LEDs and two buttons. It seems none of my interactions with GPIO are working. I can verify that the init is being called, but the LEDS and Interrupt handlers never seem to get called. Can you please take a look and let me know if I am doing things correctly?
My definitions:
#define BUT_1 PB_14 // Pin 1
#define BUT_2 PA_12 // Pin 2
#define LED_1 PA_8 // Pin 3
#define LED_2 4 // Pin 4
#define LED_3 PB_15 // Pin 5
RUI_GPIO_ST but1;
RUI_GPIO_ST but2;
RUI_GPIO_ST led1;
RUI_GPIO_ST led2;
RUI_GPIO_ST led3;
My init:
but1.pin_num = BUT_1;
but1.dir = RUI_GPIO_PIN_DIR_INPUT;
but1.pull = RUI_GPIO_PIN_PULLUP;
rui_gpio_interrupt(true, but1, RUI_GPIO_EDGE_FALL, RUI_GPIO_IRQ_HIGH_PRIORITY, handleButton1);
but2.pin_num = BUT_2;
but1.dir = RUI_GPIO_PIN_DIR_INPUT;
but1.pull = RUI_GPIO_PIN_PULLUP;
rui_gpio_interrupt(true, but2, RUI_GPIO_EDGE_FALL, RUI_GPIO_IRQ_HIGH_PRIORITY, handleButton2);
led1.pin_num = LED_1;
led1.dir = RUI_GPIO_PIN_DIR_OUTPUT;
led1.pull = RUI_GPIO_PIN_NOPULL;
led2.pin_num = LED_2;
led2.dir = RUI_GPIO_PIN_DIR_OUTPUT;
led3.pull = RUI_GPIO_PIN_NOPULL;
led3.pin_num = LED_3;
led3.dir = RUI_GPIO_PIN_DIR_OUTPUT;
led3.pull = RUI_GPIO_PIN_NOPULL;
rui_gpio_init(&but1);
rui_gpio_init(&but2);
rui_gpio_init(&led1);
rui_gpio_init(&led2);
rui_gpio_init(&led3);
rui_gpio_rw(RUI_IF_WRITE,&led1,0);
rui_gpio_rw(RUI_IF_WRITE,&led2,0);
rui_delay_ms(200);
rui_gpio_rw(RUI_IF_WRITE,&led1,1);
rui_gpio_rw(RUI_IF_WRITE,&led2,1);
An example handler:
void handleButton1(){
RUI_LOG_PRINTF("Button 1 press.\r\n");
button1State = !button1State;
if(button1State) {
rui_gpio_rw(RUI_IF_WRITE,&led2,1);
}
else {
rui_gpio_rw(RUI_IF_WRITE,&led2,0);
}
}