Loading...
Searching...
No Matches
furi_hal_infrared.h File Reference

INFRARED HAL API. More...

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

Go to the source code of this file.

Macros

#define INFRARED_MAX_FREQUENCY   56000
 
#define INFRARED_MIN_FREQUENCY   10000
 

Typedefs

typedef FuriHalInfraredTxGetDataState(* FuriHalInfraredTxGetDataISRCallback) (void *context, uint32_t *duration, bool *level)
 Callback type for providing data to INFRARED DMA TX system.
 
typedef void(* FuriHalInfraredTxSignalSentISRCallback) (void *context)
 Callback type called every time signal is sent by DMA to Timer.
 
typedef void(* FuriHalInfraredRxCaptureCallback) (void *ctx, bool level, uint32_t duration)
 Signature of callback function for receiving continuous INFRARED rx signal.
 
typedef void(* FuriHalInfraredRxTimeoutCallback) (void *ctx)
 Signature of callback function for reaching silence timeout on INFRARED port.
 

Enumerations

enum  FuriHalInfraredTxPin { FuriHalInfraredTxPinInternal , FuriHalInfraredTxPinExtPA7 , FuriHalInfraredTxPinMax }
 
enum  FuriHalInfraredTxGetDataState { FuriHalInfraredTxGetDataStateOk , FuriHalInfraredTxGetDataStateDone , FuriHalInfraredTxGetDataStateLastDone }
 

Functions

void furi_hal_infrared_async_rx_start (void)
 Initialize INFRARED RX timer to receive interrupts.
 
void furi_hal_infrared_async_rx_stop (void)
 Deinitialize INFRARED RX interrupt.
 
void furi_hal_infrared_async_rx_set_timeout (uint32_t timeout_us)
 Setup hal for receiving silence timeout.
 
void furi_hal_infrared_async_rx_set_capture_isr_callback (FuriHalInfraredRxCaptureCallback callback, void *ctx)
 Setup callback for previously initialized INFRARED RX interrupt.
 
void furi_hal_infrared_async_rx_set_timeout_isr_callback (FuriHalInfraredRxTimeoutCallback callback, void *ctx)
 Setup callback for reaching silence timeout on INFRARED port.
 
bool furi_hal_infrared_is_busy (void)
 Check if INFRARED is in use now.
 
void furi_hal_infrared_async_tx_set_data_isr_callback (FuriHalInfraredTxGetDataISRCallback callback, void *context)
 Set callback providing new data.
 
void furi_hal_infrared_async_tx_start (uint32_t freq, float duty_cycle)
 Start IR asynchronous transmission.
 
void furi_hal_infrared_async_tx_stop (void)
 Stop IR asynchronous transmission and free resources.
 
void furi_hal_infrared_async_tx_wait_termination (void)
 Wait for end of IR asynchronous transmission and free resources.
 
void furi_hal_infrared_async_tx_set_signal_sent_isr_callback (FuriHalInfraredTxSignalSentISRCallback callback, void *context)
 Set callback for end of signal transmission.
 
FuriHalInfraredTxPin furi_hal_infrared_detect_tx_output (void)
 Detect which pin has an external IR module connected.
 
void furi_hal_infrared_set_tx_output (FuriHalInfraredTxPin tx_pin)
 Set which pin will be used to transmit infrared signals.
 

Detailed Description

INFRARED HAL API.

Typedef Documentation

◆ FuriHalInfraredRxCaptureCallback

typedef void(* FuriHalInfraredRxCaptureCallback) (void *ctx, bool level, uint32_t duration)

Signature of callback function for receiving continuous INFRARED rx signal.

Parameters
[in]ctxcontext to pass to callback
[in]levellevel of input INFRARED rx signal
[in]durationduration of continuous rx signal level in us

◆ FuriHalInfraredRxTimeoutCallback

typedef void(* FuriHalInfraredRxTimeoutCallback) (void *ctx)

Signature of callback function for reaching silence timeout on INFRARED port.

Parameters
[in]ctxcontext to pass to callback

◆ FuriHalInfraredTxGetDataISRCallback

typedef FuriHalInfraredTxGetDataState( * FuriHalInfraredTxGetDataISRCallback) (void *context, uint32_t *duration, bool *level)

Callback type for providing data to INFRARED DMA TX system.

It is called every tim

◆ FuriHalInfraredTxSignalSentISRCallback

typedef void(* FuriHalInfraredTxSignalSentISRCallback) (void *context)

Callback type called every time signal is sent by DMA to Timer.

Actually, it means there are 2 timings left to send for this signal, which is almost end. Don't use this callback to stop transmission, as far as there are next signal is charged for transmission by DMA.

Enumeration Type Documentation

◆ FuriHalInfraredTxGetDataState

Enumerator
FuriHalInfraredTxGetDataStateOk 

New data obtained.

FuriHalInfraredTxGetDataStateDone 

New data obtained, and this is end of package.

FuriHalInfraredTxGetDataStateLastDone 

New data obtained, and this is end of package and no more data available.

Function Documentation

◆ furi_hal_infrared_async_rx_set_capture_isr_callback()

void furi_hal_infrared_async_rx_set_capture_isr_callback ( FuriHalInfraredRxCaptureCallback callback,
void * ctx )

Setup callback for previously initialized INFRARED RX interrupt.

Parameters
[in]callbackcallback to call when RX signal edge changing occurs
[in]ctxcontext for callback

◆ furi_hal_infrared_async_rx_set_timeout()

void furi_hal_infrared_async_rx_set_timeout ( uint32_t timeout_us)

Setup hal for receiving silence timeout.

Should be used with 'furi_hal_infrared_timeout_irq_set_callback()'.

Parameters
[in]timeout_ustime to wait for silence on INFRARED port before generating IRQ.

◆ furi_hal_infrared_async_rx_set_timeout_isr_callback()

void furi_hal_infrared_async_rx_set_timeout_isr_callback ( FuriHalInfraredRxTimeoutCallback callback,
void * ctx )

Setup callback for reaching silence timeout on INFRARED port.

Should setup hal with 'furi_hal_infrared_setup_rx_timeout_irq()' first.

Parameters
[in]callbackcallback for silence timeout
[in]ctxcontext to pass to callback

◆ furi_hal_infrared_async_rx_start()

void furi_hal_infrared_async_rx_start ( void )

Initialize INFRARED RX timer to receive interrupts.

It provides interrupts for every RX-signal edge changing with its duration.

◆ furi_hal_infrared_async_tx_set_data_isr_callback()

void furi_hal_infrared_async_tx_set_data_isr_callback ( FuriHalInfraredTxGetDataISRCallback callback,
void * context )

Set callback providing new data.

This function has to be called before furi_hal_infrared_async_tx_start().

Parameters
[in]callbackfunction to provide new data
[in]contextcontext for callback

◆ furi_hal_infrared_async_tx_set_signal_sent_isr_callback()

void furi_hal_infrared_async_tx_set_signal_sent_isr_callback ( FuriHalInfraredTxSignalSentISRCallback callback,
void * context )

Set callback for end of signal transmission.

Parameters
[in]callbackfunction to call when signal is sent
[in]contextcontext for callback

◆ furi_hal_infrared_async_tx_start()

void furi_hal_infrared_async_tx_start ( uint32_t freq,
float duty_cycle )

Start IR asynchronous transmission.

It can be stopped by 2 reasons:

  1. implicit call for furi_hal_infrared_async_tx_stop()
  2. callback can provide FuriHalInfraredTxGetDataStateLastDone response which means no more data available for transmission.

Any func (furi_hal_infrared_async_tx_stop() or furi_hal_infrared_async_tx_wait_termination()) has to be called to wait end of transmission and free resources.

Parameters
[in]freqfrequency for PWM
[in]duty_cycleduty cycle for PWM

◆ furi_hal_infrared_async_tx_stop()

void furi_hal_infrared_async_tx_stop ( void )

Stop IR asynchronous transmission and free resources.

Transmission will stop as soon as transmission reaches end of package (FuriHalInfraredTxGetDataStateDone or FuriHalInfraredTxGetDataStateLastDone).

◆ furi_hal_infrared_async_tx_wait_termination()

void furi_hal_infrared_async_tx_wait_termination ( void )

Wait for end of IR asynchronous transmission and free resources.

Transmission will stop as soon as transmission reaches end of transmission (FuriHalInfraredTxGetDataStateLastDone).

◆ furi_hal_infrared_detect_tx_output()

FuriHalInfraredTxPin furi_hal_infrared_detect_tx_output ( void )

Detect which pin has an external IR module connected.

External IR modules are detected by enabling a weak pull-up on supported pins and testing whether the input is still low.

This method works best on modules that employ a FET with a strong pull-down or a BJT for driving IR LEDs.

The module MUST pull the input voltage down to at least 0.9V or lower in order for it to be detected.

If no module has been detected, FuriHalInfraredTxPinInternal is returned.

Returns
numeric identifier of the first pin with a module detected.

◆ furi_hal_infrared_is_busy()

bool furi_hal_infrared_is_busy ( void )

Check if INFRARED is in use now.

Returns
true if INFRARED is busy, false otherwise.

◆ furi_hal_infrared_set_tx_output()

void furi_hal_infrared_set_tx_output ( FuriHalInfraredTxPin tx_pin)

Set which pin will be used to transmit infrared signals.

Parameters
[in]tx_pinpin to be used for signal transmission.