Edit online

数据结构设计

struct aic_ir {
    spinlock_t      ir_lock;
    struct rc_dev   *rc;
    void __iomem    *base;
    struct clk      *clk;
    struct reset_control *rst;
    const char      *map_name;        /*CIR 模块使用的 scancode 映射表*/
    unsigned int    tx_duty;      /*发送红外信号时的占空比*/
    int             irq;
    u32             rx_level;             /*指示空闲状态下 RX 的电平状态*/
    u8              rx_flag;              /*指示 RXFIFO 中是否已接收到数据*/
};

driver 层数据结构

typedef struct aic_cir
{
    struct rt_device    dev;
    aic_cir_ctrl_t      aic_cir_ctrl;
    cir_config_t        config;
} aic_cir_t;

hal 层数据结构

typedef enum {
    CIR_EVENT_RECEIVE_COMPLETE,
    CIR_EVENT_ERROR,
} cir_event_t;

typedef struct aic_cir_ctrl aic_cir_ctrl_t;
struct aic_cir_ctrl {
    unsigned long       cir_base;
    uint8_t             irq_num;
    uint8_t             clk_idx;
    void (*callback)(aic_cir_ctrl_t *aic_cir_ctrl, cir_event_t event,
                     void *arg);
    void                *arg;
    uint8_t             tx_data[128];
    uint8_t             rx_data[128];
    uint32_t            rx_idx;
    uint8_t             rx_level;
    uint8_t             rx_flag; /* Indicates if rxfifo has received data */
};