DemoPublic/MCU/DevDriverDemo/Device.h

72 lines
1.8 KiB
C

/**
* @file Device.h
* @author Rick Chan
* @brief
* @version 0.1
* @date 2020-04-01
*
* @copyright Copyright (c) 2020
*
*/
#ifndef DEVICE_H
#define DEVICE_H
#include "Type.h"
typedef enum DEVID
{
EC_DEV_FST = -1,
EC_DEV_DEMO00 = 0,
EC_DEV_DEMO01 = 1,
EC_DEV_DEMO10 = 2,
EC_DEV_DEMO11 = 3,
EC_DEV_END
}EU_DEVID;
typedef void (*IntHdl)(uint32_t id, void* arg);
typedef enum PW_LEVEL
{
EC_PW_S0, // Normal
EC_PW_S1, // Sleep
EC_PW_S2, // Stop
EC_PW_S3, // Standby
EC_PW_S4, // Poweroff
}EU_PW_LEVEL;
typedef struct DEVICE
{
uint32_t Opened;
EU_ERR (*Init)(struct DEVICE*); // Unnecessary
EU_ERR (*Open)(struct DEVICE*); // Necessary
void (*Close)(struct DEVICE*); // Unnecessary
int64_t (*Read)(struct DEVICE*, void*, void*, int64_t, uint32_t); // Unnecessary
int64_t (*Write)(struct DEVICE*, void*, void*, int64_t, uint32_t); // Unnecessary
int (*Seek)(struct DEVICE*, int); // Unnecessary
EU_ERR (*IOCtl)(struct DEVICE*, uint32_t, void*, void*); // Unnecessary
EU_ERR (*PwCtl)(struct DEVICE*, EU_PW_LEVEL); // Unnecessary
EU_ERR (*EnInt)(struct DEVICE*, void*, IntHdl, void*); // Unnecessary
EU_ERR (*DisInt)(struct DEVICE*, void*); // Unnecessary
void* Prv; // Unnecessary
}ST_DEVICE;
void DevInit(void);
EU_ERR DevOpen(EU_DEVID id);
void DevClose(EU_DEVID id);
int64_t DevRead(EU_DEVID id, void* ex, void* buf, int64_t nbytes, uint32_t timeout);
int64_t DevWrite(EU_DEVID id, void* ex, void* buf, int64_t nbytes, uint32_t timeout);
EU_ERR DevIOCtl(EU_DEVID id, uint32_t ctl, void* ex, void* data);
EU_ERR DevPwCtl(EU_DEVID id, EU_PW_LEVEL level);
EU_ERR DevEnInt(EU_DEVID id, void* ex, IntHdl handle, void* arg);
EU_ERR DevDisInt(EU_DEVID id, void* ex);
typedef enum IOCTL
{
EC_IOCTL_DEMO_CTL0,
EC_IOCTL_DEMO_CTL1,
EC_IOCTL_DEM1_CTL1
}EU_IOCTL;
#endif // DEVICE_H