Skip to content

Instantly share code, notes, and snippets.

@KStandiford
Created August 20, 2022 18:29
Show Gist options
  • Save KStandiford/2e7485e226ffe8f3475d526c57dffccc to your computer and use it in GitHub Desktop.
Save KStandiford/2e7485e226ffe8f3475d526c57dffccc to your computer and use it in GitHub Desktop.
pedant comments for piccolo_os_v1

OK, I'll send you a box of commas....

I won't talk about style or language or more SDK compliant ways of doing things, but I did notice a couple of places where minor changes might remove some pitfalls when students start to play with v1.0. And I fell into every single one of these myself! And I still love the simplicity and appreciate that this caused me to deep dive the ARM and SDK documentation. Yes, piccolo_os is a teaching aid, and I learned a lot!

  • piccolo_os.h should be in the CMakeLists.txt add_executable list. Just changing the number of tasks, for example, will not force a build otherwise.
  • running main() in handler mode after piccolo_init() is a mine field. Calling sleep_ms() after that (in order to delay to reconnect the terminal emulator for stdio on USB for example) will just hang. It is trivial to move the call to __piccolo_task_init() from piccolo_init() to the beginning of piccolo_start(). Then the student can play all they want in the Pico SDK while they are setting things up.
  • Of course if you follow my suggestion above, you cannot run the task one time during the task creation. With preemption this becomes a minefield as well, since preemption is not working during task creation. The task_stack = __piccolo_pre_switch(task_stack) can be removed from __piccolo_os_create_task with no impact.
  • OK, one verging on style ... I wish piccolo_sleep() Had the same API as sleep_ms(). (But I didn't fix it in this branch!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment