bl_mcu_sdk/drivers/lhal/include/bflb_ir.h
jzlv a77b0dc866 [update][lhal] update lhal
* update lhal api comments
* add cam driver
* add efuse driver
* add iso11898 driver
2022-12-21 20:20:40 +08:00

375 lines
8.7 KiB
C

#ifndef _BFLB_IR_H
#define _BFLB_IR_H
#include "bflb_core.h"
/** @addtogroup LHAL
* @{
*/
/** @addtogroup IR
* @{
*/
#if !defined(BL616)
/** @defgroup IR_TX_MODE ir tx mode definition
* @{
*/
#define IR_TX_NEC 0
#define IR_TX_RC5 1
#define IR_TX_SWM 2
#define IR_TX_CUSTOMIZE 3
/**
* @}
*/
/** @defgroup IR_TX_FIFO_WIDTH ir tx fifo width valid width definition
* @{
*/
#if !defined(BL602) && !defined(BL702)
#define IR_TX_FIFO_WIDTH_8BIT 0
#define IR_TX_FIFO_WIDTH_16BIT 1
#define IR_TX_FIFO_WIDTH_24BIT 2
#endif
#define IR_TX_FIFO_WIDTH_32BIT 3
/**
* @}
*/
/** @defgroup IR_TX_INTEN ir tx interrupt enable definition
* @{
*/
#define IR_TX_INTEN_END (1 << 0)
#if !defined(BL602) && !defined(BL702)
#define IR_TX_INTEN_FIFO (1 << 1)
#define IR_TX_INTEN_FER (1 << 2)
#endif
/**
* @}
*/
/** @defgroup IR_TX_INTSTS ir tx interrupt status definition
* @{
*/
#define IR_TX_INTSTS_END (1 << 0)
#if !defined(BL602) && !defined(BL702)
#define IR_TX_INTSTS_FIFO (1 << 1)
#define IR_TX_INTSTS_FER (1 << 2)
#endif
/**
* @}
*/
#endif
#if !defined(BL702L)
/** @defgroup IR_RX_MODE ir rx mode definition
* @{
*/
#define IR_RX_NEC 0
#define IR_RX_RC5 1
#define IR_RX_SWM 2
/**
* @}
*/
/** @defgroup IR_RX_INTEN ir rx interrupt enable definition
* @{
*/
#define IR_RX_INTEN_END (1 << 0)
#if !defined(BL602) && !defined(BL702)
#define IR_RX_INTEN_FIFO (1 << 1)
#define IR_RX_INTEN_FER (1 << 2)
#endif
/**
* @}
*/
/** @defgroup IR_RX_INTSTS ir rx interrupt status definition
* @{
*/
#define IR_RX_INTSTS_END (1 << 0)
#if !defined(BL602) && !defined(BL702)
#define IR_RX_INTSTS_FIFO (1 << 1)
#define IR_RX_INTSTS_FER (1 << 2)
#endif
/**
* @}
*/
#endif
#if !defined(BL616)
/**
* @brief IR TX configuration structure
*
* @param tx_mode TX mode select,NEC protocol/RC-5 protocol/software mode/customize
* @param data_bits Bit count of data phase (don't care if tx freerun mode is enabled)
* @param tail_inverse Enable or disable signal of tail pulse inverse (don't care if SWM is enabled)
* @param tail_enable Enable or disable signal of tail pulse (don't care if SWM is enabled)
* @param head_inverse Enable or disable signal of head pulse inverse (don't care if SWM is enabled)
* @param head_enable Enable or disable signal of head pulse (don't care if SWM is enabled)
* @param logic1_inverse Enable or disable signal of logic 1 pulse inverse (don't care if SWM is enabled)
* @param logic0_inverse Enable or disable signal of logic 0 pulse inverse (don't care if SWM is enabled)
* @param data_enable Enable or disable signal of data pulse (don't care if SWM is enabled)
* @param swm_enable Enable or disable software mode(SWM)
* @param output_modulation Enable or disable signal of output modulation
* @param output_inverse Enable or disable signal of output inverse,0:output stays at low during idle state,1:stay at high
* @param freerun_enable Enable or disable tx freerun mode (don't care if SWM is enabled)
* @param continue_enable Disable:idle time between frames = (tailPulseWidth_0+tailPulseWidth_1)*pulseWidthUnit,Enable:no idle time between frames
* @param fifo_width IR frame size(also the valid width for each fifo entry)
* @param fifo_threshold TX FIFO threshold
* @param logic0_pulse_width_1 Pulse width of logic 0 pulse phase 1 (don't care if SWM is enabled)
* @param logic0_pulse_width_0 Pulse width of logic 0 pulse phase 0 (don't care if SWM is enabled)
* @param logic1_pulse_width_1 Pulse width of logic 1 pulse phase 1 (don't care if SWM is enabled)
* @param logic1_pulse_width_0 Pulse width of logic 1 pulse phase 0 (don't care if SWM is enabled)
* @param head_pulse_width_1 Pulse width of head pulse phase 1 (don't care if SWM is enabled)
* @param head_pulse_width_0 Pulse width of head pulse phase 0 (don't care if SWM is enabled)
* @param tail_pulse_width_1 Pulse width of tail pulse phase 1 (don't care if SWM is enabled)
* @param tail_pulse_width_0 Pulse width of tail pulse phase 0 (don't care if SWM is enabled)
* @param modu_width_1 Modulation phase 1 width
* @param modu_width_0 Modulation phase 0 width
* @param pulse_width_unit Pulse width unit
*/
struct bflb_ir_tx_config_s {
uint8_t tx_mode;
uint8_t data_bits;
uint8_t tail_inverse;
uint8_t tail_enable;
uint8_t head_inverse;
uint8_t head_enable;
uint8_t logic1_inverse;
uint8_t logic0_inverse;
uint8_t data_enable;
uint8_t swm_enable;
uint8_t output_modulation;
uint8_t output_inverse;
uint8_t freerun_enable;
uint8_t continue_enable;
uint8_t fifo_width;
uint8_t fifo_threshold;
uint8_t logic0_pulse_width_1;
uint8_t logic0_pulse_width_0;
uint8_t logic1_pulse_width_1;
uint8_t logic1_pulse_width_0;
uint8_t head_pulse_width_1;
uint8_t head_pulse_width_0;
uint8_t tail_pulse_width_1;
uint8_t tail_pulse_width_0;
uint8_t modu_width_1;
uint8_t modu_width_0;
uint16_t pulse_width_unit;
};
#endif
#if !defined(BL702L)
/**
* @brief IR RX configuration structure
*
* @param rx_mode RX mode select,NEC protocol/RC-5 protocol/software mode
* @param input_inverse Enable or disable signal of input inverse
* @param deglitch_enable Enable or disable signal of rx input de-glitch function
* @param deglitch_cnt De-glitch function cycle count
* @param data_threshold Pulse width threshold for logic 0/1 detection (don't care if SWM is enabled)
* @param end_threshold Pulse width threshold to trigger end condition
* @param fifo_threshold RX FIFO threshold
*/
struct bflb_ir_rx_config_s {
uint8_t rx_mode;
uint8_t input_inverse;
uint8_t deglitch_enable;
uint8_t deglitch_cnt;
uint16_t data_threshold;
uint16_t end_threshold;
uint16_t fifo_threshold;
};
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(BL616)
/**
* @brief
*
* @param [in] dev
* @param [in] config
*/
void bflb_ir_tx_init(struct bflb_device_s *dev, const struct bflb_ir_tx_config_s *config);
/**
* @brief
*
* @param [in] dev
* @param [in] data
* @param [in] length
*/
void bflb_ir_send(struct bflb_device_s *dev, uint32_t *data, uint32_t length);
/**
* @brief
*
* @param [in] dev
* @param [in] data
* @param [in] length
*/
void bflb_ir_swm_send(struct bflb_device_s *dev, uint16_t *data, uint8_t length);
/**
* @brief
*
* @param [in] dev
* @param [in] enable
*/
void bflb_ir_tx_enable(struct bflb_device_s *dev, bool enable);
/**
* @brief
*
* @param [in] dev
* @param [in] int_type
* @param [in] mask
*/
void bflb_ir_txint_mask(struct bflb_device_s *dev, uint8_t int_type, bool mask);
/**
* @brief
*
* @param [in] dev
* @return uint32_t
*/
uint32_t bflb_ir_get_txint_status(struct bflb_device_s *dev);
/**
* @brief
*
* @param [in] dev
*/
void bflb_ir_txint_clear(struct bflb_device_s *dev);
#if !defined(BL602) && !defined(BL702)
/**
* @brief
*
* @param [in] dev
* @param [in] enable
*/
void bflb_ir_link_txdma(struct bflb_device_s *dev, bool enable);
/**
* @brief
*
* @param [in] dev
* @return uint8_t
*/
uint8_t bflb_ir_get_txfifo_cnt(struct bflb_device_s *dev);
/**
* @brief
*
* @param [in] dev
*/
void bflb_ir_txfifo_clear(struct bflb_device_s *dev);
#endif
#endif
#if !defined(BL702L)
/**
* @brief
*
* @param [in] dev
* @param [in] config
*/
void bflb_ir_rx_init(struct bflb_device_s *dev, const struct bflb_ir_rx_config_s *config);
/**
* @brief
*
* @param [in] dev
* @param [in] data
* @return uint8_t
*/
uint8_t bflb_ir_receive(struct bflb_device_s *dev, uint64_t *data);
/**
* @brief
*
* @param [in] dev
* @param [in] data
* @param [in] length
* @return uint8_t
*/
uint8_t bflb_ir_swm_receive(struct bflb_device_s *dev, uint16_t *data, uint8_t length);
/**
* @brief
*
* @param [in] dev
* @param [in] enable
*/
void bflb_ir_rx_enable(struct bflb_device_s *dev, bool enable);
/**
* @brief
*
* @param [in] dev
* @return uint8_t
*/
uint8_t bflb_ir_get_rxfifo_cnt(struct bflb_device_s *dev);
/**
* @brief
*
* @param [in] dev
*/
void bflb_ir_rxfifo_clear(struct bflb_device_s *dev);
/**
* @brief
*
* @param [in] dev
* @param [in] int_type
* @param [in] mask
*/
void bflb_ir_rxint_mask(struct bflb_device_s *dev, uint8_t int_type, bool mask);
/**
* @brief
*
* @param [in] dev
* @return uint32_t
*/
uint32_t bflb_ir_get_rxint_status(struct bflb_device_s *dev);
/**
* @brief
*
* @param [in] dev
*/
void bflb_ir_rxint_clear(struct bflb_device_s *dev);
#endif
/**
* @brief
*
* @param [in] dev
* @param [in] cmd
* @param [in] arg
* @return int
*/
int bflb_ir_feature_control(struct bflb_device_s *dev, int cmd, size_t arg);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
/**
* @}
*/
#endif