typo + main fixes
This commit is contained in:
+23
-16
@@ -38,16 +38,18 @@ struct params {
|
||||
state *s;
|
||||
};
|
||||
|
||||
static state global_state = {
|
||||
.counter = 0,
|
||||
.can_incr = true,
|
||||
.on_reset = false,
|
||||
.is_reset = false,
|
||||
.status = RUNNING,
|
||||
};
|
||||
|
||||
void init_state(state *s) {
|
||||
s->lock = xSemaphoreCreateMutex();
|
||||
if (s != NULL) {
|
||||
*s = (state) {
|
||||
.counter = 0,
|
||||
.can_incr = true,
|
||||
.on_reset = false,
|
||||
.is_reset = false,
|
||||
.status = RUNNING,
|
||||
};
|
||||
|
||||
s->lock = xSemaphoreCreateMutex();
|
||||
}
|
||||
}
|
||||
|
||||
void incr_counter(state *s) {
|
||||
@@ -112,9 +114,11 @@ bool is_resetting(state *s) {
|
||||
}
|
||||
|
||||
void reset(state *s) {
|
||||
s->push_clock = 0;
|
||||
s->counter = 0;
|
||||
s->is_reset = true;
|
||||
if (s != NULL) {
|
||||
s->push_clock = 0;
|
||||
s->counter = 0;
|
||||
s->is_reset = true;
|
||||
}
|
||||
}
|
||||
|
||||
void blink_success(uint gpio, uint32_t delay_ms, bool in_task) {
|
||||
@@ -239,7 +243,7 @@ void run_led_control(state *s) {
|
||||
/**
|
||||
* Initialize needed GPIO.
|
||||
*/
|
||||
void init_gpio() {
|
||||
void init_gpio(void) {
|
||||
#ifdef PICO_DEFAULT_LED_PIN
|
||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||
@@ -253,7 +257,7 @@ void init_gpio() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback when unable to initialize task (not enough stask memory).
|
||||
* Callback when unable to initialize task (not enough stack memory).
|
||||
* Increase `uxStackDepth` arg when creating task if needed.
|
||||
*/
|
||||
void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName) {
|
||||
@@ -276,17 +280,20 @@ void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName) {
|
||||
* You can then push the button and see the red led lights on.
|
||||
* After 10 pushed, the red light lights off and the default led too.
|
||||
* To reset the application, holds the button ~2 secs, the red light will
|
||||
* blink two time and the application will be started again.
|
||||
* blink three times and the application will be started again.
|
||||
*
|
||||
*/
|
||||
int main() {
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
init_gpio();
|
||||
|
||||
state global_state;
|
||||
init_state(&global_state);
|
||||
|
||||
run_health(&global_state);
|
||||
run_led_control(&global_state);
|
||||
|
||||
vTaskStartScheduler();
|
||||
|
||||
blink_failed(PICO_DEFAULT_LED_PIN, 200, false);
|
||||
}
|
||||
Reference in New Issue
Block a user