-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added usb support for USB MSC wired up to uSD card for mouting to computer. * Updated main settings screen to have a USB MSC button for enabling and disabling USB MSC. Deault is disabled on boot so that programming / logging can be done. * Refactor box-emu-hal some to have kconfig for selecting hardware version and configuring the input driver based on that. * Added support for Aw9523 input driver (V1 hardware which changes compared to V0) * Update espp submodule * Update file system to expose sdcard for use by usb subsystem. related / WIP #45 #46
- Loading branch information
Showing
21 changed files
with
1,584 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
idf_component_register( | ||
INCLUDE_DIRS "include" | ||
SRC_DIRS "src" | ||
REQUIRES "driver" "heap" "fatfs" "esp_lcd" "esp_psram" "spi_flash" "nvs_flash" "codec" "display" "display_drivers" "mcp23x17" "input_drivers" "tt21100" "gt911" "drv2605" "event_manager" "i2c" "task" "timer" | ||
REQUIRES "driver" "heap" "fatfs" "esp_lcd" "esp_psram" "esp_tinyusb" "spi_flash" "nvs_flash" "codec" "aw9523" "display" "display_drivers" "mcp23x17" "input_drivers" "tt21100" "gt911" "drv2605" "event_manager" "i2c" "task" "timer" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,33 @@ | ||
menu "BOX Emulator HAL Configuration" | ||
menu "BOX Emulator Configuration" | ||
|
||
choice | ||
prompt "Hardware Configuration" | ||
prompt "Hardware Revision" | ||
default HARDWARE_V1 | ||
help | ||
Select the version of the hardware you're using. | ||
config HARDWARE_V0 | ||
bool "Hardware V0" | ||
help | ||
This is the hardware version 0 of the BOX. It uses custom 3d printed button plastics and tactile switches. | ||
It only supports the ESP32-S3-BOX. | ||
config HARDWARE_V1 | ||
bool "Hardware V1" | ||
help | ||
This is the hardware version 1 of the BOX. It uses gameboy color button plastics and membranes | ||
and supports both the ESP32-S3-BOX and the ESP32-S3-BOX-3. It also adds support for physical volume | ||
buttons, battery measurement, and a battery charging LED. | ||
endchoice | ||
|
||
choice | ||
prompt "Module Configuration" | ||
default HARDWARE_BOX | ||
help | ||
Select the dev-kit / hardware you're using. | ||
Select which display + SoC module you're using. | ||
config HARDWARE_BOX | ||
bool "ESP BOX" | ||
bool "ESP32-S3-BOX" | ||
config HARDWARE_BOX_3 | ||
bool "ESP BOX 3" | ||
config HARDWARE_TDECK | ||
bool "LILYGO T DECK" | ||
depends on HARDWARE_V1 | ||
bool "ESP32-S3-BOX-3" | ||
endchoice | ||
|
||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## IDF Component Manager Manifest File | ||
dependencies: | ||
espressif/esp_tinyusb: "^1.4.2" | ||
idf: "^5.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#if CONFIG_HARDWARE_BOX | ||
#include "box.hpp" | ||
#elif CONFIG_HARDWARE_BOX_3 | ||
#include "box_3.hpp" | ||
#else | ||
#error "Invalid module selection" | ||
#endif | ||
|
||
#if CONFIG_HARDWARE_V0 | ||
#include "emu_v0.hpp" | ||
#elif CONFIG_HARDWARE_V1 | ||
#include "emu_v1.hpp" | ||
#else | ||
#error "Invalid hardware version" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#if CONFIG_HARDWARE_V0 | ||
#include "mcp23x17.hpp" | ||
using InputDriver = espp::Mcp23x17; | ||
static constexpr uint16_t START_PIN = (1<<0) << 0; // start pin is on port a of the MCP23x17 | ||
static constexpr uint16_t SELECT_PIN = (1<<1) << 0; // select pin is on port a of the MCP23x17 | ||
static constexpr uint16_t UP_PIN = (1<<0) << 8; // up pin is on port b of the MCP23x17 | ||
static constexpr uint16_t DOWN_PIN = (1<<1) << 8; // down pin is on port b of the MCP23x17 | ||
static constexpr uint16_t LEFT_PIN = (1<<2) << 8; // left pin is on port b of the MCP23x17 | ||
static constexpr uint16_t RIGHT_PIN = (1<<3) << 8; // right pin is on port b of the MCP23x17 | ||
static constexpr uint16_t A_PIN = (1<<4) << 8; // a pin is on port b of the MCP23x17 | ||
static constexpr uint16_t B_PIN = (1<<5) << 8; // b pin is on port b of the MCP23x17 | ||
static constexpr uint16_t X_PIN = (1<<6) << 8; // x pin is on port b of the MCP23x17 | ||
static constexpr uint16_t Y_PIN = (1<<7) << 8; // y pin is on port b of the MCP23x17 | ||
static constexpr uint16_t DIRECTION_MASK = (UP_PIN | DOWN_PIN | LEFT_PIN | RIGHT_PIN | A_PIN | B_PIN | X_PIN | Y_PIN | START_PIN | SELECT_PIN); | ||
static constexpr uint16_t INTERRUPT_MASK = (START_PIN | SELECT_PIN); | ||
static constexpr uint8_t PORT_0_DIRECTION_MASK = DIRECTION_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_DIRECTION_MASK = (DIRECTION_MASK >> 8) & 0xFF; | ||
static constexpr uint8_t PORT_0_INTERRUPT_MASK = INTERRUPT_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_INTERRUPT_MASK = (INTERRUPT_MASK >> 8) & 0xFF; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#if CONFIG_HARDWARE_V1 | ||
#include "aw9523.hpp" | ||
using InputDriver = espp::Aw9523; | ||
static constexpr gpio_num_t VBAT_SENSE_PIN = GPIO_NUM_14; // battery sense pin is on GPIO 14 | ||
static constexpr gpio_num_t AW9523_INT_PIN = GPIO_NUM_21; // interrupt pin is on GPIO 21 | ||
static constexpr uint16_t UP_PIN = (1<<0) << 0; // up pin is on port 0 of the AW9523 | ||
static constexpr uint16_t DOWN_PIN = (1<<1) << 0; // down pin is on port 0 of the AW9523 | ||
static constexpr uint16_t LEFT_PIN = (1<<2) << 0; // left pin is on port 0 of the AW9523 | ||
static constexpr uint16_t RIGHT_PIN = (1<<3) << 0; // right pin is on port 0 of the AW9523 | ||
static constexpr uint16_t A_PIN = (1<<4) << 0; // a pin is on port 0 of the AW9523 | ||
static constexpr uint16_t B_PIN = (1<<5) << 0; // b pin is on port 0 of the AW9523 | ||
static constexpr uint16_t X_PIN = (1<<6) << 0; // x pin is on port 0 of the AW9523 | ||
static constexpr uint16_t Y_PIN = (1<<7) << 0; // y pin is on port 0 of the AW9523 | ||
static constexpr uint16_t START_PIN = (1<<0) << 8; // start pin is on port 1 of the AW9523 | ||
static constexpr uint16_t SELECT_PIN = (1<<1) << 8; // select pin is on port 1 of the AW9523 | ||
static constexpr uint16_t BAT_ALERT_PIN = (1<<3) << 8; // battery alert pin is on port 1 of the AW9523 | ||
static constexpr uint16_t VOL_UP_PIN = (1<<4) << 8; // volume up pin is on port 1 of the AW9523 | ||
static constexpr uint16_t VOL_DOWN_PIN = (1<<5) << 8; // volume down pin is on port 1 of the AW9523 | ||
static constexpr uint16_t DIRECTION_MASK = (UP_PIN | DOWN_PIN | LEFT_PIN | RIGHT_PIN | A_PIN | B_PIN | X_PIN | Y_PIN | START_PIN | SELECT_PIN | BAT_ALERT_PIN | VOL_UP_PIN | VOL_DOWN_PIN); | ||
static constexpr uint16_t INTERRUPT_MASK = (BAT_ALERT_PIN); | ||
static constexpr uint8_t PORT_0_DIRECTION_MASK = DIRECTION_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_DIRECTION_MASK = (DIRECTION_MASK >> 8) & 0xFF; | ||
static constexpr uint8_t PORT_0_INTERRUPT_MASK = INTERRUPT_MASK & 0xFF; | ||
static constexpr uint8_t PORT_1_INTERRUPT_MASK = (INTERRUPT_MASK >> 8) & 0xFF; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include <tinyusb.h> | ||
#include <tusb_msc_storage.h> | ||
|
||
#include "fs_init.hpp" | ||
|
||
bool usb_is_enabled(); | ||
void usb_init(); | ||
void usb_deinit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.