Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ esp/GBPlay/esp-cmd.bat
server/dist/
server/node_modules/
test-roms/
.project
4 changes: 4 additions & 0 deletions esp/GBPlay_pio/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.pio
.cproject
.project
.settings
4 changes: 4 additions & 0 deletions esp/GBPlay_pio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(GBPlay)
3 changes: 3 additions & 0 deletions esp/GBPlay_pio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# GBPlay hardware code

This code is meant to be compiled using the ESP idf SDK v4.4.x.
5 changes: 5 additions & 0 deletions esp/GBPlay_pio/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# TODO: split up into separate components
idf_component_register(
SRCS "GBPlay.c" "commands.c" "http.c" "socket.c" "hardware/led.c" "hardware/spi.c" "hardware/storage.c" "hardware/wifi.c" "tasks/network_manager.c" "tasks/socket_manager.c" "tasks/status_indicator.c"
INCLUDE_DIRS "."
)
73 changes: 73 additions & 0 deletions esp/GBPlay_pio/main/GBPlay.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include <esp_console.h>
#include <esp_event.h>
#include <soc/soc.h>
#include <soc/rtc_cntl_reg.h>
#include <unistd.h>

#include "commands.h"
#include "hardware/led.h"
#include "hardware/spi.h"
#include "hardware/storage.h"
#include "hardware/wifi.h"

#include "tasks/network_manager.h"
#include "tasks/socket_manager.h"
#include "tasks/status_indicator.h"

#define CONFIG_CONSOLE_MAX_COMMAND_LINE_LENGTH 1024

void init_console()
{
esp_console_repl_t* repl = NULL;
esp_console_dev_uart_config_t uart_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT();

esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
repl_config.max_cmdline_length = CONFIG_CONSOLE_MAX_COMMAND_LINE_LENGTH;

// Prompt to be printed before each line.
// This can be customized, made dynamic, etc.
repl_config.prompt = "GBLink >";

cmds_register();

ESP_ERROR_CHECK(esp_console_new_repl_uart(&uart_config, &repl_config, &repl));
ESP_ERROR_CHECK(esp_console_start_repl(repl));
}

void start_tasks()
{
task_network_manager_start(0 /* core */, 2 /* priority */);
task_status_indicator_start(0 /* core */, 1 /* priority */);

task_socket_manager_start(1 /* core */, 1 /* priority */);
}

void app_main()
{
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); // Disable brownout detector

esp_event_loop_create_default();

// Initialize hardware
led_initialize();
spi_initialize();
storage_initialize();
wifi_initialize();

// Initialize REPL
init_console();

// Let's-a-go
start_tasks();

while (true)
{
sleep(1);
}

wifi_deinitialize();
storage_deinitialize();
spi_deinitialize();

esp_event_loop_delete_default();
}
Loading