-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from stevenewald/subscribe
Add subscriptions for buttons
- Loading branch information
Showing
26 changed files
with
457 additions
and
115 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
namespace edge { | ||
constexpr uint8_t MAX_PROCESSES = 10; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,13 +1,20 @@ | ||
#pragma once | ||
|
||
#include "drivers/driver_commands.hpp" | ||
#include "drivers/driver_enums.hpp" | ||
|
||
#include <stdio.h> | ||
|
||
namespace edge::drivers { | ||
|
||
void do_async_work(); | ||
|
||
etl::optional<int> handle_command(DriverType type, int arg1, int arg2, int arg3); | ||
etl::optional<int> handle_command(DriverCommand type, int arg1, int arg2, int arg3); | ||
|
||
void handle_subscribe( | ||
DriverSubscribe type, ButtonCallbackPtr callback, int arg1, int arg2, | ||
uint8_t process_id | ||
); | ||
|
||
etl::optional<button_subscribe_callback> get_ready_callback(uint8_t process_id); | ||
|
||
} // namespace edge::drivers |
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
namespace edge::drivers { | ||
enum class DriverCommand { | ||
GET_TIME = 0, | ||
LED_DISPLAY = 1, | ||
BUTTONS = 2, | ||
TERMINAL_OUTPUT = 3 | ||
}; | ||
|
||
enum class DriverSubscribe { NOTIFY_BUTTON_PRESS = 0 }; | ||
|
||
enum class GPIOConfiguration { OUT, IN_NORES, IN_PDR, IN_PUR }; | ||
|
||
enum class ButtonType { A = 0, B = 1 }; | ||
|
||
using ButtonCallbackPtr = void (*)(ButtonType); | ||
|
||
struct button_subscribe_callback { | ||
ButtonCallbackPtr callback; | ||
ButtonType type; | ||
}; | ||
|
||
} // namespace edge::drivers |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include "hil/gpiote_wrapper.hpp" | ||
#include "hil/hil_enums.hpp" | ||
|
||
namespace edge::drivers { | ||
class GPIOTEPin { | ||
uint32_t channel; | ||
|
||
public: | ||
// TODO: use PORT event instead so we aren't limited to 8 of these | ||
GPIOTEPin( | ||
uint32_t channel, uint32_t pin_number, aidan::GPIOTEEventPolarity polarity, | ||
void (*callback)(int) | ||
) : channel(channel) | ||
{ | ||
aidan::configure_gpiote_event(channel, pin_number, polarity); | ||
aidan::set_gpiote_callback(channel, callback); | ||
} | ||
|
||
GPIOTEPin(const GPIOTEPin&) = delete; | ||
GPIOTEPin(GPIOTEPin&&) = delete; | ||
GPIOTEPin& operator=(const GPIOTEPin&) = delete; | ||
GPIOTEPin& operator=(GPIOTEPin&&) = delete; | ||
|
||
~GPIOTEPin() { aidan::clear_gpiote_event(channel); } | ||
}; | ||
} // namespace edge::drivers |
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "hil_enums.hpp" | ||
|
||
#include <nrf_gpiote.h> | ||
|
||
#include <cstdint> | ||
|
||
namespace edge::aidan { | ||
|
||
void set_gpiote_callback(uint32_t channel, void (*callback)(int)); | ||
|
||
void clear_gpiote_event(uint32_t channel); | ||
|
||
void configure_gpiote_event( | ||
uint32_t channel, uint32_t pin_number, GPIOTEEventPolarity polarity | ||
); | ||
} // namespace edge::aidan |
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <nrf_gpiote.h> | ||
|
||
namespace edge::aidan { | ||
enum class InputResistor { PUR, PDR, NONE }; | ||
|
||
enum class GPIOTEEventPolarity { | ||
LO_TO_HI = NRF_GPIOTE_POLARITY_LOTOHI, | ||
HI_TO_LO = NRF_GPIOTE_POLARITY_HITOLO, | ||
TOGGLE = NRF_GPIOTE_POLARITY_TOGGLE, | ||
}; | ||
|
||
enum class GPIOTETask { SET, CLEAR }; | ||
} // namespace edge::aidan |
This file contains 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.