Skip to content

Commit

Permalink
Merge pull request #49 from badgeteam/renze/troopers2023
Browse files Browse the repository at this point in the history
Troopers 2023: initial support
  • Loading branch information
renzenicolai authored Jul 4, 2023
2 parents 5a549a6 + c609792 commit adbf182
Show file tree
Hide file tree
Showing 36 changed files with 4,419 additions and 0 deletions.
17 changes: 17 additions & 0 deletions components/driver_launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if(CONFIG_DRIVER_LAUNCHER_ENABLE)
set(srcs
"modlauncher.c"
)
else()
set(srcs "")
endif()

set(include
"include"
)

idf_component_register(
SRCS "${srcs}"
INCLUDE_DIRS "${include}"
REQUIRES micropython
)
5 changes: 5 additions & 0 deletions components/driver_launcher/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
menu "Driver: Badge.team launcher"
config DRIVER_BADGEAPI_ENABLE
bool "Enable the Badge.team launcher driver"
default n
endmenu
36 changes: 36 additions & 0 deletions components/driver_launcher/modlauncher.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef NO_QSTR
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/runtime.h"
#include <driver/uart.h>

#include <esp_system.h>
#include "soc/rtc.h"
#include "soc/rtc_cntl_reg.h"
#endif

#define TAG "LAUNCHER_UPY"

void driver_launcher_init() {

}

static mp_obj_t driver_launcher_return_to_launcher() {
REG_WRITE(RTC_CNTL_STORE0_REG, 0);
esp_restart();
return mp_const_none;
}

static MP_DEFINE_CONST_FUN_OBJ_0(launcher_return_to_launcher_obj, driver_launcher_return_to_launcher);

STATIC const mp_rom_map_elem_t launcher_module_globals_table[] = {
{MP_ROM_QSTR(MP_QSTR_exit_python), MP_ROM_PTR(&launcher_return_to_launcher_obj)},
};

STATIC MP_DEFINE_CONST_DICT(launcher_module_globals, launcher_module_globals_table);

//===================================
const mp_obj_module_t launcher_module = {
.base = {&mp_type_module},
.globals = (mp_obj_dict_t *)&launcher_module_globals,
};
17 changes: 17 additions & 0 deletions components/driver_launcher/project_include.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Include all files that contain MP bindings
set(mods
"${COMPONENT_DIR}/modlauncher.c"
)

#Define the name of your module here
set(mod_name "launcher")
set(mod_register "launcher")

if(CONFIG_DRIVER_LAUNCHER_ENABLE)
message(STATUS "Launcher API enabled")
set(EXTMODS "${EXTMODS}" "${mods}" CACHE INTERNAL "")
set(EXTMODS_NAMES "${EXTMODS_NAMES}" "${mod_name}" CACHE INTERNAL "")
set(EXTMODS_INIT "${EXTMODS_INIT}" "\"${mod_name}\"@\"${mod_register}\"^" CACHE INTERNAL "")
else()
message(STATUS "Launcher API disabled")
endif()
Loading

0 comments on commit adbf182

Please sign in to comment.