#ifndef _HAL_H_
#define _HAL_H_

#include "stdint.h"
#include "stdbool.h"

typedef enum
{
    I2C_PORT_1 = 0,
    I2C_PORT_2,
    I2C_PORT_3,
    I2C_PORT_4,
    I2C_PORT_5
}eI2CPort;

// I2C 操作模式
typedef enum {
    I2C_MODE_POLLING = 0,
    I2C_MODE_DMA
} I2C_ReadMode;

typedef enum{
    I2C_TRANSFER_BUSY = 0,
    I2C_TRANSFER_DONE,
    I2C_TRANSFER_ERROR
}I2C_Transfer_Status;

#pragma pack(1)
typedef struct
{
    uint16_t    header;     ///< 数据头
    uint8_t     rev;        ///< 预留，固定为0x03
    uint8_t     cmd;        ///< 命令
    uint8_t     para[5];    ///< 参数
    uint16_t    checkSum;   ///< checksum
}finger_cmd;
#pragma pack()

typedef struct{
    uint8_t port;           ///< 使用哪个iic接口
    uint8_t step;
    finger_cmd  cmd;
    
    I2C_Transfer_Status (*write)(uint8_t port, uint32_t addr, uint8_t *data, uint16_t size);
    I2C_Transfer_Status (*read)(uint8_t port, uint32_t addr, uint8_t *data, uint16_t size);

    void (*delayMs)(uint32_t ms);///< ms延时
    uint32_t (*getTimeMs)(void);///< 读取当前时间戳，ms
} I2C_PlatformInterface_t;


extern bool I2C_Init(uint8_t port, I2C_PlatformInterface_t *com);

#endif

