Skip to content
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

[Epic] - Gain deep understanding of mbed os #1

Closed
ladislas opened this issue Nov 21, 2019 · 3 comments
Closed

[Epic] - Gain deep understanding of mbed os #1

ladislas opened this issue Nov 21, 2019 · 3 comments
Assignees
Labels
01 - type: epic General discussion about a futur or current topic

Comments

@ladislas
Copy link
Member

ladislas commented Nov 21, 2019

It's important do precisely study and understand how mbed works, the different API, drivers & communication stacks.

This issue of type: epic will be used to gather information, share what we have learned and things that could be useful in the future.

Resources

@ladislas ladislas added 01 - type: epic General discussion about a futur or current topic 90 - priority: high in progress labels Nov 21, 2019
@ladislas
Copy link
Member Author

Communication / Command Processing

In our avr prototype, we use a homemade circular buffer to group commands before processing.

mbed provides something similar with built-in critical sections lock so it can be used from ISR (if needed).

https://os.mbed.com/docs/mbed-os/v5.14/apis/circularbuffer.html

Both have push/write, pop/read, peek/peek and status functions.

Our buffer also has a hasPattern function to look for specific patterns inside the buffer, e.g. the start sequence (https://github.com/leka/LKAlphaComSpecs/#start-sequence)

https://github.com/leka/LKAlphaOS-avr/blob/develop/lib/Buffer/Buffer.cpp#L153

@ladislas
Copy link
Member Author

Thread synchronization with EventFlags

https://os.mbed.com/docs/mbed-os/v5.14/apis/eventflags.html

I haven't tested it, but EventFlags could be a very nice tool to synchronize our threads with the wait_any function:

https://os.mbed.com/docs/mbed-os/v5.14/mbed-os-api-doxy/classrtos_1_1_event_flags.html#a666b81f3ea18439300f8c6d88cacad80

For LED animation, something like this could work, we need to try it out:

// inside a thread function doing the animation
while(true) {
	// ...
	leds.shine(200, 34, 78);
	if event_flags.wait_any(STOP_FLAG, 10/*ms to wait*/) != 0 {
		break; // break from while loop
	}
	leds.shine(150, 34, 90);
	// ...
}

The same tool can be used to "start" threads.

signal_wait should also be explored:

https://os.mbed.com/docs/mbed-os/v5.14/mbed-os-api-doxy/classrtos_1_1_thread.html#a2b0659360b5cb4b1273d2362398c0294

@ladislas
Copy link
Member Author

ladislas commented Feb 5, 2020

Simplify your code with mbed-events

@ladislas ladislas moved this from Backlog to To do in LekaOS - Epics & Stories Mar 30, 2020
@ladislas ladislas moved this from To do to In progress in LekaOS - Epics & Stories Mar 30, 2020
@ladislas ladislas changed the title Gain deep understanding of mbed os [Epic] - Gain deep understanding of mbed os Aug 28, 2020
LekaOS - Epics & Stories automation moved this from In progress to Done Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 - type: epic General discussion about a futur or current topic
Projects
No open projects
Development

No branches or pull requests

2 participants