|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "hal/spi_types.h" |
| 4 | +#include "driver/gpio.h" |
| 5 | +#include "driver/i2s_std.h" |
| 6 | +#include "driver/spi_master.h" |
| 7 | + |
| 8 | +#include "i2c.hpp" |
| 9 | +#include "st7789.hpp" |
| 10 | +#include "touchpad_input.hpp" |
| 11 | +#include "gt911.hpp" |
| 12 | + |
| 13 | +namespace box_hal { |
| 14 | + |
| 15 | +static constexpr std::string_view dev_kit = "ESP32-S3-BOX-3"; |
| 16 | + |
| 17 | +// internal i2c (touchscreen, audio codec) |
| 18 | +static constexpr auto internal_i2c_port = I2C_NUM_0; |
| 19 | +static constexpr auto internal_i2c_clock_speed = 400 * 1000; |
| 20 | +static constexpr gpio_num_t internal_i2c_sda = GPIO_NUM_8; |
| 21 | +static constexpr gpio_num_t internal_i2c_scl = GPIO_NUM_18; |
| 22 | + |
| 23 | +// external I2c (peripherals) |
| 24 | +static constexpr auto external_i2c_port = I2C_NUM_1; |
| 25 | +static constexpr auto external_i2c_clock_speed = 400 * 1000; |
| 26 | +static constexpr gpio_num_t external_i2c_sda = GPIO_NUM_41; |
| 27 | +static constexpr gpio_num_t external_i2c_scl = GPIO_NUM_40; |
| 28 | + |
| 29 | +// LCD |
| 30 | +static constexpr int lcd_clock_speed = 60 * 1000 * 1000; |
| 31 | +static constexpr auto lcd_spi_num = SPI2_HOST; |
| 32 | +static constexpr gpio_num_t lcd_cs = GPIO_NUM_5; |
| 33 | +static constexpr gpio_num_t lcd_mosi = GPIO_NUM_6; |
| 34 | +static constexpr gpio_num_t lcd_sclk = GPIO_NUM_7; |
| 35 | +static constexpr gpio_num_t lcd_reset = GPIO_NUM_48; |
| 36 | +static constexpr gpio_num_t lcd_dc = GPIO_NUM_4; |
| 37 | +static constexpr gpio_num_t backlight = GPIO_NUM_47; // was 45 on ESP32-S3-BOX |
| 38 | +static constexpr size_t display_width = 320; |
| 39 | +static constexpr size_t display_height = 240; |
| 40 | +static constexpr bool backlight_value = true; |
| 41 | +static constexpr bool reset_value = true; // was false on ESP32-S3-BOX |
| 42 | +static constexpr bool invert_colors = true; |
| 43 | +static constexpr auto rotation = espp::Display::Rotation::LANDSCAPE; |
| 44 | +static constexpr bool mirror_x = true; |
| 45 | +static constexpr bool mirror_y = true; |
| 46 | +using DisplayDriver = espp::St7789; |
| 47 | + |
| 48 | +// touch |
| 49 | +static constexpr bool touch_swap_xy = false; |
| 50 | +static constexpr bool touch_invert_x = false; |
| 51 | +static constexpr bool touch_invert_y = false; |
| 52 | +static constexpr gpio_num_t touch_interrupt = GPIO_NUM_3; |
| 53 | +using TouchDriver = espp::Gt911; |
| 54 | + #define TOUCH_DRIVER_USE_WRITE 1 |
| 55 | + #define TOUCH_DRIVER_USE_READ 0 |
| 56 | + #define TOUCH_DRIVER_USE_WRITE_READ 1 |
| 57 | + |
| 58 | +// sound |
| 59 | +static constexpr gpio_num_t sound_power_pin = GPIO_NUM_46; |
| 60 | +static constexpr auto i2s_port = I2S_NUM_0; |
| 61 | +static constexpr gpio_num_t i2s_mck_io = GPIO_NUM_2; |
| 62 | +static constexpr gpio_num_t i2s_bck_io = GPIO_NUM_17; |
| 63 | +static constexpr gpio_num_t i2s_ws_io = GPIO_NUM_45; // was 47 on ESP32-S3-BOX |
| 64 | +static constexpr gpio_num_t i2s_do_io = GPIO_NUM_15; |
| 65 | +static constexpr gpio_num_t i2s_di_io = GPIO_NUM_16; |
| 66 | +static constexpr gpio_num_t mute_pin = GPIO_NUM_1; |
| 67 | + |
| 68 | +// uSD card |
| 69 | +static constexpr gpio_num_t sdcard_cs = GPIO_NUM_10; |
| 70 | +static constexpr gpio_num_t sdcard_mosi = GPIO_NUM_11; |
| 71 | +static constexpr gpio_num_t sdcard_miso = GPIO_NUM_13; |
| 72 | +static constexpr gpio_num_t sdcard_sclk = GPIO_NUM_12; |
| 73 | +static constexpr auto sdcard_spi_num = SPI3_HOST; |
| 74 | + |
| 75 | +} // namespace box_hal |
0 commit comments