typo + main fixes

This commit is contained in:
rmanach 2025-02-21 12:50:04 +01:00
parent 0e0a044c66
commit 045a1e20d5
4 changed files with 28 additions and 22 deletions

View File

@ -24,14 +24,14 @@ ifeq ($(strip $(name)), "")
@false
endif
project: .check-name
@./scripts/scaffold_project.bash $(name) $(SDK_VERSION)
ifeq ($(shell test -d $(name) && echo "ok"),)
@echo "error: project $(name) does not exist"
@false
endif
project: .check-name
@./scripts/scaffold_project.bash $(name) $(SDK_VERSION)
format: .check-name
@test -f "$(shell find /usr/bin/ -name astyle)" && astyle --style=java --indent=spaces=4 -K -xC120 $(name)/*.c

View File

@ -52,7 +52,7 @@ make push name=<project_name>
**NOTE**: you have to USB plug your Pico device in **BOOTSEL** mode before executing the command.
After the load, the device will automatically reboot and be unpluged. And the program fresly pushed will start.
After the load, the device will automatically reboot and be unpluged. And the program freshly pushed will start.
## Get device info
When plugging your device in **BOOTSEL** mode, you can get the device information using:

View File

@ -61,9 +61,8 @@
#define configENABLE_FPU 1 // 1: Enable Floating Point Unit
#define configUSE_TASK_FPU_SUPPORT 1 // Enable FPU context save/restore
#define configENABLE_TRUSTZONE 0 // 1: Enable TrustZone
#define configRUN_FREERTOS_SECURE_ONLY 0 // Non-secure mode to match port
#define configENABLE_MPU 0 // 1: Enable Memory Protection Unit (defined twice in original)
#define configRUN_FREERTOS_SECURE_ONLY 1 // 1: Run in secure mode only
#define configENABLE_MPU 0 // 1: Enable Memory Protection Unit (defined twice in original)
#define configUSE_16_BIT_TICKS 0 // 0: Use 32-bit ticks, 1: Use 16-bit ticks
// SMP Configuration

View File

@ -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);
}