blackmagic-esp32-s2/main/main.c

82 lines
1.8 KiB
C
Raw Normal View History

2021-10-14 09:04:00 +01:00
#include <stdint.h>
#include <esp_log.h>
2021-11-22 11:24:16 +00:00
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <rom/ets_sys.h>
#include "usb.h"
2021-10-14 09:30:43 +01:00
#include "nvs.h"
2021-10-17 15:06:53 +01:00
#include "gdb_main.h"
2021-10-24 20:22:24 +01:00
#include "led.h"
2021-12-01 04:15:45 +00:00
#include "cli-uart.h"
2021-10-26 10:37:49 +01:00
#include "i2c.h"
2021-11-22 11:24:16 +00:00
#include "network.h"
#include "network-http.h"
2021-11-22 22:13:12 +00:00
#include "network-uart.h"
2021-11-30 04:38:57 +00:00
#include "network-gdb.h"
#include "factory-reset-service.h"
2021-11-30 04:38:57 +00:00
#include <gdb-glue.h>
#include <soft-uart-log.h>
2021-10-14 09:04:00 +01:00
static const char* TAG = "main";
2021-10-17 15:06:53 +01:00
void gdb_application_thread(void* pvParameters) {
ESP_LOGI("gdb", "start");
while(1) {
gdb_main();
}
ESP_LOGI("gdb", "end");
}
#include <platform.h>
#include <driver/gpio.h>
void pins_init() {
gpio_config_t io_conf;
// disable interrupt
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
// set as output mode
io_conf.mode = GPIO_MODE_OUTPUT;
// bit mask of the pins that you want to set
io_conf.pin_bit_mask = ((1 << SWCLK_PIN) | (1 << SWDIO_PIN));
// disable pull-down mode
io_conf.pull_down_en = 0;
// disable pull-up mode
io_conf.pull_up_en = 0;
// configure GPIO with the given settings
gpio_config(&io_conf);
}
2021-10-14 09:04:00 +01:00
void app_main(void) {
// Software UART logging at pin 7, 57600 baud
soft_uart_log_init(7, 57600);
2021-10-14 09:04:00 +01:00
ESP_LOGI(TAG, "start");
2021-11-22 11:24:16 +00:00
factory_reset_service_init();
2021-11-30 04:38:57 +00:00
gdb_glue_init();
2021-10-28 06:03:33 +01:00
led_init();
led_set_blue(255);
2021-10-14 09:04:00 +01:00
2021-11-22 11:24:16 +00:00
nvs_init();
network_init();
network_http_server_init();
// network_uart_server_init();
2021-11-30 04:38:57 +00:00
network_gdb_server_init();
2021-11-22 11:24:16 +00:00
usb_init();
2021-12-01 04:15:45 +00:00
cli_uart_init();
2021-10-26 10:37:49 +01:00
2021-12-01 04:15:45 +00:00
// TODO uart and i2c share the same pins, need switching mechanics
2021-10-26 10:37:49 +01:00
// i2c_init();
// i2c_scan();
2021-11-22 11:53:19 +00:00
pins_init();
2021-11-24 17:21:32 +00:00
xTaskCreate(&gdb_application_thread, "gdb_thread", 4096, NULL, 5, NULL);
2021-10-28 06:03:33 +01:00
led_set_blue(0);
2021-10-14 09:04:00 +01:00
ESP_LOGI(TAG, "end");
}