-
Notifications
You must be signed in to change notification settings - Fork 4
feat: export UARTs to Ariel #68
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
05da4cf
refactor: address clippy lint
chrysn 9d943a6
schema: Define host_facing UART property
chrysn acf7c8d
sbd/ariel: Expose presence of host facing UARTs as `has_host_facing_u…
chrysn d88c0e7
schema/uart: Add property for UART MCU peripherals
chrysn 946e1e7
ariel: Generate code for UARTs
chrysn 2cef98f
ariel: Test code generation
chrysn d73fe14
refactor(uart): equate absent and empty .possible_peripherals
chrysn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,6 +88,27 @@ impl Target { | |
| false | ||
| } | ||
| } | ||
|
|
||
| /// Returns true if there are any UARTs listed for this board. | ||
| #[must_use] | ||
| pub fn has_uarts(&self) -> bool { | ||
| if let Some(uarts) = &self.uarts { | ||
| !uarts.is_empty() | ||
| } else { | ||
| false | ||
| } | ||
| } | ||
|
|
||
| /// Returns true if there are any UARTs listed for this board that have the | ||
| /// [`Uart::host_facing`] property. | ||
| #[must_use] | ||
| pub fn has_host_facing_uart(&self) -> bool { | ||
| if let Some(uarts) = &self.uarts { | ||
| uarts.iter().any(|u| u.host_facing) | ||
| } else { | ||
| false | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] | ||
|
|
@@ -164,6 +185,49 @@ pub struct Uart { | |
| pub tx_pin: String, | ||
| pub cts_pin: Option<String>, | ||
| pub rts_pin: Option<String>, | ||
| /// Peripheral device names, any of which is fundamentally available to serve this connection | ||
| /// as the peripheral that takes control of the TX and RX pins. | ||
| /// | ||
| /// # Usage | ||
| /// | ||
| /// All items in the list are peripheral names of the MCU for which the UART interface is | ||
| /// implemented. For example, on EFM32, a pin combination might be configurable either using | ||
| /// `LEUART0` or `USART1`, in which case those are given as values. | ||
| /// | ||
| /// On some OSes and platforms (e. g., at the time of writing, in Ariel OS on nRF devices), | ||
| /// using that device name might entail using companion peripherals that are statically | ||
| /// selected (e. g. `UARTE0` being bundled with `TIMER4`, `PPI_CH14`, `PPI_CH15` and | ||
| /// `PPI_GROUP5`). This is an implementation detail of the OS; the name in this list is still | ||
| /// only the name of the one peripheral that performs the UART functionality. | ||
| /// | ||
| /// # Future development | ||
| /// | ||
| /// When future versions of `sbd` or the OSes consuming this file learn to process per-MCU | ||
| /// information, this field might go away. Instead, the possible peripherals might be deduced | ||
| /// purely from the MCU's peripheral mapping and the `*_pin` values. | ||
| /// | ||
| /// When multiple UARTs are in use in an application and their possible peripherals overlap, | ||
| /// deciding which of the choices to take is a [hard problem]. When none of the peripherals are | ||
| /// available, the OS's mechanism of choosing a peripheral may need enhancing: For example, | ||
| /// Ariel OS (at the time of writing) only selects the first peripheral. Future versions might | ||
| /// pick the first one that has not previously been taken, and ideally, a static choice would | ||
| /// be made at build time solving the satisfiability problem. | ||
| /// | ||
| /// When no peripheral is given, or all are used for other purposes, the OS may fall back to | ||
| /// bit-banging operation; currently, they do not. | ||
| /// | ||
| /// [hard problem]: https://en.wikipedia.org/wiki/Boolean_satisfiability_problem | ||
| #[serde(default)] | ||
| pub possible_peripherals: Vec<String>, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, so this is clearly chip specific meta info. We'll have to move this there (at some point). Let's go with it for now. |
||
|
|
||
| /// Set if the board supports using it with a host system (e.g. the build host), and this UART | ||
| /// would typically face that system. | ||
| /// | ||
| /// For example, this is set on boards with built-in programmers on UARTs that are exposed by | ||
| /// the programmer as USB serial devices. Typical applications querying this are tools that | ||
| /// report debug or measurement data. | ||
| #[serde(default)] | ||
| pub host_facing: bool, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.