flipperzero-firmware/firmware/targets/furi-hal-include/furi-hal-subghz.h

179 lines
4.8 KiB
C
Raw Normal View History

#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <toolbox/level_duration.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Radio Presets */
typedef enum {
Skorp subghz signal archive (#667) * SubGhz: Add millis() furi, add subghz history struct * SubGhz: Fix subghz history * Gubghz: Fix code repeat history, add clean history * SubGhz: reading and adding keys to history * Gui: Renaming Sub 1-Ghz -> SubGhz * Archive: Renaming Sub 1-Ghz -> SubGhz * SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol * Archive: Fix name subghz * SubGhz: Menu navigation * Assets: Add assets/SubGHz/icon.png * Assets: add new icons for subghz * SubGhz: Fix name Add manually scene * SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol * SubGhz: fix memory leak * SubGhz: change of receiving frequency for read scene * SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene * SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser * Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter * Fix formatting and release build * SubGhz: Delete read scene * SubGhz: Fix frequency add manualli scene, refactoring code * SubGhz: 2 profiles for OOK, fix broken build. * SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code * SubGhz: fix assert on worker double stop. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 13:51:48 +00:00
FuriHalSubGhzPresetOok270Async, /** OOK, bandwidth 270kHz, asynchronous */
FuriHalSubGhzPresetOok650Async, /** OOK, bandwidth 650kHz, asynchronous */
FuriHalSubGhzPreset2FSKAsync, /** FM, asynchronous */
2021-08-08 18:03:25 +00:00
} FuriHalSubGhzPreset;
/** Switchable Radio Paths */
typedef enum {
2021-08-08 18:03:25 +00:00
FuriHalSubGhzPathIsolate, /** Isolate Radio from antenna */
FuriHalSubGhzPath433, /** Center Frquency: 433MHz. Path 1: SW1RF1-SW2RF2, LCLCL */
FuriHalSubGhzPath315, /** Center Frquency: 315MHz. Path 2: SW1RF2-SW2RF1, LCLCLCL */
FuriHalSubGhzPath868, /** Center Frquency: 868MHz. Path 3: SW1RF3-SW2RF3, LCLC */
} FuriHalSubGhzPath;
/** SubGhz state */
typedef enum {
SubGhzStateInit, /** Init pending */
SubGhzStateIdle, /** Idle, energy save mode */
SubGhzStateAsyncRx, /** Async RX started */
SubGhzStateAsyncTx, /** Async TX started, DMA and timer is on */
SubGhzStateAsyncTxLast, /** Async TX continue, DMA completed and timer got last value to go */
SubGhzStateAsyncTxEnd, /** Async TX complete, cleanup needed */
} SubGhzState;
/** SubGhz regulation, receive transmission on the current frequency for the region */
typedef enum {
SubGhzRegulationOnlyRx, /**only Rx*/
SubGhzRegulationTxRx, /**TxRx*/
} SubGhzRegulation;
/** Initialize and switch to power save mode
* Used by internal API-HAL initalization routine
* Can be used to reinitialize device to safe state and send it to sleep
*/
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_init();
/** Send device to sleep mode */
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_sleep();
/** Dump info to stdout */
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_dump_state();
/** Load registers from preset by preset name
* @param preset to load
*/
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_load_preset(FuriHalSubGhzPreset preset);
/** Get status */
2021-08-08 18:03:25 +00:00
uint8_t furi_hal_subghz_get_status();
/** Load registers
* @param register-value pairs array, terminated with {0,0}
*/
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_load_registers(const uint8_t data[][2]);
/** Load PATABLE
* @param data, 8 uint8_t values
*/
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_load_patable(const uint8_t data[8]);
/** Write packet to FIFO
* @param data, bytes array
* @param size, size
*/
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size);
/** Read packet from FIFO
* @param data, pointer
* @param size, size
*/
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_read_packet(uint8_t* data, uint8_t* size);
/** Flush rx FIFO buffer */
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_flush_rx();
/** Shutdown
* Issue spwd command
* @warning registers content will be lost
*/
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_shutdown();
/** Reset
* Issue reset command
* @warning registers content will be lost
*/
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_reset();
/** Switch to Idle */
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_idle();
/** Switch to Recieve */
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_rx();
/** Switch to Transmit
* @return true if the transfer is allowed by belonging to the region
*/
bool furi_hal_subghz_tx();
/** Get RSSI value in dBm */
2021-08-08 18:03:25 +00:00
float furi_hal_subghz_get_rssi();
/** Check if frequency is in valid range
* @return true if frequncy is valid, otherwise false
*/
2021-08-08 18:03:25 +00:00
bool furi_hal_subghz_is_frequency_valid(uint32_t value);
/** Set frequency and path
* This function automatically selects antenna matching network
* @param frequency in herz
* @return real frequency in herz
*/
2021-08-08 18:03:25 +00:00
uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value);
/** Set frequency
* @param frequency in herz
* @return real frequency in herz
*/
2021-08-08 18:03:25 +00:00
uint32_t furi_hal_subghz_set_frequency(uint32_t value);
/** Set path
* @param radio path to use
*/
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_set_path(FuriHalSubGhzPath path);
/* High Level API */
/** Signal Timings Capture callback */
2021-08-08 18:03:25 +00:00
typedef void (*FuriHalSubGhzCaptureCallback)(bool level, uint32_t duration, void* context);
/** Enable signal timings capture
* Initializes GPIO and TIM2 for timings capture
*/
2021-08-12 14:42:56 +00:00
void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void* context);
/** Disable signal timings capture
* Resets GPIO and TIM2
*/
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_stop_async_rx();
2021-08-12 14:42:56 +00:00
/** Async TX callback type
* @param context - callback context
* @return LevelDuration
*/
2021-08-12 14:42:56 +00:00
typedef LevelDuration (*FuriHalSubGhzAsyncTxCallback)(void* context);
2021-08-12 14:42:56 +00:00
/** Start async TX
* Initializes GPIO, TIM2 and DMA1 for signal output
* @return true if the transfer is allowed by belonging to the region
*/
bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* context);
/** Wait for async transmission to complete */
2021-08-12 14:42:56 +00:00
bool furi_hal_subghz_is_async_tx_complete();
/** Stop async transmission and cleanup resources
* Resets GPIO, TIM2, and DMA1
*/
2021-08-08 18:03:25 +00:00
void furi_hal_subghz_stop_async_tx();
#ifdef __cplusplus
}
#endif