mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 02:28:36 -07:00
[FL-3889] 5V on GPIO control for ext. modules (#3830)
* Make file extensions case-insensitive * Bump protobuf version * Add support for 5V control via RPC * Add support for 5V control via Expansion protocol * Update running instructions * Update expansion module documentation * Prettify condition * Test RPC OTG control as well * Assets: bump protobuf version * Disable PVS license expiration check, fix PVS warnings Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -64,8 +64,28 @@ typedef enum {
|
||||
* @brief Enumeration of suported control commands.
|
||||
*/
|
||||
typedef enum {
|
||||
ExpansionFrameControlCommandStartRpc = 0x00, /**< Start an RPC session. */
|
||||
ExpansionFrameControlCommandStopRpc = 0x01, /**< Stop an open RPC session. */
|
||||
/** @brief Start an RPC session.
|
||||
*
|
||||
* Must only be used while the RPC session is NOT active.
|
||||
*/
|
||||
ExpansionFrameControlCommandStartRpc = 0x00,
|
||||
/** @brief Stop an open RPC session.
|
||||
*
|
||||
* Must only be used while the RPC session IS active.
|
||||
*/
|
||||
ExpansionFrameControlCommandStopRpc = 0x01,
|
||||
/** @brief Enable OTG (5V) on external GPIO.
|
||||
*
|
||||
* Must only be used while the RPC session is NOT active,
|
||||
* otherwise OTG is to be controlled via RPC messages.
|
||||
*/
|
||||
ExpansionFrameControlCommandEnableOtg = 0x02,
|
||||
/** @brief Disable OTG (5V) on external GPIO.
|
||||
*
|
||||
* Must only be used while the RPC session is NOT active,
|
||||
* otherwise OTG is to be controlled via RPC messages.
|
||||
*/
|
||||
ExpansionFrameControlCommandDisableOtg = 0x03,
|
||||
} ExpansionFrameControlCommand;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
@@ -245,9 +245,18 @@ static bool expansion_worker_handle_state_connected(
|
||||
|
||||
do {
|
||||
if(rx_frame->header.type == ExpansionFrameTypeControl) {
|
||||
if(rx_frame->content.control.command != ExpansionFrameControlCommandStartRpc) break;
|
||||
instance->state = ExpansionWorkerStateRpcActive;
|
||||
if(!expansion_worker_rpc_session_open(instance)) break;
|
||||
const uint8_t command = rx_frame->content.control.command;
|
||||
if(command == ExpansionFrameControlCommandStartRpc) {
|
||||
if(!expansion_worker_rpc_session_open(instance)) break;
|
||||
instance->state = ExpansionWorkerStateRpcActive;
|
||||
} else if(command == ExpansionFrameControlCommandEnableOtg) {
|
||||
furi_hal_power_enable_otg();
|
||||
} else if(command == ExpansionFrameControlCommandDisableOtg) {
|
||||
furi_hal_power_disable_otg();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!expansion_worker_send_status_response(instance, ExpansionFrameErrorNone)) break;
|
||||
|
||||
} else if(rx_frame->header.type == ExpansionFrameTypeHeartbeat) {
|
||||
@@ -279,9 +288,14 @@ static bool expansion_worker_handle_state_rpc_active(
|
||||
if(size_consumed != rx_frame->content.data.size) break;
|
||||
|
||||
} else if(rx_frame->header.type == ExpansionFrameTypeControl) {
|
||||
if(rx_frame->content.control.command != ExpansionFrameControlCommandStopRpc) break;
|
||||
instance->state = ExpansionWorkerStateConnected;
|
||||
expansion_worker_rpc_session_close(instance);
|
||||
const uint8_t command = rx_frame->content.control.command;
|
||||
if(command == ExpansionFrameControlCommandStopRpc) {
|
||||
instance->state = ExpansionWorkerStateConnected;
|
||||
expansion_worker_rpc_session_close(instance);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!expansion_worker_send_status_response(instance, ExpansionFrameErrorNone)) break;
|
||||
|
||||
} else if(rx_frame->header.type == ExpansionFrameTypeStatus) {
|
||||
|
||||
Reference in New Issue
Block a user