WIP Kconfig system, user butter handling, gps peripheral support
This commit is contained in:
parent
1eaafbcef0
commit
bcddd92340
5 changed files with 95 additions and 0 deletions
6
include/user_button.h
Normal file
6
include/user_button.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef __USER_BUTTON_H
|
||||
#define __USER_BUTTON_H
|
||||
|
||||
void user_button_init();
|
||||
|
||||
#endif
|
|
@ -3,6 +3,7 @@ set(COMPONENT_SRCS "\
|
|||
lorcomm.c\
|
||||
ble.c\
|
||||
console.c\
|
||||
user_button.c\
|
||||
cmd_bw.c\
|
||||
cmd_cr.c\
|
||||
cmd_sf.c\
|
||||
|
|
44
main/Kconfig.projbuild
Normal file
44
main/Kconfig.projbuild
Normal file
|
@ -0,0 +1,44 @@
|
|||
menu "LoRComm Config"
|
||||
menuconfig LORCOMM_GPS_ENABLED
|
||||
bool "Enable GPS receiver"
|
||||
help
|
||||
Enables attached GPS receiver
|
||||
|
||||
if LORCOMM_GPS_ENABLED
|
||||
config LORCOMM_GPS_RX
|
||||
int "GPS RX Pin"
|
||||
default 13
|
||||
help
|
||||
GPIO to receive data from GPS receiver
|
||||
endif
|
||||
|
||||
choice LORCOMM_BUTTON_ACTION
|
||||
bool "User Button Action"
|
||||
default LORCOMM_BUTTON_ACTION_HELO
|
||||
help
|
||||
Selection action to be performed when the user button
|
||||
is pressed.
|
||||
|
||||
config LORCOMM_BUTTON_ACTION_NONE
|
||||
bool "Do nothing"
|
||||
help
|
||||
Do nothing
|
||||
|
||||
config LORCOMM_BUTTON_ACTION_HELO
|
||||
bool "Send HELO"
|
||||
help
|
||||
Send out a HELO packet and listen for response
|
||||
|
||||
if LORCOMM_GPS_ENABLED
|
||||
config LORCOMM_BUTTON_ACTION_GPS
|
||||
bool "Send GPS"
|
||||
help
|
||||
Sends GPS coordinates and listens for ACK.
|
||||
endif
|
||||
endchoice
|
||||
|
||||
config LORCOMM_BUTTON_ACTION_ENABLED
|
||||
bool
|
||||
default n if LORCOMM_BUTTON_ACTION_NONE
|
||||
default y
|
||||
endmenu
|
|
@ -14,6 +14,7 @@
|
|||
#include "esp32-lora.h"
|
||||
#include "console.h"
|
||||
#include "ble.h"
|
||||
#include "user_button.h"
|
||||
|
||||
static const char *TAG = "loracom-main";
|
||||
|
||||
|
@ -88,6 +89,10 @@ void app_main(void) {
|
|||
|
||||
lora32_enable_continuous_rx(&lora);
|
||||
|
||||
#ifdef CONFIG_LORCOMM_BUTTON_ACTION_ENABLED
|
||||
user_button_init();
|
||||
#endif
|
||||
|
||||
while(1) {
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
|
39
main/user_button.c
Normal file
39
main/user_button.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "driver/gpio.h"
|
||||
|
||||
static xQueueHandle gpio_evt_queue = NULL;
|
||||
|
||||
static void IRAM_ATTR gpio_isr_handler(void* arg)
|
||||
{
|
||||
uint32_t gpio_num = (uint32_t) arg;
|
||||
xQueueSendFromISR(gpio_evt_queue, &gpio_num, NULL);
|
||||
}
|
||||
|
||||
static void gpio_task_example(void* arg) {
|
||||
uint32_t io_num;
|
||||
for(;;) {
|
||||
if(xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) {
|
||||
printf("GPIO[%d] intr, val: %d\n", io_num, gpio_get_level(io_num));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void user_button_init() {
|
||||
gpio_config_t io_conf;
|
||||
|
||||
io_conf.intr_type = GPIO_PIN_INTR_NEGEDGE;
|
||||
io_conf.mode = GPIO_MODE_INPUT;
|
||||
io_conf.pin_bit_mask = (1L << 0);
|
||||
io_conf.pull_down_en = 0;
|
||||
io_conf.pull_up_en = 0;
|
||||
|
||||
gpio_config(&io_conf);
|
||||
|
||||
gpio_evt_queue = xQueueCreate(10, sizeof(uint32_t));
|
||||
xTaskCreate(gpio_task_example, "gpio_task_example", 2048, NULL, 10, NULL);
|
||||
|
||||
gpio_install_isr_service(0);
|
||||
gpio_isr_handler_add(0, gpio_isr_handler, (void*) 0);
|
||||
}
|
Loading…
Reference in a new issue