2022-08-22 20:06:17 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define FURI_RETURNS_NONNULL __attribute__((returns_nonnull))
|
|
|
|
|
|
|
|
|
|
#ifndef MAX
|
|
|
|
|
#define MAX(a, b) \
|
|
|
|
|
({ \
|
|
|
|
|
__typeof__(a) _a = (a); \
|
|
|
|
|
__typeof__(b) _b = (b); \
|
|
|
|
|
_a > _b ? _a : _b; \
|
|
|
|
|
})
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef MIN
|
|
|
|
|
#define MIN(a, b) \
|
|
|
|
|
({ \
|
|
|
|
|
__typeof__(a) _a = (a); \
|
|
|
|
|
__typeof__(b) _b = (b); \
|
|
|
|
|
_a < _b ? _a : _b; \
|
|
|
|
|
})
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-04-13 17:47:38 +03:00
|
|
|
#ifndef ABS
|
|
|
|
|
#define ABS(a) ({ (a) < 0 ? -(a) : (a); })
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-08-22 20:06:17 +03:00
|
|
|
#ifndef ROUND_UP_TO
|
|
|
|
|
#define ROUND_UP_TO(a, b) \
|
|
|
|
|
({ \
|
|
|
|
|
__typeof__(a) _a = (a); \
|
|
|
|
|
__typeof__(b) _b = (b); \
|
|
|
|
|
_a / _b + !!(_a % _b); \
|
|
|
|
|
})
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef CLAMP
|
|
|
|
|
#define CLAMP(x, upper, lower) (MIN(upper, MAX(x, lower)))
|
|
|
|
|
#endif
|
|
|
|
|
|
[FL-3954, FL-3955] New CLI architecture (#4111)
* feat: FuriThread stdin
* ci: fix f18
* feat: stdio callback context
* feat: FuriPipe
* POTENTIALLY EXPLOSIVE pipe welding
* fix: non-explosive welding
* Revert welding
* docs: furi_pipe
* feat: pipe event loop integration
* update f18 sdk
* f18
* docs: make doxygen happy
* fix: event loop not triggering when pipe attached to stdio
* fix: partial stdout in pipe
* allow simultaneous in and out subscription in event loop
* feat: vcp i/o
* feat: cli ansi stuffs and history
* feat: more line editing
* working but slow cli rewrite
* restore previous speed after 4 days of debugging 🥲
* fix: cli_app_should_stop
* fix: cli and event_loop memory leaks
* style: remove commented out code
* ci: fix pvs warnings
* fix: unit tests, event_loop crash
* ci: fix build
* ci: silence pvs warning
* feat: cli gpio
* ci: fix formatting
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* feat: cli completions
* Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads
* merge fixups
* temporarily exclude speaker_debug app
* pvs and unit tests fixups
* feat: commands in fals
* move commands out of flash, code cleanup
* ci: fix errors
* fix: run commands in buffer when stopping session
* speedup cli file transfer
* fix f18
* separate cli_shell into modules
* fix pvs warning
* fix qflipper refusing to connect
* remove temp debug logs
* remove erroneous conclusion
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* unit test for the fix
* improve thread stdio callback signatures
* pipe stdout timeout
* update api symbols
* fix f18, formatting
* fix pvs warnings
* increase stack size, hope to fix unit tests
* cli: revert flag changes
* cli: fix formatting
* cli, fbt: loopback perf benchmark
* thread, event_loop: subscribing to thread flags
* cli: signal internal events using thread flags, improve performance
* fix f18, formatting
* event_loop: fix crash
* storage_cli: increase write_chunk buffer size again
* cli: explanation for order=0
* thread, event_loop: thread flags callback refactor
* cli: increase stack size
* cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char
* cli: use plain array instead of mlib for history
* cli: prepend file name to static fns
* cli: fix formatting
* cli_shell: increase stack size
* cli: fix rpc lockup
* cli: better lockup fix
* cli: fix f18
* fix merge
---------
Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
2025-04-02 22:10:10 +04:00
|
|
|
#ifndef CLAMP_WRAPAROUND
|
|
|
|
|
#define CLAMP_WRAPAROUND(x, upper, lower) \
|
|
|
|
|
({ \
|
|
|
|
|
__typeof__(x) _x = (x); \
|
|
|
|
|
__typeof__(upper) _upper = (upper); \
|
|
|
|
|
__typeof__(lower) _lower = (lower); \
|
|
|
|
|
(_x > _upper) ? _lower : ((_x < _lower) ? _upper : _x); \
|
|
|
|
|
})
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-08-22 20:06:17 +03:00
|
|
|
#ifndef COUNT_OF
|
|
|
|
|
#define COUNT_OF(x) (sizeof(x) / sizeof(x[0]))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef FURI_SWAP
|
|
|
|
|
#define FURI_SWAP(x, y) \
|
|
|
|
|
do { \
|
|
|
|
|
typeof(x) SWAP = x; \
|
|
|
|
|
x = y; \
|
|
|
|
|
y = SWAP; \
|
|
|
|
|
} while(0)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef PLACE_IN_SECTION
|
|
|
|
|
#define PLACE_IN_SECTION(x) __attribute__((section(x)))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef ALIGN
|
|
|
|
|
#define ALIGN(n) __attribute__((aligned(n)))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef __weak
|
|
|
|
|
#define __weak __attribute__((weak))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef UNUSED
|
|
|
|
|
#define UNUSED(X) (void)(X)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef STRINGIFY
|
|
|
|
|
#define STRINGIFY(x) #x
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef TOSTRING
|
|
|
|
|
#define TOSTRING(x) STRINGIFY(x)
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-05-29 20:40:56 +04:00
|
|
|
#ifndef CONCATENATE
|
2024-07-15 07:38:49 +03:00
|
|
|
#define CONCATENATE(a, b) CONCATENATE_(a, b)
|
2023-05-29 20:40:56 +04:00
|
|
|
#define CONCATENATE_(a, b) a##b
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-08-22 20:06:17 +03:00
|
|
|
#ifndef REVERSE_BYTES_U32
|
2024-02-12 02:04:12 +00:00
|
|
|
#define REVERSE_BYTES_U32(x) \
|
|
|
|
|
((((x) & 0x000000FF) << 24) | (((x) & 0x0000FF00) << 8) | (((x) & 0x00FF0000) >> 8) | \
|
|
|
|
|
(((x) & 0xFF000000) >> 24))
|
2022-08-22 20:06:17 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef FURI_BIT
|
|
|
|
|
#define FURI_BIT(x, n) (((x) >> (n)) & 1)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef FURI_BIT_SET
|
2022-09-19 15:30:18 +03:00
|
|
|
#define FURI_BIT_SET(x, n) \
|
|
|
|
|
({ \
|
|
|
|
|
__typeof__(x) _x = (1); \
|
|
|
|
|
(x) |= (_x << (n)); \
|
|
|
|
|
})
|
2022-08-22 20:06:17 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef FURI_BIT_CLEAR
|
2023-01-17 15:55:49 +03:00
|
|
|
#define FURI_BIT_CLEAR(x, n) \
|
|
|
|
|
({ \
|
|
|
|
|
__typeof__(x) _x = (1); \
|
|
|
|
|
(x) &= ~(_x << (n)); \
|
|
|
|
|
})
|
2022-08-22 20:06:17 +03:00
|
|
|
#endif
|
|
|
|
|
|
[FL-2529][FL-1628] New LF-RFID subsystem (#1601)
* Makefile: unit tests pack
* RFID: pulse joiner and its unit test
* Move pulse protocol helpers to appropriate place
* Drop pulse_joiner tests
* Generic protocol, protocols dictionary, unit test
* Protocol dict unit test
* iButton: protocols dictionary
* Lib: varint
* Lib: profiler
* Unit test: varint
* rfid: worker mockup
* LFRFID: em4100 unit test
* Storage: file_exist function
* rfid: fsk osc
* rfid: generic fsk demodulator
* rfid: protocol em4100
* rfid: protocol h10301
* rfid: protocol io prox xsf
* Unit test: rfid protocols
* rfid: new hal
* rfid: raw worker
* Unit test: fix error output
* rfid: worker
* rfid: plain c cli
* fw: migrate to scons
* lfrfid: full io prox support
* unit test: io prox protocol
* SubGHZ: move bit defines to source
* FSK oscillator: level duration compability
* libs: bit manipulation library
* lfrfid: ioprox protocol, use bit library and new level duration method of FSK ocillator
* bit lib: unit tests
* Bit lib: parity tests, remove every nth bit, copy bits
* Lfrfid: awid protocol
* bit lib: uint16 and uint32 getters, unit tests
* lfrfid: FDX-B read, draft version
* Minunit: better memeq assert
* bit lib: reverse, print, print regions
* Protocol dict: get protocol features, get protocol validate count
* lfrfid worker: improved read
* lfrfid raw worker: psk support
* Cli: rfid plain C cli
* protocol AWID: render
* protocol em4100: render
* protocol h10301: render
* protocol indala26: support every indala 26 scramble
* Protocol IO Prox: render
* Protocol FDX-B: advanced read
* lfrfid: remove unused test function
* lfrfid: fix os primitives
* bit lib: crc16 and unit tests
* FDX-B: save data
* lfrfid worker: increase stream size. Alloc raw worker only when needed.
* lfrfid: indala26 emulation
* lfrfid: prepare to write
* lfrfid: fdx-b emulation
* lfrfid: awid, ioprox write
* lfrfid: write t55xx w\o validation
* lfrfid: better t55xx block0 handling
* lfrfid: use new t5577 functions in worker
* lfrfid: improve protocol description
* lfrfid: write and verify
* lfrfid: delete cpp cli
* lfrfid: improve worker usage
* lfrfid-app: step to new worker
* lfrfid: old indala (I40134) load fallback
* lfrfid: indala26, recover wrong synced data
* lfrfid: remove old worker
* lfrfid app: dummy read screen
* lfrfid app: less dummy read screen
* lfrfid: generic 96-bit HID protocol (covers up to HID 37-bit)
* rename
* lfrfid: improve indala26 read
* lfrfid: generic 192-bit HID protocol (covers all HID extended)
* lfrfid: TODO about HID render
* lfrfid: new protocol FDX-A
* lfrfid-app: correct worker stop on exit
* misc fixes
* lfrfid: FDX-A and HID distinguishability has been fixed.
* lfrfid: decode HID size header and render it (#1612)
* lfrfid: rename HID96 and HID192 to HIDProx and HIDExt
* lfrfid: extra actions scene
* lfrfid: decode generic HID Proximity size lazily (#1618)
* lib: stream of data buffers concept
* lfrfid: raw file helper
* lfrfid: changed raw worker api
* lfrfid: packed varint pair
* lfrfid: read stream speedup
* lfrfid app: show read mode
* Documentation
* lfrfid app: raw read gui
* lfrfid app: storage check for raw read
* memleak fix
* review fixes
* lfrfid app: read blink color
* lfrfid app: reset key name after read
* review fixes
* lfrfid app: fix copypasted text
* review fixes
* lfrfid: disable debug gpio
* lfrfid: card detection events
* lfrfid: change validation color from magenta to green
* Update core_defines.
* lfrfid: prefix fdx-b id by zeroes
* lfrfid: parse up to 43-bit HID Proximity keys (#1640)
* Fbt: downgrade toolchain and fix PS1
* lfrfid: fix unit tests
* lfrfid app: remove printf
* lfrfid: indala26, use bit 55 as data
* lfrfid: indala26, better brief format
* lfrfid: indala26, loading fallback
* lfrfid: read timing tuning
Co-authored-by: James Ide <ide@users.noreply.github.com>
Co-authored-by: あく <alleteam@gmail.com>
2022-08-24 01:57:39 +10:00
|
|
|
#define FURI_SW_MEMBARRIER() asm volatile("" : : : "memory")
|
|
|
|
|
|
2022-08-22 20:06:17 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|