Skip to content

Commit

Permalink
[FL-1885] USB-UART bridge (#778)
Browse files Browse the repository at this point in the history
* [FL-1885] USB-UART: app and worker
* [FL-1885] USB-UART: UART on CDC0

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
  • Loading branch information
nminaylov and skotopes authored Oct 21, 2021
1 parent c2535f4 commit 88cee46
Show file tree
Hide file tree
Showing 32 changed files with 1,097 additions and 161 deletions.
23 changes: 16 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
PROJECT_ROOT := $(abspath $(dir $(abspath $(firstword $(MAKEFILE_LIST)))))
COPRO_DIR := $(PROJECT_ROOT)/lib/STM32CubeWB/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x

NPROCS := 1
OS := $(shell uname -s)

ifeq ($(OS), Linux)
NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
else ifeq ($(OS), Darwin)
NPROCS := $(shell sysctl -n hw.ncpu)
endif

.PHONY: all
all: bootloader_all firmware_all

Expand All @@ -15,7 +24,7 @@ flash: bootloader_flash firmware_flash

.PHONY: debug
debug:
$(MAKE) -C firmware -j9 debug
$(MAKE) -C firmware -j$(NPROCS) debug

.PHONY: wipe
wipe:
Expand All @@ -24,29 +33,29 @@ wipe:

.PHONY: bootloader_all
bootloader_all:
$(MAKE) -C $(PROJECT_ROOT)/bootloader -j9 all
$(MAKE) -C $(PROJECT_ROOT)/bootloader -j$(NPROCS) all

.PHONY: firmware_all
firmware_all:
$(MAKE) -C $(PROJECT_ROOT)/firmware -j9 all
$(MAKE) -C $(PROJECT_ROOT)/firmware -j$(NPROCS) all

.PHONY: bootloader_clean
bootloader_clean:
$(MAKE) -C $(PROJECT_ROOT)/bootloader -j9 clean
$(MAKE) -C $(PROJECT_ROOT)/bootloader -j$(NPROCS) clean

.PHONY: firmware_clean
firmware_clean:
$(MAKE) -C $(PROJECT_ROOT)/firmware -j9 clean
$(MAKE) -C $(PROJECT_ROOT)/firmware -j$(NPROCS) clean

.PHONY: bootloader_flash
bootloader_flash:
rm $(PROJECT_ROOT)/bootloader/.obj/f*/flash || true
$(MAKE) -C $(PROJECT_ROOT)/bootloader -j9 flash
$(MAKE) -C $(PROJECT_ROOT)/bootloader -j$(NPROCS) flash

.PHONY: firmware_flash
firmware_flash:
rm $(PROJECT_ROOT)/firmware/.obj/f*/flash || true
$(MAKE) -C $(PROJECT_ROOT)/firmware -j9 flash
$(MAKE) -C $(PROJECT_ROOT)/firmware -j$(NPROCS) flash

.PHONY: flash_radio
flash_radio:
Expand Down
2 changes: 2 additions & 0 deletions applications/debug_tools/bad_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ static void badusb_worker(void* context) {
evt.worker.state = WorkerStateDone;
osMessageQueuePut(app->event_queue, &evt, 0, osWaitForever);

furi_hal_hid_kb_release_all();

osThreadExit();
}

Expand Down
6 changes: 6 additions & 0 deletions applications/gpio/gpio_app.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ GpioApp* gpio_app_alloc() {
view_dispatcher_add_view(
app->view_dispatcher, GpioAppViewGpioTest, gpio_test_get_view(app->gpio_test));

view_dispatcher_add_view(
app->view_dispatcher, GpioAppViewUsbUart, variable_item_list_get_view(app->var_item_list));

scene_manager_next_scene(app->scene_manager, GpioSceneStart);

return app;
Expand All @@ -54,10 +57,13 @@ void gpio_app_free(GpioApp* app) {
view_dispatcher_remove_view(app->view_dispatcher, GpioAppViewVarItemList);
variable_item_list_free(app->var_item_list);
view_dispatcher_remove_view(app->view_dispatcher, GpioAppViewGpioTest);
view_dispatcher_remove_view(app->view_dispatcher, GpioAppViewUsbUart);
gpio_test_free(app->gpio_test);

// View dispatcher
view_dispatcher_free(app->view_dispatcher);
scene_manager_free(app->scene_manager);

// Close records
furi_record_close("gui");
furi_record_close("notification");
Expand Down
3 changes: 2 additions & 1 deletion applications/gpio/gpio_app_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <gui/gui.h>
#include <gui/view_dispatcher.h>
#include <gui/scene_manager.h>
#include <gui/modules/submenu.h>
#include <notification/notification-messages.h>

#include <gui/modules/variable-item-list.h>
#include "views/gpio_test.h"

Expand All @@ -25,4 +25,5 @@ struct GpioApp {
typedef enum {
GpioAppViewVarItemList,
GpioAppViewGpioTest,
GpioAppViewUsbUart,
} GpioAppView;
1 change: 1 addition & 0 deletions applications/gpio/scenes/gpio_scene_config.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ADD_SCENE(gpio, start, Start)
ADD_SCENE(gpio, test, Test)
ADD_SCENE(gpio, usb_uart, UsbUart)
8 changes: 8 additions & 0 deletions applications/gpio/scenes/gpio_scene_start.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
#define GPIO_SCENE_START_CUSTOM_EVENT_OTG_OFF (0UL)
#define GPIO_SCENE_START_CUSTOM_EVENT_OTG_ON (1UL)
#define GPIO_SCENE_START_CUSTOM_EVENT_TEST (2UL)
#define GPIO_SCENE_START_CUSTOM_EVENT_USB_UART (3UL)

enum GpioItem {
GpioItemOtg,
GpioItemTest,
GpioItemUsbUart,
};

enum GpioOtg {
Expand All @@ -27,6 +29,9 @@ static void gpio_scene_start_var_list_enter_callback(void* context, uint32_t ind
if(index == GpioItemTest) {
view_dispatcher_send_custom_event(
app->view_dispatcher, GPIO_SCENE_START_CUSTOM_EVENT_TEST);
} else if(index == GpioItemUsbUart) {
view_dispatcher_send_custom_event(
app->view_dispatcher, GPIO_SCENE_START_CUSTOM_EVENT_USB_UART);
}
}

Expand Down Expand Up @@ -65,6 +70,7 @@ void gpio_scene_start_on_enter(void* context) {
variable_item_set_current_value_text(item, gpio_otg_text[GpioOtgOff]);
}
variable_item_list_add(var_item_list, "GPIO tester", 0, NULL, NULL);
variable_item_list_add(var_item_list, "USB-UART bridge", 0, NULL, NULL);

view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewVarItemList);
}
Expand All @@ -80,6 +86,8 @@ bool gpio_scene_start_on_event(void* context, SceneManagerEvent event) {
furi_hal_power_disable_otg();
} else if(event.event == GPIO_SCENE_START_CUSTOM_EVENT_TEST) {
scene_manager_next_scene(app->scene_manager, GpioSceneTest);
} else if(event.event == GPIO_SCENE_START_CUSTOM_EVENT_USB_UART) {
scene_manager_next_scene(app->scene_manager, GpioSceneUsbUart);
}
consumed = true;
}
Expand Down
Loading

0 comments on commit 88cee46

Please sign in to comment.