-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring into modular structure with hierarchical CMakeLists.txt t…
…o enable building of unit tests.
- Loading branch information
Showing
48 changed files
with
359 additions
and
229 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
File renamed without changes.
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,29 @@ | ||
add_subdirectory(common) | ||
add_subdirectory(drivers) | ||
add_subdirectory(scheduler) | ||
add_subdirectory(states) | ||
add_subdirectory(tasks) | ||
|
||
add_executable(samwise main.c init.c) | ||
target_link_libraries(samwise PUBLIC scheduler error rfm9x) | ||
|
||
# Global include directory common for all targets | ||
target_include_directories(samwise PUBLIC | ||
"${PROJECT_SOURCE_DIR}/src/common" | ||
"${PROJECT_SOURCE_DIR}/src/drivers/rfm9x" | ||
"${PROJECT_SOURCE_DIR}/src/scheduler" | ||
) | ||
|
||
pico_set_program_name(samwise "samwise") | ||
pico_set_program_version(samwise "0.1") | ||
|
||
# Modify the below lines to enable/disable output over UART/USB | ||
pico_enable_stdio_uart(samwise 0) | ||
pico_enable_stdio_usb(samwise 1) | ||
|
||
# Add the standard include files to the build | ||
target_include_directories(samwise PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/common # common headers | ||
) | ||
|
||
pico_add_extra_outputs(samwise) |
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 @@ | ||
add_subdirectory(error) |
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,6 @@ | ||
add_library(error error.c) | ||
target_link_libraries(error PUBLIC pico_stdlib) | ||
|
||
target_include_directories(error PUBLIC | ||
"${PROJECT_SOURCE_DIR}/src/common" | ||
) |
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 |
---|---|---|
|
@@ -5,4 +5,6 @@ | |
|
||
#pragma once | ||
|
||
#include "pico/stdlib.h" | ||
|
||
void fatal_error(); |
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
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,64 @@ | ||
#pragma once | ||
|
||
#include <stdlib.h> | ||
|
||
#include "typedefs.h" | ||
#include "slate.h" | ||
|
||
#define MAX_TASKS_PER_STATE 10 | ||
|
||
/** | ||
* Holds the info for a single task. A single task can belong to multiple | ||
* states. | ||
*/ | ||
typedef struct sched_task | ||
{ | ||
/** | ||
* Friendly name for the task. | ||
*/ | ||
const char *name; | ||
|
||
/** | ||
* Minimum number of milliseconds between dispatches of this task. | ||
*/ | ||
const uint32_t dispatch_period_ms; | ||
|
||
/** | ||
* Earliest time this task can be dispatched. | ||
*/ | ||
absolute_time_t next_dispatch; | ||
|
||
/** | ||
* Called once when the task initializes. | ||
* @param slate Pointer to the current satellite slate | ||
*/ | ||
void (*task_init)(slate_t *slate); | ||
|
||
/** | ||
* Called each time the task dispatches. | ||
* @param slate Pointer to the current satellite slate | ||
*/ | ||
void (*task_dispatch)(slate_t *slate); | ||
|
||
} sched_task_t; | ||
|
||
/** | ||
* Holds the info for defining a state. | ||
*/ | ||
typedef struct sched_state | ||
{ | ||
/** | ||
* Friendly name for the state. | ||
*/ | ||
const char *name; | ||
|
||
size_t num_tasks; | ||
sched_task_t *task_list[MAX_TASKS_PER_STATE]; | ||
|
||
/** | ||
* Called each time the state dispatches. | ||
* @param slate Pointer to the current satellite slate | ||
* @return The next state to transition to | ||
*/ | ||
struct sched_state *(*get_next_state)(slate_t *slate); | ||
} sched_state_t; |
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 @@ | ||
typedef struct samwise_slate slate_t; | ||
typedef struct sched_state sched_state_t; | ||
typedef struct sched_task sched_task_t; | ||
typedef struct _rfm9x rfm9x_t; |
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 @@ | ||
add_subdirectory(rfm9x) |
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,8 @@ | ||
add_library(rfm9x rfm9x.c) | ||
|
||
target_link_libraries(rfm9x PRIVATE error pico_stdlib hardware_spi) | ||
|
||
target_include_directories(rfm9x PUBLIC | ||
"${PROJECT_SOURCE_DIR}/src/common" | ||
"${PROJECT_SOURCE_DIR}/src/common/error" | ||
) |
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
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
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,12 @@ | ||
#pragma once | ||
|
||
#include "pico/stdlib.h" | ||
|
||
#include "macros.h" | ||
#include "slate.h" | ||
#include "state_machine.h" | ||
|
||
#include "init.h" | ||
|
||
#include "rfm9x.h" | ||
#include "scheduler.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,12 @@ | ||
add_library(scheduler scheduler.c) | ||
target_link_libraries(scheduler PUBLIC pico_stdlib hardware_spi init_state running_state error) | ||
|
||
target_include_directories(scheduler PUBLIC | ||
"${PROJECT_SOURCE_DIR}/src/common" | ||
"${PROJECT_SOURCE_DIR}/src/states/init" | ||
"${PROJECT_SOURCE_DIR}/src/states/running" | ||
) | ||
|
||
# Debug message to print the list of include directories for state_machine | ||
get_target_property(INCLUDE_DIRS scheduler INCLUDE_DIRECTORIES) | ||
message("[state_machine] Include directories: ${INCLUDE_DIRS}") |
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.