[FL-3040] Audio support for SubGhz (#2131)

* Furi_hal_speaker: multiple resource usage
* Furi_hal_speaker: fix multiple resource usage
* Furi_hal_speaker: fix music_player_worker
* Furi_hal_speaker: fix mutex release queue handling
* SubGhz: add furi_hal_subghz_set_debug_pin
* SubGhz: add sound SubGhz Read, SubGhz Read RAW
* furi_hal_speaker: add __attribute__((warn_unused_result)) for furi_hal_speaker_acquire()
* Furi_hal_speaker: fix review comments
* SubGhz: cleanup naming and locking timings
* SubGhz,FuriHal: fix speaker deinit logic and subghz speaker release sequence
* FuriHal: crash on speaker acquire/release from IRQ
* Furi, FuriHal: FURI_WARN_UNUSED and documentation update
* Bump api symbols version: fix broken speaker

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Skorpionm
2022-12-17 02:20:10 +04:00
committed by GitHub
parent 3681a5478c
commit 2dea6969fe
14 changed files with 325 additions and 113 deletions

View File

@@ -4,16 +4,63 @@
*/
#pragma once
#include <furi.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Init speaker */
void furi_hal_speaker_init();
/** Deinit speaker */
void furi_hal_speaker_deinit();
/** Acquire speaker ownership
*
* @warning You must acquire speaker ownership before use
*
* @param timeout Timeout during which speaker ownership must be acquired
*
* @return bool returns true on success
*/
FURI_WARN_UNUSED bool furi_hal_speaker_acquire(uint32_t timeout);
/** Release speaker ownership
*
* @warning You must release speaker ownership after use
*/
void furi_hal_speaker_release();
/** Check current process speaker ownership
*
* @warning always returns true if called from ISR
*
* @return bool returns true if process owns speaker
*/
bool furi_hal_speaker_is_mine();
/** Play a note
*
* @warning no ownership check if called from ISR
*
* @param frequency The frequency
* @param volume The volume
*/
void furi_hal_speaker_start(float frequency, float volume);
/** Set volume
*
* @warning no ownership check if called from ISR
*
* @param volume The volume
*/
void furi_hal_speaker_set_volume(float volume);
/** Stop playback
*
* @warning no ownership check if called from ISR
*/
void furi_hal_speaker_stop();
#ifdef __cplusplus

View File

@@ -9,6 +9,7 @@
#include <stdint.h>
#include <stddef.h>
#include <toolbox/level_duration.h>
#include <furi_hal_gpio.h>
#ifdef __cplusplus
extern "C" {
@@ -34,9 +35,9 @@ typedef enum {
/** Switchable Radio Paths */
typedef enum {
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 */
FuriHalSubGhzPath433, /**< Center Frequency: 433MHz. Path 1: SW1RF1-SW2RF2, LCLCL */
FuriHalSubGhzPath315, /**< Center Frequency: 315MHz. Path 2: SW1RF2-SW2RF1, LCLCLCL */
FuriHalSubGhzPath868, /**< Center Frequency: 868MHz. Path 3: SW1RF3-SW2RF3, LCLC */
} FuriHalSubGhzPath;
/** SubGhz state */
@@ -60,8 +61,17 @@ typedef enum {
SubGhzRegulationTxRx, /**TxRx*/
} SubGhzRegulation;
/* Mirror RX/TX async modulation signal to specified pin
*
* @warning Configures pin to output mode. Make sure it is not connected
* directly to power or ground.
*
* @param[in] pin pointer to the gpio pin structure or NULL to disable
*/
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin);
/** Initialize and switch to power save mode Used by internal API-HAL
* initalization routine Can be used to reinitialize device to safe state and
* initialization routine Can be used to reinitialize device to safe state and
* send it to sleep
*/
void furi_hal_subghz_init();
@@ -105,13 +115,13 @@ void furi_hal_subghz_load_patable(const uint8_t data[8]);
*/
void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size);
/** Check if recieve pipe is not empty
/** Check if receive pipe is not empty
*
* @return true if not empty
*/
bool furi_hal_subghz_rx_pipe_not_empty();
/** Check if recieved data crc is valid
/** Check if received data crc is valid
*
* @return true if valid
*/
@@ -132,7 +142,7 @@ void furi_hal_subghz_flush_rx();
*/
void furi_hal_subghz_flush_tx();
/** Shutdown Issue spwd command
/** Shutdown Issue SPWD command
* @warning registers content will be lost
*/
void furi_hal_subghz_shutdown();
@@ -146,7 +156,7 @@ void furi_hal_subghz_reset();
*/
void furi_hal_subghz_idle();
/** Switch to Recieve
/** Switch to Receive
*/
void furi_hal_subghz_rx();
@@ -172,7 +182,7 @@ uint8_t furi_hal_subghz_get_lqi();
*
* @param value frequency in Hz
*
* @return true if frequncy is valid, otherwise false
* @return true if frequency is valid, otherwise false
*/
bool furi_hal_subghz_is_frequency_valid(uint32_t value);
@@ -181,7 +191,7 @@ bool furi_hal_subghz_is_frequency_valid(uint32_t value);
*
* @param value frequency in Hz
*
* @return real frequency in herz
* @return real frequency in Hz
*/
uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value);
@@ -189,7 +199,7 @@ uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value);
*
* @param value frequency in Hz
*
* @return real frequency in herz
* @return real frequency in Hz
*/
uint32_t furi_hal_subghz_set_frequency(uint32_t value);