Skip to content
This repository was archived by the owner on May 3, 2026. It is now read-only.

Commit d1f7f2c

Browse files
committed
fix build errors
1 parent 450519c commit d1f7f2c

3 files changed

Lines changed: 43 additions & 36 deletions

File tree

src/system/startup.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ extern "C" {
2525
// Initialization routines provided elsewhere
2626
void rtos_initialize();
2727
void vfs_initialize();
28-
void system_daemon_initialize();
29-
void graphical_context_daemon_initialize();
3028

3129
[[gnu::weak]]
3230
void display_initialize() {}
@@ -40,6 +38,8 @@ void __libc_init_array();
4038
void vexTasksRun();
4139
} // extern "C"
4240

41+
void system_daemon_initialize();
42+
4343
// this goes in the first 32-byte chunk of the user program
4444
// which is why the entrypoint is offset from 0x3800000 by 0x20
4545
// only the first 16 bytes of this chunk is used however
@@ -53,7 +53,6 @@ vcodesig vexCodeSig = {V5_SIG_MAGIC, V5_SIG_TYPE_USER, V5_SIG_OWNER_PARTNER, V5_
5353
static void pros_init() {
5454
rtos_initialize();
5555
vfs_initialize();
56-
graphical_context_daemon_initialize();
5756
display_initialize();
5857
// Note: system_daemon_initialize must be called last, per design requirements.
5958
system_daemon_initialize();
Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,41 @@
1212
*/
1313

1414
#include "kapi.h"
15+
#include "pros/devices/port.hpp"
1516
#include "system/optimizers.h"
1617
#include "system/user_functions.h" // IWYU pragma: keep
1718

18-
extern void vdml_background_processing();
19+
extern "C" {
20+
void vexTasksRun();
21+
void ser_output_flush();
22+
}
23+
24+
void port_mutex_take_all() {
25+
for (int i = 0; i < zest::SmartPort::MAX_SMART_PORTS; i++) {
26+
zest::SmartPort::from_index(i).get_mutex().take();
27+
}
28+
}
29+
30+
void port_mutex_give_all() {
31+
for (int i = 0; i < zest::SmartPort::MAX_SMART_PORTS; i++) {
32+
zest::SmartPort::from_index(i).get_mutex().give();
33+
}
34+
}
1935

20-
extern void port_mutex_take_all();
21-
extern void port_mutex_give_all();
36+
static void _disabled_task(void*);
37+
static void _autonomous_task(void*);
38+
static void _opcontrol_task(void*);
39+
static void _competition_initialize_task(void*);
40+
static void _initialize_task(void*);
41+
static void _system_daemon_task(void*);
2242

2343
static task_stack_t competition_task_stack[TASK_STACK_DEPTH_DEFAULT];
2444
static static_task_s_t competition_task_buffer;
25-
static task_t competition_task;
45+
static pros::task_t competition_task;
2646

2747
static task_stack_t system_daemon_task_stack[TASK_STACK_DEPTH_DEFAULT];
2848
static static_task_s_t system_daemon_task_buffer;
29-
static task_t system_daemon_task;
30-
31-
static void _disabled_task(void* ign);
32-
static void _autonomous_task(void* ign);
33-
static void _opcontrol_task(void* ign);
34-
static void _competition_initialize_task(void* ign);
35-
36-
static void _initialize_task(void* ign);
37-
static void _system_daemon_task(void* ign);
49+
static pros::task_t system_daemon_task;
3850

3951
enum state_task {
4052
E_OPCONTROL_TASK = 0,
@@ -43,18 +55,15 @@ enum state_task {
4355
E_COMP_INIT_TASK
4456
};
4557

46-
char task_names[4][32] = {
58+
static const char task_names[4][32] = {
4759
"User Operator Control (PROS)",
4860
"User Autonomous (PROS)",
4961
"User Disabled (PROS)",
5062
"User Comp. Init. (PROS)"
5163
};
52-
task_fn_t task_fns[4] =
53-
{_opcontrol_task, _autonomous_task, _disabled_task, _competition_initialize_task};
5464

55-
extern void ser_output_flush(void);
56-
57-
void vexTasksRun();
65+
static task_fn_t task_fns[4] =
66+
{_opcontrol_task, _autonomous_task, _disabled_task, _competition_initialize_task};
5867

5968
// does the basic background operations that need to occur every 2ms
6069
static inline void do_background_operations() {
@@ -63,12 +72,11 @@ static inline void do_background_operations() {
6372
rtos_suspend_all();
6473
vexTasksRun();
6574
rtos_resume_all();
66-
vdml_background_processing();
6775
port_mutex_give_all();
6876
}
6977

70-
static void _system_daemon_task(void* ign) {
71-
uint32_t time = millis();
78+
static void _system_daemon_task(void*) {
79+
uint32_t time = pros::millis();
7280
// Initialize status to an invalid state to force an update the first loop
7381
uint32_t status = (uint32_t)(1 << 8);
7482
uint32_t task_state;
@@ -78,7 +86,7 @@ static void _system_daemon_task(void* ign) {
7886
// Take all port mutexes to prevent user code from attempting to access VDML during this time.
7987
// User code could be running if a task is created from a global ctor
8088
port_mutex_take_all();
81-
task_delay(2);
89+
pros::c::task_delay(2);
8290
port_mutex_give_all();
8391

8492
// start up user initialize task. once the user initialize function completes,
@@ -94,18 +102,18 @@ static void _system_daemon_task(void* ign) {
94102
&competition_task_buffer
95103
);
96104

97-
time = millis();
98-
while (!task_notify_take(true, 2)) {
105+
time = pros::millis();
106+
while (!pros::c::task_notify_take(true, 2)) {
99107
// wait for initialize to finish
100108
do_background_operations();
101109
}
102110
while (1) {
103111
do_background_operations();
104112

105-
if (unlikely(status != competition_get_status())) {
113+
if (unlikely(status != pros::c::competition_get_status())) {
106114
// Have a new competition status, need to clean up whatever's running
107115
uint32_t old_status = status;
108-
status = competition_get_status();
116+
status = pros::c::competition_get_status();
109117
enum state_task state = E_OPCONTROL_TASK;
110118
if ((status & COMPETITION_DISABLED) && (old_status & COMPETITION_DISABLED)) {
111119
// Don't restart the disabled task even if other bits have changed (e.g. auton bit)
@@ -124,13 +132,13 @@ static void _system_daemon_task(void* ign) {
124132
state = E_AUTON_TASK;
125133
}
126134

127-
task_state = task_get_state(competition_task);
135+
task_state = pros::c::task_get_state(competition_task);
128136
// delete the task only if it's in normal operation (e.g. not deleted)
129137
// The valid task states AREN'T deleted, invalid, or running (running
130138
// means it's the current task, which will never be the case)
131-
if (task_state == E_TASK_STATE_READY || task_state == E_TASK_STATE_BLOCKED
132-
|| task_state == E_TASK_STATE_SUSPENDED) {
133-
task_delete(competition_task);
139+
if (task_state == pros::E_TASK_STATE_READY || task_state == pros::E_TASK_STATE_BLOCKED
140+
|| task_state == pros::E_TASK_STATE_SUSPENDED) {
141+
pros::c::task_delete(competition_task);
134142
}
135143

136144
competition_task = task_create_static(
@@ -144,7 +152,7 @@ static void _system_daemon_task(void* ign) {
144152
);
145153
}
146154

147-
task_delay_until(&time, 2);
155+
pros::c::task_delay_until(&time, 2);
148156
}
149157
}
150158

@@ -165,7 +173,7 @@ void system_daemon_initialize() {
165173
#define FUNC(NAME) \
166174
static void _##NAME##_task(void* ign) { \
167175
user_##NAME(); \
168-
task_notify(system_daemon_task); \
176+
pros::c::task_notify(system_daemon_task); \
169177
}
170178
#include "system/user_functions/c_list.h"
171179
#undef FUNC

0 commit comments

Comments
 (0)