feat: ariel-os example initial#97
Conversation
|
|
||
| | EndpointTy | kind | handler | | ||
| | ---------- | ---- | ------- | | ||
| | PingEndpoint | blocking | ping_handler | |
There was a problem hiding this comment.
Just a note that we should probably pick a different handler for the docs, I need to remove this from my examples too. As of today, ping is built-in to postcard-rpc, so it's confusing to users if there is a "builtin" one and a provided one.
| let mut config = embassy_usb::Config::new(0x16c0, 0x27DD); | ||
| config.manufacturer = Some("OneVariable"); | ||
| config.product = Some("ov-twin"); | ||
| config.serial_number = Some("12345678"); |
There was a problem hiding this comment.
This should probably be dynamic and not const - it should use the serial number of the device, e.g. from flash memory or whatever
|
|
||
| type AppMutex = embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| type AppDriver = usb::UsbDriver; | ||
| type AppStorage = WireStorage<AppMutex, AppDriver, 256, 256, 64, 256>; |
There was a problem hiding this comment.
Does Ariel have opinions on configurable params like this? For example setting the relevant buffer sizes here?
There was a problem hiding this comment.
Somewhat ... we define env variables for those and set them from the build system. The usb descriptor sizes, we didn't expose yet, though.
|
|
||
| /// Helper to get unique ID from flash | ||
| pub fn get_unique_id() -> Option<u64> { | ||
| // TODO |
There was a problem hiding this comment.
Ariel has a device id in bytes form (I think platform specific length), this needs wiring up and convert to u64.
|
|
||
| pub struct Context; | ||
|
|
||
| type AppMutex = embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
There was a problem hiding this comment.
On ariel, any application might run in isr, one-thread or multi-threaded mode, so I tend to default to the criticalsection mutex.
| loop { | ||
| // Somehow at least on nrf52840dk, this is needed, otherwise the | ||
| // `ariel_os_embassy::init_task()` task starves. | ||
| Timer::after(Duration::from_millis(100)).await; |
There was a problem hiding this comment.
This stumped me. Somehow the other task (on the same executor) is starved without this delay here, and USB doesn't enumerate anymore.
| pub cell: StaticCell<Mutex<M, EUsbWireTxInner<D>>>, | ||
| } | ||
|
|
||
| /// A helper type for `static` storage of buffers and driver components |
There was a problem hiding this comment.
So this is WireStorage without the USB state. The impl is copy&pasted and then I removed some lines.
A lot can be deduplicated here, also in the original implementation. Ideally they'd all share snippets. It took me some time to get an idea of what's postcard specific and what not. Also, the poststation variant has only some small differences, which are IMO hard to spot.
There was a problem hiding this comment.
Ideally they'd all share snippets
Or maybe the no-usb-state version could be a field of the original one.
| // In principle you might want to call msos_feature() just on a specific function, | ||
| // if your device also has other functions that still use standard class drivers. | ||
|
|
||
| // TODO: increase ariel MSOS descriptors |
There was a problem hiding this comment.
TODO (Ariel defaults for MSOS are too small. Works without on Linux.)
This adds an example based on Ariel OS.
Currently WIP, as Ariel likes to keep control of the usb builder, as does postcard-rpc. Ownership conflict.