diff --git a/scripts/build.sh b/scripts/build.sh index 4e9327c..89504eb 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -10,6 +10,7 @@ export SDKCONFIG_DEFAULTS=${PWD}/config/sdkconfig.defaults . ${IDF_PATH}/export.sh +idf.py set-target esp32s3 idf.py build # idk how to put it in the right place diff --git a/src/App.cpp b/src/App.cpp new file mode 100644 index 0000000..b8ebe65 --- /dev/null +++ b/src/App.cpp @@ -0,0 +1,31 @@ + +#include "App.hpp" + +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_log.h" +#include "sdkconfig.h" + +#include "pins.hpp" + +App::App() { + ESP_LOGI(TAG, "App constructor"); +} + +uint32_t App::main() { + + ESP_LOGI(TAG, "Example configured to blink GPIO LED!"); + gpio_reset_pin(gpio_onboardLed); + gpio_set_direction(gpio_onboardLed, GPIO_MODE_OUTPUT); + + while (1) { + ESP_LOGI(TAG, "Turning the LED %s!", ledState == true ? "ON" : "OFF"); + gpio_set_level(gpio_onboardLed, ledState); + /* Toggle the LED state */ + ledState = !ledState; + vTaskDelay(blinkTime / portTICK_PERIOD_MS); + } + + return 1; // unreachable +} diff --git a/src/App.hpp b/src/App.hpp new file mode 100644 index 0000000..0e42fee --- /dev/null +++ b/src/App.hpp @@ -0,0 +1,21 @@ + +#pragma once + +#include + +class App { + +public: + + App(); + ~App() = default; + + uint32_t main(); + +private: + + uint32_t ledState = 0; + uint32_t blinkTime = 250; + const char *TAG = "app"; + +}; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9a2434a..14d5180 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,4 +6,4 @@ idf_component_register( PRIV_REQUIRES spi_flash REQUIRES esp_driver_gpio INCLUDE_DIRS "." -) \ No newline at end of file +) diff --git a/src/main.cpp b/src/main.cpp index 3263601..1067fb3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,7 +14,7 @@ void app_main(void) { ESP_LOGI(TAG, "Program start"); App app; - int8_t status = app.main(); + int32_t status = app.main(); ESP_LOGI(TAG, "App main returned status %d", status); } diff --git a/src/pins.hpp b/src/pins.hpp new file mode 100644 index 0000000..29a6dec --- /dev/null +++ b/src/pins.hpp @@ -0,0 +1,34 @@ + +#include "driver/gpio.h" + +// onboard led +const gpio_num_t gpio_onboardLed = GPIO_NUM_2; + +// misc +const gpio_num_t gpio_msdDetect = GPIO_NUM_8; +const gpio_num_t gpio_ws2812b = GPIO_NUM_9; + +// i2c +const gpio_num_t gpio_i2c_dout = GPIO_NUM_11; +const gpio_num_t gpio_i2c_din = GPIO_NUM_12; + +// i2c expander interrupts +const gpio_num_t gpio_i2c_intrA = GPIO_NUM_14; +const gpio_num_t gpio_i2c_intrB = GPIO_NUM_13; + +// uart +const gpio_num_t gpio_uart_rx = (gpio_num_t)44; // should already be configured +const gpio_num_t gpio_uart_tx = (gpio_num_t)43; // should already be configured + +// seven segment display +const gpio_num_t gpio_ssd_latch = GPIO_NUM_17; +const gpio_num_t gpio_ssd_clk = GPIO_NUM_18; +const gpio_num_t gpio_ssd_data = GPIO_NUM_21; + +// i2s +const gpio_num_t gpio_i2s_wsel = GPIO_NUM_38; +const gpio_num_t gpio_i2s_din = GPIO_NUM_39; +const gpio_num_t gpio_i2s_bck = (gpio_num_t)40; // idk why it only goes up to 40 +const gpio_num_t gpio_i2s_mck = (gpio_num_t)41; +const gpio_num_t gpio_i2s_mute = (gpio_num_t)42; +const gpio_num_t gpio_i2s_shdn = (gpio_num_t)45;