-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
2,646 additions
and
561 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
BasedOnStyle: LLVM | ||
IndentWidth: 4 | ||
... |
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,3 @@ | ||
.pio | ||
.vscode/.browse.c_cpp.db* | ||
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch | ||
.vscode | ||
dist |
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,6 +1,3 @@ | ||
[submodule "lib/nthaka"] | ||
path = lib/nthaka | ||
url = https://github.com/U-1F992/nthaka.git | ||
[submodule "lib/Bluewhale"] | ||
path = lib/Bluewhale | ||
url = https://github.com/mizuyoukanao/Bluewhale.git |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Submodule Bluewhale
deleted from
eefedb
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 @@ | ||
--- | ||
BasedOnStyle: LLVM | ||
IndentWidth: 4 | ||
... |
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,14 @@ | ||
CMakeLists.txt.user | ||
CMakeCache.txt | ||
CMakeFiles | ||
CMakeScripts | ||
Testing | ||
Makefile | ||
cmake_install.cmake | ||
install_manifest.txt | ||
compile_commands.json | ||
CTestTestfile.cmake | ||
_deps | ||
CMakeUserPresets.json | ||
build | ||
.vscode |
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,25 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
set(CMAKE_VERBOSE_MAKEFILE ON) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
project(jiangtun-core VERSION 0.1.0) | ||
set(CMAKE_C_STANDARD 90) | ||
set(CMAKE_C_EXTENSIONS OFF) | ||
|
||
file(GLOB_RECURSE SRC_FILES src/*.c) | ||
add_library(jiangtun-core STATIC ${SRC_FILES}) | ||
target_include_directories(jiangtun-core PUBLIC include) | ||
target_compile_options(jiangtun-core PRIVATE -Wall -Wextra -Wpedantic -Werror) | ||
|
||
enable_testing() | ||
|
||
add_executable(jiangtun-core_test_command test/command.c) | ||
target_link_libraries(jiangtun-core_test_command jiangtun-core) | ||
target_compile_options(jiangtun-core_test_command PRIVATE -Wall -Wextra -Wpedantic -Werror) | ||
add_test(NAME jiangtun-core_test_command COMMAND jiangtun-core_test_command) | ||
|
||
add_executable(jiangtun-core_test_arduino test/arduino.c) | ||
target_link_libraries(jiangtun-core_test_arduino jiangtun-core) | ||
target_compile_options(jiangtun-core_test_arduino PRIVATE -Wall -Wextra -Wpedantic -Werror) | ||
add_test(NAME jiangtun-core_test_arduino COMMAND jiangtun-core_test_arduino) |
30 changes: 30 additions & 0 deletions
30
lib/jiangtun-core/LoopTimeMeasurement/LoopTimeMeasurement.ino
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,30 @@ | ||
#include <Arduino.h> | ||
|
||
#include <stdio.h> | ||
|
||
static unsigned long start_time = 0; | ||
static unsigned int loop_count = 0; | ||
|
||
void setup(void) { | ||
Serial.begin(); | ||
start_time = micros(); | ||
} | ||
|
||
void loop_(void) { | ||
} | ||
|
||
void loop(void) { | ||
loop_(); | ||
|
||
if (loop_count++ >= 1000) { | ||
unsigned long total_time = micros() - start_time; | ||
double average_time = (double)total_time / 1000.0; | ||
char buffer[256]; | ||
|
||
sprintf(buffer, "Average time per loop: %lf\n", average_time); | ||
Serial.print(buffer); | ||
|
||
start_time = micros(); | ||
loop_count = 0; | ||
} | ||
} |
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,67 @@ | ||
#ifndef JIANGTUN_H | ||
#define JIANGTUN_H | ||
|
||
#include "jiangtun/board.h" | ||
#include "jiangtun/command.h" | ||
#include "jiangtun/compat.h" | ||
#include "jiangtun/optional.h" | ||
#include "jiangtun/report.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define JIANGTUN_LOOPS_FOR_TIMEOUT 5 | ||
#define JIANGTUN_LED_ON_MILLIS 100 | ||
#define JIANGTUN_RESET_BLOCKING_MILLIS 500 | ||
|
||
typedef jiangtun_uint32_t jiangtun_feature_flag_t; | ||
#define JIANGTUN_FEATURE_ENABLE_LED_BLINK ((jiangtun_feature_flag_t)(1 << 4)) | ||
#define JIANGTUN_FEATURE_ENABLE_NXMC2 ((jiangtun_feature_flag_t)(1 << 3)) | ||
#define JIANGTUN_FEATURE_ENABLE_POKECON ((jiangtun_feature_flag_t)(1 << 2)) | ||
#define JIANGTUN_FEATURE_ENABLE_ORCA ((jiangtun_feature_flag_t)(1 << 1)) | ||
#define JIANGTUN_FEATURE_ENABLE_DOL ((jiangtun_feature_flag_t)(1 << 0)) | ||
|
||
typedef enum jiangtun_log_level_t { | ||
JIANGTUN_LOG_LEVEL_WARN, | ||
JIANGTUN_LOG_LEVEL_INFO, | ||
JIANGTUN_LOG_LEVEL_DEBUG | ||
} jiangtun_log_level_t; | ||
|
||
typedef struct jiangtun_t { | ||
jiangtun_board_t *board; | ||
jiangtun_feature_flag_t features; | ||
|
||
jiangtun_nxmc2_command_t nxmc2; | ||
jiangtun_pokecon_command_t pokecon; | ||
jiangtun_orca_command_t orca; | ||
jiangtun_dol_command_t dol; | ||
jiangtun_command_t *commands[4]; | ||
|
||
jiangtun_report_mode3_t reports[4]; | ||
jiangtun_report_mode3_t *recently_patched; | ||
|
||
jiangtun_bool_t any_pending; | ||
|
||
jiangtun_optional_uint8_t carry_over; | ||
|
||
jiangtun_uint32_t timeout_loop; | ||
|
||
jiangtun_optional_uint32_t led_on_start_time; | ||
jiangtun_optional_uint32_t reset_blocking_start_time; | ||
|
||
jiangtun_log_level_t log_level; | ||
|
||
char buffer[128]; | ||
char log_buffer[128]; | ||
} jiangtun_t; | ||
|
||
void jiangtun_init(jiangtun_t *, jiangtun_board_t *, jiangtun_feature_flag_t, | ||
jiangtun_log_level_t); | ||
void jiangtun_loop(jiangtun_t *); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* JIANGTUN_H */ |
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,47 @@ | ||
#ifndef JIANGTUN_BOARD_H | ||
#define JIANGTUN_BOARD_H | ||
|
||
#include "compat.h" | ||
#include "report.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct jiangtun_board_t { | ||
jiangtun_bool_t (*serial_getc)(struct jiangtun_board_t *, | ||
jiangtun_uint8_t *); | ||
void (*serial_puts)(struct jiangtun_board_t *, const char *); | ||
jiangtun_bool_t (*gamecube_send)(struct jiangtun_board_t *, jiangtun_bool_t, | ||
jiangtun_report_mode3_t *); | ||
void (*led_set)(struct jiangtun_board_t *, jiangtun_bool_t); | ||
jiangtun_uint32_t (*get_millis)(struct jiangtun_board_t *); | ||
} jiangtun_board_t; | ||
|
||
typedef jiangtun_bool_t (*jiangtun_serial_getc_t)(jiangtun_board_t *, | ||
jiangtun_uint8_t *); | ||
typedef void (*jiangtun_serial_puts_t)(jiangtun_board_t *, const char *); | ||
typedef jiangtun_bool_t (*jiangtun_gamecube_send_t)(jiangtun_board_t *, | ||
jiangtun_bool_t, | ||
jiangtun_report_mode3_t *); | ||
typedef void (*jiangtun_led_set_t)(jiangtun_board_t *, jiangtun_bool_t); | ||
typedef jiangtun_uint32_t (*jiangtun_get_millis_t)(jiangtun_board_t *); | ||
|
||
jiangtun_bool_t jiangtun_board_serial_getc(jiangtun_board_t *, | ||
jiangtun_uint8_t *); | ||
void jiangtun_board_serial_puts(jiangtun_board_t *, const char *); | ||
jiangtun_bool_t jiangtun_board_gamecube_send(jiangtun_board_t *, | ||
jiangtun_bool_t, | ||
jiangtun_report_mode3_t *); | ||
void jiangtun_board_led_set(jiangtun_board_t *, jiangtun_bool_t); | ||
jiangtun_uint32_t jiangtun_board_get_millis(jiangtun_board_t *); | ||
|
||
void jiangtun_board_init(jiangtun_board_t *, jiangtun_serial_getc_t, | ||
jiangtun_serial_puts_t, jiangtun_gamecube_send_t, | ||
jiangtun_led_set_t, jiangtun_get_millis_t); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* JIANGTUN_BOARD_H */ |
Oops, something went wrong.