add app
This commit is contained in:
31
src/App.cpp
Normal file
31
src/App.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
#include "App.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
#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
|
||||
}
|
||||
21
src/App.hpp
Normal file
21
src/App.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include<stdint.h>
|
||||
|
||||
class App {
|
||||
|
||||
public:
|
||||
|
||||
App();
|
||||
~App() = default;
|
||||
|
||||
uint32_t main();
|
||||
|
||||
private:
|
||||
|
||||
uint32_t ledState = 0;
|
||||
uint32_t blinkTime = 250;
|
||||
const char *TAG = "app";
|
||||
|
||||
};
|
||||
@@ -6,4 +6,4 @@ idf_component_register(
|
||||
PRIV_REQUIRES spi_flash
|
||||
REQUIRES esp_driver_gpio
|
||||
INCLUDE_DIRS "."
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
34
src/pins.hpp
Normal file
34
src/pins.hpp
Normal file
@@ -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;
|
||||
Reference in New Issue
Block a user