2020-10-29 07:11:16 +00:00
|
|
|
#include "power.h"
|
2021-01-08 04:42:48 +00:00
|
|
|
#include "power_views.h"
|
2020-10-29 07:11:16 +00:00
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
#include <furi.h>
|
2020-11-11 06:31:35 +00:00
|
|
|
|
|
|
|
#include <menu/menu.h>
|
|
|
|
#include <menu/menu_item.h>
|
2021-01-08 04:42:48 +00:00
|
|
|
|
2020-10-29 07:11:16 +00:00
|
|
|
#include <gui/gui.h>
|
2021-01-29 13:52:16 +00:00
|
|
|
#include <gui/view_port.h>
|
2021-01-08 04:42:48 +00:00
|
|
|
#include <gui/view.h>
|
|
|
|
#include <gui/view_dispatcher.h>
|
2021-01-20 16:51:01 +00:00
|
|
|
#include <gui/modules/dialog.h>
|
2020-10-29 07:11:16 +00:00
|
|
|
#include <assets_icons.h>
|
2020-11-16 10:16:34 +00:00
|
|
|
#include <cli/cli.h>
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
#include <stm32wbxx.h>
|
2020-10-29 07:11:16 +00:00
|
|
|
|
|
|
|
struct Power {
|
2021-01-08 04:42:48 +00:00
|
|
|
ViewDispatcher* view_dispatcher;
|
|
|
|
View* info_view;
|
|
|
|
|
2020-10-29 07:11:16 +00:00
|
|
|
Icon* usb_icon;
|
2021-01-29 13:52:16 +00:00
|
|
|
ViewPort* usb_view_port;
|
2020-10-29 07:11:16 +00:00
|
|
|
|
|
|
|
Icon* battery_icon;
|
2021-01-29 13:52:16 +00:00
|
|
|
ViewPort* battery_view_port;
|
2020-10-29 07:11:16 +00:00
|
|
|
|
2021-01-20 16:51:01 +00:00
|
|
|
Dialog* dialog;
|
|
|
|
|
2020-11-11 06:31:35 +00:00
|
|
|
ValueMutex* menu_vm;
|
2020-11-16 10:16:34 +00:00
|
|
|
Cli* cli;
|
2020-11-11 06:31:35 +00:00
|
|
|
MenuItem* menu;
|
2020-10-29 07:11:16 +00:00
|
|
|
};
|
|
|
|
|
2020-12-14 10:50:32 +00:00
|
|
|
void power_draw_usb_callback(Canvas* canvas, void* context) {
|
2020-10-29 07:11:16 +00:00
|
|
|
assert(context);
|
|
|
|
Power* power = context;
|
2020-12-14 10:50:32 +00:00
|
|
|
canvas_draw_icon(canvas, 0, 0, power->usb_icon);
|
2020-10-29 07:11:16 +00:00
|
|
|
}
|
|
|
|
|
2020-12-14 10:50:32 +00:00
|
|
|
void power_draw_battery_callback(Canvas* canvas, void* context) {
|
2020-10-29 07:11:16 +00:00
|
|
|
assert(context);
|
|
|
|
Power* power = context;
|
|
|
|
|
2020-12-14 10:50:32 +00:00
|
|
|
canvas_draw_icon(canvas, 0, 0, power->battery_icon);
|
2021-01-08 04:42:48 +00:00
|
|
|
with_view_model(
|
|
|
|
power->info_view, (PowerInfoModel * model) {
|
|
|
|
canvas_draw_box(canvas, 2, 2, (float)model->charge / 100 * 14, 4);
|
|
|
|
});
|
2020-10-29 07:11:16 +00:00
|
|
|
}
|
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
uint32_t power_info_back_callback(void* context) {
|
|
|
|
return VIEW_NONE;
|
|
|
|
}
|
|
|
|
|
2021-01-08 04:42:48 +00:00
|
|
|
void power_menu_off_callback(void* context) {
|
2020-11-11 06:31:35 +00:00
|
|
|
api_hal_power_off();
|
|
|
|
}
|
2020-10-29 07:11:16 +00:00
|
|
|
|
2021-01-20 16:51:01 +00:00
|
|
|
void power_menu_reset_dialog_result(DialogResult result, void* context) {
|
|
|
|
if(result == DialogResultLeft) {
|
|
|
|
api_hal_boot_set_mode(ApiHalBootModeDFU);
|
|
|
|
NVIC_SystemReset();
|
|
|
|
} else if(result == DialogResultRight) {
|
|
|
|
api_hal_boot_set_mode(ApiHalBootModeNormal);
|
|
|
|
NVIC_SystemReset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-08 04:42:48 +00:00
|
|
|
void power_menu_reset_callback(void* context) {
|
2021-01-20 16:51:01 +00:00
|
|
|
Power* power = context;
|
|
|
|
dialog_set_result_callback(power->dialog, power_menu_reset_dialog_result);
|
|
|
|
dialog_set_header_text(power->dialog, "Reset type");
|
|
|
|
dialog_set_text(power->dialog, "Reboot where?");
|
|
|
|
dialog_set_left_button_text(power->dialog, "DFU");
|
|
|
|
dialog_set_right_button_text(power->dialog, "OS");
|
|
|
|
view_dispatcher_switch_to_view(power->view_dispatcher, PowerViewDialog);
|
2020-11-11 06:31:35 +00:00
|
|
|
}
|
2020-10-29 07:11:16 +00:00
|
|
|
|
2021-01-08 04:42:48 +00:00
|
|
|
void power_menu_enable_otg_callback(void* context) {
|
|
|
|
api_hal_power_enable_otg();
|
2020-10-29 07:11:16 +00:00
|
|
|
}
|
|
|
|
|
2021-01-08 04:42:48 +00:00
|
|
|
void power_menu_disable_otg_callback(void* context) {
|
|
|
|
api_hal_power_disable_otg();
|
2020-12-18 18:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-01-08 04:42:48 +00:00
|
|
|
void power_menu_info_callback(void* context) {
|
2020-12-18 18:03:28 +00:00
|
|
|
Power* power = context;
|
2021-01-08 04:42:48 +00:00
|
|
|
view_dispatcher_switch_to_view(power->view_dispatcher, PowerViewInfo);
|
2020-12-18 18:03:28 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 07:11:16 +00:00
|
|
|
Power* power_alloc() {
|
|
|
|
Power* power = furi_alloc(sizeof(Power));
|
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
power->menu_vm = furi_record_open("menu");
|
2020-11-11 06:31:35 +00:00
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
power->cli = furi_record_open("cli");
|
2020-11-16 10:16:34 +00:00
|
|
|
|
2020-11-11 06:31:35 +00:00
|
|
|
power->menu = menu_item_alloc_menu("Power", NULL);
|
|
|
|
menu_item_subitem_add(
|
2021-01-08 04:42:48 +00:00
|
|
|
power->menu, menu_item_alloc_function("Off", NULL, power_menu_off_callback, power));
|
|
|
|
menu_item_subitem_add(
|
|
|
|
power->menu, menu_item_alloc_function("Reset", NULL, power_menu_reset_callback, power));
|
2020-11-11 06:31:35 +00:00
|
|
|
menu_item_subitem_add(
|
|
|
|
power->menu,
|
2021-01-08 04:42:48 +00:00
|
|
|
menu_item_alloc_function("Enable OTG", NULL, power_menu_enable_otg_callback, power));
|
2020-11-11 06:31:35 +00:00
|
|
|
menu_item_subitem_add(
|
|
|
|
power->menu,
|
2021-01-08 04:42:48 +00:00
|
|
|
menu_item_alloc_function("Disable OTG", NULL, power_menu_disable_otg_callback, power));
|
2020-12-18 18:03:28 +00:00
|
|
|
menu_item_subitem_add(
|
2021-01-08 04:42:48 +00:00
|
|
|
power->menu, menu_item_alloc_function("Info", NULL, power_menu_info_callback, power));
|
|
|
|
|
|
|
|
power->view_dispatcher = view_dispatcher_alloc();
|
|
|
|
power->info_view = view_alloc();
|
|
|
|
view_allocate_model(power->info_view, ViewModelTypeLockFree, sizeof(PowerInfoModel));
|
|
|
|
view_set_draw_callback(power->info_view, power_info_draw_callback);
|
|
|
|
view_set_previous_callback(power->info_view, power_info_back_callback);
|
|
|
|
view_dispatcher_add_view(power->view_dispatcher, PowerViewInfo, power->info_view);
|
2020-11-11 06:31:35 +00:00
|
|
|
|
2021-01-20 16:51:01 +00:00
|
|
|
power->dialog = dialog_alloc();
|
|
|
|
dialog_set_context(power->dialog, power);
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
power->view_dispatcher, PowerViewDialog, dialog_get_view(power->dialog));
|
|
|
|
|
2020-10-29 07:11:16 +00:00
|
|
|
power->usb_icon = assets_icons_get(I_USBConnected_15x8);
|
2021-01-29 13:52:16 +00:00
|
|
|
power->usb_view_port = view_port_alloc();
|
|
|
|
view_port_set_width(power->usb_view_port, icon_get_width(power->usb_icon));
|
|
|
|
view_port_draw_callback_set(power->usb_view_port, power_draw_usb_callback, power);
|
2020-10-29 07:11:16 +00:00
|
|
|
|
|
|
|
power->battery_icon = assets_icons_get(I_Battery_19x8);
|
2021-01-29 13:52:16 +00:00
|
|
|
power->battery_view_port = view_port_alloc();
|
|
|
|
view_port_set_width(power->battery_view_port, icon_get_width(power->battery_icon));
|
|
|
|
view_port_draw_callback_set(power->battery_view_port, power_draw_battery_callback, power);
|
2020-10-29 07:11:16 +00:00
|
|
|
|
|
|
|
return power;
|
|
|
|
}
|
|
|
|
|
|
|
|
void power_free(Power* power) {
|
|
|
|
assert(power);
|
|
|
|
free(power);
|
|
|
|
}
|
|
|
|
|
2020-11-16 10:16:34 +00:00
|
|
|
void power_cli_poweroff(string_t args, void* context) {
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("Poweroff in 3 seconds");
|
2020-11-17 17:08:31 +00:00
|
|
|
osDelay(3000);
|
2020-11-16 10:16:34 +00:00
|
|
|
api_hal_power_off();
|
|
|
|
}
|
|
|
|
|
2020-11-17 17:08:31 +00:00
|
|
|
void power_cli_reset(string_t args, void* context) {
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("NVIC System Reset in 3 seconds");
|
2020-11-17 17:08:31 +00:00
|
|
|
osDelay(3000);
|
|
|
|
NVIC_SystemReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void power_cli_dfu(string_t args, void* context) {
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf("NVIC System Reset to DFU mode in 3 seconds");
|
2020-11-17 17:08:31 +00:00
|
|
|
api_hal_boot_set_mode(ApiHalBootModeDFU);
|
|
|
|
osDelay(3000);
|
|
|
|
NVIC_SystemReset();
|
|
|
|
}
|
|
|
|
|
2020-12-02 10:47:13 +00:00
|
|
|
void power_cli_test(string_t args, void* context) {
|
|
|
|
string_t buffer;
|
|
|
|
string_init(buffer);
|
|
|
|
api_hal_power_dump_state(buffer);
|
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311)
* FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started.
* Furi record, stdglue: check mutex allocation
* remove unused test
* Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state.
* Interrupt manager: explicitly init list.
* Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options.
* BLE: call debug uart callback on transmission complete
* FreeRTOS: add configUSE_NEWLIB_REENTRANT
* API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib.
* F4: update stack protection CFLAGS to match used compiller
* F4: disable compiller stack protection because of incompatibility with current compiller
* Makefile: return openocd logs to gdb
* BLE: fixed pin, moar power, ble trace info.
* Prevent sleep when connection is active
* Makefile: return serial port to upload rule, add workaround for mac os
* Furi: prevent usage of stack for cmsis functions.
* F4: add missing includes, add debugger breakpoints
* Applications: per app stack size.
* Furi: honor kernel state in stdglue
* FreeRTOS: remove unused hooks
* Cleanup and format sources
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
|
|
|
printf(string_get_cstr(buffer));
|
2020-12-02 10:47:13 +00:00
|
|
|
string_clear(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void power_cli_otg_on(string_t args, void* context) {
|
|
|
|
api_hal_power_enable_otg();
|
|
|
|
}
|
|
|
|
|
|
|
|
void power_cli_otg_off(string_t args, void* context) {
|
|
|
|
api_hal_power_disable_otg();
|
|
|
|
}
|
|
|
|
|
2020-10-29 07:11:16 +00:00
|
|
|
void power_task(void* p) {
|
|
|
|
(void)p;
|
|
|
|
Power* power = power_alloc();
|
|
|
|
|
2020-11-16 17:12:05 +00:00
|
|
|
if(power->cli) {
|
|
|
|
cli_add_command(power->cli, "poweroff", power_cli_poweroff, power);
|
2020-11-17 17:08:31 +00:00
|
|
|
cli_add_command(power->cli, "reset", power_cli_reset, power);
|
|
|
|
cli_add_command(power->cli, "dfu", power_cli_dfu, power);
|
2020-12-02 10:47:13 +00:00
|
|
|
cli_add_command(power->cli, "power_test", power_cli_test, power);
|
|
|
|
cli_add_command(power->cli, "power_otg_on", power_cli_otg_on, power);
|
|
|
|
cli_add_command(power->cli, "power_otg_off", power_cli_otg_off, power);
|
2020-11-16 17:12:05 +00:00
|
|
|
}
|
2020-11-16 10:16:34 +00:00
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
Gui* gui = furi_record_open("gui");
|
2021-01-29 13:52:16 +00:00
|
|
|
gui_add_view_port(gui, power->usb_view_port, GuiLayerStatusBarLeft);
|
|
|
|
gui_add_view_port(gui, power->battery_view_port, GuiLayerStatusBarRight);
|
2021-01-08 04:42:48 +00:00
|
|
|
view_dispatcher_attach_to_gui(power->view_dispatcher, gui, ViewDispatcherTypeFullscreen);
|
2020-10-29 07:11:16 +00:00
|
|
|
|
2020-11-11 06:31:35 +00:00
|
|
|
with_value_mutex(
|
|
|
|
power->menu_vm, (Menu * menu) { menu_item_add(menu, power->menu); });
|
|
|
|
|
|
|
|
api_hal_power_init();
|
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
furi_record_create("power", power);
|
2020-10-29 07:11:16 +00:00
|
|
|
|
|
|
|
while(1) {
|
2021-01-08 04:42:48 +00:00
|
|
|
with_view_model(
|
|
|
|
power->info_view, (PowerInfoModel * model) {
|
|
|
|
model->charge = api_hal_power_get_pct();
|
|
|
|
model->capacity_remaining = api_hal_power_get_battery_remaining_capacity();
|
|
|
|
model->capacity_full = api_hal_power_get_battery_full_capacity();
|
|
|
|
model->current_charger = api_hal_power_get_battery_current(ApiHalPowerICCharger);
|
|
|
|
model->current_gauge = api_hal_power_get_battery_current(ApiHalPowerICFuelGauge);
|
|
|
|
model->voltage_charger = api_hal_power_get_battery_voltage(ApiHalPowerICCharger);
|
|
|
|
model->voltage_gauge = api_hal_power_get_battery_voltage(ApiHalPowerICFuelGauge);
|
|
|
|
model->temperature_charger =
|
|
|
|
api_hal_power_get_battery_temperature(ApiHalPowerICCharger);
|
|
|
|
model->temperature_gauge =
|
|
|
|
api_hal_power_get_battery_temperature(ApiHalPowerICFuelGauge);
|
|
|
|
});
|
|
|
|
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_update(power->battery_view_port);
|
|
|
|
view_port_enabled_set(power->usb_view_port, api_hal_power_is_charging());
|
2020-10-29 07:11:16 +00:00
|
|
|
osDelay(1000);
|
|
|
|
}
|
|
|
|
}
|