Merge branch 'DarkFlippers:dev' into subghz_refactoring_step_by_step

This commit is contained in:
gid9798 2023-05-09 22:42:28 +03:00 committed by GitHub
commit 88bd5aef40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
97 changed files with 14926 additions and 1276 deletions

12
.gitmodules vendored
View File

@ -1,9 +1,6 @@
[submodule "lib/mlib"]
path = lib/mlib
url = https://github.com/P-p-H-d/mlib.git
[submodule "lib/STM32CubeWB"]
path = lib/STM32CubeWB
url = https://github.com/Flipper-Zero/STM32CubeWB.git
[submodule "lib/littlefs"]
path = lib/littlefs
url = https://github.com/littlefs-project/littlefs.git
@ -37,3 +34,12 @@
[submodule "lib/heatshrink"]
path = lib/heatshrink
url = https://github.com/flipperdevices/heatshrink.git
[submodule "lib/st_cmsis_device_wb"]
path = lib/stm32wb_cmsis
url = https://github.com/STMicroelectronics/cmsis_device_wb
[submodule "lib/stm32wbxx_hal_driver"]
path = lib/stm32wb_hal
url = https://github.com/STMicroelectronics/stm32wbxx_hal_driver
[submodule "lib/stm32wb_copro"]
path = lib/stm32wb_copro
url = https://github.com/flipperdevices/stm32wb_copro.git

View File

@ -1 +1 @@
--ignore-ccache -C gccarm --rules-config .pvsconfig -e lib/fatfs -e lib/fnv1a-hash -e lib/FreeRTOS-Kernel -e lib/heatshrink -e lib/libusb_stm32 -e lib/littlefs -e lib/mbedtls -e lib/micro-ecc -e lib/microtar -e lib/mlib -e lib/qrcode -e lib/ST25RFAL002 -e lib/STM32CubeWB -e lib/u8g2 -e lib/nanopb -e */arm-none-eabi/* -e applications/external/dap_link/lib/free-dap
--ignore-ccache -C gccarm --rules-config .pvsconfig -e lib/cmsis_core -e lib/fatfs -e lib/fnv1a-hash -e lib/FreeRTOS-Kernel -e lib/heatshrink -e lib/libusb_stm32 -e lib/littlefs -e lib/mbedtls -e lib/micro-ecc -e lib/microtar -e lib/mlib -e lib/qrcode -e lib/ST25RFAL002 -e lib/stm32wb_cmsis -e lib/stm32wb_copro -e lib/stm32wb_hal -e lib/u8g2 -e lib/nanopb -e */arm-none-eabi/* -e applications/external/dap_link/lib/free-dap

View File

@ -11,11 +11,10 @@
"args": {
"useSingleResult": true,
"env": {
"PATH": "${workspaceFolder};${env:PATH}",
"FBT_QUIET": 1
"PATH": "${workspaceFolder}${command:extension.commandvariable.envListSep}${env:PATH}"
},
"command": "fbt get_blackmagic",
"description": "Get Blackmagic device",
"command": "fbt -s get_blackmagic",
"description": "Get Blackmagic device"
}
}
],
@ -28,20 +27,21 @@
"type": "cortex-debug",
"servertype": "openocd",
"device": "stlink",
"svdFile": "./debug/STM32WB55_CM4.svd",
"svdFile": "./scripts/debug/STM32WB55_CM4.svd",
// If you're debugging early in the boot process, before OS scheduler is running,
// you have to comment out the following line.
"rtos": "FreeRTOS",
"configFiles": [
"interface/stlink.cfg",
"./debug/stm32wbx.cfg",
"./scripts/debug/stm32wbx.cfg",
],
"postAttachCommands": [
"source scripts/debug/flipperversion.py",
"fw-version",
// "compare-sections",
"source debug/flipperapps.py",
"source scripts/debug/flipperapps.py",
"fap-set-debug-elf-root build/latest/.extapps",
// "source debug/FreeRTOS/FreeRTOS.py",
// "svd_load debug/STM32WB55_CM4.svd"
// "source scripts/debug/FreeRTOS/FreeRTOS.py",
]
// "showDevDebugOutput": "raw",
},
@ -53,14 +53,16 @@
"type": "cortex-debug",
"servertype": "external",
"gdbTarget": "${input:BLACKMAGIC}",
"svdFile": "./debug/STM32WB55_CM4.svd",
"svdFile": "./scripts/debug/STM32WB55_CM4.svd",
"rtos": "FreeRTOS",
"postAttachCommands": [
"monitor swdp_scan",
"attach 1",
"set confirm off",
"set mem inaccessible-by-default off",
"source debug/flipperapps.py",
"source scripts/debug/flipperversion.py",
"fw-version",
"source scripts/debug/flipperapps.py",
"fap-set-debug-elf-root build/latest/.extapps",
// "compare-sections",
]
@ -75,10 +77,12 @@
"servertype": "jlink",
"interface": "swd",
"device": "STM32WB55RG",
"svdFile": "./debug/STM32WB55_CM4.svd",
"svdFile": "./scripts/debug/STM32WB55_CM4.svd",
"rtos": "FreeRTOS",
"postAttachCommands": [
"source debug/flipperapps.py",
"source scripts/debug/flipperversion.py",
"fw-version",
"source scripts/debug/flipperapps.py",
"fap-set-debug-elf-root build/latest/.extapps",
]
// "showDevDebugOutput": "raw",
@ -91,27 +95,20 @@
"type": "cortex-debug",
"servertype": "openocd",
"device": "cmsis-dap",
"svdFile": "./debug/STM32WB55_CM4.svd",
"svdFile": "./scripts/debug/STM32WB55_CM4.svd",
"rtos": "FreeRTOS",
"configFiles": [
"interface/cmsis-dap.cfg",
"./debug/stm32wbx.cfg",
"./scripts/debug/stm32wbx.cfg",
],
"postAttachCommands": [
"source debug/flipperapps.py",
"source scripts/debug/flipperversion.py",
"fw-version",
"source scripts/debug/flipperapps.py",
"fap-set-debug-elf-root build/latest/.extapps",
],
// "showDevDebugOutput": "raw",
},
{
"name": "fbt debug",
"type": "python",
"request": "launch",
"program": "./lib/scons/scripts/scons.py",
"args": [
"plugin_dist"
]
},
{
"name": "python debug",
"type": "python",

View File

@ -8,7 +8,8 @@
"amiralizadeh9480.cpp-helper",
"marus25.cortex-debug",
"zxh404.vscode-proto3",
"augustocdias.tasks-shell-input"
"augustocdias.tasks-shell-input",
"rioj7.command-variable"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [

View File

@ -1,19 +1,14 @@
### New changes
* If you have copied any apps manually into `apps` folder - remove `apps` folder or that specific apps you copied on your microSD before installing this release to avoid issues!
* Plugins: RFID and iButton Fuzzer remove excessive free's (thanks @Willy-JL)
* Plugins: Use COUNT_OF in mouse jiggler
* Plugins: Added Numpad keyboard to HID app (by @clipboard1 | PR #452)
* About: Don't show 00 on about screens
* SubGHz: Combine FuriString allocs and other small changes
* Infrared: Updated universal remote assets (by @amec0e | PR #454)
* Update slideshow: Replace QR code with good old link
* OFW: Various Furi/FuriHal bug fixes and improvements -> **Breaking API change, api was changed from 24.x to 26.x**
* OFW: Loader refactoring, part 1 -> **Breaking API change, api was changed from 23.x to 24.x** **(this will make your manually copied plugins not work, update them in same way you installed them, or delete `apps` folder and then install firmware, if you using extra pack builds (with `e` in version) all apps in _Extra will be updated automatically)**
* OFW: Dolphin builder in ufbt; minor ufbt/fbt improvements
* OFW: Added API version to device info
* OFW: Gui: relax some asserts in view
* OFW: Move gauge calibration to separate header, add f18 calibration
* OFW: Fix TERMINFO on Linux systems
* Extra pack: Some app fixes
* OFW: ble: attempt to handle hardfaulted c2
* OFW: Add Mfkey32 application
* OFW: Added DigitalSequence and PulseReader
* OFW: Debug: revert cortex debug to lxml and drop DWT **(reapply your VSCode launch.json from example folder)**
* OFW: furi_crash: added C2 status; added fw-version gdb command
* OFW: Removed STM32CubeWB module
* OFW: API version in UI
* OFW: ufbt: deploying sample ufbt automation for new apps; added `source "ufbt -s env"` for toolchain access
* OFW: Fix storage.py exist_dir logic
#### [🎲 Download latest extra apps pack](https://github.com/xMasterX/all-the-plugins/archive/refs/heads/main.zip)

View File

@ -239,19 +239,31 @@ distenv.PhonyTarget(
)
# Debug alien elf
debug_other_opts = [
"-ex",
"source ${FBT_DEBUG_DIR}/PyCortexMDebug/PyCortexMDebug.py",
# "-ex",
# "source ${FBT_DEBUG_DIR}/FreeRTOS/FreeRTOS.py",
"-ex",
"source ${FBT_DEBUG_DIR}/flipperversion.py",
"-ex",
"fw-version",
]
distenv.PhonyTarget(
"debug_other",
"${GDBPYCOM}",
GDBOPTS="${GDBOPTS_BASE}",
GDBREMOTE="${OPENOCD_GDB_PIPE}",
GDBPYOPTS='-ex "source ${FBT_DEBUG_DIR}/PyCortexMDebug/PyCortexMDebug.py" ',
GDBPYOPTS=debug_other_opts,
)
distenv.PhonyTarget(
"debug_other_blackmagic",
"${GDBPYCOM}",
GDBOPTS="${GDBOPTS_BASE} ${GDBOPTS_BLACKMAGIC}",
GDBREMOTE="$${BLACKMAGIC_ADDR}",
GDBREMOTE="${BLACKMAGIC_ADDR}",
GDBPYOPTS=debug_other_opts,
)
@ -335,3 +347,9 @@ vscode_dist = distenv.Install("#.vscode", distenv.Glob("#.vscode/example/*"))
distenv.Precious(vscode_dist)
distenv.NoClean(vscode_dist)
distenv.Alias("vscode_dist", vscode_dist)
# Configure shell with build tools
distenv.PhonyTarget(
"env",
"@echo $( ${FBT_SCRIPT_DIR}/toolchain/fbtenv.sh $)",
)

View File

@ -0,0 +1,17 @@
App(
appid="mfkey32",
name="Mfkey32",
apptype=FlipperAppType.EXTERNAL,
targets=["f7"],
entry_point="mfkey32_main",
requires=[
"gui",
"storage",
],
stack_size=1 * 1024,
fap_icon="mfkey.png",
fap_category="Tools",
fap_author="noproto",
fap_icon_assets="images",
fap_weburl="https://github.com/noproto/FlipperMfkey",
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

BIN
applications/external/mfkey32/mfkey.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

1349
applications/external/mfkey32/mfkey32.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@ void nfc_scene_mfkey_complete_on_enter(void* context) {
AlignCenter,
AlignCenter,
FontSecondary,
"Now use mfkey32v2\nto extract keys");
"Now use Mfkey32\nto extract keys");
widget_add_button_element(
nfc->widget, GuiButtonTypeCenter, "OK", nfc_scene_mfkey_complete_callback, nfc);

View File

@ -64,13 +64,16 @@ void desktop_debug_render(Canvas* canvas, void* model) {
version_get_builddate(ver));
canvas_draw_str(canvas, 0, 30 + STATUS_BAR_Y_SHIFT, buffer);
uint16_t api_major, api_minor;
furi_hal_info_get_api_version(&api_major, &api_minor);
snprintf(
buffer,
sizeof(buffer),
"%s%s [%s] %s",
"%s%s [%d.%d] %s",
version_get_dirty_flag(ver) ? "[!] " : "",
version_get_githash(ver),
version_get_gitbranchnum(ver),
api_major,
api_minor,
c2_ver ? c2_ver->StackTypeString : "<none>");
canvas_draw_str(canvas, 0, 40 + STATUS_BAR_Y_SHIFT, buffer);

View File

@ -7,6 +7,7 @@
#include <furi_hal_version.h>
#include <furi_hal_region.h>
#include <furi_hal_bt.h>
#include <furi_hal_info.h>
typedef DialogMessageButton (*AboutDialogScreen)(DialogsApp* dialogs, DialogMessage* message);
@ -164,14 +165,17 @@ static DialogMessageButton fw_version_screen(DialogsApp* dialogs, DialogMessage*
if(!ver) { //-V1051
furi_string_cat_printf(buffer, "No info\n");
} else {
uint16_t api_major, api_minor;
furi_hal_info_get_api_version(&api_major, &api_minor);
furi_string_cat_printf(
buffer,
"%s [%s]\n%s%s [%s] %s\n[%d] %s",
"%s [%s]\n%s%s [%d.%d] %s\n[%d] %s",
version_get_version(ver),
version_get_builddate(ver),
version_get_dirty_flag(ver) ? "[!] " : "",
version_get_githash(ver),
version_get_gitbranchnum(ver),
api_major,
api_minor,
c2_ver ? c2_ver->StackTypeString : "<none>",
version_get_target(ver),
version_get_gitbranch(ver));

View File

@ -3,4 +3,4 @@ Version: 1
Data length: 18
Plain data: f1 99 41 43 a1 2f 23 01 de f3 c5 8d 91 4b 1e 50 4a c9
Timings length: 1304
Timings: 37 37 36 37 37 37 36 339 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 640 37 37 37 37 36 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 37 640 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 339 37 37 36 37 37 37 36 37 37 37 37 36 37 37 37 640 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 641 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 36 37 37 37 37 338 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 36 37 37 37 37 36 37 37 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 37 36 37 641 37 36 37 37 37 36 37 37 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 640 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 339 36 37 37 37 37 36 37 37 37 36 37 37 37 36 37 641 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 36 37 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 641 37 37 36 37 37 37 36 37 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 641 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 37 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 36 37 37 37 37 36 37 641 37 36 37 37 37 36 37 37 37 36 37 37 37 37 36 641 37 37 36 37 37 37 36 37 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 37 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 338 37 37 37 37 36 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 641 37 37 36 37 37 37 37 338 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 339 36 37 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 37 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 37 37 37 36 37 37 37 37 640 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 37 37 37 36 37 37 37 36 641 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 36 37 37 37 36 37 37 37 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 0
Timings: 37 37 36 37 37 37 36 339 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 640 37 37 37 37 36 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 37 640 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 339 37 37 36 37 37 37 36 37 37 37 37 36 37 37 37 640 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 641 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 36 37 37 37 37 338 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 36 37 37 37 37 36 37 37 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 37 36 37 641 37 36 37 37 37 36 37 37 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 640 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 339 36 37 37 37 37 36 37 37 37 36 37 37 37 36 37 641 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 36 37 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 641 37 37 36 37 37 37 36 37 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 641 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 37 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 36 37 37 37 37 36 37 641 37 36 37 37 37 36 37 37 37 36 37 37 37 37 36 641 37 37 36 37 37 37 36 37 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 37 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 338 37 37 37 37 36 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 641 37 37 36 37 37 37 37 338 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 339 36 37 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 37 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 37 37 37 36 37 37 37 37 640 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 37 37 37 36 37 37 37 36 641 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 339 36 37 37 37 36 37 37 37 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 37

View File

@ -3,4 +3,4 @@ Version: 1
Data length: 4
Plain data: 14 d8 a0 c9
Timings length: 296
Timings: 37 37 36 37 37 37 36 641 37 37 36 37 37 37 37 338 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 338 37 37 37 37 36 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 339 37 37 36 37 37 37 37 640 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 339 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 36 37 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 36 37 37 37 37 338 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 641 36 37 37 37 37 36 37 0
Timings: 37 37 36 37 37 37 36 641 37 37 36 37 37 37 37 338 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 36 37 37 37 37 36 339 37 37 36 37 37 37 36 339 37 37 37 36 37 37 37 338 37 37 37 36 37 37 37 338 37 37 37 37 36 37 37 339 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 641 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 339 37 37 36 37 37 37 37 640 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 339 36 37 37 37 36 37 37 339 37 36 37 37 37 36 37 339 37 36 37 37 37 36 37 339 37 37 36 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 641 36 37 37 37 36 37 37 37 36 37 37 37 36 37 37 641 37 36 37 37 37 36 37 339 37 36 37 37 37 37 36 37 37 37 36 37 37 37 36 641 37 37 36 37 37 37 37 338 37 37 37 36 37 37 37 36 37 37 37 36 37 37 37 339 36 37 37 37 36 37 37 641 36 37 37 37 37 36 37 37

View File

@ -1,84 +0,0 @@
PyCortexMDebug
==============
*A set of GDB/Python-based utilities to make life debugging ARM Cortex-M processors a bit easier*
It will consist of several modules which will hopefully become integrated as they evolve. Presently, there is only one:
## SVD
ARM defines an SVD (System View Description) file format in its CMSIS
standard as a means for Cortex-M-based chip manufacturers to provide a
common description of peripherals, registers, and register fields. You
can download SVD files for different manufacturers
[here](http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php).
My implementation so far has only tested STM32 chips but should hold for others. If others are like those from ST,
expect plenty of errors in the file. Like GPIOA having a register named GPIOB_OSPEEDR and lots of 16-bit registers
that are listed as 32!
The implementation consists of two components -- An xml parser module (pysvd) and a GDB file (gdb_svd).
I haven't yet worked out a perfect workflow for this, though it's quite easy to use when
you already tend to have a GDB initialization file for starting up OpenOCD and the like.
However your workflow works, just make sure to, in GDB:
source gdb_svd.py
svd_load [your_svd_file].svd
These files can be huge so it might take a second or two. Anyways, after that, you can do
svd
to list available peripherals with descriptions. Or you can do
svd [some_peripheral_name]
to see all of the registers (with their values) for a given peripheral. For more details, run
svd [some_peripheral_name] [some_register_name]
to see all of the field values with descriptions.
You can add format modifiers like:
* `svd/x` will display values in hex
* `svd/o` will display values in octal
* `svd/t` or `svd/b` will display values in binary
* `svd/a` will display values in hex and try to resolve symbols from the values
All field values are displayed at the correct lengths as provided by the SVD files.
Also, tab completion exists for nearly everything! When in doubt, run `svd help`.
### TODO
Enable writing to registers and individual fields
### Bugs
There are probably a few. All planning, writing, and testing of this was done in an afternoon. There may be
some oddities in working with non-STM32 parts. I'll play with this when I start working with other
controllers again. If something's giving you trouble, describe the problem and it shall be fixed.
## DWT
The ARM Data Watchpoint and Trace Unit (DWT) offers data watchpoints and a series of gated cycle counters. For now,
I only support the raw cycle counter but facilities are in place to make use of others. As this is independent of the
specific device under test, commands are simple and you can configure a clock speed to get real time values from
counters.
dwt configclk 48000000
will set the current core clock speed. Then
dwt cyccnt reset
dwt cyccnt enable
will reset and start the cycle counter. At any point
dwt cycnt
will then indicate the number of cycles and amount of time that has passed.
## ITM/ETM support
This is not implemented yet. I want to have more complete support for some of the nicer debug and trace features
on Cortex-M processors. Parts of this will probably be dependent on OpenOCD and possibly on specific interfaces.
I'll try to avoid this where possible but can't make any promises.

View File

@ -1,160 +0,0 @@
#!/usr/bin/env python
"""
This file is part of PyCortexMDebug
PyCortexMDebug is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PyCortexMDebug is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PyCortexMDebug. If not, see <http://www.gnu.org/licenses/>.
"""
import gdb
import struct
DWT_CTRL = 0xE0001000
DWT_CYCCNT = 0xE0001004
DWT_CPICNT = 0xE0001008
DWT_EXTCNT = 0xE000100C
DWT_SLEEPCNT = 0xE0001010
DWT_LSUCNT = 0xE0001014
DWT_FOLDCNT = 0xE0001018
DWT_PCSR = 0xE000101C
prefix = "dwt : "
class DWT(gdb.Command):
clk = None
is_init = False
def __init__(self):
gdb.Command.__init__(self, "dwt", gdb.COMMAND_DATA)
@staticmethod
def read(address, bits=32):
"""Read from memory (using print) and return an integer"""
value = gdb.selected_inferior().read_memory(address, bits / 8)
return struct.unpack_from("<i", value)[0]
@staticmethod
def write(address, value, bits=32):
"""Set a value in memory"""
gdb.selected_inferior().write_memory(address, bytes(value), bits / 8)
def invoke(self, args, from_tty):
if not self.is_init:
self.write(0xE000EDFC, self.read(0xE000EDFC) | (1 << 24))
self.write(DWT_CTRL, 0)
self.is_init = True
s = list(map(lambda x: x.lower(), str(args).split(" ")))
# Check for empty command
if s[0] in ["", "help"]:
self.print_help()
return ()
if s[0] == "cyccnt":
if len(s) > 1:
if s[1][:2] == "en":
self.cyccnt_en()
elif s[1][0] == "r":
self.cyccnt_reset()
elif s[1][0] == "d":
self.cyccnt_dis()
gdb.write(
prefix
+ "CYCCNT ({}): ".format("ON" if (self.read(DWT_CTRL) & 1) else "OFF")
+ self.cycles_str(self.read(DWT_CYCCNT))
)
elif s[0] == "reset":
if len(s) > 1:
if s[1] == "cyccnt":
self.cyccnt_reset()
gdb.write(prefix + "CYCCNT reset\n")
if s[1] == "counters":
self.cyccnt_reset()
gdb.write(prefix + "CYCCNT reset\n")
else:
self.cyccnt_reset()
gdb.write(prefix + "CYCCNT reset\n")
else:
# Reset everything
self.cyccnt_reset()
gdb.write(prefix + "CYCCNT reset\n")
elif s[0] == "configclk":
if len(s) == 2:
try:
self.clk = float(s[1])
except:
self.print_help()
else:
self.print_help()
else:
# Try to figure out what stupid went on here
gdb.write(args)
self.print_help()
@staticmethod
def complete(text, word):
text = str(text).lower()
s = text.split(" ")
commands = ["configclk", "reset", "cyccnt"]
reset_commands = ["counters", "cyccnt"]
cyccnt_commands = ["enable", "reset", "disable"]
if len(s) == 1:
return filter(lambda x: x.startswith(s[0]), commands)
if len(s) == 2:
if s[0] == "reset":
return filter(lambda x: x.startswith(s[1]), reset_commands)
if s[0] == "cyccnt":
return filter(lambda x: x.startswith(s[1]), cyccnt_commands)
def cycles_str(self, cycles):
if self.clk:
return "%d cycles, %.3es\n" % (cycles, cycles * 1.0 / self.clk)
else:
return "%d cycles"
def cyccnt_en(self):
self.write(DWT_CTRL, self.read(DWT_CTRL) | 1)
def cyccnt_dis(self):
self.write(DWT_CTRL, self.read(DWT_CTRL) & 0xFFFFFFFE)
def cyccnt_reset(self, value=0):
self.write(DWT_CYCCNT, value)
def cpicnt_reset(self, value=0):
self.write(DWT_CPICNT, value & 0xFF)
@staticmethod
def print_help():
gdb.write("Usage:\n")
gdb.write("=========\n")
gdb.write("dwt:\n")
gdb.write("\tList available peripherals\n")
gdb.write("dwt configclk [Hz]:\n")
gdb.write("\tSet clock for rendering time values in seconds\n")
gdb.write("dwt reset:\n")
gdb.write("\tReset everything in DWT\n")
gdb.write("dwt reset counters:\n")
gdb.write("\tReset all DWT counters\n")
gdb.write("dwt cyccnt\n")
gdb.write("\tDisplay the cycle count\n")
gdb.write("\td(default):decimal, x: hex, o: octal, b: binary\n")
return
# Registers our class to GDB when sourced:
DWT()

View File

@ -1,586 +0,0 @@
#!/usr/bin/env python
"Makes working with XML feel like you are working with JSON"
try:
from defusedexpat import pyexpat as expat
except ImportError:
from xml.parsers import expat
from xml.sax.saxutils import XMLGenerator
from xml.sax.xmlreader import AttributesImpl
try: # pragma no cover
from cStringIO import StringIO
except ImportError: # pragma no cover
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from inspect import isgenerator
class ObjectDict(dict):
def __getattr__(self, name):
if name in self:
return self[name]
else:
raise AttributeError("No such attribute: " + name)
try: # pragma no cover
_basestring = basestring
except NameError: # pragma no cover
_basestring = str
try: # pragma no cover
_unicode = unicode
except NameError: # pragma no cover
_unicode = str
__author__ = "Martin Blech"
__version__ = "0.12.0"
__license__ = "MIT"
class ParsingInterrupted(Exception):
pass
class _DictSAXHandler(object):
def __init__(
self,
item_depth=0,
item_callback=lambda *args: True,
xml_attribs=True,
attr_prefix="@",
cdata_key="#text",
force_cdata=False,
cdata_separator="",
postprocessor=None,
dict_constructor=ObjectDict,
strip_whitespace=True,
namespace_separator=":",
namespaces=None,
force_list=None,
comment_key="#comment",
):
self.path = []
self.stack = []
self.data = []
self.item = None
self.item_depth = item_depth
self.xml_attribs = xml_attribs
self.item_callback = item_callback
self.attr_prefix = attr_prefix
self.cdata_key = cdata_key
self.force_cdata = force_cdata
self.cdata_separator = cdata_separator
self.postprocessor = postprocessor
self.dict_constructor = dict_constructor
self.strip_whitespace = strip_whitespace
self.namespace_separator = namespace_separator
self.namespaces = namespaces
self.namespace_declarations = ObjectDict()
self.force_list = force_list
self.comment_key = comment_key
def _build_name(self, full_name):
if self.namespaces is None:
return full_name
i = full_name.rfind(self.namespace_separator)
if i == -1:
return full_name
namespace, name = full_name[:i], full_name[i + 1 :]
try:
short_namespace = self.namespaces[namespace]
except KeyError:
short_namespace = namespace
if not short_namespace:
return name
else:
return self.namespace_separator.join((short_namespace, name))
def _attrs_to_dict(self, attrs):
if isinstance(attrs, dict):
return attrs
return self.dict_constructor(zip(attrs[0::2], attrs[1::2]))
def startNamespaceDecl(self, prefix, uri):
self.namespace_declarations[prefix or ""] = uri
def startElement(self, full_name, attrs):
name = self._build_name(full_name)
attrs = self._attrs_to_dict(attrs)
if attrs and self.namespace_declarations:
attrs["xmlns"] = self.namespace_declarations
self.namespace_declarations = ObjectDict()
self.path.append((name, attrs or None))
if len(self.path) > self.item_depth:
self.stack.append((self.item, self.data))
if self.xml_attribs:
attr_entries = []
for key, value in attrs.items():
key = self.attr_prefix + self._build_name(key)
if self.postprocessor:
entry = self.postprocessor(self.path, key, value)
else:
entry = (key, value)
if entry:
attr_entries.append(entry)
attrs = self.dict_constructor(attr_entries)
else:
attrs = None
self.item = attrs or None
self.data = []
def endElement(self, full_name):
name = self._build_name(full_name)
if len(self.path) == self.item_depth:
item = self.item
if item is None:
item = None if not self.data else self.cdata_separator.join(self.data)
should_continue = self.item_callback(self.path, item)
if not should_continue:
raise ParsingInterrupted()
if len(self.stack):
data = None if not self.data else self.cdata_separator.join(self.data)
item = self.item
self.item, self.data = self.stack.pop()
if self.strip_whitespace and data:
data = data.strip() or None
if data and self.force_cdata and item is None:
item = self.dict_constructor()
if item is not None:
if data:
self.push_data(item, self.cdata_key, data)
self.item = self.push_data(self.item, name, item)
else:
self.item = self.push_data(self.item, name, data)
else:
self.item = None
self.data = []
self.path.pop()
def characters(self, data):
if not self.data:
self.data = [data]
else:
self.data.append(data)
def comments(self, data):
if self.strip_whitespace:
data = data.strip()
self.item = self.push_data(self.item, self.comment_key, data)
def push_data(self, item, key, data):
if self.postprocessor is not None:
result = self.postprocessor(self.path, key, data)
if result is None:
return item
key, data = result
if item is None:
item = self.dict_constructor()
try:
value = item[key]
if isinstance(value, list):
value.append(data)
else:
item[key] = [value, data]
except KeyError:
if self._should_force_list(key, data):
item[key] = [data]
else:
item[key] = data
return item
def _should_force_list(self, key, value):
if not self.force_list:
return False
if isinstance(self.force_list, bool):
return self.force_list
try:
return key in self.force_list
except TypeError:
return self.force_list(self.path[:-1], key, value)
def parse(
xml_input,
encoding=None,
expat=expat,
process_namespaces=False,
namespace_separator=":",
disable_entities=True,
process_comments=False,
**kwargs
):
"""Parse the given XML input and convert it into a dictionary.
`xml_input` can either be a `string`, a file-like object, or a generator of strings.
If `xml_attribs` is `True`, element attributes are put in the dictionary
among regular child elements, using `@` as a prefix to avoid collisions. If
set to `False`, they are just ignored.
Simple example::
>>> import xmltodict
>>> doc = xmltodict.parse(\"\"\"
... <a prop="x">
... <b>1</b>
... <b>2</b>
... </a>
... \"\"\")
>>> doc['a']['@prop']
u'x'
>>> doc['a']['b']
[u'1', u'2']
If `item_depth` is `0`, the function returns a dictionary for the root
element (default behavior). Otherwise, it calls `item_callback` every time
an item at the specified depth is found and returns `None` in the end
(streaming mode).
The callback function receives two parameters: the `path` from the document
root to the item (name-attribs pairs), and the `item` (dict). If the
callback's return value is false-ish, parsing will be stopped with the
:class:`ParsingInterrupted` exception.
Streaming example::
>>> def handle(path, item):
... print('path:%s item:%s' % (path, item))
... return True
...
>>> xmltodict.parse(\"\"\"
... <a prop="x">
... <b>1</b>
... <b>2</b>
... </a>\"\"\", item_depth=2, item_callback=handle)
path:[(u'a', {u'prop': u'x'}), (u'b', None)] item:1
path:[(u'a', {u'prop': u'x'}), (u'b', None)] item:2
The optional argument `postprocessor` is a function that takes `path`,
`key` and `value` as positional arguments and returns a new `(key, value)`
pair where both `key` and `value` may have changed. Usage example::
>>> def postprocessor(path, key, value):
... try:
... return key + ':int', int(value)
... except (ValueError, TypeError):
... return key, value
>>> xmltodict.parse('<a><b>1</b><b>2</b><b>x</b></a>',
... postprocessor=postprocessor)
ObjectDict([(u'a', ObjectDict([(u'b:int', [1, 2]), (u'b', u'x')]))])
You can pass an alternate version of `expat` (such as `defusedexpat`) by
using the `expat` parameter. E.g:
>>> import defusedexpat
>>> xmltodict.parse('<a>hello</a>', expat=defusedexpat.pyexpat)
ObjectDict([(u'a', u'hello')])
You can use the force_list argument to force lists to be created even
when there is only a single child of a given level of hierarchy. The
force_list argument is a tuple of keys. If the key for a given level
of hierarchy is in the force_list argument, that level of hierarchy
will have a list as a child (even if there is only one sub-element).
The index_keys operation takes precedence over this. This is applied
after any user-supplied postprocessor has already run.
For example, given this input:
<servers>
<server>
<name>host1</name>
<os>Linux</os>
<interfaces>
<interface>
<name>em0</name>
<ip_address>10.0.0.1</ip_address>
</interface>
</interfaces>
</server>
</servers>
If called with force_list=('interface',), it will produce
this dictionary:
{'servers':
{'server':
{'name': 'host1',
'os': 'Linux'},
'interfaces':
{'interface':
[ {'name': 'em0', 'ip_address': '10.0.0.1' } ] } } }
`force_list` can also be a callable that receives `path`, `key` and
`value`. This is helpful in cases where the logic that decides whether
a list should be forced is more complex.
If `process_comment` is `True` then comment will be added with comment_key
(default=`'#comment'`) to then tag which contains comment
For example, given this input:
<a>
<b>
<!-- b comment -->
<c>
<!-- c comment -->
1
</c>
<d>2</d>
</b>
</a>
If called with process_comment=True, it will produce
this dictionary:
'a': {
'b': {
'#comment': 'b comment',
'c': {
'#comment': 'c comment',
'#text': '1',
},
'd': '2',
},
}
"""
handler = _DictSAXHandler(namespace_separator=namespace_separator, **kwargs)
if isinstance(xml_input, _unicode):
if not encoding:
encoding = "utf-8"
xml_input = xml_input.encode(encoding)
if not process_namespaces:
namespace_separator = None
parser = expat.ParserCreate(encoding, namespace_separator)
try:
parser.ordered_attributes = True
except AttributeError:
# Jython's expat does not support ordered_attributes
pass
parser.StartNamespaceDeclHandler = handler.startNamespaceDecl
parser.StartElementHandler = handler.startElement
parser.EndElementHandler = handler.endElement
parser.CharacterDataHandler = handler.characters
if process_comments:
parser.CommentHandler = handler.comments
parser.buffer_text = True
if disable_entities:
try:
# Attempt to disable DTD in Jython's expat parser (Xerces-J).
feature = "http://apache.org/xml/features/disallow-doctype-decl"
parser._reader.setFeature(feature, True)
except AttributeError:
# For CPython / expat parser.
# Anything not handled ends up here and entities aren't expanded.
parser.DefaultHandler = lambda x: None
# Expects an integer return; zero means failure -> expat.ExpatError.
parser.ExternalEntityRefHandler = lambda *x: 1
if hasattr(xml_input, "read"):
parser.ParseFile(xml_input)
elif isgenerator(xml_input):
for chunk in xml_input:
parser.Parse(chunk, False)
parser.Parse(b"", True)
else:
parser.Parse(xml_input, True)
return handler.item
def _process_namespace(name, namespaces, ns_sep=":", attr_prefix="@"):
if not namespaces:
return name
try:
ns, name = name.rsplit(ns_sep, 1)
except ValueError:
pass
else:
ns_res = namespaces.get(ns.strip(attr_prefix))
name = (
"{}{}{}{}".format(
attr_prefix if ns.startswith(attr_prefix) else "", ns_res, ns_sep, name
)
if ns_res
else name
)
return name
def _emit(
key,
value,
content_handler,
attr_prefix="@",
cdata_key="#text",
depth=0,
preprocessor=None,
pretty=False,
newl="\n",
indent="\t",
namespace_separator=":",
namespaces=None,
full_document=True,
expand_iter=None,
):
key = _process_namespace(key, namespaces, namespace_separator, attr_prefix)
if preprocessor is not None:
result = preprocessor(key, value)
if result is None:
return
key, value = result
if (
not hasattr(value, "__iter__")
or isinstance(value, _basestring)
or isinstance(value, dict)
):
value = [value]
for index, v in enumerate(value):
if full_document and depth == 0 and index > 0:
raise ValueError("document with multiple roots")
if v is None:
v = ObjectDict()
elif isinstance(v, bool):
if v:
v = _unicode("true")
else:
v = _unicode("false")
elif not isinstance(v, dict):
if (
expand_iter
and hasattr(v, "__iter__")
and not isinstance(v, _basestring)
):
v = ObjectDict(((expand_iter, v),))
else:
v = _unicode(v)
if isinstance(v, _basestring):
v = ObjectDict(((cdata_key, v),))
cdata = None
attrs = ObjectDict()
children = []
for ik, iv in v.items():
if ik == cdata_key:
cdata = iv
continue
if ik.startswith(attr_prefix):
ik = _process_namespace(
ik, namespaces, namespace_separator, attr_prefix
)
if ik == "@xmlns" and isinstance(iv, dict):
for k, v in iv.items():
attr = "xmlns{}".format(":{}".format(k) if k else "")
attrs[attr] = _unicode(v)
continue
if not isinstance(iv, _unicode):
iv = _unicode(iv)
attrs[ik[len(attr_prefix) :]] = iv
continue
children.append((ik, iv))
if pretty:
content_handler.ignorableWhitespace(depth * indent)
content_handler.startElement(key, AttributesImpl(attrs))
if pretty and children:
content_handler.ignorableWhitespace(newl)
for child_key, child_value in children:
_emit(
child_key,
child_value,
content_handler,
attr_prefix,
cdata_key,
depth + 1,
preprocessor,
pretty,
newl,
indent,
namespaces=namespaces,
namespace_separator=namespace_separator,
expand_iter=expand_iter,
)
if cdata is not None:
content_handler.characters(cdata)
if pretty and children:
content_handler.ignorableWhitespace(depth * indent)
content_handler.endElement(key)
if pretty and depth:
content_handler.ignorableWhitespace(newl)
def unparse(
input_dict,
output=None,
encoding="utf-8",
full_document=True,
short_empty_elements=False,
**kwargs
):
"""Emit an XML document for the given `input_dict` (reverse of `parse`).
The resulting XML document is returned as a string, but if `output` (a
file-like object) is specified, it is written there instead.
Dictionary keys prefixed with `attr_prefix` (default=`'@'`) are interpreted
as XML node attributes, whereas keys equal to `cdata_key`
(default=`'#text'`) are treated as character data.
The `pretty` parameter (default=`False`) enables pretty-printing. In this
mode, lines are terminated with `'\n'` and indented with `'\t'`, but this
can be customized with the `newl` and `indent` parameters.
"""
if full_document and len(input_dict) != 1:
raise ValueError("Document must have exactly one root.")
must_return = False
if output is None:
output = StringIO()
must_return = True
if short_empty_elements:
content_handler = XMLGenerator(output, encoding, True)
else:
content_handler = XMLGenerator(output, encoding)
if full_document:
content_handler.startDocument()
for key, value in input_dict.items():
_emit(key, value, content_handler, full_document=full_document, **kwargs)
if full_document:
content_handler.endDocument()
if must_return:
value = output.getvalue()
try: # pragma no cover
value = value.decode(encoding)
except AttributeError: # pragma no cover
pass
return value
if __name__ == "__main__": # pragma: no cover
import sys
import marshal
try:
stdin = sys.stdin.buffer
stdout = sys.stdout.buffer
except AttributeError:
stdin = sys.stdin
stdout = sys.stdout
(item_depth,) = sys.argv[1:]
item_depth = int(item_depth)
def handle_item(path, item):
marshal.dump((path, item), stdout)
return True
try:
root = parse(
stdin,
item_depth=item_depth,
item_callback=handle_item,
dict_constructor=dict,
)
if item_depth == 0:
handle_item([], root)
except KeyboardInterrupt:
pass

View File

@ -929,7 +929,9 @@ RECURSIVE = YES
EXCLUDE = \
lib/mlib \
lib/STM32CubeWB \
lib/stm32wb_cmsis \
lib/stm32wb_copro \
lib/stm32wb_hal_driver \
lib/littlefs \
lib/nanopb \
assets/protobuf \

View File

@ -133,7 +133,7 @@ For example, to build a package only for installing BLE FULL stack:
scripts/update.py generate \
-t f7 -d r13.3_full -v "BLE FULL 13.3" \
--stage dist/f7/flipper-z-f7-updater-*.bin \
--radio lib/STM32CubeWB/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x/stm32wb5x_BLE_Stack_full_fw.bin \
--radio lib/stm32wb_copro/firmware/stm32wb5x_BLE_Stack_full_fw.bin \
--radiotype ble_full
```

View File

@ -13,6 +13,7 @@ To use `fbt`, you only need `git` installed in your system.
> However, if you wish to use tools supplied with the toolchain outside `fbt`, you can open an *fbt shell*, with properly configured environment.
> - On Windows, simply run `scripts/toolchain/fbtenv.cmd`.
> - On Linux & MacOS, run `source scripts/toolchain/fbtenv.sh` in a new shell.
> - You can also type ```. `./fbt -s env` ``` in your shell. (Keep the "." at the beginning.)
If your system is not supported by pre-built toolchain variants or you want to use custom versions of dependencies, you can `set FBT_NOENV=1`. `fbt` will skip toolchain & environment configuration and will expect all tools to be available on your system's `PATH`. *(this option is not available on Windows)*

3
fbt
View File

@ -5,6 +5,7 @@
set -eu;
# private variables
N_GIT_THREADS="$(getconf _NPROCESSORS_ONLN)";
SCRIPT_PATH="$(cd "$(dirname "$0")" && pwd -P)";
SCONS_DEFAULT_FLAGS="--warn=target-not-built";
SCONS_EP="python3 -m SCons";
@ -28,7 +29,7 @@ if [ -z "$FBT_NO_SYNC" ]; then
echo "\".git\" directory not found, please clone repo via \"git clone\"";
exit 1;
fi
git submodule update --init --depth 1;
git submodule update --init --depth 1 --jobs "$N_GIT_THREADS";
fi
$SCONS_EP $SCONS_DEFAULT_FLAGS "$@"

View File

@ -5,7 +5,7 @@ set SCONS_EP=python -m SCons
if [%FBT_NO_SYNC%] == [] (
if exist ".git" (
git submodule update --init --depth 1
git submodule update --init --depth 1 --jobs %NUMBER_OF_PROCESSORS%
) else (
echo Not in a git repo, please clone with "git clone"
exit /b 1

View File

@ -19,10 +19,10 @@ DIST_SUFFIX = "local"
# Coprocessor firmware
COPRO_OB_DATA = "scripts/ob.data"
# Must match lib/STM32CubeWB version
# Must match lib/stm32wb_copro version
COPRO_CUBE_VERSION = "1.15.0"
COPRO_CUBE_DIR = "lib/STM32CubeWB"
COPRO_CUBE_DIR = "lib/stm32wb_copro"
# Default radio stack
COPRO_STACK_BIN = "stm32wb5x_BLE_Stack_light_fw.bin"
@ -32,13 +32,8 @@ COPRO_STACK_TYPE = "ble_light"
# Leave 0 to let scripts automatically calculate it
COPRO_STACK_ADDR = "0x0"
# If you override COPRO_CUBE_DIR on command-line, override this as well
COPRO_STACK_BIN_DIR = posixpath.join(
COPRO_CUBE_DIR,
"Projects",
"STM32WB_Copro_Wireless_Binaries",
"STM32WB5x",
)
# If you override COPRO_CUBE_DIR on commandline, override this as well
COPRO_STACK_BIN_DIR = posixpath.join(COPRO_CUBE_DIR, "firmware")
# Supported toolchain versions
FBT_TOOLCHAIN_VERSIONS = (" 10.3.",)

View File

@ -7,7 +7,7 @@ env.Append(
libenv = env.Clone(FW_LIB_NAME="flipper${TARGET_HW}")
libenv.Append(
CPPPATH=[
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl",
"#/lib/stm32wb_copro/wpan/interface/patterns/ble_thread/tl",
]
)
libenv.ApplyLibFlags()

View File

@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,26.0,,
Version,+,26.2,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/cli/cli.h,,
Header,+,applications/services/cli/cli_vcp.h,,
@ -78,33 +78,6 @@ Header,+,firmware/targets/furi_hal_include/furi_hal_usb_hid.h,,
Header,+,firmware/targets/furi_hal_include/furi_hal_usb_hid_u2f.h,,
Header,+,firmware/targets/furi_hal_include/furi_hal_version.h,,
Header,+,firmware/targets/furi_hal_include/furi_hal_vibro.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_adc.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_bus.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_comp.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_cortex.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crc.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crs.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dma.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dmamux.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_exti.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_gpio.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_hsem.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_i2c.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_ipcc.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_iwdg.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lptim.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lpuart.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pka.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pwr.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rcc.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rng.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rtc.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_spi.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_system.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_tim.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_usart.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_utils.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_wwdg.h,,
Header,+,lib/flipper_application/api_hashtable/api_hashtable.h,,
Header,+,lib/flipper_application/api_hashtable/compilesort.hpp,,
Header,+,lib/flipper_application/flipper_application.h,,
@ -156,6 +129,34 @@ Header,+,lib/one_wire/maxim_crc.h,,
Header,+,lib/one_wire/one_wire_host.h,,
Header,+,lib/one_wire/one_wire_slave.h,,
Header,+,lib/print/wrappers.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_adc.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_bus.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_comp.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_cortex.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_crc.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_crs.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_dma.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_dmamux.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_exti.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_gpio.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_hsem.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_i2c.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_ipcc.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_iwdg.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_lptim.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_lpuart.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_pka.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_pwr.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rcc.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rng.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rtc.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_spi.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_system.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_tim.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_usart.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_utils.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_wwdg.h,,
Header,+,lib/pulse_reader/pulse_reader.h,,
Header,+,lib/toolbox/args.h,,
Header,+,lib/toolbox/crc32_calc.h,,
Header,+,lib/toolbox/dir_walk.h,,
@ -201,8 +202,8 @@ Function,-,LL_EXTI_StructInit,void,LL_EXTI_InitTypeDef*
Function,-,LL_GPIO_DeInit,ErrorStatus,GPIO_TypeDef*
Function,+,LL_GPIO_Init,ErrorStatus,"GPIO_TypeDef*, LL_GPIO_InitTypeDef*"
Function,-,LL_GPIO_StructInit,void,LL_GPIO_InitTypeDef*
Function,-,LL_I2C_DeInit,ErrorStatus,I2C_TypeDef*
Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, LL_I2C_InitTypeDef*"
Function,-,LL_I2C_DeInit,ErrorStatus,const I2C_TypeDef*
Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, const LL_I2C_InitTypeDef*"
Function,-,LL_I2C_StructInit,void,LL_I2C_InitTypeDef*
Function,-,LL_Init1msTick,void,uint32_t
Function,+,LL_LPTIM_DeInit,ErrorStatus,LPTIM_TypeDef*
@ -823,6 +824,7 @@ Function,+,furi_hal_bt_change_app,_Bool,"FuriHalBtProfile, GapEventCallback, voi
Function,+,furi_hal_bt_clear_white_list,_Bool,
Function,+,furi_hal_bt_dump_state,void,FuriString*
Function,+,furi_hal_bt_ensure_c2_mode,_Bool,BleGlueC2Mode
Function,-,furi_hal_bt_get_hardfault_info,const FuriHalBtHardfaultInfo*,
Function,+,furi_hal_bt_get_key_storage_buff,void,"uint8_t**, uint16_t*"
Function,+,furi_hal_bt_get_radio_stack,FuriHalBtStack,
Function,+,furi_hal_bt_get_rssi,float,
@ -1574,6 +1576,15 @@ Function,+,protocol_dict_render_brief_data,void,"ProtocolDict*, FuriString*, siz
Function,+,protocol_dict_render_data,void,"ProtocolDict*, FuriString*, size_t"
Function,+,protocol_dict_set_data,void,"ProtocolDict*, size_t, const uint8_t*, size_t"
Function,-,pselect,int,"int, fd_set*, fd_set*, fd_set*, const timespec*, const sigset_t*"
Function,-,pulse_reader_alloc,PulseReader*,"const GpioPin*, uint32_t"
Function,-,pulse_reader_free,void,PulseReader*
Function,-,pulse_reader_receive,uint32_t,"PulseReader*, int"
Function,-,pulse_reader_samples,uint32_t,PulseReader*
Function,-,pulse_reader_set_bittime,void,"PulseReader*, uint32_t"
Function,-,pulse_reader_set_pull,void,"PulseReader*, GpioPull"
Function,-,pulse_reader_set_timebase,void,"PulseReader*, PulseReaderUnit"
Function,-,pulse_reader_start,void,PulseReader*
Function,-,pulse_reader_stop,void,PulseReader*
Function,-,putc,int,"int, FILE*"
Function,-,putc_unlocked,int,"int, FILE*"
Function,-,putchar,int,int

1 entry status name type params
2 Version + 26.0 26.2
3 Header + applications/services/bt/bt_service/bt.h
4 Header + applications/services/cli/cli.h
5 Header + applications/services/cli/cli_vcp.h
78 Header + firmware/targets/furi_hal_include/furi_hal_usb_hid_u2f.h
79 Header + firmware/targets/furi_hal_include/furi_hal_version.h
80 Header + firmware/targets/furi_hal_include/furi_hal_vibro.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_adc.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_bus.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_comp.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_cortex.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crc.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crs.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dma.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dmamux.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_exti.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_gpio.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_hsem.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_i2c.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_ipcc.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_iwdg.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lptim.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lpuart.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pka.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pwr.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rcc.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rng.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rtc.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_spi.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_system.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_tim.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_usart.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_utils.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_wwdg.h
81 Header + lib/flipper_application/api_hashtable/api_hashtable.h
82 Header + lib/flipper_application/api_hashtable/compilesort.hpp
83 Header + lib/flipper_application/flipper_application.h
129 Header + lib/one_wire/one_wire_host.h
130 Header + lib/one_wire/one_wire_slave.h
131 Header + lib/print/wrappers.h
132 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_adc.h
133 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_bus.h
134 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_comp.h
135 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_cortex.h
136 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_crc.h
137 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_crs.h
138 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_dma.h
139 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_dmamux.h
140 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_exti.h
141 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_gpio.h
142 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_hsem.h
143 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_i2c.h
144 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_ipcc.h
145 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_iwdg.h
146 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_lptim.h
147 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_lpuart.h
148 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_pka.h
149 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_pwr.h
150 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_rcc.h
151 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_rng.h
152 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_rtc.h
153 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_spi.h
154 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_system.h
155 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_tim.h
156 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_usart.h
157 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_utils.h
158 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_wwdg.h
159 Header + lib/pulse_reader/pulse_reader.h
160 Header + lib/toolbox/args.h
161 Header + lib/toolbox/crc32_calc.h
162 Header + lib/toolbox/dir_walk.h
202 Function - LL_GPIO_DeInit ErrorStatus GPIO_TypeDef*
203 Function + LL_GPIO_Init ErrorStatus GPIO_TypeDef*, LL_GPIO_InitTypeDef*
204 Function - LL_GPIO_StructInit void LL_GPIO_InitTypeDef*
205 Function - LL_I2C_DeInit ErrorStatus I2C_TypeDef* const I2C_TypeDef*
206 Function + LL_I2C_Init ErrorStatus I2C_TypeDef*, LL_I2C_InitTypeDef* I2C_TypeDef*, const LL_I2C_InitTypeDef*
207 Function - LL_I2C_StructInit void LL_I2C_InitTypeDef*
208 Function - LL_Init1msTick void uint32_t
209 Function + LL_LPTIM_DeInit ErrorStatus LPTIM_TypeDef*
824 Function + furi_hal_bt_clear_white_list _Bool
825 Function + furi_hal_bt_dump_state void FuriString*
826 Function + furi_hal_bt_ensure_c2_mode _Bool BleGlueC2Mode
827 Function - furi_hal_bt_get_hardfault_info const FuriHalBtHardfaultInfo*
828 Function + furi_hal_bt_get_key_storage_buff void uint8_t**, uint16_t*
829 Function + furi_hal_bt_get_radio_stack FuriHalBtStack
830 Function + furi_hal_bt_get_rssi float
1576 Function + protocol_dict_render_data void ProtocolDict*, FuriString*, size_t
1577 Function + protocol_dict_set_data void ProtocolDict*, size_t, const uint8_t*, size_t
1578 Function - pselect int int, fd_set*, fd_set*, fd_set*, const timespec*, const sigset_t*
1579 Function - pulse_reader_alloc PulseReader* const GpioPin*, uint32_t
1580 Function - pulse_reader_free void PulseReader*
1581 Function - pulse_reader_receive uint32_t PulseReader*, int
1582 Function - pulse_reader_samples uint32_t PulseReader*
1583 Function - pulse_reader_set_bittime void PulseReader*, uint32_t
1584 Function - pulse_reader_set_pull void PulseReader*, GpioPull
1585 Function - pulse_reader_set_timebase void PulseReader*, PulseReaderUnit
1586 Function - pulse_reader_start void PulseReader*
1587 Function - pulse_reader_stop void PulseReader*
1588 Function - putc int int, FILE*
1589 Function - putc_unlocked int int, FILE*
1590 Function - putchar int int

View File

@ -14,7 +14,7 @@
"flipper18",
"furi",
"freertos",
"stm32cubewb",
"stm32wb",
"hwdrivers",
"fatfs",
"littlefs",

View File

@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,26.0,,
Version,+,26.2,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/cli/cli.h,,
Header,+,applications/services/cli/cli_vcp.h,,
@ -85,35 +85,6 @@ Header,+,firmware/targets/furi_hal_include/furi_hal_usb_hid.h,,
Header,+,firmware/targets/furi_hal_include/furi_hal_usb_hid_u2f.h,,
Header,+,firmware/targets/furi_hal_include/furi_hal_version.h,,
Header,+,firmware/targets/furi_hal_include/furi_hal_vibro.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_adc.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_bus.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_comp.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_cortex.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crc.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crs.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dma.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dmamux.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_exti.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_gpio.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_hsem.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_i2c.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_ipcc.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_iwdg.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lptim.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lpuart.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pka.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pwr.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rcc.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rng.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rtc.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_spi.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_system.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_tim.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_usart.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_utils.h,,
Header,+,lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_wwdg.h,,
Header,-,lib/STM32CubeWB/Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h,,
Header,+,lib/STM32CubeWB/Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h,,
Header,+,lib/flipper_application/api_hashtable/api_hashtable.h,,
Header,+,lib/flipper_application/api_hashtable/compilesort.hpp,,
Header,+,lib/flipper_application/flipper_application.h,,
@ -178,6 +149,34 @@ Header,+,lib/one_wire/maxim_crc.h,,
Header,+,lib/one_wire/one_wire_host.h,,
Header,+,lib/one_wire/one_wire_slave.h,,
Header,+,lib/print/wrappers.h,,
Header,+,lib/pulse_reader/pulse_reader.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_adc.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_bus.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_comp.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_cortex.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_crc.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_crs.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_dma.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_dmamux.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_exti.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_gpio.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_hsem.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_i2c.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_ipcc.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_iwdg.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_lptim.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_lpuart.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_pka.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_pwr.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rcc.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rng.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_rtc.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_spi.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_system.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_tim.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_usart.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_utils.h,,
Header,+,lib/stm32wb_hal/Inc/stm32wbxx_ll_wwdg.h,,
Header,+,lib/subghz/blocks/const.h,,
Header,+,lib/subghz/blocks/decoder.h,,
Header,+,lib/subghz/blocks/encoder.h,,
@ -238,8 +237,8 @@ Function,-,LL_EXTI_StructInit,void,LL_EXTI_InitTypeDef*
Function,-,LL_GPIO_DeInit,ErrorStatus,GPIO_TypeDef*
Function,+,LL_GPIO_Init,ErrorStatus,"GPIO_TypeDef*, LL_GPIO_InitTypeDef*"
Function,-,LL_GPIO_StructInit,void,LL_GPIO_InitTypeDef*
Function,-,LL_I2C_DeInit,ErrorStatus,I2C_TypeDef*
Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, LL_I2C_InitTypeDef*"
Function,-,LL_I2C_DeInit,ErrorStatus,const I2C_TypeDef*
Function,+,LL_I2C_Init,ErrorStatus,"I2C_TypeDef*, const LL_I2C_InitTypeDef*"
Function,-,LL_I2C_StructInit,void,LL_I2C_InitTypeDef*
Function,-,LL_Init1msTick,void,uint32_t
Function,+,LL_LPTIM_DeInit,ErrorStatus,LPTIM_TypeDef*
@ -762,6 +761,16 @@ Function,+,dialog_message_set_text,void,"DialogMessage*, const char*, uint8_t, u
Function,+,dialog_message_show,DialogMessageButton,"DialogsApp*, const DialogMessage*"
Function,+,dialog_message_show_storage_error,void,"DialogsApp*, const char*"
Function,-,difftime,double,"time_t, time_t"
Function,-,digital_sequence_add,void,"DigitalSequence*, uint8_t"
Function,-,digital_sequence_alloc,DigitalSequence*,"uint32_t, const GpioPin*"
Function,-,digital_sequence_clear,void,DigitalSequence*
Function,-,digital_sequence_free,void,DigitalSequence*
Function,-,digital_sequence_send,_Bool,DigitalSequence*
Function,-,digital_sequence_set_sendtime,void,"DigitalSequence*, uint32_t"
Function,-,digital_sequence_set_signal,void,"DigitalSequence*, uint8_t, DigitalSignal*"
Function,-,digital_sequence_timebase_correction,void,"DigitalSequence*, float"
Function,-,digital_signal_add,void,"DigitalSignal*, uint32_t"
Function,-,digital_signal_add_pulse,void,"DigitalSignal*, uint32_t, _Bool"
Function,-,digital_signal_alloc,DigitalSignal*,uint32_t
Function,-,digital_signal_append,_Bool,"DigitalSignal*, DigitalSignal*"
Function,-,digital_signal_free,void,DigitalSignal*
@ -1028,6 +1037,7 @@ Function,+,furi_hal_bt_change_app,_Bool,"FuriHalBtProfile, GapEventCallback, voi
Function,+,furi_hal_bt_clear_white_list,_Bool,
Function,+,furi_hal_bt_dump_state,void,FuriString*
Function,+,furi_hal_bt_ensure_c2_mode,_Bool,BleGlueC2Mode
Function,-,furi_hal_bt_get_hardfault_info,const FuriHalBtHardfaultInfo*,
Function,+,furi_hal_bt_get_key_storage_buff,void,"uint8_t**, uint16_t*"
Function,+,furi_hal_bt_get_radio_stack,FuriHalBtStack,
Function,+,furi_hal_bt_get_rssi,float,
@ -2212,6 +2222,15 @@ Function,+,protocol_dict_render_brief_data,void,"ProtocolDict*, FuriString*, siz
Function,+,protocol_dict_render_data,void,"ProtocolDict*, FuriString*, size_t"
Function,+,protocol_dict_set_data,void,"ProtocolDict*, size_t, const uint8_t*, size_t"
Function,-,pselect,int,"int, fd_set*, fd_set*, fd_set*, const timespec*, const sigset_t*"
Function,-,pulse_reader_alloc,PulseReader*,"const GpioPin*, uint32_t"
Function,-,pulse_reader_free,void,PulseReader*
Function,-,pulse_reader_receive,uint32_t,"PulseReader*, int"
Function,-,pulse_reader_samples,uint32_t,PulseReader*
Function,-,pulse_reader_set_bittime,void,"PulseReader*, uint32_t"
Function,-,pulse_reader_set_pull,void,"PulseReader*, GpioPull"
Function,-,pulse_reader_set_timebase,void,"PulseReader*, PulseReaderUnit"
Function,-,pulse_reader_start,void,PulseReader*
Function,-,pulse_reader_stop,void,PulseReader*
Function,-,putc,int,"int, FILE*"
Function,-,putc_unlocked,int,"int, FILE*"
Function,-,putchar,int,int
@ -4457,7 +4476,6 @@ Function,+,uECC_sign,int,"const uint8_t*, const uint8_t*, unsigned, uint8_t*, uE
Function,-,uECC_sign_deterministic,int,"const uint8_t*, const uint8_t*, unsigned, const uECC_HashContext*, uint8_t*, uECC_Curve"
Function,-,uECC_valid_public_key,int,"const uint8_t*, uECC_Curve"
Function,-,uECC_verify,int,"const uint8_t*, const uint8_t*, unsigned, const uint8_t*, uECC_Curve"
Function,-,ucStreamBufferGetStreamBufferType,uint8_t,StreamBufferHandle_t
Function,+,uint8_to_hex_chars,void,"const uint8_t*, uint8_t*, int"
Function,-,ulTaskGenericNotifyTake,uint32_t,"UBaseType_t, BaseType_t, TickType_t"
Function,-,ulTaskGenericNotifyValueClear,uint32_t,"TaskHandle_t, UBaseType_t, uint32_t"
@ -4469,7 +4487,6 @@ Function,-,usbd_poll,void,usbd_device*
Function,-,utf8_show,void,
Function,-,utoa,char*,"unsigned, char*, int"
Function,-,uxListRemove,UBaseType_t,ListItem_t*
Function,-,uxStreamBufferGetStreamBufferNumber,UBaseType_t,StreamBufferHandle_t
Function,-,uxTaskGetNumberOfTasks,UBaseType_t,
Function,-,uxTaskGetStackHighWaterMark,UBaseType_t,TaskHandle_t
Function,-,uxTaskGetStackHighWaterMark2,uint16_t,TaskHandle_t
@ -4494,8 +4511,6 @@ Function,-,vPortFree,void,void*
Function,-,vPortGetHeapStats,void,HeapStats_t*
Function,-,vPortInitialiseBlocks,void,
Function,-,vPortSuppressTicksAndSleep,void,TickType_t
Function,+,vStreamBufferDelete,void,StreamBufferHandle_t
Function,-,vStreamBufferSetStreamBufferNumber,void,"StreamBufferHandle_t, UBaseType_t"
Function,-,vTaskAllocateMPURegions,void,"TaskHandle_t, const MemoryRegion_t*"
Function,-,vTaskDelay,void,const TickType_t
Function,-,vTaskDelete,void,TaskHandle_t
@ -4639,21 +4654,6 @@ Function,+,widget_reset,void,Widget*
Function,-,xPortGetFreeHeapSize,size_t,
Function,-,xPortGetMinimumEverFreeHeapSize,size_t,
Function,-,xPortStartScheduler,BaseType_t,
Function,-,xStreamBufferBytesAvailable,size_t,StreamBufferHandle_t
Function,+,xStreamBufferGenericCreate,StreamBufferHandle_t,"size_t, size_t, BaseType_t"
Function,-,xStreamBufferGenericCreateStatic,StreamBufferHandle_t,"size_t, size_t, BaseType_t, uint8_t*, StaticStreamBuffer_t*"
Function,-,xStreamBufferIsEmpty,BaseType_t,StreamBufferHandle_t
Function,-,xStreamBufferIsFull,BaseType_t,StreamBufferHandle_t
Function,-,xStreamBufferNextMessageLengthBytes,size_t,StreamBufferHandle_t
Function,+,xStreamBufferReceive,size_t,"StreamBufferHandle_t, void*, size_t, TickType_t"
Function,-,xStreamBufferReceiveCompletedFromISR,BaseType_t,"StreamBufferHandle_t, BaseType_t*"
Function,-,xStreamBufferReceiveFromISR,size_t,"StreamBufferHandle_t, void*, size_t, BaseType_t*"
Function,-,xStreamBufferReset,BaseType_t,StreamBufferHandle_t
Function,-,xStreamBufferSend,size_t,"StreamBufferHandle_t, const void*, size_t, TickType_t"
Function,-,xStreamBufferSendCompletedFromISR,BaseType_t,"StreamBufferHandle_t, BaseType_t*"
Function,+,xStreamBufferSendFromISR,size_t,"StreamBufferHandle_t, const void*, size_t, BaseType_t*"
Function,-,xStreamBufferSetTriggerLevel,BaseType_t,"StreamBufferHandle_t, size_t"
Function,-,xStreamBufferSpacesAvailable,size_t,StreamBufferHandle_t
Function,-,xTaskAbortDelay,BaseType_t,TaskHandle_t
Function,-,xTaskCallApplicationTaskHook,BaseType_t,"TaskHandle_t, void*"
Function,-,xTaskCatchUpTicks,BaseType_t,TickType_t

1 entry status name type params
2 Version + 26.0 26.2
3 Header + applications/services/bt/bt_service/bt.h
4 Header + applications/services/cli/cli.h
5 Header + applications/services/cli/cli_vcp.h
85 Header + firmware/targets/furi_hal_include/furi_hal_usb_hid_u2f.h
86 Header + firmware/targets/furi_hal_include/furi_hal_version.h
87 Header + firmware/targets/furi_hal_include/furi_hal_vibro.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_adc.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_bus.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_comp.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_cortex.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crc.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_crs.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dma.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_dmamux.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_exti.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_gpio.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_hsem.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_i2c.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_ipcc.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_iwdg.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lptim.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_lpuart.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pka.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_pwr.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rcc.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rng.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_rtc.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_spi.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_system.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_tim.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_usart.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_utils.h
Header + lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/stm32wbxx_ll_wwdg.h
Header - lib/STM32CubeWB/Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h
Header + lib/STM32CubeWB/Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h
88 Header + lib/flipper_application/api_hashtable/api_hashtable.h
89 Header + lib/flipper_application/api_hashtable/compilesort.hpp
90 Header + lib/flipper_application/flipper_application.h
149 Header + lib/one_wire/one_wire_host.h
150 Header + lib/one_wire/one_wire_slave.h
151 Header + lib/print/wrappers.h
152 Header + lib/pulse_reader/pulse_reader.h
153 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_adc.h
154 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_bus.h
155 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_comp.h
156 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_cortex.h
157 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_crc.h
158 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_crs.h
159 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_dma.h
160 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_dmamux.h
161 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_exti.h
162 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_gpio.h
163 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_hsem.h
164 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_i2c.h
165 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_ipcc.h
166 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_iwdg.h
167 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_lptim.h
168 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_lpuart.h
169 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_pka.h
170 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_pwr.h
171 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_rcc.h
172 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_rng.h
173 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_rtc.h
174 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_spi.h
175 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_system.h
176 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_tim.h
177 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_usart.h
178 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_utils.h
179 Header + lib/stm32wb_hal/Inc/stm32wbxx_ll_wwdg.h
180 Header + lib/subghz/blocks/const.h
181 Header + lib/subghz/blocks/decoder.h
182 Header + lib/subghz/blocks/encoder.h
237 Function - LL_GPIO_DeInit ErrorStatus GPIO_TypeDef*
238 Function + LL_GPIO_Init ErrorStatus GPIO_TypeDef*, LL_GPIO_InitTypeDef*
239 Function - LL_GPIO_StructInit void LL_GPIO_InitTypeDef*
240 Function - LL_I2C_DeInit ErrorStatus I2C_TypeDef* const I2C_TypeDef*
241 Function + LL_I2C_Init ErrorStatus I2C_TypeDef*, LL_I2C_InitTypeDef* I2C_TypeDef*, const LL_I2C_InitTypeDef*
242 Function - LL_I2C_StructInit void LL_I2C_InitTypeDef*
243 Function - LL_Init1msTick void uint32_t
244 Function + LL_LPTIM_DeInit ErrorStatus LPTIM_TypeDef*
761 Function + dialog_message_show DialogMessageButton DialogsApp*, const DialogMessage*
762 Function + dialog_message_show_storage_error void DialogsApp*, const char*
763 Function - difftime double time_t, time_t
764 Function - digital_sequence_add void DigitalSequence*, uint8_t
765 Function - digital_sequence_alloc DigitalSequence* uint32_t, const GpioPin*
766 Function - digital_sequence_clear void DigitalSequence*
767 Function - digital_sequence_free void DigitalSequence*
768 Function - digital_sequence_send _Bool DigitalSequence*
769 Function - digital_sequence_set_sendtime void DigitalSequence*, uint32_t
770 Function - digital_sequence_set_signal void DigitalSequence*, uint8_t, DigitalSignal*
771 Function - digital_sequence_timebase_correction void DigitalSequence*, float
772 Function - digital_signal_add void DigitalSignal*, uint32_t
773 Function - digital_signal_add_pulse void DigitalSignal*, uint32_t, _Bool
774 Function - digital_signal_alloc DigitalSignal* uint32_t
775 Function - digital_signal_append _Bool DigitalSignal*, DigitalSignal*
776 Function - digital_signal_free void DigitalSignal*
1037 Function + furi_hal_bt_clear_white_list _Bool
1038 Function + furi_hal_bt_dump_state void FuriString*
1039 Function + furi_hal_bt_ensure_c2_mode _Bool BleGlueC2Mode
1040 Function - furi_hal_bt_get_hardfault_info const FuriHalBtHardfaultInfo*
1041 Function + furi_hal_bt_get_key_storage_buff void uint8_t**, uint16_t*
1042 Function + furi_hal_bt_get_radio_stack FuriHalBtStack
1043 Function + furi_hal_bt_get_rssi float
2222 Function + protocol_dict_render_data void ProtocolDict*, FuriString*, size_t
2223 Function + protocol_dict_set_data void ProtocolDict*, size_t, const uint8_t*, size_t
2224 Function - pselect int int, fd_set*, fd_set*, fd_set*, const timespec*, const sigset_t*
2225 Function - pulse_reader_alloc PulseReader* const GpioPin*, uint32_t
2226 Function - pulse_reader_free void PulseReader*
2227 Function - pulse_reader_receive uint32_t PulseReader*, int
2228 Function - pulse_reader_samples uint32_t PulseReader*
2229 Function - pulse_reader_set_bittime void PulseReader*, uint32_t
2230 Function - pulse_reader_set_pull void PulseReader*, GpioPull
2231 Function - pulse_reader_set_timebase void PulseReader*, PulseReaderUnit
2232 Function - pulse_reader_start void PulseReader*
2233 Function - pulse_reader_stop void PulseReader*
2234 Function - putc int int, FILE*
2235 Function - putc_unlocked int int, FILE*
2236 Function - putchar int int
4476 Function - uECC_sign_deterministic int const uint8_t*, const uint8_t*, unsigned, const uECC_HashContext*, uint8_t*, uECC_Curve
4477 Function - uECC_valid_public_key int const uint8_t*, uECC_Curve
4478 Function - uECC_verify int const uint8_t*, const uint8_t*, unsigned, const uint8_t*, uECC_Curve
Function - ucStreamBufferGetStreamBufferType uint8_t StreamBufferHandle_t
4479 Function + uint8_to_hex_chars void const uint8_t*, uint8_t*, int
4480 Function - ulTaskGenericNotifyTake uint32_t UBaseType_t, BaseType_t, TickType_t
4481 Function - ulTaskGenericNotifyValueClear uint32_t TaskHandle_t, UBaseType_t, uint32_t
4487 Function - utf8_show void
4488 Function - utoa char* unsigned, char*, int
4489 Function - uxListRemove UBaseType_t ListItem_t*
Function - uxStreamBufferGetStreamBufferNumber UBaseType_t StreamBufferHandle_t
4490 Function - uxTaskGetNumberOfTasks UBaseType_t
4491 Function - uxTaskGetStackHighWaterMark UBaseType_t TaskHandle_t
4492 Function - uxTaskGetStackHighWaterMark2 uint16_t TaskHandle_t
4511 Function - vPortGetHeapStats void HeapStats_t*
4512 Function - vPortInitialiseBlocks void
4513 Function - vPortSuppressTicksAndSleep void TickType_t
Function + vStreamBufferDelete void StreamBufferHandle_t
Function - vStreamBufferSetStreamBufferNumber void StreamBufferHandle_t, UBaseType_t
4514 Function - vTaskAllocateMPURegions void TaskHandle_t, const MemoryRegion_t*
4515 Function - vTaskDelay void const TickType_t
4516 Function - vTaskDelete void TaskHandle_t
4654 Function - xPortGetFreeHeapSize size_t
4655 Function - xPortGetMinimumEverFreeHeapSize size_t
4656 Function - xPortStartScheduler BaseType_t
Function - xStreamBufferBytesAvailable size_t StreamBufferHandle_t
Function + xStreamBufferGenericCreate StreamBufferHandle_t size_t, size_t, BaseType_t
Function - xStreamBufferGenericCreateStatic StreamBufferHandle_t size_t, size_t, BaseType_t, uint8_t*, StaticStreamBuffer_t*
Function - xStreamBufferIsEmpty BaseType_t StreamBufferHandle_t
Function - xStreamBufferIsFull BaseType_t StreamBufferHandle_t
Function - xStreamBufferNextMessageLengthBytes size_t StreamBufferHandle_t
Function + xStreamBufferReceive size_t StreamBufferHandle_t, void*, size_t, TickType_t
Function - xStreamBufferReceiveCompletedFromISR BaseType_t StreamBufferHandle_t, BaseType_t*
Function - xStreamBufferReceiveFromISR size_t StreamBufferHandle_t, void*, size_t, BaseType_t*
Function - xStreamBufferReset BaseType_t StreamBufferHandle_t
Function - xStreamBufferSend size_t StreamBufferHandle_t, const void*, size_t, TickType_t
Function - xStreamBufferSendCompletedFromISR BaseType_t StreamBufferHandle_t, BaseType_t*
Function + xStreamBufferSendFromISR size_t StreamBufferHandle_t, const void*, size_t, BaseType_t*
Function - xStreamBufferSetTriggerLevel BaseType_t StreamBufferHandle_t, size_t
Function - xStreamBufferSpacesAvailable size_t StreamBufferHandle_t
4657 Function - xTaskAbortDelay BaseType_t TaskHandle_t
4658 Function - xTaskCallApplicationTaskHook BaseType_t TaskHandle_t, void*
4659 Function - xTaskCatchUpTicks BaseType_t TickType_t

View File

@ -54,6 +54,26 @@ void ble_glue_set_key_storage_changed_callback(
ble_glue->context = context;
}
///////////////////////////////////////////////////////////////////////////////
/* TL hook to catch hardfaults */
int32_t ble_glue_TL_SYS_SendCmd(uint8_t* buffer, uint16_t size) {
if(furi_hal_bt_get_hardfault_info()) {
furi_crash("ST(R) Copro(R) HardFault");
}
return TL_SYS_SendCmd(buffer, size);
}
void shci_register_io_bus(tSHciIO* fops) {
/* Register IO bus services */
fops->Init = TL_SYS_Init;
fops->Send = ble_glue_TL_SYS_SendCmd;
}
///////////////////////////////////////////////////////////////////////////////
void ble_glue_init() {
ble_glue = malloc(sizeof(BleGlue));
ble_glue->status = BleGlueStatusStartup;

View File

@ -19,6 +19,8 @@
/* Time, in ms, to wait for mode transition before crashing */
#define C2_MODE_SWITCH_TIMEOUT 10000
#define FURI_HAL_BT_HARDFAULT_INFO_MAGIC 0x1170FD0F
FuriMutex* furi_hal_bt_core2_mtx = NULL;
static FuriHalBtStack furi_hal_bt_stack = FuriHalBtStackUnknown;
@ -440,3 +442,12 @@ bool furi_hal_bt_ensure_c2_mode(BleGlueC2Mode mode) {
FURI_LOG_E(TAG, "Failed to switch C2 mode: %d", fw_start_res);
return false;
}
const FuriHalBtHardfaultInfo* furi_hal_bt_get_hardfault_info() {
/* AN5289, 4.8.2 */
const FuriHalBtHardfaultInfo* info = (FuriHalBtHardfaultInfo*)(SRAM2A_BASE);
if(info->magic != FURI_HAL_BT_HARDFAULT_INFO_MAGIC) {
return NULL;
}
return info;
}

View File

@ -27,7 +27,7 @@
#define FURI_HAL_FLASH_OPT_KEY2 0x4C5D6E7F
#define FURI_HAL_FLASH_OB_TOTAL_WORDS (0x80 / (sizeof(uint32_t) * 2))
/* lib/STM32CubeWB/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_RfWithFlash/Core/Src/flash_driver.c
/* STM32CubeWB/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_RfWithFlash/Core/Src/flash_driver.c
* ProcessSingleFlashOperation, quote:
> In most BLE application, the flash should not be blocked by the CPU2 longer than FLASH_TIMEOUT_VALUE (1000ms)
> However, it could be that for some marginal application, this time is longer.

View File

@ -20,7 +20,7 @@
"flipper7",
"furi",
"freertos",
"stm32cubewb",
"stm32wb",
"hwdrivers",
"fatfs",
"littlefs",
@ -28,6 +28,7 @@
"flipperformat",
"toolbox",
"nfc",
"pulse_reader",
"microtar",
"usb_stm32",
"st25rfal002",

View File

@ -224,6 +224,19 @@ uint32_t furi_hal_bt_get_transmitted_packets();
*/
bool furi_hal_bt_ensure_c2_mode(BleGlueC2Mode mode);
typedef struct {
uint32_t magic;
uint32_t source_pc;
uint32_t source_lr;
uint32_t source_sp;
} FuriHalBtHardfaultInfo;
/** Get hardfault info
*
* @return hardfault info. NULL if no hardfault
*/
const FuriHalBtHardfaultInfo* furi_hal_bt_get_hardfault_info();
#ifdef __cplusplus
}
#endif

View File

@ -6,6 +6,7 @@
#include <furi_hal_power.h>
#include <furi_hal_rtc.h>
#include <furi_hal_debug.h>
#include <furi_hal_bt.h>
#include <stdio.h>
#include <FreeRTOS.h>
@ -87,6 +88,20 @@ static void __furi_print_stack_info() {
__furi_put_uint32_as_text(uxTaskGetStackHighWaterMark(NULL) * 4);
}
static void __furi_print_bt_stack_info() {
const FuriHalBtHardfaultInfo* fault_info = furi_hal_bt_get_hardfault_info();
if(fault_info == NULL) {
furi_hal_console_puts("\r\n\tcore2: not faulted");
} else {
furi_hal_console_puts("\r\n\tcore2: hardfaulted.\r\n\tPC: ");
__furi_put_uint32_as_hex(fault_info->source_pc);
furi_hal_console_puts("\r\n\tLR: ");
__furi_put_uint32_as_hex(fault_info->source_lr);
furi_hal_console_puts("\r\n\tSP: ");
__furi_put_uint32_as_hex(fault_info->source_sp);
}
}
static void __furi_print_heap_info() {
furi_hal_console_puts("\r\n\t heap total: ");
__furi_put_uint32_as_text(xPortGetTotalHeapSize());
@ -136,6 +151,7 @@ FURI_NORETURN void __furi_crash() {
__furi_print_stack_info();
}
__furi_print_heap_info();
__furi_print_bt_stack_info();
#ifndef FURI_DEBUG
// Check if debug enabled by DAP

View File

@ -1,25 +1,38 @@
# Structure
- `app-scened-template` - Scened template app library
- `app-template` - Template app library
- `FreeRTOS-Kernel` - FreeRTOS kernel source code
- `FreeRTOS-glue` - Extra glue to hold together FreeRTOS kernel and flipper firmware
- `ST25RFAL002` - ST25R3916 Driver and protocol stack
- `app-scened-template` - C++ app library
- `callback-connector` - Callback connector library
- `drivers` - Drivers that we wrote
- `fatfs` - External storage file system
- `cmsis_core` - CMSIS Core package, contain cortex-m core headers
- `cxxheaderparser` - C++ headers parser, used by SDK bundler
- `digital_signal` - Digital signal library: used by NFC for software implemented protocols
- `drivers` - Various flipper drivers
- `fatfs` - FatFS file system driver
- `flipper_application` - Flipper application library, used for FAPs
- `flipper_format` - Flipper File Format library
- `fnv1a-hash` - Fnv1a hash library
- `heatshrink` - Image compression library
- `infrared` - Infrared library
- `libusb_stm32` - STM32 USB library
- `littlefs` - Internal storage file system
- `micro-ecc` - Elliptic Curve Crytography library
- `microtar` - TAR archive support library
- `mlib` - Algorithms and containers
- `nanopb` - Nano Protobuf library
- `nfc` - Nfc library
- `one_wire` - One wire library
- `qrcode` - Qr code generator library
- `ST25RFAL002` - ST253916 driver and NFC hal
- `STM32CubeWB` - STM32WB series cube package
- `subghz` - SubGhz library
- `toolbox` - Toolbox of things that we are using but don't place in core
- `u8g2` - Graphics library that we use to draw GUI
- `fnv1a-hash` - FNV-1a hash library
- `heatshrink` - Heatshrink compression library
- `ibutton` - ibutton library, used by iButton application
- `infrared` - Infrared library, used by Infrared application
- `lfrfid` - LF-RFID library, used by LF RFID application
- `libusb_stm32` - LibUSB for STM32 series MCU
- `littlefs` - LittleFS file system driver, used by internal storage
- `mbedtls` - MbedTLS cryptography library
- `micro-ecc` - MicroECC cryptography library
- `microtar` - MicroTAR library
- `mlib` - M-Lib C containers library
- `nanopb` - NanoPB library, protobuf implementation for MCU
- `nfc` - NFC library, used by NFC application
- `one_wire` - OneWire library, used by iButton application
- `print` - Tiny printf implementation
- `pulse_reader` - Pulse Reader library used by NFC for software implemented protocols
- `qrcode` - QR-Code library
- `stm32wb_cmsis` - STM32WB series CMSIS headers, extends CMSIS Core
- `stm32wb_copro` - STM32WB Copro library: contains WPAN and radio co-processor firmware
- `stm32wb_hal` - STM32WB HAL library, extends STM32WB CMSIS and provides HAL
- `subghz` - Subghz library, used by SubGhz application
- `toolbox` - Toolbox library, contains various things that is used by flipper firmware
- `u8g2` - u8g2 graphics library, used by GUI subsystem
- `update_util` - update utilities library, used by updater

View File

@ -4,6 +4,7 @@ env.Append(
LINT_SOURCES=[
Dir("app-scened-template"),
Dir("digital_signal"),
Dir("pulse_reader"),
Dir("drivers"),
Dir("flipper_format"),
Dir("infrared"),
@ -14,6 +15,7 @@ env.Append(
Dir("u8g2"),
Dir("update_util"),
Dir("print"),
Dir("pulse_reader"),
],
)
@ -77,7 +79,7 @@ env.Append(
libs = env.BuildModules(
[
"STM32CubeWB",
"stm32wb",
"freertos",
"print",
"microtar",
@ -94,6 +96,7 @@ libs = env.BuildModules(
"mbedtls",
"subghz",
"nfc",
"pulse_reader",
"appframe",
"misc",
"lfrfid",

@ -1 +0,0 @@
Subproject commit c4cec8ae57a79e949a184cd0b4117a008a0a25a7

View File

@ -1,72 +0,0 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/STM32CubeWB/Drivers/CMSIS/Device/ST/STM32WBxx/Include",
"#/lib/STM32CubeWB/Drivers/CMSIS/Include",
"#/lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN",
],
CPPDEFINES=[
"STM32WB",
"STM32WB55xx",
"USE_FULL_ASSERT",
"USE_FULL_LL_DRIVER",
],
SDK_HEADERS=[
*env.GlobRecursive("*_ll_*.h", "#/lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/", exclude="*usb.h"),
File("STM32CubeWB/Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h"),
File("STM32CubeWB/Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h"),
],
)
if env["RAM_EXEC"]:
env.Append(
CPPDEFINES=[
"VECT_TAB_SRAM",
],
)
libenv = env.Clone(FW_LIB_NAME="stm32cubewb")
libenv.Append(
CPPPATH=[
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/ble",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/shci",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities",
]
)
libenv.ApplyLibFlags()
sources = libenv.GlobRecursive(
"*_ll_*.c", "STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Src/", exclude="*usb.c"
)
sources += Glob(
"STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/shci/*.c",
source=True,
)
sources += Glob(
"STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl/*_tl*.c",
source=True,
)
sources += [
"STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl/tl_mbox.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/svc/Src/svc_ctl.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_gap_aci.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_gatt_aci.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_hal_aci.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_hci_le.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_l2cap_aci.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/template/osal.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities/dbg_trace.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities/otp.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities/stm_list.c",
]
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

View File

@ -0,0 +1,894 @@
/**************************************************************************//**
* @file cmsis_armcc.h
* @brief CMSIS compiler ARMCC (Arm Compiler 5) header file
* @version V5.4.0
* @date 20. January 2023
******************************************************************************/
/*
* Copyright (c) 2009-2023 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CMSIS_ARMCC_H
#define __CMSIS_ARMCC_H
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
#error "Please use Arm Compiler Toolchain V4.0.677 or later!"
#endif
/* CMSIS compiler control architecture macros */
#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \
(defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) )
#define __ARM_ARCH_6M__ 1
#endif
#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1))
#define __ARM_ARCH_7M__ 1
#endif
#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1))
#define __ARM_ARCH_7EM__ 1
#endif
/* __ARM_ARCH_8M_BASE__ not applicable */
/* __ARM_ARCH_8M_MAIN__ not applicable */
/* __ARM_ARCH_8_1M_MAIN__ not applicable */
/* CMSIS compiler control DSP macros */
#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
#define __ARM_FEATURE_DSP 1
#endif
/* CMSIS compiler specific defines */
#ifndef __ASM
#define __ASM __asm
#endif
#ifndef __INLINE
#define __INLINE __inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static __inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE static __forceinline
#endif
#ifndef __NO_RETURN
#define __NO_RETURN __declspec(noreturn)
#endif
#ifndef __USED
#define __USED __attribute__((used))
#endif
#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif
#ifndef __PACKED
#define __PACKED __attribute__((packed))
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT __packed struct
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION __packed union
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
#define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
#endif
#ifndef __UNALIGNED_UINT16_WRITE
#define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
#endif
#ifndef __UNALIGNED_UINT16_READ
#define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
#endif
#ifndef __UNALIGNED_UINT32_WRITE
#define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
#endif
#ifndef __UNALIGNED_UINT32_READ
#define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
#endif
#ifndef __ALIGNED
#define __ALIGNED(x) __attribute__((aligned(x)))
#endif
#ifndef __RESTRICT
#define __RESTRICT __restrict
#endif
#ifndef __COMPILER_BARRIER
#define __COMPILER_BARRIER() __memory_changed()
#endif
#ifndef __NO_INIT
#define __NO_INIT __attribute__ ((section (".bss.noinit"), zero_init))
#endif
#ifndef __ALIAS
#define __ALIAS(x) __attribute__ ((alias(x)))
#endif
/* ######################### Startup and Lowlevel Init ######################## */
#ifndef __PROGRAM_START
#define __PROGRAM_START __main
#endif
#ifndef __INITIAL_SP
#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
#endif
#ifndef __STACK_LIMIT
#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base
#endif
#ifndef __VECTOR_TABLE
#define __VECTOR_TABLE __Vectors
#endif
#ifndef __VECTOR_TABLE_ATTRIBUTE
#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET")))
#endif
/* ########################## Core Instruction Access ######################### */
/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
Access to dedicated instructions
@{
*/
/**
\brief No Operation
\details No Operation does nothing. This instruction can be used for code alignment purposes.
*/
#define __NOP __nop
/**
\brief Wait For Interrupt
\details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
*/
#define __WFI __wfi
/**
\brief Wait For Event
\details Wait For Event is a hint instruction that permits the processor to enter
a low-power state until one of a number of events occurs.
*/
#define __WFE __wfe
/**
\brief Send Event
\details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
*/
#define __SEV __sev
/**
\brief Instruction Synchronization Barrier
\details Instruction Synchronization Barrier flushes the pipeline in the processor,
so that all instructions following the ISB are fetched from cache or memory,
after the instruction has been completed.
*/
#define __ISB() __isb(0xF)
/**
\brief Data Synchronization Barrier
\details Acts as a special kind of Data Memory Barrier.
It completes when all explicit memory accesses before this instruction complete.
*/
#define __DSB() __dsb(0xF)
/**
\brief Data Memory Barrier
\details Ensures the apparent order of the explicit memory operations before
and after the instruction, without ensuring their completion.
*/
#define __DMB() __dmb(0xF)
/**
\brief Reverse byte order (32 bit)
\details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
\param [in] value Value to reverse
\return Reversed value
*/
#define __REV __rev
/**
\brief Reverse byte order (16 bit)
\details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
\param [in] value Value to reverse
\return Reversed value
*/
#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
{
rev16 r0, r0
bx lr
}
#endif
/**
\brief Reverse byte order (16 bit)
\details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
\param [in] value Value to reverse
\return Reversed value
*/
#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
{
revsh r0, r0
bx lr
}
#endif
/**
\brief Rotate Right in unsigned value (32 bit)
\details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
\param [in] op1 Value to rotate
\param [in] op2 Number of Bits to rotate
\return Rotated value
*/
#define __ROR __ror
/**
\brief Breakpoint
\details Causes the processor to enter Debug state.
Debug tools can use this to investigate system state when the instruction at a particular address is reached.
\param [in] value is ignored by the processor.
If required, a debugger can use it to store additional information about the breakpoint.
*/
#define __BKPT(value) __breakpoint(value)
/**
\brief Reverse bit order of value
\details Reverses the bit order of the given value.
\param [in] value Value to reverse
\return Reversed value
*/
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
#define __RBIT __rbit
#else
__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
{
uint32_t result;
uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
result = value; /* r will be reversed bits of v; first get LSB of v */
for (value >>= 1U; value != 0U; value >>= 1U)
{
result <<= 1U;
result |= value & 1U;
s--;
}
result <<= s; /* shift when v's highest bits are zero */
return result;
}
#endif
/**
\brief Count leading zeros
\details Counts the number of leading zeros of a data value.
\param [in] value Value to count the leading zeros
\return number of leading zeros in value
*/
#define __CLZ __clz
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
/**
\brief LDR Exclusive (8 bit)
\details Executes a exclusive LDR instruction for 8 bit value.
\param [in] ptr Pointer to data
\return value of type uint8_t at (*ptr)
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
#else
#define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
#endif
/**
\brief LDR Exclusive (16 bit)
\details Executes a exclusive LDR instruction for 16 bit values.
\param [in] ptr Pointer to data
\return value of type uint16_t at (*ptr)
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
#else
#define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
#endif
/**
\brief LDR Exclusive (32 bit)
\details Executes a exclusive LDR instruction for 32 bit values.
\param [in] ptr Pointer to data
\return value of type uint32_t at (*ptr)
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
#else
#define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
#endif
/**
\brief STR Exclusive (8 bit)
\details Executes a exclusive STR instruction for 8 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __STREXB(value, ptr) __strex(value, ptr)
#else
#define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
#endif
/**
\brief STR Exclusive (16 bit)
\details Executes a exclusive STR instruction for 16 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __STREXH(value, ptr) __strex(value, ptr)
#else
#define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
#endif
/**
\brief STR Exclusive (32 bit)
\details Executes a exclusive STR instruction for 32 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __STREXW(value, ptr) __strex(value, ptr)
#else
#define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
#endif
/**
\brief Remove the exclusive lock
\details Removes the exclusive lock which is created by LDREX.
*/
#define __CLREX __clrex
/**
\brief Signed Saturate
\details Saturates a signed value.
\param [in] value Value to be saturated
\param [in] sat Bit position to saturate to (1..32)
\return Saturated value
*/
#define __SSAT __ssat
/**
\brief Unsigned Saturate
\details Saturates an unsigned value.
\param [in] value Value to be saturated
\param [in] sat Bit position to saturate to (0..31)
\return Saturated value
*/
#define __USAT __usat
/**
\brief Rotate Right with Extend (32 bit)
\details Moves each bit of a bitstring right by one bit.
The carry input is shifted in at the left end of the bitstring.
\param [in] value Value to rotate
\return Rotated value
*/
#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
{
rrx r0, r0
bx lr
}
#endif
/**
\brief LDRT Unprivileged (8 bit)
\details Executes a Unprivileged LDRT instruction for 8 bit value.
\param [in] ptr Pointer to data
\return value of type uint8_t at (*ptr)
*/
#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
/**
\brief LDRT Unprivileged (16 bit)
\details Executes a Unprivileged LDRT instruction for 16 bit values.
\param [in] ptr Pointer to data
\return value of type uint16_t at (*ptr)
*/
#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
/**
\brief LDRT Unprivileged (32 bit)
\details Executes a Unprivileged LDRT instruction for 32 bit values.
\param [in] ptr Pointer to data
\return value of type uint32_t at (*ptr)
*/
#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
/**
\brief STRT Unprivileged (8 bit)
\details Executes a Unprivileged STRT instruction for 8 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
*/
#define __STRBT(value, ptr) __strt(value, ptr)
/**
\brief STRT Unprivileged (16 bit)
\details Executes a Unprivileged STRT instruction for 16 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
*/
#define __STRHT(value, ptr) __strt(value, ptr)
/**
\brief STRT Unprivileged (32 bit)
\details Executes a Unprivileged STRT instruction for 32 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
*/
#define __STRT(value, ptr) __strt(value, ptr)
#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
/**
\brief Signed Saturate
\details Saturates a signed value.
\param [in] value Value to be saturated
\param [in] sat Bit position to saturate to (1..32)
\return Saturated value
*/
__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
{
if ((sat >= 1U) && (sat <= 32U))
{
const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
const int32_t min = -1 - max ;
if (val > max)
{
return max;
}
else if (val < min)
{
return min;
}
}
return val;
}
/**
\brief Unsigned Saturate
\details Saturates an unsigned value.
\param [in] value Value to be saturated
\param [in] sat Bit position to saturate to (0..31)
\return Saturated value
*/
__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
{
if (sat <= 31U)
{
const uint32_t max = ((1U << sat) - 1U);
if (val > (int32_t)max)
{
return max;
}
else if (val < 0)
{
return 0U;
}
}
return (uint32_t)val;
}
#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
/* ########################### Core Function Access ########################### */
/** \ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
@{
*/
/**
\brief Enable IRQ Interrupts
\details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
Can only be executed in Privileged modes.
*/
/* intrinsic void __enable_irq(); */
/**
\brief Disable IRQ Interrupts
\details Disables IRQ interrupts by setting special-purpose register PRIMASK.
Can only be executed in Privileged modes.
*/
/* intrinsic void __disable_irq(); */
/**
\brief Get Control Register
\details Returns the content of the Control Register.
\return Control Register value
*/
__STATIC_INLINE uint32_t __get_CONTROL(void)
{
register uint32_t __regControl __ASM("control");
return(__regControl);
}
/**
\brief Set Control Register
\details Writes the given value to the Control Register.
\param [in] control Control Register value to set
*/
__STATIC_INLINE void __set_CONTROL(uint32_t control)
{
register uint32_t __regControl __ASM("control");
__regControl = control;
__ISB();
}
/**
\brief Get IPSR Register
\details Returns the content of the IPSR Register.
\return IPSR Register value
*/
__STATIC_INLINE uint32_t __get_IPSR(void)
{
register uint32_t __regIPSR __ASM("ipsr");
return(__regIPSR);
}
/**
\brief Get APSR Register
\details Returns the content of the APSR Register.
\return APSR Register value
*/
__STATIC_INLINE uint32_t __get_APSR(void)
{
register uint32_t __regAPSR __ASM("apsr");
return(__regAPSR);
}
/**
\brief Get xPSR Register
\details Returns the content of the xPSR Register.
\return xPSR Register value
*/
__STATIC_INLINE uint32_t __get_xPSR(void)
{
register uint32_t __regXPSR __ASM("xpsr");
return(__regXPSR);
}
/**
\brief Get Process Stack Pointer
\details Returns the current value of the Process Stack Pointer (PSP).
\return PSP Register value
*/
__STATIC_INLINE uint32_t __get_PSP(void)
{
register uint32_t __regProcessStackPointer __ASM("psp");
return(__regProcessStackPointer);
}
/**
\brief Set Process Stack Pointer
\details Assigns the given value to the Process Stack Pointer (PSP).
\param [in] topOfProcStack Process Stack Pointer value to set
*/
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
{
register uint32_t __regProcessStackPointer __ASM("psp");
__regProcessStackPointer = topOfProcStack;
}
/**
\brief Get Main Stack Pointer
\details Returns the current value of the Main Stack Pointer (MSP).
\return MSP Register value
*/
__STATIC_INLINE uint32_t __get_MSP(void)
{
register uint32_t __regMainStackPointer __ASM("msp");
return(__regMainStackPointer);
}
/**
\brief Set Main Stack Pointer
\details Assigns the given value to the Main Stack Pointer (MSP).
\param [in] topOfMainStack Main Stack Pointer value to set
*/
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
{
register uint32_t __regMainStackPointer __ASM("msp");
__regMainStackPointer = topOfMainStack;
}
/**
\brief Get Priority Mask
\details Returns the current state of the priority mask bit from the Priority Mask Register.
\return Priority Mask value
*/
__STATIC_INLINE uint32_t __get_PRIMASK(void)
{
register uint32_t __regPriMask __ASM("primask");
return(__regPriMask);
}
/**
\brief Set Priority Mask
\details Assigns the given value to the Priority Mask Register.
\param [in] priMask Priority Mask
*/
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
{
register uint32_t __regPriMask __ASM("primask");
__regPriMask = (priMask);
}
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
/**
\brief Enable FIQ
\details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
Can only be executed in Privileged modes.
*/
#define __enable_fault_irq __enable_fiq
/**
\brief Disable FIQ
\details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
Can only be executed in Privileged modes.
*/
#define __disable_fault_irq __disable_fiq
/**
\brief Get Base Priority
\details Returns the current value of the Base Priority register.
\return Base Priority register value
*/
__STATIC_INLINE uint32_t __get_BASEPRI(void)
{
register uint32_t __regBasePri __ASM("basepri");
return(__regBasePri);
}
/**
\brief Set Base Priority
\details Assigns the given value to the Base Priority register.
\param [in] basePri Base Priority value to set
*/
__STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
{
register uint32_t __regBasePri __ASM("basepri");
__regBasePri = (basePri & 0xFFU);
}
/**
\brief Set Base Priority with condition
\details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
or the new value increases the BASEPRI priority level.
\param [in] basePri Base Priority value to set
*/
__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
{
register uint32_t __regBasePriMax __ASM("basepri_max");
__regBasePriMax = (basePri & 0xFFU);
}
/**
\brief Get Fault Mask
\details Returns the current value of the Fault Mask register.
\return Fault Mask register value
*/
__STATIC_INLINE uint32_t __get_FAULTMASK(void)
{
register uint32_t __regFaultMask __ASM("faultmask");
return(__regFaultMask);
}
/**
\brief Set Fault Mask
\details Assigns the given value to the Fault Mask register.
\param [in] faultMask Fault Mask value to set
*/
__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
{
register uint32_t __regFaultMask __ASM("faultmask");
__regFaultMask = (faultMask & (uint32_t)1U);
}
#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
/**
\brief Get FPSCR
\details Returns the current value of the Floating Point Status/Control register.
\return Floating Point Status/Control register value
*/
__STATIC_INLINE uint32_t __get_FPSCR(void)
{
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
register uint32_t __regfpscr __ASM("fpscr");
return(__regfpscr);
#else
return(0U);
#endif
}
/**
\brief Set FPSCR
\details Assigns the given value to the Floating Point Status/Control register.
\param [in] fpscr Floating Point Status/Control value to set
*/
__STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
{
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
register uint32_t __regfpscr __ASM("fpscr");
__regfpscr = (fpscr);
#else
(void)fpscr;
#endif
}
/*@} end of CMSIS_Core_RegAccFunctions */
/* ################### Compiler specific Intrinsics ########################### */
/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
Access to dedicated SIMD instructions
@{
*/
#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
#define __SADD8 __sadd8
#define __QADD8 __qadd8
#define __SHADD8 __shadd8
#define __UADD8 __uadd8
#define __UQADD8 __uqadd8
#define __UHADD8 __uhadd8
#define __SSUB8 __ssub8
#define __QSUB8 __qsub8
#define __SHSUB8 __shsub8
#define __USUB8 __usub8
#define __UQSUB8 __uqsub8
#define __UHSUB8 __uhsub8
#define __SADD16 __sadd16
#define __QADD16 __qadd16
#define __SHADD16 __shadd16
#define __UADD16 __uadd16
#define __UQADD16 __uqadd16
#define __UHADD16 __uhadd16
#define __SSUB16 __ssub16
#define __QSUB16 __qsub16
#define __SHSUB16 __shsub16
#define __USUB16 __usub16
#define __UQSUB16 __uqsub16
#define __UHSUB16 __uhsub16
#define __SASX __sasx
#define __QASX __qasx
#define __SHASX __shasx
#define __UASX __uasx
#define __UQASX __uqasx
#define __UHASX __uhasx
#define __SSAX __ssax
#define __QSAX __qsax
#define __SHSAX __shsax
#define __USAX __usax
#define __UQSAX __uqsax
#define __UHSAX __uhsax
#define __USAD8 __usad8
#define __USADA8 __usada8
#define __SSAT16 __ssat16
#define __USAT16 __usat16
#define __UXTB16 __uxtb16
#define __UXTAB16 __uxtab16
#define __SXTB16 __sxtb16
#define __SXTAB16 __sxtab16
#define __SMUAD __smuad
#define __SMUADX __smuadx
#define __SMLAD __smlad
#define __SMLADX __smladx
#define __SMLALD __smlald
#define __SMLALDX __smlaldx
#define __SMUSD __smusd
#define __SMUSDX __smusdx
#define __SMLSD __smlsd
#define __SMLSDX __smlsdx
#define __SMLSLD __smlsld
#define __SMLSLDX __smlsldx
#define __SEL __sel
#define __QADD __qadd
#define __QSUB __qsub
#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
((int64_t)(ARG3) << 32U) ) >> 32U))
#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2))
#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
/*@} end of group CMSIS_SIMD_intrinsics */
#endif /* __CMSIS_ARMCC_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,303 @@
/**************************************************************************//**
* @file cmsis_compiler.h
* @brief CMSIS compiler generic header file
* @version V5.3.0
* @date 04. April 2023
******************************************************************************/
/*
* Copyright (c) 2009-2023 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CMSIS_COMPILER_H
#define __CMSIS_COMPILER_H
#include <stdint.h>
/*
* Arm Compiler 4/5
*/
#if defined ( __CC_ARM )
#include "cmsis_armcc.h"
/*
* Arm Compiler 6.6 LTM (armclang)
*/
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
#include "cmsis_armclang_ltm.h"
/*
* Arm Compiler above 6.10.1 (armclang)
*/
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
#include "cmsis_armclang.h"
/*
* TI Arm Clang Compiler (tiarmclang)
*/
#elif defined (__ti__)
#include "cmsis_tiarmclang.h"
/*
* GNU Compiler
*/
#elif defined ( __GNUC__ )
#include "cmsis_gcc.h"
/*
* IAR Compiler
*/
#elif defined ( __ICCARM__ )
#include <cmsis_iccarm.h>
/*
* TI Arm Compiler (armcl)
*/
#elif defined ( __TI_ARM__ )
#include <cmsis_ccs.h>
#ifndef __ASM
#define __ASM __asm
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __STATIC_INLINE
#endif
#ifndef __NO_RETURN
#define __NO_RETURN __attribute__((noreturn))
#endif
#ifndef __USED
#define __USED __attribute__((used))
#endif
#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif
#ifndef __PACKED
#define __PACKED __attribute__((packed))
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT struct __attribute__((packed))
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION union __attribute__((packed))
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
struct __attribute__((packed)) T_UINT32 { uint32_t v; };
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
#endif
#ifndef __UNALIGNED_UINT16_WRITE
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT16_READ
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
#endif
#ifndef __UNALIGNED_UINT32_WRITE
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT32_READ
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
#endif
#ifndef __ALIGNED
#define __ALIGNED(x) __attribute__((aligned(x)))
#endif
#ifndef __RESTRICT
#define __RESTRICT __restrict
#endif
#ifndef __COMPILER_BARRIER
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
#define __COMPILER_BARRIER() (void)0
#endif
#ifndef __NO_INIT
#define __NO_INIT __attribute__ ((section (".bss.noinit")))
#endif
#ifndef __ALIAS
#define __ALIAS(x) __attribute__ ((alias(x)))
#endif
/*
* TASKING Compiler
*/
#elif defined ( __TASKING__ )
/*
* The CMSIS functions have been implemented as intrinsics in the compiler.
* Please use "carm -?i" to get an up to date list of all intrinsics,
* Including the CMSIS ones.
*/
#ifndef __ASM
#define __ASM __asm
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __STATIC_INLINE
#endif
#ifndef __NO_RETURN
#define __NO_RETURN __attribute__((noreturn))
#endif
#ifndef __USED
#define __USED __attribute__((used))
#endif
#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif
#ifndef __PACKED
#define __PACKED __packed__
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT struct __packed__
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION union __packed__
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
struct __packed__ T_UINT32 { uint32_t v; };
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
#endif
#ifndef __UNALIGNED_UINT16_WRITE
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT16_READ
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
#endif
#ifndef __UNALIGNED_UINT32_WRITE
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT32_READ
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
#endif
#ifndef __ALIGNED
#define __ALIGNED(x) __align(x)
#endif
#ifndef __RESTRICT
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
#define __RESTRICT
#endif
#ifndef __COMPILER_BARRIER
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
#define __COMPILER_BARRIER() (void)0
#endif
#ifndef __NO_INIT
#define __NO_INIT __attribute__ ((section (".bss.noinit")))
#endif
#ifndef __ALIAS
#define __ALIAS(x) __attribute__ ((alias(x)))
#endif
/*
* COSMIC Compiler
*/
#elif defined ( __CSMC__ )
#include <cmsis_csm.h>
#ifndef __ASM
#define __ASM _asm
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __STATIC_INLINE
#endif
#ifndef __NO_RETURN
// NO RETURN is automatically detected hence no warning here
#define __NO_RETURN
#endif
#ifndef __USED
#warning No compiler specific solution for __USED. __USED is ignored.
#define __USED
#endif
#ifndef __WEAK
#define __WEAK __weak
#endif
#ifndef __PACKED
#define __PACKED @packed
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT @packed struct
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION @packed union
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
@packed struct T_UINT32 { uint32_t v; };
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
#endif
#ifndef __UNALIGNED_UINT16_WRITE
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT16_READ
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
#endif
#ifndef __UNALIGNED_UINT32_WRITE
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT32_READ
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
#endif
#ifndef __ALIGNED
#warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
#define __ALIGNED(x)
#endif
#ifndef __RESTRICT
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
#define __RESTRICT
#endif
#ifndef __COMPILER_BARRIER
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
#define __COMPILER_BARRIER() (void)0
#endif
#ifndef __NO_INIT
#define __NO_INIT __attribute__ ((section (".bss.noinit")))
#endif
#ifndef __ALIAS
#define __ALIAS(x) __attribute__ ((alias(x)))
#endif
#else
#error Unknown compiler.
#endif
#endif /* __CMSIS_COMPILER_H */

2217
lib/cmsis_core/cmsis_gcc.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
/**************************************************************************//**
* @file cmsis_version.h
* @brief CMSIS Core(M) Version definitions
* @version V5.0.5
* @date 02. February 2022
******************************************************************************/
/*
* Copyright (c) 2009-2022 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined (__clang__)
#pragma clang system_header /* treat file as system include file */
#endif
#ifndef __CMSIS_VERSION_H
#define __CMSIS_VERSION_H
/* CMSIS Version definitions */
#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
#define __CM_CMSIS_VERSION_SUB ( 6U) /*!< [15:0] CMSIS Core(M) sub version */
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
__CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
#endif

2170
lib/cmsis_core/core_cm4.h Normal file

File diff suppressed because it is too large Load Diff

275
lib/cmsis_core/mpu_armv7.h Normal file
View File

@ -0,0 +1,275 @@
/******************************************************************************
* @file mpu_armv7.h
* @brief CMSIS MPU API for Armv7-M MPU
* @version V5.1.2
* @date 25. May 2020
******************************************************************************/
/*
* Copyright (c) 2017-2020 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined (__clang__)
#pragma clang system_header /* treat file as system include file */
#endif
#ifndef ARM_MPU_ARMV7_H
#define ARM_MPU_ARMV7_H
#define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes
#define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes
#define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes
#define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes
#define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes
#define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte
#define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes
#define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes
#define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes
#define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes
#define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes
#define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes
#define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes
#define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes
#define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes
#define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte
#define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes
#define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes
#define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes
#define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes
#define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes
#define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes
#define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes
#define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes
#define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes
#define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte
#define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes
#define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes
#define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access
#define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only
#define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only
#define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access
#define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only
#define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access
/** MPU Region Base Address Register Value
*
* \param Region The region to be configured, number 0 to 15.
* \param BaseAddress The base address for the region.
*/
#define ARM_MPU_RBAR(Region, BaseAddress) \
(((BaseAddress) & MPU_RBAR_ADDR_Msk) | \
((Region) & MPU_RBAR_REGION_Msk) | \
(MPU_RBAR_VALID_Msk))
/**
* MPU Memory Access Attributes
*
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
* \param IsShareable Region is shareable between multiple bus masters.
* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
*/
#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \
((((TypeExtField) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \
(((IsShareable) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \
(((IsCacheable) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \
(((IsBufferable) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk))
/**
* MPU Region Attribute and Size Register Value
*
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_.
* \param SubRegionDisable Sub-region disable field.
* \param Size Region size of the region to be configured, for example 4K, 8K.
*/
#define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \
((((DisableExec) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \
(((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \
(((AccessAttributes) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk))) | \
(((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \
(((Size) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \
(((MPU_RASR_ENABLE_Msk))))
/**
* MPU Region Attribute and Size Register Value
*
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
* \param IsShareable Region is shareable between multiple bus masters.
* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
* \param SubRegionDisable Sub-region disable field.
* \param Size Region size of the region to be configured, for example 4K, 8K.
*/
#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \
ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size)
/**
* MPU Memory Access Attribute for strongly ordered memory.
* - TEX: 000b
* - Shareable
* - Non-cacheable
* - Non-bufferable
*/
#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U)
/**
* MPU Memory Access Attribute for device memory.
* - TEX: 000b (if shareable) or 010b (if non-shareable)
* - Shareable or non-shareable
* - Non-cacheable
* - Bufferable (if shareable) or non-bufferable (if non-shareable)
*
* \param IsShareable Configures the device memory as shareable or non-shareable.
*/
#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U))
/**
* MPU Memory Access Attribute for normal memory.
* - TEX: 1BBb (reflecting outer cacheability rules)
* - Shareable or non-shareable
* - Cacheable or non-cacheable (reflecting inner cacheability rules)
* - Bufferable or non-bufferable (reflecting inner cacheability rules)
*
* \param OuterCp Configures the outer cache policy.
* \param InnerCp Configures the inner cache policy.
* \param IsShareable Configures the memory as shareable or non-shareable.
*/
#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) >> 1U), ((InnerCp) & 1U))
/**
* MPU Memory Access Attribute non-cacheable policy.
*/
#define ARM_MPU_CACHEP_NOCACHE 0U
/**
* MPU Memory Access Attribute write-back, write and read allocate policy.
*/
#define ARM_MPU_CACHEP_WB_WRA 1U
/**
* MPU Memory Access Attribute write-through, no write allocate policy.
*/
#define ARM_MPU_CACHEP_WT_NWA 2U
/**
* MPU Memory Access Attribute write-back, no write allocate policy.
*/
#define ARM_MPU_CACHEP_WB_NWA 3U
/**
* Struct for a single MPU Region
*/
typedef struct {
uint32_t RBAR; //!< The region base address register value (RBAR)
uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR
} ARM_MPU_Region_t;
/** Enable the MPU.
* \param MPU_Control Default access permissions for unconfigured regions.
*/
__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control)
{
__DMB();
MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
#endif
__DSB();
__ISB();
}
/** Disable the MPU.
*/
__STATIC_INLINE void ARM_MPU_Disable(void)
{
__DMB();
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
#endif
MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
__DSB();
__ISB();
}
/** Clear and disable the given MPU region.
* \param rnr Region number to be cleared.
*/
__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
{
MPU->RNR = rnr;
MPU->RASR = 0U;
}
/** Configure an MPU region.
* \param rbar Value for RBAR register.
* \param rasr Value for RASR register.
*/
__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
{
MPU->RBAR = rbar;
MPU->RASR = rasr;
}
/** Configure the given MPU region.
* \param rnr Region number to be configured.
* \param rbar Value for RBAR register.
* \param rasr Value for RASR register.
*/
__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr)
{
MPU->RNR = rnr;
MPU->RBAR = rbar;
MPU->RASR = rasr;
}
/** Memcpy with strictly ordered memory access, e.g. used by code in ARM_MPU_Load().
* \param dst Destination data is copied to.
* \param src Source data is copied from.
* \param len Amount of data words to be copied.
*/
__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
{
uint32_t i;
for (i = 0U; i < len; ++i)
{
dst[i] = src[i];
}
}
/** Load the given number of MPU regions from a table.
* \param table Pointer to the MPU configuration table.
* \param cnt Amount of regions to be configured.
*/
__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
{
const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
while (cnt > MPU_TYPE_RALIASES) {
ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize);
table += MPU_TYPE_RALIASES;
cnt -= MPU_TYPE_RALIASES;
}
ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize);
}
#endif

View File

@ -1,23 +1,98 @@
#include "digital_signal.h"
#include <furi.h>
#include <stm32wbxx_ll_dma.h>
#include <stm32wbxx_ll_tim.h>
#include <furi_hal.h>
#include <furi_hal_resources.h>
#include <math.h>
#pragma GCC optimize("O3,unroll-loops,Ofast")
#include <stm32wbxx_ll_dma.h>
#include <stm32wbxx_ll_tim.h>
/* must be on bank B */
#define DEBUG_OUTPUT gpio_ext_pb3
struct ReloadBuffer {
uint32_t* buffer; /* DMA ringbuffer */
uint32_t size; /* maximum entry count of the ring buffer */
uint32_t write_pos; /* current buffer write index */
uint32_t read_pos; /* current buffer read index */
bool dma_active;
};
struct DigitalSequence {
uint8_t signals_size;
bool bake;
uint32_t sequence_used;
uint32_t sequence_size;
DigitalSignal** signals;
uint8_t* sequence;
const GpioPin* gpio;
uint32_t send_time;
bool send_time_active;
LL_DMA_InitTypeDef dma_config_gpio;
LL_DMA_InitTypeDef dma_config_timer;
uint32_t* gpio_buff;
struct ReloadBuffer* dma_buffer;
};
struct DigitalSignalInternals {
uint64_t factor;
uint32_t reload_reg_entries;
uint32_t reload_reg_remainder;
uint32_t gpio_buff[2];
const GpioPin* gpio;
LL_DMA_InitTypeDef dma_config_gpio;
LL_DMA_InitTypeDef dma_config_timer;
};
#define TAG "DigitalSignal"
#define F_TIM (64000000.0)
#define T_TIM 1562 //15.625 ns *100
#define T_TIM_DIV2 781 //15.625 ns / 2 *100
#define T_TIM 1562 /* 15.625 ns *100 */
#define T_TIM_DIV2 781 /* 15.625 ns / 2 *100 */
/* maximum entry count of the sequence dma ring buffer */
#define SEQUENCE_DMA_RINGBUFFER_SIZE 32
/* maximum number of DigitalSignals in a sequence */
#define SEQUENCE_SIGNALS_SIZE 32
/*
* if sequence size runs out from the initial value passed to digital_sequence_alloc
* the size will be increased by this amount and reallocated
*/
#define SEQUENCE_SIZE_REALLOCATE_INCREMENT 256
DigitalSignal* digital_signal_alloc(uint32_t max_edges_cnt) {
DigitalSignal* signal = malloc(sizeof(DigitalSignal));
signal->start_level = true;
signal->edges_max_cnt = max_edges_cnt;
signal->edge_timings = malloc(max_edges_cnt * sizeof(uint32_t));
signal->reload_reg_buff = malloc(max_edges_cnt * sizeof(uint32_t));
signal->edge_timings = malloc(signal->edges_max_cnt * sizeof(uint32_t));
signal->edge_cnt = 0;
signal->reload_reg_buff = malloc(signal->edges_max_cnt * sizeof(uint32_t));
signal->internals = malloc(sizeof(DigitalSignalInternals));
DigitalSignalInternals* internals = signal->internals;
internals->factor = 1024 * 1024;
internals->dma_config_gpio.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH;
internals->dma_config_gpio.Mode = LL_DMA_MODE_CIRCULAR;
internals->dma_config_gpio.PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT;
internals->dma_config_gpio.MemoryOrM2MDstIncMode = LL_DMA_MEMORY_INCREMENT;
internals->dma_config_gpio.PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_WORD;
internals->dma_config_gpio.MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_WORD;
internals->dma_config_gpio.NbData = 2;
internals->dma_config_gpio.PeriphRequest = LL_DMAMUX_REQ_TIM2_UP;
internals->dma_config_gpio.Priority = LL_DMA_PRIORITY_VERYHIGH;
internals->dma_config_timer.PeriphOrM2MSrcAddress = (uint32_t) & (TIM2->ARR);
internals->dma_config_timer.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH;
internals->dma_config_timer.Mode = LL_DMA_MODE_NORMAL;
internals->dma_config_timer.PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT;
internals->dma_config_timer.MemoryOrM2MDstIncMode = LL_DMA_MEMORY_INCREMENT;
internals->dma_config_timer.PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_WORD;
internals->dma_config_timer.MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_WORD;
internals->dma_config_timer.PeriphRequest = LL_DMAMUX_REQ_TIM2_UP;
internals->dma_config_timer.Priority = LL_DMA_PRIORITY_HIGH;
return signal;
}
@ -27,6 +102,7 @@ void digital_signal_free(DigitalSignal* signal) {
free(signal->edge_timings);
free(signal->reload_reg_buff);
free(signal->internals);
free(signal);
}
@ -37,7 +113,10 @@ bool digital_signal_append(DigitalSignal* signal_a, DigitalSignal* signal_b) {
if(signal_a->edges_max_cnt < signal_a->edge_cnt + signal_b->edge_cnt) {
return false;
}
/* in case there are no edges in our target signal, the signal to append makes the rules */
if(!signal_a->edge_cnt) {
signal_a->start_level = signal_b->start_level;
}
bool end_level = signal_a->start_level;
if(signal_a->edge_cnt) {
end_level = signal_a->start_level ^ !(signal_a->edge_cnt % 2);
@ -72,6 +151,32 @@ uint32_t digital_signal_get_edges_cnt(DigitalSignal* signal) {
return signal->edge_cnt;
}
void digital_signal_add(DigitalSignal* signal, uint32_t ticks) {
furi_assert(signal);
furi_assert(signal->edge_cnt < signal->edges_max_cnt);
signal->edge_timings[signal->edge_cnt++] = ticks;
}
void digital_signal_add_pulse(DigitalSignal* signal, uint32_t ticks, bool level) {
furi_assert(signal);
furi_assert(signal->edge_cnt < signal->edges_max_cnt);
/* virgin signal? add it as the only level */
if(signal->edge_cnt == 0) {
signal->start_level = level;
signal->edge_timings[signal->edge_cnt++] = ticks;
} else {
bool end_level = signal->start_level ^ !(signal->edge_cnt % 2);
if(level != end_level) {
signal->edge_timings[signal->edge_cnt++] = ticks;
} else {
signal->edge_timings[signal->edge_cnt - 1] += ticks;
}
}
}
uint32_t digital_signal_get_edge(DigitalSignal* signal, uint32_t edge_num) {
furi_assert(signal);
furi_assert(edge_num < signal->edge_cnt);
@ -80,94 +185,473 @@ uint32_t digital_signal_get_edge(DigitalSignal* signal, uint32_t edge_num) {
}
void digital_signal_prepare_arr(DigitalSignal* signal) {
uint32_t t_signal_rest = signal->edge_timings[0];
uint32_t r_count_tick_arr = 0;
uint32_t r_rest_div = 0;
furi_assert(signal);
for(size_t i = 0; i < signal->edge_cnt - 1; i++) {
r_count_tick_arr = t_signal_rest / T_TIM;
r_rest_div = t_signal_rest % T_TIM;
t_signal_rest = signal->edge_timings[i + 1] + r_rest_div;
DigitalSignalInternals* internals = signal->internals;
if(r_rest_div < T_TIM_DIV2) {
signal->reload_reg_buff[i] = r_count_tick_arr - 1;
/* set up signal polarities */
if(internals->gpio) {
uint32_t bit_set = internals->gpio->pin;
uint32_t bit_reset = internals->gpio->pin << 16;
#ifdef DEBUG_OUTPUT
bit_set |= DEBUG_OUTPUT.pin;
bit_reset |= DEBUG_OUTPUT.pin << 16;
#endif
if(signal->start_level) {
internals->gpio_buff[0] = bit_set;
internals->gpio_buff[1] = bit_reset;
} else {
signal->reload_reg_buff[i] = r_count_tick_arr;
t_signal_rest -= T_TIM;
internals->gpio_buff[0] = bit_reset;
internals->gpio_buff[1] = bit_set;
}
}
/* set up edge timings */
internals->reload_reg_entries = 0;
for(size_t pos = 0; pos < signal->edge_cnt; pos++) {
uint32_t edge_scaled = (internals->factor * signal->edge_timings[pos]) / (1024 * 1024);
uint32_t pulse_duration = edge_scaled + internals->reload_reg_remainder;
if(pulse_duration < 10 || pulse_duration > 10000000) {
FURI_LOG_D(
TAG,
"[prepare] pulse_duration out of range: %lu = %lu * %llu",
pulse_duration,
signal->edge_timings[pos],
internals->factor);
pulse_duration = 100;
}
uint32_t pulse_ticks = (pulse_duration + T_TIM_DIV2) / T_TIM;
internals->reload_reg_remainder = pulse_duration - (pulse_ticks * T_TIM);
if(pulse_ticks > 1) {
signal->reload_reg_buff[internals->reload_reg_entries++] = pulse_ticks - 1;
}
}
}
void digital_signal_send(DigitalSignal* signal, const GpioPin* gpio) {
furi_assert(signal);
furi_assert(gpio);
static void digital_signal_stop_dma() {
LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_1);
LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_2);
LL_DMA_ClearFlag_TC1(DMA1);
LL_DMA_ClearFlag_TC2(DMA1);
}
// Configure gpio as output
furi_hal_gpio_init(gpio, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
static void digital_signal_stop_timer() {
LL_TIM_DisableCounter(TIM2);
LL_TIM_DisableUpdateEvent(TIM2);
LL_TIM_DisableDMAReq_UPDATE(TIM2);
}
// Init gpio buffer and DMA channel
uint16_t gpio_reg = gpio->port->ODR;
uint16_t gpio_buff[2];
if(signal->start_level) {
gpio_buff[0] = gpio_reg | gpio->pin;
gpio_buff[1] = gpio_reg & ~(gpio->pin);
} else {
gpio_buff[0] = gpio_reg & ~(gpio->pin);
gpio_buff[1] = gpio_reg | gpio->pin;
}
LL_DMA_InitTypeDef dma_config = {};
dma_config.MemoryOrM2MDstAddress = (uint32_t)gpio_buff;
dma_config.PeriphOrM2MSrcAddress = (uint32_t) & (gpio->port->ODR);
dma_config.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH;
dma_config.Mode = LL_DMA_MODE_CIRCULAR;
dma_config.PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT;
dma_config.MemoryOrM2MDstIncMode = LL_DMA_MEMORY_INCREMENT;
dma_config.PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_HALFWORD;
dma_config.MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_HALFWORD;
dma_config.NbData = 2;
dma_config.PeriphRequest = LL_DMAMUX_REQ_TIM2_UP;
dma_config.Priority = LL_DMA_PRIORITY_VERYHIGH;
LL_DMA_Init(DMA1, LL_DMA_CHANNEL_1, &dma_config);
LL_DMA_SetDataLength(DMA1, LL_DMA_CHANNEL_1, 2);
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_1);
static void digital_signal_setup_timer() {
digital_signal_stop_timer();
// Init timer arr register buffer and DMA channel
digital_signal_prepare_arr(signal);
dma_config.MemoryOrM2MDstAddress = (uint32_t)signal->reload_reg_buff;
dma_config.PeriphOrM2MSrcAddress = (uint32_t) & (TIM2->ARR);
dma_config.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH;
dma_config.Mode = LL_DMA_MODE_NORMAL;
dma_config.PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT;
dma_config.MemoryOrM2MDstIncMode = LL_DMA_MEMORY_INCREMENT;
dma_config.PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_WORD;
dma_config.MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_WORD;
dma_config.NbData = signal->edge_cnt - 2;
dma_config.PeriphRequest = LL_DMAMUX_REQ_TIM2_UP;
dma_config.Priority = LL_DMA_PRIORITY_HIGH;
LL_DMA_Init(DMA1, LL_DMA_CHANNEL_2, &dma_config);
LL_DMA_SetDataLength(DMA1, LL_DMA_CHANNEL_2, signal->edge_cnt - 2);
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_2);
// Set up timer
LL_TIM_SetCounterMode(TIM2, LL_TIM_COUNTERMODE_UP);
LL_TIM_SetClockDivision(TIM2, LL_TIM_CLOCKDIVISION_DIV1);
LL_TIM_SetPrescaler(TIM2, 0);
LL_TIM_SetAutoReload(TIM2, 10);
LL_TIM_SetAutoReload(TIM2, 0xFFFFFFFF);
LL_TIM_SetCounter(TIM2, 0);
}
static void digital_signal_start_timer() {
LL_TIM_EnableCounter(TIM2);
LL_TIM_EnableUpdateEvent(TIM2);
LL_TIM_EnableDMAReq_UPDATE(TIM2);
// Start transactions
LL_TIM_GenerateEvent_UPDATE(TIM2); // Do we really need it?
LL_TIM_EnableCounter(TIM2);
while(!LL_DMA_IsActiveFlag_TC2(DMA1))
;
LL_DMA_ClearFlag_TC1(DMA1);
LL_DMA_ClearFlag_TC2(DMA1);
LL_TIM_DisableCounter(TIM2);
LL_TIM_SetCounter(TIM2, 0);
LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_1);
LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_2);
LL_TIM_GenerateEvent_UPDATE(TIM2);
}
static bool digital_signal_setup_dma(DigitalSignal* signal) {
furi_assert(signal);
DigitalSignalInternals* internals = signal->internals;
if(!signal->internals->reload_reg_entries) {
return false;
}
digital_signal_stop_dma();
internals->dma_config_gpio.MemoryOrM2MDstAddress = (uint32_t)internals->gpio_buff;
internals->dma_config_gpio.PeriphOrM2MSrcAddress = (uint32_t) & (internals->gpio->port->BSRR);
internals->dma_config_timer.MemoryOrM2MDstAddress = (uint32_t)signal->reload_reg_buff;
internals->dma_config_timer.NbData = signal->internals->reload_reg_entries;
/* set up DMA channel 1 and 2 for GPIO and timer copy operations */
LL_DMA_Init(DMA1, LL_DMA_CHANNEL_1, &internals->dma_config_gpio);
LL_DMA_Init(DMA1, LL_DMA_CHANNEL_2, &internals->dma_config_timer);
/* enable both DMA channels */
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_1);
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_2);
return true;
}
void digital_signal_send(DigitalSignal* signal, const GpioPin* gpio) {
furi_assert(signal);
if(!signal->edge_cnt) {
return;
}
/* Configure gpio as output */
signal->internals->gpio = gpio;
furi_hal_gpio_init(
signal->internals->gpio, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
digital_signal_prepare_arr(signal);
digital_signal_setup_dma(signal);
digital_signal_setup_timer();
digital_signal_start_timer();
while(!LL_DMA_IsActiveFlag_TC2(DMA1)) {
}
digital_signal_stop_timer();
digital_signal_stop_dma();
}
static void digital_sequence_alloc_signals(DigitalSequence* sequence, uint32_t size) {
sequence->signals_size = size;
sequence->signals = malloc(sequence->signals_size * sizeof(DigitalSignal*));
}
static void digital_sequence_alloc_sequence(DigitalSequence* sequence, uint32_t size) {
sequence->sequence_used = 0;
sequence->sequence_size = size;
sequence->sequence = malloc(sequence->sequence_size);
sequence->send_time = 0;
sequence->send_time_active = false;
}
DigitalSequence* digital_sequence_alloc(uint32_t size, const GpioPin* gpio) {
furi_assert(gpio);
DigitalSequence* sequence = malloc(sizeof(DigitalSequence));
sequence->gpio = gpio;
sequence->bake = false;
sequence->dma_buffer = malloc(sizeof(struct ReloadBuffer));
sequence->dma_buffer->size = SEQUENCE_DMA_RINGBUFFER_SIZE;
sequence->dma_buffer->buffer = malloc(sequence->dma_buffer->size * sizeof(uint32_t));
sequence->dma_config_gpio.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH;
sequence->dma_config_gpio.Mode = LL_DMA_MODE_CIRCULAR;
sequence->dma_config_gpio.PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT;
sequence->dma_config_gpio.MemoryOrM2MDstIncMode = LL_DMA_MEMORY_INCREMENT;
sequence->dma_config_gpio.PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_WORD;
sequence->dma_config_gpio.MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_WORD;
sequence->dma_config_gpio.NbData = 2;
sequence->dma_config_gpio.PeriphRequest = LL_DMAMUX_REQ_TIM2_UP;
sequence->dma_config_gpio.Priority = LL_DMA_PRIORITY_VERYHIGH;
sequence->dma_config_timer.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH;
sequence->dma_config_timer.Mode = LL_DMA_MODE_CIRCULAR;
sequence->dma_config_timer.PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT;
sequence->dma_config_timer.MemoryOrM2MDstIncMode = LL_DMA_MEMORY_INCREMENT;
sequence->dma_config_timer.PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_WORD;
sequence->dma_config_timer.MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_WORD;
sequence->dma_config_timer.PeriphOrM2MSrcAddress = (uint32_t) & (TIM2->ARR);
sequence->dma_config_timer.MemoryOrM2MDstAddress = (uint32_t)sequence->dma_buffer->buffer;
sequence->dma_config_timer.NbData = sequence->dma_buffer->size;
sequence->dma_config_timer.PeriphRequest = LL_DMAMUX_REQ_TIM2_UP;
sequence->dma_config_timer.Priority = LL_DMA_PRIORITY_HIGH;
digital_sequence_alloc_signals(sequence, SEQUENCE_SIGNALS_SIZE);
digital_sequence_alloc_sequence(sequence, size);
return sequence;
}
void digital_sequence_free(DigitalSequence* sequence) {
furi_assert(sequence);
free(sequence->signals);
free(sequence->sequence);
free(sequence->dma_buffer->buffer);
free(sequence->dma_buffer);
free(sequence);
}
void digital_sequence_set_signal(
DigitalSequence* sequence,
uint8_t signal_index,
DigitalSignal* signal) {
furi_assert(sequence);
furi_assert(signal);
furi_assert(signal_index < sequence->signals_size);
sequence->signals[signal_index] = signal;
signal->internals->gpio = sequence->gpio;
signal->internals->reload_reg_remainder = 0;
digital_signal_prepare_arr(signal);
}
void digital_sequence_set_sendtime(DigitalSequence* sequence, uint32_t send_time) {
furi_assert(sequence);
sequence->send_time = send_time;
sequence->send_time_active = true;
}
void digital_sequence_add(DigitalSequence* sequence, uint8_t signal_index) {
furi_assert(sequence);
furi_assert(signal_index < sequence->signals_size);
if(sequence->sequence_used >= sequence->sequence_size) {
sequence->sequence_size += SEQUENCE_SIZE_REALLOCATE_INCREMENT;
sequence->sequence = realloc(sequence->sequence, sequence->sequence_size); //-V701
furi_assert(sequence->sequence);
}
sequence->sequence[sequence->sequence_used++] = signal_index;
}
static bool digital_sequence_setup_dma(DigitalSequence* sequence) {
furi_assert(sequence);
digital_signal_stop_dma();
sequence->dma_config_gpio.MemoryOrM2MDstAddress = (uint32_t)sequence->gpio_buff;
sequence->dma_config_gpio.PeriphOrM2MSrcAddress = (uint32_t) & (sequence->gpio->port->BSRR);
/* set up DMA channel 1 and 2 for GPIO and timer copy operations */
LL_DMA_Init(DMA1, LL_DMA_CHANNEL_1, &sequence->dma_config_gpio);
LL_DMA_Init(DMA1, LL_DMA_CHANNEL_2, &sequence->dma_config_timer);
/* enable both DMA channels */
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_1);
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_2);
return true;
}
static DigitalSignal* digital_sequence_bake(DigitalSequence* sequence) {
furi_assert(sequence);
uint32_t edges = 0;
for(uint32_t pos = 0; pos < sequence->sequence_used; pos++) {
uint8_t signal_index = sequence->sequence[pos];
DigitalSignal* sig = sequence->signals[signal_index];
edges += sig->edge_cnt;
}
DigitalSignal* ret = digital_signal_alloc(edges);
for(uint32_t pos = 0; pos < sequence->sequence_used; pos++) {
uint8_t signal_index = sequence->sequence[pos];
DigitalSignal* sig = sequence->signals[signal_index];
digital_signal_append(ret, sig);
}
return ret;
}
static void digital_sequence_update_pos(DigitalSequence* sequence) {
struct ReloadBuffer* dma_buffer = sequence->dma_buffer;
dma_buffer->read_pos = dma_buffer->size - LL_DMA_GetDataLength(DMA1, LL_DMA_CHANNEL_2);
}
static const uint32_t wait_ms = 10;
static const uint32_t wait_ticks = wait_ms * 1000 * 64;
static void digital_sequence_finish(DigitalSequence* sequence) {
struct ReloadBuffer* dma_buffer = sequence->dma_buffer;
if(dma_buffer->dma_active) {
uint32_t prev_timer = DWT->CYCCNT;
uint32_t end_pos = (dma_buffer->write_pos + 1) % dma_buffer->size;
do {
uint32_t last_pos = dma_buffer->read_pos;
digital_sequence_update_pos(sequence);
/* we are finished, when the DMA transferred the 0xFFFFFFFF-timer which is the current write_pos */
if(dma_buffer->read_pos == end_pos) {
break;
}
if(last_pos != dma_buffer->read_pos) { //-V547
prev_timer = DWT->CYCCNT;
}
if(DWT->CYCCNT - prev_timer > wait_ticks) {
FURI_LOG_D(
TAG,
"[SEQ] hung %lu ms in finish (ARR 0x%08lx, read %lu, write %lu)",
wait_ms,
TIM2->ARR,
dma_buffer->read_pos,
dma_buffer->write_pos);
break;
}
} while(1);
}
digital_signal_stop_timer();
digital_signal_stop_dma();
}
static void digital_sequence_queue_pulse(DigitalSequence* sequence, uint32_t length) {
struct ReloadBuffer* dma_buffer = sequence->dma_buffer;
if(dma_buffer->dma_active) {
uint32_t prev_timer = DWT->CYCCNT;
uint32_t end_pos = (dma_buffer->write_pos + 1) % dma_buffer->size;
do {
uint32_t last_pos = dma_buffer->read_pos;
digital_sequence_update_pos(sequence);
if(dma_buffer->read_pos != end_pos) {
break;
}
if(last_pos != dma_buffer->read_pos) { //-V547
prev_timer = DWT->CYCCNT;
}
if(DWT->CYCCNT - prev_timer > wait_ticks) {
FURI_LOG_D(
TAG,
"[SEQ] hung %lu ms in queue (ARR 0x%08lx, read %lu, write %lu)",
wait_ms,
TIM2->ARR,
dma_buffer->read_pos,
dma_buffer->write_pos);
break;
}
} while(1);
}
dma_buffer->buffer[dma_buffer->write_pos] = length;
dma_buffer->write_pos = (dma_buffer->write_pos + 1) % dma_buffer->size;
dma_buffer->buffer[dma_buffer->write_pos] = 0xFFFFFFFF;
}
bool digital_sequence_send(DigitalSequence* sequence) {
furi_assert(sequence);
struct ReloadBuffer* dma_buffer = sequence->dma_buffer;
furi_hal_gpio_init(sequence->gpio, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
#ifdef DEBUG_OUTPUT
furi_hal_gpio_init(&DEBUG_OUTPUT, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
#endif
if(sequence->bake) {
DigitalSignal* sig = digital_sequence_bake(sequence);
digital_signal_send(sig, sequence->gpio);
digital_signal_free(sig);
return true;
}
int32_t remainder = 0;
bool traded_first = false;
FURI_CRITICAL_ENTER();
dma_buffer->dma_active = false;
dma_buffer->buffer[0] = 0xFFFFFFFF;
dma_buffer->read_pos = 0;
dma_buffer->write_pos = 0;
for(uint32_t seq_pos = 0; seq_pos < sequence->sequence_used; seq_pos++) {
uint8_t signal_index = sequence->sequence[seq_pos];
DigitalSignal* sig = sequence->signals[signal_index];
bool last_signal = ((seq_pos + 1) == sequence->sequence_used);
/* all signals are prepared and we can re-use the GPIO buffer from the fist signal */
if(seq_pos == 0) {
sequence->gpio_buff = sig->internals->gpio_buff;
}
for(uint32_t pulse_pos = 0; pulse_pos < sig->internals->reload_reg_entries; pulse_pos++) {
if(traded_first) {
traded_first = false;
continue;
}
uint32_t pulse_length = 0;
bool last_pulse = ((pulse_pos + 1) == sig->internals->reload_reg_entries);
pulse_length = sig->reload_reg_buff[pulse_pos];
/* when we are too late more than half a tick, make the first edge temporarily longer */
if(remainder >= T_TIM_DIV2) {
remainder -= T_TIM;
pulse_length += 1;
}
remainder += sig->internals->reload_reg_remainder;
/* last pulse in that signal and have a next signal? */
if(last_pulse) {
if((seq_pos + 1) < sequence->sequence_used) {
DigitalSignal* sig_next = sequence->signals[sequence->sequence[seq_pos + 1]];
/* when a signal ends with the same level as the next signal begins, let the fist signal generate the whole pulse */
/* beware, we do not want the level after the last edge, but the last level before that edge */
bool end_level = sig->start_level ^ ((sig->edge_cnt % 2) == 0);
/* take from the next, add it to the current if they have the same level */
if(end_level == sig_next->start_level) {
pulse_length += sig_next->reload_reg_buff[0];
traded_first = true;
}
}
}
digital_sequence_queue_pulse(sequence, pulse_length);
/* start transmission when buffer was filled enough */
bool start_send = sequence->dma_buffer->write_pos >= (sequence->dma_buffer->size - 4);
/* or it was the last pulse */
if(last_pulse && last_signal) {
start_send = true;
}
/* start transmission */
if(start_send && !dma_buffer->dma_active) {
digital_sequence_setup_dma(sequence);
digital_signal_setup_timer();
/* if the send time is specified, wait till the core timer passed beyond that time */
if(sequence->send_time_active) {
sequence->send_time_active = false;
while(sequence->send_time - DWT->CYCCNT < 0x80000000) {
}
}
digital_signal_start_timer();
dma_buffer->dma_active = true;
}
}
}
/* wait until last dma transaction was finished */
digital_sequence_finish(sequence);
FURI_CRITICAL_EXIT();
return true;
}
void digital_sequence_clear(DigitalSequence* sequence) {
furi_assert(sequence);
sequence->sequence_used = 0;
}
void digital_sequence_timebase_correction(DigitalSequence* sequence, float factor) {
for(uint32_t sig_pos = 0; sig_pos < sequence->signals_size; sig_pos++) {
DigitalSignal* signal = sequence->signals[sig_pos];
if(signal) {
signal->internals->factor = (uint32_t)(1024 * 1024 * factor);
digital_signal_prepare_arr(signal);
}
}
}

View File

@ -10,18 +10,35 @@
extern "C" {
#endif
typedef struct {
/* helper for easier signal generation */
#define DIGITAL_SIGNAL_MS(x) ((x)*100000000UL)
#define DIGITAL_SIGNAL_US(x) ((x)*100000UL)
#define DIGITAL_SIGNAL_NS(x) ((x)*100UL)
#define DIGITAL_SIGNAL_PS(x) ((x) / 10UL)
/* using an anonymous type for the internals */
typedef struct DigitalSignalInternals DigitalSignalInternals;
/* and a public one for accessing user-side fields */
typedef struct DigitalSignal {
bool start_level;
uint32_t edge_cnt;
uint32_t edges_max_cnt;
uint32_t* edge_timings;
uint32_t* reload_reg_buff;
uint32_t* reload_reg_buff; /* internal, but used by unit tests */
DigitalSignalInternals* internals;
} DigitalSignal;
typedef struct DigitalSequence DigitalSequence;
DigitalSignal* digital_signal_alloc(uint32_t max_edges_cnt);
void digital_signal_free(DigitalSignal* signal);
void digital_signal_add(DigitalSignal* signal, uint32_t ticks);
void digital_signal_add_pulse(DigitalSignal* signal, uint32_t ticks, bool level);
bool digital_signal_append(DigitalSignal* signal_a, DigitalSignal* signal_b);
void digital_signal_prepare_arr(DigitalSignal* signal);
@ -34,6 +51,25 @@ uint32_t digital_signal_get_edge(DigitalSignal* signal, uint32_t edge_num);
void digital_signal_send(DigitalSignal* signal, const GpioPin* gpio);
DigitalSequence* digital_sequence_alloc(uint32_t size, const GpioPin* gpio);
void digital_sequence_free(DigitalSequence* sequence);
void digital_sequence_set_signal(
DigitalSequence* sequence,
uint8_t signal_index,
DigitalSignal* signal);
void digital_sequence_set_sendtime(DigitalSequence* sequence, uint32_t send_time);
void digital_sequence_add(DigitalSequence* sequence, uint8_t signal_index);
bool digital_sequence_send(DigitalSequence* sequence);
void digital_sequence_clear(DigitalSequence* sequence);
void digital_sequence_timebase_correction(DigitalSequence* sequence, float factor);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,27 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/pulse_reader",
],
SDK_HEADERS=[
File("pulse_reader.h"),
],
)
libenv = env.Clone(FW_LIB_NAME="pulse_reader")
libenv.ApplyLibFlags()
libenv.AppendUnique(
CCFLAGS=[
# Required for lib to be linkable with .faps
"-mword-relocations",
"-mlong-calls",
],
)
sources = libenv.GlobRecursive("*.c*")
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

View File

@ -0,0 +1,233 @@
#include "pulse_reader.h"
#include <limits.h>
#include <furi.h>
#include <furi_hal.h>
#include <furi_hal_gpio.h>
#include <stm32wbxx_ll_dma.h>
#include <stm32wbxx_ll_dmamux.h>
#include <stm32wbxx_ll_tim.h>
#include <stm32wbxx_ll_exti.h>
struct PulseReader {
uint32_t* timer_buffer;
uint32_t* gpio_buffer;
uint32_t size;
uint32_t pos;
uint32_t timer_value;
uint32_t gpio_value;
uint32_t gpio_mask;
uint32_t unit_multiplier;
uint32_t unit_divider;
uint32_t bit_time;
uint32_t dma_channel;
const GpioPin* gpio;
GpioPull pull;
LL_DMA_InitTypeDef dma_config_timer;
LL_DMA_InitTypeDef dma_config_gpio;
};
#define GPIO_PIN_MAP(pin, prefix) \
(((pin) == (LL_GPIO_PIN_0)) ? prefix##0 : \
((pin) == (LL_GPIO_PIN_1)) ? prefix##1 : \
((pin) == (LL_GPIO_PIN_2)) ? prefix##2 : \
((pin) == (LL_GPIO_PIN_3)) ? prefix##3 : \
((pin) == (LL_GPIO_PIN_4)) ? prefix##4 : \
((pin) == (LL_GPIO_PIN_5)) ? prefix##5 : \
((pin) == (LL_GPIO_PIN_6)) ? prefix##6 : \
((pin) == (LL_GPIO_PIN_7)) ? prefix##7 : \
((pin) == (LL_GPIO_PIN_8)) ? prefix##8 : \
((pin) == (LL_GPIO_PIN_9)) ? prefix##9 : \
((pin) == (LL_GPIO_PIN_10)) ? prefix##10 : \
((pin) == (LL_GPIO_PIN_11)) ? prefix##11 : \
((pin) == (LL_GPIO_PIN_12)) ? prefix##12 : \
((pin) == (LL_GPIO_PIN_13)) ? prefix##13 : \
((pin) == (LL_GPIO_PIN_14)) ? prefix##14 : \
prefix##15)
#define GET_DMAMUX_EXTI_LINE(pin) GPIO_PIN_MAP(pin, LL_DMAMUX_REQ_GEN_EXTI_LINE)
PulseReader* pulse_reader_alloc(const GpioPin* gpio, uint32_t size) {
PulseReader* signal = malloc(sizeof(PulseReader));
signal->timer_buffer = malloc(size * sizeof(uint32_t));
signal->gpio_buffer = malloc(size * sizeof(uint32_t));
signal->dma_channel = LL_DMA_CHANNEL_4;
signal->gpio = gpio;
signal->pull = GpioPullNo;
signal->size = size;
signal->timer_value = 0;
signal->pos = 0;
pulse_reader_set_timebase(signal, PulseReaderUnit64MHz);
pulse_reader_set_bittime(signal, 1);
signal->dma_config_timer.Direction = LL_DMA_DIRECTION_PERIPH_TO_MEMORY;
signal->dma_config_timer.PeriphOrM2MSrcAddress = (uint32_t) & (TIM2->CNT);
signal->dma_config_timer.PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT;
signal->dma_config_timer.PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_WORD;
signal->dma_config_timer.MemoryOrM2MDstAddress = (uint32_t)signal->timer_buffer;
signal->dma_config_timer.MemoryOrM2MDstIncMode = LL_DMA_MEMORY_INCREMENT;
signal->dma_config_timer.MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_WORD;
signal->dma_config_timer.Mode = LL_DMA_MODE_CIRCULAR;
signal->dma_config_timer.PeriphRequest =
LL_DMAMUX_REQ_GENERATOR0; /* executes LL_DMA_SetPeriphRequest */
signal->dma_config_timer.Priority = LL_DMA_PRIORITY_VERYHIGH;
signal->dma_config_gpio.Direction = LL_DMA_DIRECTION_PERIPH_TO_MEMORY;
signal->dma_config_gpio.PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT;
signal->dma_config_gpio.PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_WORD;
signal->dma_config_gpio.MemoryOrM2MDstIncMode = LL_DMA_MEMORY_INCREMENT;
signal->dma_config_gpio.MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_WORD;
signal->dma_config_gpio.Mode = LL_DMA_MODE_CIRCULAR;
signal->dma_config_gpio.PeriphRequest =
LL_DMAMUX_REQ_GENERATOR0; /* executes LL_DMA_SetPeriphRequest */
signal->dma_config_gpio.Priority = LL_DMA_PRIORITY_VERYHIGH;
return signal;
}
void pulse_reader_set_timebase(PulseReader* signal, PulseReaderUnit unit) {
switch(unit) {
case PulseReaderUnit64MHz:
signal->unit_multiplier = 1;
signal->unit_divider = 1;
break;
case PulseReaderUnitPicosecond:
signal->unit_multiplier = 15625;
signal->unit_divider = 1;
break;
case PulseReaderUnitNanosecond:
signal->unit_multiplier = 15625;
signal->unit_divider = 1000;
break;
case PulseReaderUnitMicrosecond:
signal->unit_multiplier = 15625;
signal->unit_divider = 1000000;
break;
}
}
void pulse_reader_set_bittime(PulseReader* signal, uint32_t bit_time) {
signal->bit_time = bit_time;
}
void pulse_reader_set_pull(PulseReader* signal, GpioPull pull) {
signal->pull = pull;
}
void pulse_reader_free(PulseReader* signal) {
furi_assert(signal);
free(signal->timer_buffer);
free(signal->gpio_buffer);
free(signal);
}
uint32_t pulse_reader_samples(PulseReader* signal) {
uint32_t dma_pos = signal->size - (uint32_t)LL_DMA_GetDataLength(DMA1, signal->dma_channel);
return ((signal->pos + signal->size) - dma_pos) % signal->size;
}
void pulse_reader_stop(PulseReader* signal) {
LL_DMA_DisableChannel(DMA1, signal->dma_channel);
LL_DMA_DisableChannel(DMA1, signal->dma_channel + 1);
LL_DMAMUX_DisableRequestGen(NULL, LL_DMAMUX_REQ_GEN_0);
LL_TIM_DisableCounter(TIM2);
furi_hal_gpio_init_simple(signal->gpio, GpioModeAnalog);
}
void pulse_reader_start(PulseReader* signal) {
/* configure DMA to read from a timer peripheral */
signal->dma_config_timer.NbData = signal->size;
signal->dma_config_gpio.PeriphOrM2MSrcAddress = (uint32_t) & (signal->gpio->port->IDR);
signal->dma_config_gpio.MemoryOrM2MDstAddress = (uint32_t)signal->gpio_buffer;
signal->dma_config_gpio.NbData = signal->size;
/* start counter */
LL_TIM_SetCounterMode(TIM2, LL_TIM_COUNTERMODE_UP);
LL_TIM_SetClockDivision(TIM2, LL_TIM_CLOCKDIVISION_DIV1);
LL_TIM_SetPrescaler(TIM2, 0);
LL_TIM_SetAutoReload(TIM2, 0xFFFFFFFF);
LL_TIM_SetCounter(TIM2, 0);
LL_TIM_EnableCounter(TIM2);
/* generator 0 gets fed by EXTI_LINEn */
LL_DMAMUX_SetRequestSignalID(
NULL, LL_DMAMUX_REQ_GEN_0, GET_DMAMUX_EXTI_LINE(signal->gpio->pin));
/* trigger on rising edge of the interrupt */
LL_DMAMUX_SetRequestGenPolarity(NULL, LL_DMAMUX_REQ_GEN_0, LL_DMAMUX_REQ_GEN_POL_RISING);
/* now enable request generation again */
LL_DMAMUX_EnableRequestGen(NULL, LL_DMAMUX_REQ_GEN_0);
/* we need the EXTI to be configured as interrupt generating line, but no ISR registered */
furi_hal_gpio_init_ex(
signal->gpio, GpioModeInterruptRiseFall, signal->pull, GpioSpeedVeryHigh, GpioAltFnUnused);
/* capture current timer */
signal->pos = 0;
signal->timer_value = TIM2->CNT;
signal->gpio_mask = signal->gpio->pin;
signal->gpio_value = signal->gpio->port->IDR & signal->gpio_mask;
/* now set up DMA with these settings */
LL_DMA_Init(DMA1, signal->dma_channel, &signal->dma_config_timer);
LL_DMA_Init(DMA1, signal->dma_channel + 1, &signal->dma_config_gpio);
LL_DMA_EnableChannel(DMA1, signal->dma_channel);
LL_DMA_EnableChannel(DMA1, signal->dma_channel + 1);
}
uint32_t pulse_reader_receive(PulseReader* signal, int timeout_us) {
uint32_t start_time = DWT->CYCCNT;
uint32_t timeout_ticks = timeout_us * (F_TIM2 / 1000000);
do {
/* get the DMA's next write position by reading "remaining length" register */
uint32_t dma_pos =
signal->size - (uint32_t)LL_DMA_GetDataLength(DMA1, signal->dma_channel);
/* the DMA has advanced in the ringbuffer */
if(dma_pos != signal->pos) {
uint32_t delta = signal->timer_buffer[signal->pos] - signal->timer_value;
uint32_t last_gpio_value = signal->gpio_value;
signal->gpio_value = signal->gpio_buffer[signal->pos];
/* check if the GPIO really toggled. if not, we lost an edge :( */
if(((last_gpio_value ^ signal->gpio_value) & signal->gpio_mask) != signal->gpio_mask) {
signal->gpio_value ^= signal->gpio_mask;
return PULSE_READER_LOST_EDGE;
}
signal->timer_value = signal->timer_buffer[signal->pos];
signal->pos++;
signal->pos %= signal->size;
uint32_t delta_unit = 0;
/* probably larger values, so choose a wider data type */
if(signal->unit_divider > 1) {
delta_unit =
(uint32_t)((uint64_t)delta * (uint64_t)signal->unit_multiplier / signal->unit_divider);
} else {
delta_unit = delta * signal->unit_multiplier;
}
/* if to be scaled to bit times, save a few instructions. should be faster */
if(signal->bit_time > 1) {
return (delta_unit + signal->bit_time / 2) / signal->bit_time;
}
return delta_unit;
}
/* check for timeout */
uint32_t elapsed = DWT->CYCCNT - start_time;
if(elapsed > timeout_ticks) {
return PULSE_READER_NO_EDGE;
}
} while(true);
}

View File

@ -0,0 +1,122 @@
#pragma once
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <furi_hal_gpio.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PULSE_READER_NO_EDGE (0xFFFFFFFFUL)
#define PULSE_READER_LOST_EDGE (0xFFFFFFFEUL)
#define F_TIM2 (64000000UL)
/**
* unit of the edge durations to return
*/
typedef enum {
PulseReaderUnit64MHz,
PulseReaderUnitPicosecond,
PulseReaderUnitNanosecond,
PulseReaderUnitMicrosecond,
} PulseReaderUnit;
/* using an anonymous type */
typedef struct PulseReader PulseReader;
/** Allocate a PulseReader object
*
* Allocates memory for a ringbuffer and initalizes the object
*
* @param[in] gpio the GPIO to use. will get configured as input.
* @param[in] size number of edges to buffer
*/
PulseReader* pulse_reader_alloc(const GpioPin* gpio, uint32_t size);
/** Free a PulseReader object
*
* Frees all memory of the given object
*
* @param[in] signal previously allocated PulseReader object.
*/
void pulse_reader_free(PulseReader* signal);
/** Start signal capturing
*
* Initializes DMA1, TIM2 and DMAMUX_REQ_GEN_0 to automatically capture timer values.
* Ensure that interrupts are always enabled, as the used EXTI line is handled as one.
*
* @param[in] signal previously allocated PulseReader object.
*/
void pulse_reader_start(PulseReader* signal);
/** Stop signal capturing
*
* Frees DMA1, TIM2 and DMAMUX_REQ_GEN_0
*
* @param[in] signal previously allocated PulseReader object.
*/
void pulse_reader_stop(PulseReader* signal);
/** Recevie a sample from ringbuffer
*
* Waits for the specified time until a new edge gets detected.
* If not configured otherwise, the pulse duration will be in picosecond resolution.
* If a bittime was configured, the return value will contain the properly rounded
* number of bit times measured.
*
* @param[in] signal previously allocated PulseReader object.
* @param[in] timeout_us time to wait for a signal [µs]
*
* @returns the scaled value of the pulse duration
*/
uint32_t pulse_reader_receive(PulseReader* signal, int timeout_us);
/** Get available samples
*
* Get the number of available samples in the ringbuffer
*
* @param[in] signal previously allocated PulseReader object.
*
* @returns the number of samples in buffer
*/
uint32_t pulse_reader_samples(PulseReader* signal);
/** Set timebase
*
* Set the timebase to be used when returning pulse duration.
*
* @param[in] signal previously allocated PulseReader object.
* @param[in] unit PulseReaderUnit64MHz or PulseReaderUnitPicosecond
*/
void pulse_reader_set_timebase(PulseReader* signal, PulseReaderUnit unit);
/** Set bit time
*
* Set the number of timebase units per bit.
* When set, the pulse_reader_receive() will return an already rounded
* bit count value instead of the raw duration.
*
* Set to 1 to return duration again.
*
* @param[in] signal previously allocated PulseReader object.
* @param[in] bit_time
*/
void pulse_reader_set_bittime(PulseReader* signal, uint32_t bit_time);
/** Set GPIO pull direction
*
* Some GPIOs need pulldown, others don't. By default the
* pull direction is GpioPullNo.
*
* @param[in] signal previously allocated PulseReader object.
* @param[in] pull GPIO pull direction
*/
void pulse_reader_set_pull(PulseReader* signal, GpioPull pull);
#ifdef __cplusplus
}
#endif

71
lib/stm32wb.scons Normal file
View File

@ -0,0 +1,71 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/cmsis_core",
"#/lib/stm32wb_cmsis/Include",
"#/lib/stm32wb_hal/Inc",
"#/lib/stm32wb_copro/wpan",
],
CPPDEFINES=[
"STM32WB",
"STM32WB55xx",
"USE_FULL_ASSERT",
"USE_FULL_LL_DRIVER",
],
SDK_HEADERS=env.GlobRecursive(
"*_ll_*.h",
Dir("stm32wb_hal/Inc"),
exclude="*usb.h",
),
)
if env["RAM_EXEC"]:
env.Append(
CPPDEFINES=[
"VECT_TAB_SRAM",
],
)
libenv = env.Clone(FW_LIB_NAME="stm32wb")
libenv.Append(
CPPPATH=[
"#/lib/stm32wb_copro/wpan/ble",
"#/lib/stm32wb_copro/wpan/ble/core",
"#/lib/stm32wb_copro/wpan/interface/patterns/ble_thread",
"#/lib/stm32wb_copro/wpan/interface/patterns/ble_thread/shci",
"#/lib/stm32wb_copro/wpan/interface/patterns/ble_thread/tl",
"#/lib/stm32wb_copro/wpan/utilities",
]
)
libenv.ApplyLibFlags()
sources = libenv.GlobRecursive("*_ll_*.c", "stm32wb_hal/Src/", exclude="*usb.c")
sources += Glob(
"stm32wb_copro/wpan/interface/patterns/ble_thread/shci/*.c",
source=True,
)
sources += Glob(
"stm32wb_copro/wpan/interface/patterns/ble_thread/tl/*_tl*.c",
exclude="stm32wb_copro/wpan/interface/patterns/ble_thread/tl/shci_tl_if.c",
source=True,
)
sources += [
"stm32wb_copro/wpan/interface/patterns/ble_thread/tl/tl_mbox.c",
"stm32wb_copro/wpan/ble/svc/Src/svc_ctl.c",
"stm32wb_copro/wpan/ble/core/auto/ble_gap_aci.c",
"stm32wb_copro/wpan/ble/core/auto/ble_gatt_aci.c",
"stm32wb_copro/wpan/ble/core/auto/ble_hal_aci.c",
"stm32wb_copro/wpan/ble/core/auto/ble_hci_le.c",
"stm32wb_copro/wpan/ble/core/auto/ble_l2cap_aci.c",
"stm32wb_copro/wpan/ble/core/template/osal.c",
"stm32wb_copro/wpan/utilities/dbg_trace.c",
"stm32wb_copro/wpan/utilities/otp.c",
"stm32wb_copro/wpan/utilities/stm_list.c",
]
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

1
lib/stm32wb_cmsis Submodule

@ -0,0 +1 @@
Subproject commit d1b860584dfe24d40d455ae624ed14600dfa93c9

1
lib/stm32wb_copro Submodule

@ -0,0 +1 @@
Subproject commit 6c9c54f05669b2c4d436df58bb691d3b0d7c86df

1
lib/stm32wb_hal Submodule

@ -0,0 +1 @@
Subproject commit cfd0dd258cb031c95b2b2d6d04c19f9f625fe3e8

View File

@ -1,24 +1,35 @@
#include "version.h"
#include <furi.h>
/* This header is autogenerated by build system */
#include "version.inc.h"
#define VERSION_MAGIC (0xBE40u)
#define VERSION_MAJOR (0x1u)
#define VERSION_MINOR (0x0u)
struct Version {
// Header
const uint16_t magic;
const uint8_t major;
const uint8_t minor;
// Payload
const char* git_hash;
const char* git_branch;
const char* git_branch_num;
const char* build_date;
const char* custom_flipper_name;
const char* version;
// Payload bits and pieces
const uint8_t target;
const bool build_is_dirty;
};
/* version of current running firmware (bootloader/flipper) */
static const Version version = {
.magic = VERSION_MAGIC,
.major = VERSION_MAJOR,
.minor = VERSION_MINOR,
.git_hash = GIT_COMMIT,
.git_branch = GIT_BRANCH,
.git_branch_num = GIT_BRANCH_NUM,
.build_date = BUILD_DATE,
#ifdef FURI_CUSTOM_FLIPPER_NAME
.custom_flipper_name = FURI_CUSTOM_FLIPPER_NAME,
@ -47,7 +58,8 @@ const char* version_get_gitbranch(const Version* v) {
}
const char* version_get_gitbranchnum(const Version* v) {
return v ? v->git_branch_num : version.git_branch_num;
UNUSED(v);
return "0";
}
const char* version_get_builddate(const Version* v) {

View File

@ -60,7 +60,6 @@ class Main(App):
)
self.parser_copro.add_argument("cube_dir", help="Path to Cube folder")
self.parser_copro.add_argument("output_dir", help="Path to output folder")
self.parser_copro.add_argument("mcu", help="MCU series as in copro folder")
self.parser_copro.add_argument(
"--cube_ver", dest="cube_ver", help="Cube version", required=True
)
@ -254,16 +253,20 @@ class Main(App):
from flipper.assets.copro import Copro
self.logger.info("Bundling coprocessor binaries")
copro = Copro(self.args.mcu)
self.logger.info("Loading CUBE info")
copro.loadCubeInfo(self.args.cube_dir, self.args.cube_ver)
self.logger.info("Bundling")
copro.bundle(
self.args.output_dir,
self.args.stack_file,
self.args.stack_type,
self.args.stack_addr,
)
copro = Copro()
try:
self.logger.info("Loading CUBE info")
copro.loadCubeInfo(self.args.cube_dir, self.args.cube_ver)
self.logger.info("Bundling")
copro.bundle(
self.args.output_dir,
self.args.stack_file,
self.args.stack_type,
self.args.stack_addr,
)
except Exception as e:
self.logger.error(f"Failed to bundle: {e}")
return 1
self.logger.info("Complete")
return 0

View File

@ -29,7 +29,6 @@ from FreeRTOSgdb.GDBCommands import ShowQueueInfo
class Scheduler:
def __init__(self):
self._blocked = ListInspector("xSuspendedTaskList")
self._delayed1 = ListInspector("xDelayedTaskList1")
self._delayed2 = ListInspector("xDelayedTaskList2")

View File

@ -61,7 +61,6 @@ class ShowQueueInfo(gdb.Command):
if maxCount == 0:
print(outputFmt % (q.GetName(), q.GetQueueMessagesWaiting(), "", ""))
else:
for i in range(0, maxCount):
txName = ""
if i < len(sendList):

View File

@ -48,7 +48,6 @@ class HandleRegistry:
print("%d: %3s %16s" % (i, h, name))
def FilterBy(self, qMode):
"""Retrieve a List of Mutex Queue Handles"""
resp = []
for i in range(self._minIndex, self._maxIndex):

View File

@ -56,7 +56,6 @@ class ListInspector:
of some of the TCB Task lists.
"""
if self._list != None:
CastType = None
if CastTypeStr != None:
if type(CastTypeStr) == str:
@ -73,7 +72,6 @@ class ListInspector:
index = self._list["pxIndex"]
if numElems > 0 and numElems < 200:
if startElem == 0:
curr = index
else:

View File

@ -47,7 +47,6 @@ QueueMode.Map = QueueMap
class QueueInspector:
QueueType = gdb.lookup_type("Queue_t")
def __init__(self, handle):

View File

@ -11,7 +11,6 @@ import gdb
class TaskInspector:
TCBType = gdb.lookup_type("TCB_t")
def __init__(self, handle):

View File

@ -28,7 +28,5 @@ directory = path.abspath(directory)
sys.path.append(directory)
from cmdebug.svd_gdb import LoadSVD
from cmdebug.dwt_gdb import DWT
DWT()
LoadSVD()

View File

@ -0,0 +1,35 @@
PyCortexMDebug
==============
## SVD
ARM defines an SVD (System View Description) file format in its CMSIS standard as a means for Cortex-M-based chip manufacturers to provide a common description of peripherals, registers, and register fields. You can download SVD files for different manufacturers [here](http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php).
The implementation consists of two components -- An lxml-based parser module (pysvd) and a GDB file (gdb_svd). I haven't yet worked out a perfect workflow for this, though it's quite easy to use when you already tend to have a GDB initialization file for starting up OpenOCD and the like. However your workflow works, just make sure to, in GDB:
source gdb_svd.py
svd_load [your_svd_file].svd
These files can be huge so it might take a second or two. Anyways, after that, you can do
svd
to list available peripherals with descriptions. Or you can do
svd [some_peripheral_name]
to see all of the registers (with their values) for a given peripheral. For more details, run
svd [some_peripheral_name] [some_register_name]
to see all of the field values with descriptions.
You can add format modifiers like:
* `svd/x` will display values in hex
* `svd/o` will display values in octal
* `svd/t` or `svd/b` will display values in binary
* `svd/a` will display values in hex and try to resolve symbols from the values
All field values are displayed at the correct lengths as provided by the SVD files.
Also, tab completion exists for nearly everything! When in doubt, run `svd help`.

View File

@ -16,15 +16,14 @@ You should have received a copy of the GNU General Public License
along with PyCortexMDebug. If not, see <http://www.gnu.org/licenses/>.
"""
from collections import OrderedDict
from . import x2d
import traceback
import warnings
import pickle
import lxml.objectify as objectify
import sys
from collections import OrderedDict
import os
import pickle
import traceback
import re
import warnings
class SmartDict:
@ -127,31 +126,26 @@ class SVDFile:
def __init__(self, fname):
"""
Args:
fname: Filename for the SVD file
"""
f = objectify.parse(os.path.expanduser(fname))
root = f.getroot()
periph = root.peripherals.getchildren()
self.peripherals = SmartDict()
self.base_address = 0
xml_file_name = os.path.expanduser(fname)
pickle_file_name = xml_file_name + ".pickle"
root = None
if os.path.exists(pickle_file_name):
print("Loading pickled SVD")
root = pickle.load(open(pickle_file_name, "rb"))
else:
print("Loading XML SVD and pickling it")
root = x2d.parse(open(xml_file_name, "rb"))
pickle.dump(root, open(pickle_file_name, "wb"), pickle.HIGHEST_PROTOCOL)
print("Processing SVD tree")
# XML elements
for p in root["device"]["peripherals"]["peripheral"]:
for p in periph:
try:
self.peripherals[p["name"]] = SVDPeripheral(p, self)
if p.tag == "peripheral":
self.peripherals[str(p.name)] = SVDPeripheral(p, self)
else:
# This is some other tag
pass
except SVDNonFatalError as e:
# print(e)
pass
print("SVD Ready")
print(e)
def add_register(parent, node):
@ -271,11 +265,11 @@ class SVDPeripheral:
self.parent_base_address = parent.base_address
# Look for a base address, as it is required
if "baseAddress" not in svd_elem:
if not hasattr(svd_elem, "baseAddress"):
raise SVDNonFatalError("Periph without base address")
self.base_address = int(str(svd_elem.baseAddress), 0)
if "@derivedFrom" in svd_elem:
derived_from = svd_elem["@derivedFrom"]
if "derivedFrom" in svd_elem.attrib:
derived_from = svd_elem.attrib["derivedFrom"]
try:
self.name = str(svd_elem.name)
except AttributeError:
@ -301,14 +295,16 @@ class SVDPeripheral:
self.clusters = SmartDict()
if hasattr(svd_elem, "registers"):
if "register" in svd_elem.registers:
for r in svd_elem.registers.register:
if isinstance(r, x2d.ObjectDict):
add_register(self, r)
if "cluster" in svd_elem.registers:
for c in svd_elem.registers.cluster:
if isinstance(c, x2d.ObjectDict):
add_cluster(self, c)
registers = [
r
for r in svd_elem.registers.getchildren()
if r.tag in ["cluster", "register"]
]
for r in registers:
if r.tag == "cluster":
add_cluster(self, r)
elif r.tag == "register":
add_register(self, r)
def refactor_parent(self, parent):
self.parent_base_address = parent.base_address
@ -342,11 +338,11 @@ class SVDPeripheralRegister:
else:
self.size = 0x20
self.fields = SmartDict()
if "fields" in svd_elem:
if hasattr(svd_elem, "fields"):
# Filter fields to only consider those of tag "field"
for f in svd_elem.fields.field:
if isinstance(f, x2d.ObjectDict):
self.fields[str(f.name)] = SVDPeripheralRegisterField(f, self)
fields = [f for f in svd_elem.fields.getchildren() if f.tag == "field"]
for f in fields:
self.fields[str(f.name)] = SVDPeripheralRegisterField(f, self)
def refactor_parent(self, parent):
self.parent_base_address = parent.base_address

View File

@ -0,0 +1,109 @@
from dataclasses import dataclass, field
from typing import Dict, Optional
import gdb
# Must match FuriHalRtcRegisterVersion index in FuriHalRtcRegister enum
RTC_BACKUP_VERSION_REGISTER_IDX = 0x2
RTC_BASE = 0x40002800
RTC_BACKUP_BASE = RTC_BASE + 0x50
VERSION_REGISTER_ADDRESS = RTC_BACKUP_BASE + RTC_BACKUP_VERSION_REGISTER_IDX * 4
VERSION_STRUCT_MAGIC = 0xBE40
@dataclass
class VersionData:
git_hash: str
git_branch: str
build_date: str
version: str
target: int
build_is_dirty: bool
extra: Optional[Dict[str, str]] = field(default_factory=dict)
class VersionLoader:
def __init__(self, version_ptr):
self.version_ptr = version_ptr
self._cstr_type = gdb.lookup_type("char").pointer()
self._uint_type = gdb.lookup_type("unsigned int")
version_signature = version_ptr.dereference().cast(self._uint_type)
is_versioned = (version_signature & (0xFFFF)) == VERSION_STRUCT_MAGIC
if is_versioned:
self._version_data = self.load_versioned(
major=version_signature >> 16 & 0xFF,
minor=version_signature >> 24 & 0xFF,
)
else:
self._version_data = self.load_unversioned()
@property
def version(self) -> VersionData:
return self._version_data
def load_versioned(self, major, minor):
if major != 1:
raise ValueError("Unsupported version struct major version")
# Struct version 1.0
extra_data = int(self.version_ptr[5].cast(self._uint_type))
return VersionData(
git_hash=self.version_ptr[1].cast(self._cstr_type).string(),
git_branch=self.version_ptr[2].cast(self._cstr_type).string(),
build_date=self.version_ptr[3].cast(self._cstr_type).string(),
version=self.version_ptr[4].cast(self._cstr_type).string(),
target=extra_data & 0xF,
build_is_dirty=bool((extra_data >> 8) & 0xF),
)
def load_unversioned(self):
"""Parse an early version of the version struct."""
extra_data = int(self.version_ptr[5].cast(self._uint_type))
return VersionData(
git_hash=self.version_ptr[0].cast(self._cstr_type).string(),
git_branch=self.version_ptr[1].cast(self._cstr_type).string(),
# branch number is #2, but we don't care about it
build_date=self.version_ptr[3].cast(self._cstr_type).string(),
version=self.version_ptr[4].cast(self._cstr_type).string(),
target=extra_data & 0xF,
build_is_dirty=bool((extra_data >> 8) & 0xF),
)
class FlipperFwVersion(gdb.Command):
"""Print the version of Flipper's firmware."""
def __init__(self):
super(FlipperFwVersion, self).__init__("fw-version", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
void_ptr_type = gdb.lookup_type("void").pointer().pointer()
version_ptr_ptr = gdb.Value(VERSION_REGISTER_ADDRESS).cast(void_ptr_type)
if not version_ptr_ptr:
print("RTC version register is NULL")
return
version_ptr = version_ptr_ptr.dereference()
if not version_ptr:
print("Pointer to version struct is NULL")
return
version_struct = version_ptr.cast(void_ptr_type)
v = VersionLoader(version_struct)
print("Firmware version on attached Flipper:")
print(f"\tVersion: {v.version.version}")
print(f"\tBuilt on: {v.version.build_date}")
print(f"\tGit branch: {v.version.git_branch}")
print(f"\tGit commit: {v.version.git_hash}")
print(f"\tDirty: {v.version.build_is_dirty}")
print(f"\tHW Target: {v.version.target}")
FlipperFwVersion()

View File

@ -9,6 +9,7 @@ from SCons.Action import Action
from SCons.Builder import Builder
from SCons.Errors import StopError
from SCons.Warnings import WarningOnByDefault, warn
from SCons.Script import GetOption
# Adding objects for application management to env
# AppManager env["APPMGR"] - loads all manifests; manages list of known apps
@ -28,7 +29,8 @@ def LoadAppManifest(env, entry):
env["APPMGR"].load_manifest(app_manifest_file_path, entry)
env.Append(PY_LINT_SOURCES=[app_manifest_file_path])
except FlipperManifestException as e:
warn(WarningOnByDefault, str(e))
if not GetOption("silent"):
warn(WarningOnByDefault, str(e))
def PrepareApplicationsBuild(env):

View File

@ -18,7 +18,7 @@ def GetDevices(env):
def generate(env, **kw):
env.AddMethod(GetDevices)
env.SetDefault(
FBT_DEBUG_DIR="${ROOT_DIR}/debug",
FBT_DEBUG_DIR="${FBT_SCRIPT_DIR}/debug",
)
if (adapter_serial := env.subst("$OPENOCD_ADAPTER_SERIAL")) != "auto":
@ -39,10 +39,10 @@ def generate(env, **kw):
"|openocd -c 'gdb_port pipe; log_output ${FBT_DEBUG_DIR}/openocd.log' ${[SINGLEQUOTEFUNC(OPENOCD_OPTS)]}"
],
GDBOPTS_BASE=[
"-ex",
"target extended-remote ${GDBREMOTE}",
"-ex",
"source ${FBT_DEBUG_DIR}/gdbinit",
"-ex",
"target extended-remote ${GDBREMOTE}",
],
GDBOPTS_BLACKMAGIC=[
"-q",
@ -61,6 +61,8 @@ def generate(env, **kw):
"-ex",
"source ${FBT_DEBUG_DIR}/flipperapps.py",
"-ex",
"source ${FBT_DEBUG_DIR}/flipperversion.py",
"-ex",
"fap-set-debug-elf-root ${FBT_FAP_DEBUG_ELF_ROOT}",
"-ex",
"source ${FBT_DEBUG_DIR}/PyCortexMDebug/PyCortexMDebug.py",
@ -68,6 +70,8 @@ def generate(env, **kw):
"svd_load ${SVD_FILE}",
"-ex",
"compare-sections",
"-ex",
"fw-version",
],
JFLASHPROJECT="${FBT_DEBUG_DIR}/fw.jflash",
)

View File

@ -34,6 +34,9 @@ Other:
firmware_pvs:
generate a PVS-Studio report
How to open a shell with toolchain environment and other build tools:
In your shell, type "source `./fbt -s env`". You can also use "." instead of "source".
For more targets & info, see documentation/fbt.md
"""

View File

@ -1,16 +1,14 @@
import logging
import json
from io import BytesIO
import tarfile
import xml.etree.ElementTree as ET
import posixpath
import logging
import os
import posixpath
import tarfile
from io import BytesIO
from flipper.utils import file_sha256, timestamp
from flipper.assets.coprobin import CoproBinary, get_stack_type
from flipper.utils import file_sha256, timestamp
CUBE_COPRO_PATH = "Projects/STM32WB_Copro_Wireless_Binaries"
CUBE_COPRO_PATH = "firmware"
MANIFEST_TEMPLATE = {
"manifest": {"version": 0, "timestamp": 0},
@ -27,8 +25,7 @@ MANIFEST_TEMPLATE = {
class Copro:
COPRO_TAR_DIR = "core2_firmware"
def __init__(self, mcu):
self.mcu = mcu
def __init__(self):
self.version = None
self.cube_dir = None
self.mcu_copro = None
@ -38,20 +35,24 @@ class Copro:
if not os.path.isdir(cube_dir):
raise Exception(f'"{cube_dir}" doesn\'t exists')
self.cube_dir = cube_dir
self.mcu_copro = os.path.join(self.cube_dir, CUBE_COPRO_PATH, self.mcu)
self.mcu_copro = os.path.join(self.cube_dir, CUBE_COPRO_PATH)
if not os.path.isdir(self.mcu_copro):
raise Exception(f'"{self.mcu_copro}" doesn\'t exists')
cube_manifest_file = os.path.join(self.cube_dir, "package.xml")
cube_manifest = ET.parse(cube_manifest_file)
cube_package = cube_manifest.find("PackDescription")
if not cube_package:
raise Exception("Unknown Cube manifest format")
cube_version = cube_package.get("Patch") or cube_package.get("Release")
if not cube_version or not cube_version.startswith("FW.WB"):
raise Exception("Incorrect Cube package or version info")
cube_version = cube_version.replace("FW.WB.", "", 1)
try:
cube_manifest_file = os.path.join(self.cube_dir, "VERSION")
with open(cube_manifest_file, "r") as cube_manifest:
cube_version = cube_manifest.read().strip()
except IOError:
raise Exception(f"Failed to read version from {cube_manifest_file}")
if not cube_version.startswith("v"):
raise Exception(f"Invalid cube version: {cube_version}")
cube_version = cube_version[1:]
if cube_version != reference_cube_version:
raise Exception("Unsupported cube version")
raise Exception(
f"Unsupported cube version: {cube_version}, expecting {reference_cube_version}"
)
self.version = cube_version
def _getFileName(self, name):

View File

@ -5,7 +5,7 @@ import os.path
import sys
# From STM32CubeWB\Middlewares\ST\STM32_WPAN\interface\patterns\ble_thread\shci\shci.h
# From lib/stm32wb_copro/wpan/interface/patterns/ble_thread/shci/shci.h
__STACK_TYPE_CODES = {
"BLE_FULL": 0x01,
"BLE_HCI": 0x02,

View File

@ -1,12 +1,13 @@
import os
import sys
import serial
import time
import hashlib
import math
import logging
import posixpath
import enum
import hashlib
import logging
import math
import os
import posixpath
import sys
import time
import serial
def timing(func):
@ -236,6 +237,7 @@ class FlipperStorage:
filesize = os.fstat(file.fileno()).st_size
buffer_size = self.chunk_size
start_time = time.time()
while True:
filedata = file.read(buffer_size)
size = len(filedata)
@ -254,11 +256,13 @@ class FlipperStorage:
self.port.write(filedata)
self.read.until(self.CLI_PROMPT)
percent = str(math.ceil(file.tell() / filesize * 100))
ftell = file.tell()
percent = str(math.ceil(ftell / filesize * 100))
total_chunks = str(math.ceil(filesize / buffer_size))
current_chunk = str(math.ceil(file.tell() / buffer_size))
current_chunk = str(math.ceil(ftell / buffer_size))
approx_speed = ftell / (time.time() - start_time + 0.0001)
sys.stdout.write(
f"\r{percent}%, chunk {current_chunk} of {total_chunks}"
f"\r{percent}%, chunk {current_chunk} of {total_chunks} @ {approx_speed/1024:.2f} kb/s"
)
sys.stdout.flush()
print()
@ -323,7 +327,7 @@ class FlipperStorage:
return False
raise FlipperStorageException.from_error_code(path, error_code)
return True
return response == b"Directory" or response.startswith(b"Storage")
def exist_file(self, path: str):
"""Does file exist on Flipper"""

View File

@ -170,7 +170,6 @@ class Main(App):
"update.dir",
"sdk_headers.dir",
"lib.dir",
"debug.dir",
"scripts.dir",
)

View File

@ -15,7 +15,7 @@ class Main(App):
self.parser.add_argument("manifest_path", help="Manifest path")
self.parser.add_argument(
"--pkg_dir_name", help="Update dir name", default="pcbundle", required=False
"--pkg_dir_name", help="Update dir name", default=None, required=False
)
self.parser.set_defaults(func=self.install)

View File

@ -186,6 +186,33 @@ dist_env.PhonyTarget(
FBT_FAP_DEBUG_ELF_ROOT=path_as_posix(dist_env.subst("$FBT_FAP_DEBUG_ELF_ROOT")),
)
# Debug alien elf
debug_other_opts = [
"-ex",
"source ${FBT_DEBUG_DIR}/PyCortexMDebug/PyCortexMDebug.py",
"-ex",
"source ${FBT_DEBUG_DIR}/flipperversion.py",
"-ex",
"fw-version",
]
dist_env.PhonyTarget(
"debug_other",
"${GDBPYCOM}",
GDBOPTS="${GDBOPTS_BASE}",
GDBREMOTE="${OPENOCD_GDB_PIPE}",
GDBPYOPTS=debug_other_opts,
)
dist_env.PhonyTarget(
"debug_other_blackmagic",
"${GDBPYCOM}",
GDBOPTS="${GDBOPTS_BASE} ${GDBOPTS_BLACKMAGIC}",
GDBREMOTE="${BLACKMAGIC_ADDR}",
GDBPYOPTS=debug_other_opts,
)
dist_env.PhonyTarget(
"flash_blackmagic",
"$GDB $GDBOPTS $SOURCES $GDBFLASH",
@ -380,8 +407,9 @@ dist_env.Alias("vscode_dist", vscode_dist)
# Creating app from base template
dist_env.SetDefault(FBT_APPID=appenv.subst("$APPID") or "template")
app_template_dir = project_template_dir.Dir("app_template")
app_template_dist = []
for template_file in project_template_dir.Dir("app_template").glob("*"):
for template_file in app_template_dir.glob("*"):
dist_file_name = dist_env.subst(template_file.name)
if template_file.name.endswith(".png"):
app_template_dist.append(
@ -397,12 +425,13 @@ for template_file in project_template_dir.Dir("app_template").glob("*"):
},
)
)
AddPostAction(
app_template_dist[-1],
[
Mkdir(original_app_dir.Dir("images")),
Touch(original_app_dir.Dir("images").File(".gitkeep")),
# scons' glob ignores .dot directories, so we need to copy .github manually
Copy(original_app_dir.Dir(".github"), app_template_dir.Dir(".github")),
],
)
dist_env.Precious(app_template_dist)
@ -440,3 +469,8 @@ else:
raise UserError(f"Dolphin folder not found: {dolphin_src_dir}")
dist_env.PhonyTarget("dolphin_ext", Action(missing_dolphin_folder, None))
dist_env.PhonyTarget(
"env",
"@echo $( ${FBT_SCRIPT_DIR}/toolchain/fbtenv.sh $)",
)

View File

@ -8,7 +8,8 @@
"amiralizadeh9480.cpp-helper",
"marus25.cortex-debug",
"zxh404.vscode-proto3",
"augustocdias.tasks-shell-input"
"augustocdias.tasks-shell-input",
"rioj7.command-variable"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [

View File

@ -29,6 +29,8 @@
"@UFBT_DEBUG_DIR@/stm32wbx.cfg"
],
"postAttachCommands": [
"source @UFBT_DEBUG_DIR@/flipperversion.py",
"fw-version",
"source @UFBT_DEBUG_DIR@/flipperapps.py",
"fap-set-debug-elf-root @UFBT_DEBUG_ELF_DIR@"
],
@ -49,6 +51,8 @@
"@UFBT_DEBUG_DIR@/stm32wbx.cfg"
],
"postAttachCommands": [
"source @UFBT_DEBUG_DIR@/flipperversion.py",
"fw-version",
"source @UFBT_DEBUG_DIR@/flipperapps.py",
"fap-set-debug-elf-root @UFBT_DEBUG_ELF_DIR@"
],
@ -69,6 +73,8 @@
"attach 1",
"set confirm off",
"set mem inaccessible-by-default off",
"source @UFBT_DEBUG_DIR@/flipperversion.py",
"fw-version",
"source @UFBT_DEBUG_DIR@/flipperapps.py",
"fap-set-debug-elf-root @UFBT_DEBUG_ELF_DIR@"
]
@ -86,6 +92,8 @@
"svdFile": "@UFBT_DEBUG_DIR@/STM32WB55_CM4.svd",
"rtos": "FreeRTOS",
"postAttachCommands": [
"source @UFBT_DEBUG_DIR@/flipperversion.py",
"fw-version",
"source @UFBT_DEBUG_DIR@/flipperapps.py",
"fap-set-debug-elf-root @UFBT_DEBUG_ELF_DIR@"
]

View File

@ -0,0 +1,41 @@
name: "FAP: Build for multiple SDK sources"
# This will build your app for dev and release channels on GitHub.
# It will also build your app every day to make sure it's up to date with the latest SDK changes.
# See https://github.com/marketplace/actions/build-flipper-application-package-fap for more information
on:
push:
## put your main branch name under "braches"
#branches:
# - master
pull_request:
schedule:
# do a build every day
- cron: "1 1 * * *"
jobs:
ufbt-build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: dev channel
sdk-channel: dev
- name: release channel
sdk-channel: release
# You can add unofficial channels here. See ufbt action docs for more info.
name: 'ufbt: Build for ${{ matrix.name }}'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build with ufbt
uses: flipperdevices/flipperzero-ufbt-action@v0.1.1
id: build-app
with:
sdk-channel: ${{ matrix.sdk-channel }}
- name: Upload app artifacts
uses: actions/upload-artifact@v3
with:
# See ufbt action docs for other output variables
name: ${{ github.event.repository.name }}-${{ steps.build-app.outputs.suffix }}
path: ${{ steps.build-app.outputs.fap-artifacts }}

View File

@ -40,6 +40,9 @@ How to create a new application:
2. Run `ufbt vscode_dist create APPID=myapp`
3. In VSCode, open the folder and start editing.
4. Run `ufbt launch` to build and upload your application.
How to open a shell with toolchain environment and other build tools:
In your shell, type "source `ufbt -s env`". You can also use "." instead of "source".
"""

View File

@ -78,10 +78,8 @@ def generate(env, **kw):
env.SetDefault(
# Paths
SDK_DEFINITION=env.File(sdk_data["sdk_symbols"]),
FBT_DEBUG_DIR=pathlib.Path(
sdk_current_sdk_dir_node.Dir(sdk_components["debug.dir"]).abspath
).as_posix(),
FBT_SCRIPT_DIR=scripts_dir,
FBT_DEBUG_DIR=scripts_dir.Dir("debug"),
LIBPATH=sdk_current_sdk_dir_node.Dir(sdk_components["lib.dir"]),
FW_ELF=sdk_current_sdk_dir_node.File(sdk_components["firmware.elf"]),
FW_BIN=sdk_current_sdk_dir_node.File(sdk_components["full.bin"]),

View File

@ -35,8 +35,6 @@ class GitVersion:
or "unknown"
)
branch_num = self._exec_git("rev-list --count HEAD") or "n/a"
version = (
os.environ.get("DIST_SUFFIX", None)
or "unknown"
@ -58,7 +56,6 @@ class GitVersion:
return {
"GIT_COMMIT": commit,
"GIT_BRANCH": branch,
"GIT_BRANCH_NUM": branch_num,
"FURI_CUSTOM_FLIPPER_NAME": custom_fz_name,
"VERSION": version,
"BUILD_DIRTY": dirty and 1 or 0,
@ -67,7 +64,6 @@ class GitVersion:
return {
"GIT_COMMIT": commit,
"GIT_BRANCH": branch,
"GIT_BRANCH_NUM": branch_num,
"VERSION": version,
"BUILD_DIRTY": dirty and 1 or 0,
}