-
Notifications
You must be signed in to change notification settings - Fork 65
Expand docs: Baremetal setup, update pico integration #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Sources/EmbeddedSwift/Documentation.docc/SDKSupport/Baremetal.md
Outdated
Show resolved
Hide resolved
Example vector table structure: | ||
|
||
```c | ||
// Vector table for ARM Cortex-M |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a todo or gh issue to migrate these to InlineArray
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's realistic to migrate to InlineArray today -- I think the blocker is @section
being able to handle a not-completely-straightforward array, because the vector table also needs the initial SP (which is not a fptr). I can certainly file a GH issue to track this.
}; | ||
``` | ||
|
||
If you want to actually handle an interrupt (e.g. a GPIO or UART interrupt) in your Swift code, you can forward declare the function in C, and define it using `@cdecl` in Swift: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using InlineArray here would ease this learning curve by not requiring forward declarations.
|
||
However, note that Swift currently does not provide any form of synchronization or "interrupt safety" for the code that executes the interrupt. Namely, if your interrupt handler modifies global variables that are also accessed by your main program, you need to be careful about data races and ensure proper synchronization (such as using atomic operations or disabling interrupts during critical sections). Additionally, interrupt handlers should be kept short and fast to avoid blocking other important system events. | ||
|
||
## Building a minimal project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty great, but likely should move the to build-system support section
@@ -94,7 +93,7 @@ $ export PICO_SDK_PATH=<path_to_pico_sdk> | |||
$ export PICO_TOOLCHAIN_PATH=<path_to_arm_toolchain> | |||
$ ls -al | |||
-rw-r--r-- 1 kuba staff 39B Feb 2 22:08 BridgingHeader.h | |||
-rw-r--r-- 1 kuba staff 1.3K Feb 2 22:08 CMakeLists.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
Some clean up
No description provided.