2021-05-18 10:51:00 +00:00
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signature of callback function for receiving continuous IRDA rx signal.
|
|
|
|
*
|
2021-07-16 16:43:54 +00:00
|
|
|
* @param ctx[in] - context to pass to callback
|
|
|
|
* @param level[in] - level of input IRDA rx signal
|
|
|
|
* @param duration[in] - duration of continuous rx signal level in us
|
2021-05-18 10:51:00 +00:00
|
|
|
*/
|
2021-07-16 16:43:54 +00:00
|
|
|
typedef void (*ApiHalIrdaCaptureCallback)(void* ctx, bool level, uint32_t duration);
|
2021-05-18 10:51:00 +00:00
|
|
|
|
2021-07-16 16:43:54 +00:00
|
|
|
/**
|
|
|
|
* Signature of callback function for reaching silence timeout on IRDA port.
|
|
|
|
*
|
|
|
|
* @param ctx[in] - context to pass to callback
|
|
|
|
*/
|
|
|
|
typedef void (*ApiHalIrdaTimeoutCallback)(void* ctx);
|
2021-05-18 10:51:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize IRDA RX timer to receive interrupts.
|
|
|
|
* It provides interrupts for every RX-signal edge changing
|
|
|
|
* with its duration.
|
|
|
|
*/
|
|
|
|
void api_hal_irda_rx_irq_init(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deinitialize IRDA RX interrupt.
|
|
|
|
*/
|
|
|
|
void api_hal_irda_rx_irq_deinit(void);
|
|
|
|
|
2021-07-16 16:43:54 +00:00
|
|
|
/** Setup api hal for receiving silence timeout.
|
|
|
|
* Should be used with 'api_hal_irda_timeout_irq_set_callback()'.
|
|
|
|
*
|
|
|
|
* @param[in] timeout_ms - time to wait for silence on IRDA port
|
|
|
|
* before generating IRQ.
|
|
|
|
*/
|
|
|
|
void api_hal_irda_rx_timeout_irq_init(uint32_t timeout_ms);
|
|
|
|
|
2021-05-18 10:51:00 +00:00
|
|
|
/**
|
|
|
|
* Setup callback for previously initialized IRDA RX interrupt.
|
|
|
|
*
|
2021-07-16 16:43:54 +00:00
|
|
|
* @param[in] callback - callback to call when RX signal edge changing occurs
|
|
|
|
* @param[in] ctx - context for callback
|
|
|
|
*/
|
|
|
|
void api_hal_irda_rx_irq_set_callback(ApiHalIrdaCaptureCallback callback, void *ctx);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup callback for reaching silence timeout on IRDA port.
|
|
|
|
* Should setup api hal with 'api_hal_irda_setup_rx_timeout_irq()' first.
|
|
|
|
*
|
|
|
|
* @param[in] callback - callback for silence timeout
|
|
|
|
* @param[in] ctx - context to pass to callback
|
2021-05-18 10:51:00 +00:00
|
|
|
*/
|
2021-07-16 16:43:54 +00:00
|
|
|
void api_hal_irda_rx_timeout_irq_set_callback(ApiHalIrdaTimeoutCallback callback, void *ctx);
|
2021-05-18 10:51:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Start generating IRDA TX PWM. Provides PWM initialization on
|
|
|
|
* defined frequency.
|
|
|
|
*
|
2021-07-16 16:43:54 +00:00
|
|
|
* @param[in] duty_cycle - duty cycle
|
|
|
|
* @param[in] freq - PWM frequency to generate
|
2021-05-18 10:51:00 +00:00
|
|
|
*/
|
|
|
|
void api_hal_irda_pwm_set(float duty_cycle, float freq);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop generating IRDA PWM signal.
|
|
|
|
*/
|
|
|
|
void api_hal_irda_pwm_stop();
|
|
|
|
|
2021-06-09 13:04:49 +00:00
|
|
|
/**
|
|
|
|
* Check if IRDA is in use now.
|
|
|
|
* @return false - IRDA is busy, true otherwise.
|
|
|
|
*/
|
|
|
|
bool api_hal_irda_rx_irq_is_busy(void);
|
|
|
|
|
2021-05-18 10:51:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|