mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-07 22:58:10 -07:00
Add furi_hal_usb_get_config_context()
This commit is contained in:
@@ -1499,6 +1499,7 @@ Function,+,furi_hal_uart_tx,void,"FuriHalUartId, uint8_t*, size_t"
|
||||
Function,+,furi_hal_usb_disable,void,
|
||||
Function,+,furi_hal_usb_enable,void,
|
||||
Function,+,furi_hal_usb_get_config,FuriHalUsbInterface*,
|
||||
Function,+,furi_hal_usb_get_config_context,void*,
|
||||
Function,-,furi_hal_usb_init,void,
|
||||
Function,+,furi_hal_usb_is_locked,_Bool,
|
||||
Function,+,furi_hal_usb_lock,void,
|
||||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
typedef enum {
|
||||
UsbApiEventTypeSetConfig,
|
||||
UsbApiEventTypeGetConfig,
|
||||
UsbApiEventTypeGetConfigContext,
|
||||
UsbApiEventTypeLock,
|
||||
UsbApiEventTypeUnlock,
|
||||
UsbApiEventTypeIsLocked,
|
||||
@@ -168,6 +169,21 @@ FuriHalUsbInterface* furi_hal_usb_get_config() {
|
||||
return return_data.void_value;
|
||||
}
|
||||
|
||||
void* furi_hal_usb_get_config_context() {
|
||||
UsbApiEventReturnData return_data = {
|
||||
.void_value = NULL,
|
||||
};
|
||||
|
||||
UsbApiEventMessage msg = {
|
||||
.lock = api_lock_alloc_locked(),
|
||||
.type = UsbApiEventTypeGetConfigContext,
|
||||
.return_data = &return_data,
|
||||
};
|
||||
|
||||
furi_hal_usb_send_message(&msg);
|
||||
return return_data.void_value;
|
||||
}
|
||||
|
||||
void furi_hal_usb_lock() {
|
||||
UsbApiEventMessage msg = {
|
||||
.lock = api_lock_alloc_locked(),
|
||||
@@ -411,6 +427,9 @@ static void usb_process_message(UsbApiEventMessage* message) {
|
||||
case UsbApiEventTypeGetConfig:
|
||||
message->return_data->void_value = usb.interface;
|
||||
break;
|
||||
case UsbApiEventTypeGetConfigContext:
|
||||
message->return_data->void_value = usb.interface_context;
|
||||
break;
|
||||
case UsbApiEventTypeLock:
|
||||
FURI_LOG_I(TAG, "Mode lock");
|
||||
usb.mode_lock = true;
|
||||
|
||||
@@ -56,6 +56,12 @@ bool furi_hal_usb_set_config(FuriHalUsbInterface* new_if, void* ctx);
|
||||
*/
|
||||
FuriHalUsbInterface* furi_hal_usb_get_config();
|
||||
|
||||
/** Get USB device configuration context
|
||||
*
|
||||
* @return current USB device context
|
||||
*/
|
||||
void* furi_hal_usb_get_config_context();
|
||||
|
||||
/** Lock USB device mode switch
|
||||
*/
|
||||
void furi_hal_usb_lock();
|
||||
|
||||
Reference in New Issue
Block a user