-
Notifications
You must be signed in to change notification settings - Fork 0
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
Userspace LED Matrix Driver #49
Conversation
4f4772e
to
9e53e2b
Compare
b18dfac
to
b510042
Compare
44464b7
to
a9afe92
Compare
be852ff
to
023b00b
Compare
include/drivers/driver_enums.hpp
Outdated
@@ -9,6 +9,9 @@ enum class DriverCommand { | |||
BUTTONS = 2, | |||
TERMINAL_OUTPUT = 3, | |||
TIMER_CANCEL = 4, | |||
SET_PIN = 5, | |||
CLEAR_PIN = 6, | |||
SET_PIN_OUTPUT = 7, |
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.
set_pin
and set_pin_output
are kinda confusing
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.
maybe make_pin_output
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.
cahnging to config_pin_output
@@ -11,7 +12,7 @@ namespace edge { | |||
// TLDR: singleton vs everything owned by scheduler, food for thought | |||
class PendingProcessCallbacks { | |||
public: | |||
static constexpr uint8_t MAX_READY_CALLBACKS = 10; | |||
static constexpr uint8_t MAX_READY_CALLBACKS = 20; |
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.
should we bump this to like 64? I can see a world where a lot could reasonably build up in one quantum
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.
agree here but not really the actual issue
include/userlib/syscalls.hpp
Outdated
|
||
void clear_pin(uint32_t pin); | ||
|
||
void make_pin_output(uint32_t pin); |
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.
nit: make names more clear
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.
done
@@ -30,6 +32,15 @@ etl::optional<int> handle_command(DriverCommand type, int arg1, int arg2, int ar | |||
static_cast<uint32_t>(arg1) | |||
); | |||
break; | |||
case DriverCommand::SET_PIN: | |||
edge::aidan::set_gpio_pin(static_cast<uint32_t>(arg1)); |
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'd rather have an actual driver for GPIO vs driver_commands directly interacting with the HAL
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 this is fine for the illustrative purpose
src/drivers/driver_commands.cpp
Outdated
edge::aidan::clear_gpio_pin(static_cast<uint32_t>(arg1)); | ||
break; | ||
case DriverCommand::SET_PIN_OUTPUT: | ||
GPIOPin(static_cast<uint32_t>(arg1), GPIOConfiguration::OUT); |
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 feels like a really weird way to do this...
Side note (I'm willing to do this), it could be cool to have GPIOPin
be a userspace object that is returned by a syscall
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.
we could but doesnt seem needed and i dont love expoisng gpio to userspace if we want to build abstraction, cc these syscalls really just being here for illustration
@@ -1,4 +1,5 @@ | |||
#include "scheduler/pending_process_callbacks.hpp" | |||
#include "userlib/syscalls.hpp" |
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.
Revert?
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.
done
#include "hal/gpio_wrapper.hpp" | ||
#include "microbit_v2.h" | ||
#include "scheduler/pending_process_callbacks.hpp" |
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.
Revert 1 and 3
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.
done
|
||
void upkeep_led_matrix(uint32_t id) | ||
{ | ||
edge::userlib::clear_pin(rows[0]); |
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.
for_each
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.
done, other usages too
|
||
#include <cstdio> | ||
|
||
static uint8_t row_index = 0; |
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 some of these be non-static (moved into stack on led_matrix_task) or at least static function variables?
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.
all on stack now
Happy to handle some of these since some are non critical to getting the demo ready, although none should take very long. lmk |
Userspace only, as requested. Had to add a couple syscalls but it creates a nice little LED wave