typo + main fixes
This commit is contained in:
		
							parent
							
								
									0e0a044c66
								
							
						
					
					
						commit
						045a1e20d5
					
				
							
								
								
									
										6
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								Makefile
									
									
									
									
									
								
							| @ -24,14 +24,14 @@ ifeq ($(strip $(name)), "") | |||||||
| 	@false | 	@false | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| project: .check-name |  | ||||||
| 	@./scripts/scaffold_project.bash $(name) $(SDK_VERSION) |  | ||||||
| 
 |  | ||||||
| ifeq ($(shell test -d $(name) && echo "ok"),) | ifeq ($(shell test -d $(name) && echo "ok"),) | ||||||
| 	@echo "error: project $(name) does not exist" | 	@echo "error: project $(name) does not exist" | ||||||
| 	@false | 	@false | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
|  | project: .check-name | ||||||
|  | 	@./scripts/scaffold_project.bash $(name) $(SDK_VERSION) | ||||||
|  | 
 | ||||||
| format: .check-name | format: .check-name | ||||||
| 	@test -f "$(shell find /usr/bin/ -name astyle)" && astyle --style=java --indent=spaces=4 -K -xC120 $(name)/*.c | 	@test -f "$(shell find /usr/bin/ -name astyle)" && astyle --style=java --indent=spaces=4 -K -xC120 $(name)/*.c | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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. | **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 | ## Get device info | ||||||
| When plugging your device in **BOOTSEL** mode, you can get the device information using: | When plugging your device in **BOOTSEL** mode, you can get the device information using: | ||||||
|  | |||||||
| @ -61,9 +61,8 @@ | |||||||
| #define configENABLE_FPU                        1    // 1: Enable Floating Point Unit
 | #define configENABLE_FPU                        1    // 1: Enable Floating Point Unit
 | ||||||
| #define configUSE_TASK_FPU_SUPPORT              1    // Enable FPU context save/restore
 | #define configUSE_TASK_FPU_SUPPORT              1    // Enable FPU context save/restore
 | ||||||
| #define configENABLE_TRUSTZONE                  0    // 1: Enable TrustZone
 | #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 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
 | #define configUSE_16_BIT_TICKS                  0    // 0: Use 32-bit ticks, 1: Use 16-bit ticks
 | ||||||
| 
 | 
 | ||||||
| // SMP Configuration
 | // SMP Configuration
 | ||||||
|  | |||||||
| @ -38,7 +38,9 @@ struct params { | |||||||
|     state *s; |     state *s; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static state global_state = { | void init_state(state *s) { | ||||||
|  |     if (s != NULL) { | ||||||
|  |         *s = (state) { | ||||||
|             .counter = 0, |             .counter = 0, | ||||||
|             .can_incr = true, |             .can_incr = true, | ||||||
|             .on_reset = false, |             .on_reset = false, | ||||||
| @ -46,9 +48,9 @@ static state global_state = { | |||||||
|             .status = RUNNING, |             .status = RUNNING, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
| void init_state(state *s) { |  | ||||||
|         s->lock = xSemaphoreCreateMutex(); |         s->lock = xSemaphoreCreateMutex(); | ||||||
|     } |     } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| void incr_counter(state *s) { | void incr_counter(state *s) { | ||||||
|     if (s != NULL) { |     if (s != NULL) { | ||||||
| @ -112,10 +114,12 @@ bool is_resetting(state *s) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void reset(state *s) { | void reset(state *s) { | ||||||
|  |     if (s != NULL) { | ||||||
|         s->push_clock = 0; |         s->push_clock = 0; | ||||||
|         s->counter = 0; |         s->counter = 0; | ||||||
|         s->is_reset = true; |         s->is_reset = true; | ||||||
|     } |     } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| void blink_success(uint gpio, uint32_t delay_ms, bool in_task) { | void blink_success(uint gpio, uint32_t delay_ms, bool in_task) { | ||||||
|     gpio_put(gpio, true); |     gpio_put(gpio, true); | ||||||
| @ -239,7 +243,7 @@ void run_led_control(state *s) { | |||||||
| /**
 | /**
 | ||||||
|  * Initialize needed GPIO. |  * Initialize needed GPIO. | ||||||
|  */ |  */ | ||||||
| void init_gpio() { | void init_gpio(void) { | ||||||
| #ifdef PICO_DEFAULT_LED_PIN | #ifdef PICO_DEFAULT_LED_PIN | ||||||
|     gpio_init(PICO_DEFAULT_LED_PIN); |     gpio_init(PICO_DEFAULT_LED_PIN); | ||||||
|     gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); |     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. |  * Increase `uxStackDepth` arg when creating task if needed. | ||||||
|  */ |  */ | ||||||
| void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName) { | 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. |  * 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. |  * 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 |  * 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(); |     stdio_init_all(); | ||||||
|     init_gpio(); |     init_gpio(); | ||||||
| 
 | 
 | ||||||
|  |     state global_state; | ||||||
|     init_state(&global_state); |     init_state(&global_state); | ||||||
| 
 | 
 | ||||||
|     run_health(&global_state); |     run_health(&global_state); | ||||||
|     run_led_control(&global_state); |     run_led_control(&global_state); | ||||||
| 
 | 
 | ||||||
|     vTaskStartScheduler(); |     vTaskStartScheduler(); | ||||||
|  | 
 | ||||||
|  |     blink_failed(PICO_DEFAULT_LED_PIN, 200, false); | ||||||
| } | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 rmanach
						rmanach