first
This commit is contained in:
38
include_lib/system/device/adkey.h
Normal file
38
include_lib/system/device/adkey.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef DEVICE_ADKEY_H
|
||||
#define DEVICE_ADKEY_H
|
||||
|
||||
#include "typedef.h"
|
||||
#include "asm/adc_api.h"
|
||||
|
||||
|
||||
#define ADKEY_MAX_NUM 10
|
||||
|
||||
struct adkey_platform_data {
|
||||
u8 enable;
|
||||
u8 adkey_pin;
|
||||
u8 extern_up_en; //是否用外部上拉,1:用外部上拉, 0:用内部上拉10K
|
||||
u32 ad_channel;
|
||||
u16 ad_value[ADKEY_MAX_NUM];
|
||||
u8 key_value[ADKEY_MAX_NUM];
|
||||
};
|
||||
|
||||
struct adkey_rtcvdd_platform_data {
|
||||
u8 enable;
|
||||
u8 adkey_pin;
|
||||
u8 adkey_num;
|
||||
u32 ad_channel;
|
||||
u32 extern_up_res_value; //是否用外部上拉,1:用外部上拉, 0:用内部上拉10K
|
||||
u16 res_value[ADKEY_MAX_NUM]; //电阻值, 从 [大 --> 小] 配置
|
||||
u8 key_value[ADKEY_MAX_NUM];
|
||||
};
|
||||
|
||||
//ADKEY API:
|
||||
extern int adkey_init(const struct adkey_platform_data *adkey_data);
|
||||
extern u8 ad_get_key_value(void);
|
||||
|
||||
//RTCVDD ADKEY API:
|
||||
extern int adkey_rtcvdd_init(const struct adkey_rtcvdd_platform_data *rtcvdd_adkey_data);
|
||||
extern u8 adkey_rtcvdd_get_key_value(void);
|
||||
|
||||
#endif
|
||||
|
||||
83
include_lib/system/device/device.h
Normal file
83
include_lib/system/device/device.h
Normal file
@ -0,0 +1,83 @@
|
||||
#ifndef CHRDEV_H
|
||||
#define CHRDEV_H
|
||||
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
//#include "generic/ioctl.h"
|
||||
#include "generic/atomic.h"
|
||||
//#include "sys/task.h"
|
||||
#include "device/ioctl_cmds.h"
|
||||
|
||||
|
||||
struct dev_node;
|
||||
struct device;
|
||||
|
||||
|
||||
/**@struct device_operations
|
||||
* @brief device_operations结构体 \n
|
||||
* otg设备执行哪种类型的操作
|
||||
*/
|
||||
struct device_operations {
|
||||
bool (*online)(const struct dev_node *node); ///<设备在线状态查询
|
||||
int (*init)(const struct dev_node *node, void *); ///<设备初始化
|
||||
int (*open)(const char *name, struct device **device, void *arg); ///<设备开启
|
||||
int (*read)(struct device *device, void *buf, u32 len, u32); ///<读操作
|
||||
int (*write)(struct device *device, void *buf, u32 len, u32); ///<写操作
|
||||
int (*seek)(struct device *device, u32 offset, int orig); ///<设备搜索
|
||||
int (*ioctl)(struct device *device, u32 cmd, u32 arg); ///<I/O控制
|
||||
int (*close)(struct device *device); ///<设备关闭
|
||||
};
|
||||
|
||||
struct dev_node {
|
||||
const char *name;
|
||||
const struct device_operations *ops;
|
||||
void *priv_data;
|
||||
};
|
||||
|
||||
|
||||
struct device {
|
||||
atomic_t ref;
|
||||
void *private_data;
|
||||
const struct device_operations *ops;
|
||||
void *platform_data;
|
||||
void *driver_data;
|
||||
};
|
||||
|
||||
|
||||
#define REGISTER_DEVICE(node) \
|
||||
const struct dev_node node sec(.device)
|
||||
|
||||
#define REGISTER_DEVICES(node) \
|
||||
const struct dev_node node[] sec(.device)
|
||||
|
||||
|
||||
int devices_init();
|
||||
|
||||
bool dev_online(const char *name);
|
||||
|
||||
void *dev_open(const char *name, void *arg);
|
||||
|
||||
|
||||
int dev_read(void *device, void *buf, u32 len);
|
||||
|
||||
|
||||
int dev_write(void *device, void *buf, u32 len);
|
||||
|
||||
|
||||
int dev_seek(void *device, u32 offset, int orig);
|
||||
|
||||
|
||||
int dev_ioctl(void *device, int cmd, u32 arg);
|
||||
|
||||
|
||||
int dev_close(void *device);
|
||||
|
||||
|
||||
int dev_bulk_read(void *_device, void *buf, u32 offset, u32 len);
|
||||
|
||||
int dev_bulk_write(void *_device, void *buf, u32 offset, u32 len);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
190
include_lib/system/device/device_drive.h
Normal file
190
include_lib/system/device/device_drive.h
Normal file
@ -0,0 +1,190 @@
|
||||
#ifndef __DEVICE_DRIVE_H__
|
||||
#define __DEVICE_DRIVE_H__
|
||||
|
||||
#include "typedef.h"
|
||||
#include "errno-base.h"
|
||||
#include "ioctl.h"
|
||||
|
||||
#ifndef __UBOOT
|
||||
|
||||
#ifndef _MANGO_OS_
|
||||
#define _MANGO_OS_
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _MANGO_OS_
|
||||
#include "os/os_api.h"
|
||||
#else
|
||||
|
||||
|
||||
#ifndef __UBOOT
|
||||
|
||||
#ifndef _WIN_DEBUG_
|
||||
#define _WIN_DEBUG_
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _WIN_DEBUG_
|
||||
#include <pthread.h>
|
||||
typedef pthread_mutex_t OS_MUTEX;
|
||||
typedef u32 OS_ERR;
|
||||
#define OS_ERR_NONE 0
|
||||
|
||||
#else
|
||||
typedef u32 OS_MUTEX, OS_ERR;
|
||||
#define OS_ERR_NONE 0
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dev_mutex {
|
||||
OS_MUTEX *write_mutex;
|
||||
OS_MUTEX *read_mutex;
|
||||
};
|
||||
typedef enum _dev_type {
|
||||
|
||||
DEV_SDCRAD_0 = 0X10,
|
||||
DEV_SDCRAD_1,
|
||||
DEV_SDCRAD_2,
|
||||
|
||||
DEV_UDISK_H0,
|
||||
DEV_UDISK_H1,
|
||||
DEV_UDISK_F0,
|
||||
|
||||
DEV_NOR_FLASH,
|
||||
DEV_NAND_FLASH,
|
||||
|
||||
DEV_STORAGE = 0x100,
|
||||
DEV_LOGIC_DISK = 0x101,
|
||||
DEV_USB_SLAVE,
|
||||
DEV_USB_HOST,
|
||||
DEV_HID = 0x200,
|
||||
DEV_NET,
|
||||
DEV_AUDIO,
|
||||
DEV_ISP,
|
||||
} dev_type;
|
||||
|
||||
// struct partition_table
|
||||
// {
|
||||
// int partition_addr;
|
||||
// int partition_size;
|
||||
// };
|
||||
typedef struct DEV_IO {
|
||||
const char name[8];
|
||||
s32(*mount)(void *volatile parm);
|
||||
s32(*unmount)();
|
||||
s32(*read)(u8 *volatile buf, u32 addr, u32 len);
|
||||
s32(*write)(u8 *volatile buf, u32 addr, u32 len);
|
||||
s32(*ioctrl)(void *volatile parm, u32 cmd);
|
||||
s32(*power)(u32 mod);
|
||||
s32(*detect)(); //设备状态检测
|
||||
|
||||
struct dev_mutex *mutex;
|
||||
dev_type device_type;
|
||||
|
||||
void *private_data;//设备私有属性,用来提供额外接口或者存储一些设备的特性
|
||||
} dev_io_t;
|
||||
|
||||
|
||||
|
||||
//设备状态:
|
||||
typedef enum dev_sta {
|
||||
DEV_OFFLINE = 0, //--0 设备从在线切换到离线。
|
||||
DEV_ONLINE = 1, //---1 设备从离线切换到在线。
|
||||
DEV_HOLD = 2, //---2 其他值表示设备状态未改变。
|
||||
|
||||
DEV_POWER_ON = 0x10, // 0x10 – 开机
|
||||
DEV_POWER_OFF, // 0x11 -关机
|
||||
DEV_POWER_STANDBY, // 0x12 -待机
|
||||
DEV_POWER_WAKEUP, // 0x13- 唤醒
|
||||
} DEV_STA;
|
||||
//设备错误代码:
|
||||
typedef enum dev_err {
|
||||
DEV_ERR_NONE = 0,
|
||||
DEV_ERR_NOT_MOUNT,
|
||||
DEV_ERR_OVER_CAPACITY,
|
||||
|
||||
DEV_ERR_UNKNOW_CLASS,
|
||||
|
||||
DEV_ERR_NOT_READY,//设备已经在线,但是没初始化完成
|
||||
DEV_ERR_LUN,
|
||||
|
||||
DEV_ERR_TIMEOUT,
|
||||
DEV_ERR_CMD_TIMEOUT,
|
||||
DEV_ERR_READ_TIMEOUT,//0x08
|
||||
DEV_ERR_WRITE_TIMEOUT,
|
||||
|
||||
DEV_ERR_OFFLINE,//0x0a
|
||||
|
||||
DEV_ERR_CRC,
|
||||
DEV_ERR_CMD_CRC,
|
||||
DEV_ERR_READ_CRC,
|
||||
DEV_ERR_WRITE_CRC,
|
||||
|
||||
DEV_ERR_CONTROL_STALL,
|
||||
DEV_ERR_RXSTALL,//0x10
|
||||
DEV_ERR_TXSTALL,
|
||||
DEV_ERR_CONTROL,
|
||||
|
||||
DEV_ERR_NOT_STORAGE,
|
||||
DEV_ERR_INVALID_PATH,
|
||||
DEV_ERR_INVALID_DATA,
|
||||
DEV_ERR_OUTOFMEMORY,
|
||||
DEV_ERR_HANDLE_FREE,
|
||||
DEV_ERR_INVALID_HANDLE,//24
|
||||
DEV_ERR_INVALID_BUF,
|
||||
DEV_ERR_INUSE,
|
||||
DEV_ERR_NO_READ,
|
||||
DEV_ERR_NO_WRITE,
|
||||
DEV_ERR_NO_IOCTL,
|
||||
DEV_ERR_NO_POWER,
|
||||
DEV_ERR_NOT_EXIST,
|
||||
DEV_ERR_UNKNOW,
|
||||
} DEV_ERR;
|
||||
|
||||
|
||||
#define DEV_GENERAL_MAGIC 0xe0
|
||||
//每个设备必须支持的命令
|
||||
#define DEV_GET_STATUS _IOR(DEV_GENERAL_MAGIC,0xe0,u32) //获取设备状态,在线、离线、power_on、power_off、standby、……
|
||||
//设备不支持下面命令时返回 -ENOTTY
|
||||
#define DEV_GET_BLOCK_SIZE _IOR(DEV_GENERAL_MAGIC,0xe1,u32) //获取存储设备的块大小
|
||||
#define DEV_GET_BLOCK_NUM _IOR(DEV_GENERAL_MAGIC,0xe2,u32) //获取存储设备的块总数
|
||||
#define DEV_GET_DEV_ID _IOR(DEV_GENERAL_MAGIC,0xe3,u32) //获取设备的ID。SD/TF 卡返回“sdtf”(0x73647466)
|
||||
#define DEV_SECTOR_ERASE _IOW(DEV_GENERAL_MAGIC,0xe4,u32) //设备页擦除
|
||||
#define DEV_BLOCK_ERASE _IOW(DEV_GENERAL_MAGIC,0xe5,u32) //设备块擦除
|
||||
#define DEV_CHIP_ERASE _IOW(DEV_GENERAL_MAGIC,0xe6,u32) //设备擦除
|
||||
#define DEV_GET_TYPE _IOR(DEV_GENERAL_MAGIC,0xe7,u32) //返回设备的dev_type
|
||||
#define DEV_CHECK_WPSTA _IOR(DEV_GENERAL_MAGIC,0xe8,u32) //检测设备写保护状态,当参数为-1的时候返回设备的写包含状态,0的时候解除写保护,1的时候加上写保护
|
||||
|
||||
#define typecheck(type,x) \
|
||||
({ type __dummy; \
|
||||
typeof(x) __dummy2; \
|
||||
(void)(&__dummy == &__dummy2); \
|
||||
1; \
|
||||
})
|
||||
#ifndef time_after
|
||||
#define time_after(a,b) (typecheck(u32, a) && \
|
||||
typecheck(u32, b) && \
|
||||
((s32)(b) - (s32)(a) < 0))
|
||||
#endif
|
||||
|
||||
#ifndef time_before
|
||||
#define time_before(a,b) time_after(b,a)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
32
include_lib/system/device/includes.h
Normal file
32
include_lib/system/device/includes.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef DEVICE_INCLUDES_H
|
||||
#define DEVICE_INCLUDES_H
|
||||
|
||||
|
||||
|
||||
|
||||
#include "device.h"
|
||||
#include "ioctl_cmds.h"
|
||||
|
||||
#include "key_driver.h"
|
||||
#include "iokey.h"
|
||||
#include "irkey.h"
|
||||
#include "adkey.h"
|
||||
#include "slidekey.h"
|
||||
#include "touch_key.h"
|
||||
#include "rdec_key.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
85
include_lib/system/device/ioctl_cmds.h
Normal file
85
include_lib/system/device/ioctl_cmds.h
Normal file
@ -0,0 +1,85 @@
|
||||
#ifndef IOCTL_INF_H
|
||||
#define IOCTL_INF_H
|
||||
|
||||
|
||||
|
||||
|
||||
#define IOCTL_SET_IRQ_NUM 1
|
||||
#define IOCTL_SET_PRIORITY 2
|
||||
#define IOCTL_SET_DATA_WIDTH 3
|
||||
#define IOCTL_SET_SPEED 4
|
||||
#define IOCTL_SET_DETECT_MODE 5
|
||||
#define IOCTL_SET_DETECT_FUNC 6
|
||||
#define IOCTL_SET_DETECT_TIME_INTERVAL 7
|
||||
#define IOCTL_SET_PORT 8
|
||||
#define IOCTL_SET_PORT_FUNC 9
|
||||
#define IOCTL_SET_CS_PORT_FUNC 10
|
||||
#define IOCTL_SET_READ_MODE 11
|
||||
#define IOCTL_SET_WRITE_MODE 12
|
||||
#define IOCTL_SET_WRITE_PROTECT 13
|
||||
#define IOCTL_SET_START_BIT 14
|
||||
#define IOCTL_SET_STOP_BIT 15
|
||||
#define IOCTL_FLUSH 16
|
||||
#define IOCTL_REGISTER_IRQ_HANDLER 17
|
||||
#define IOCTL_UNREGISTER_IRQ_HANDLER 18
|
||||
#define IOCTL_GET_SYS_TIME 19
|
||||
#define IOCTL_SET_SYS_TIME 20
|
||||
#define IOCTL_GET_ALARM 21
|
||||
#define IOCTL_SET_ALARM 22
|
||||
#define IOCTL_SET_CAP_LOWSPEED_CARD 23
|
||||
#define IOCTL_SET_VDD50_EN 30
|
||||
#define IOCTL_GET_WEEKDAY 32
|
||||
#define IOCTL_CLR_READ_MODE 33
|
||||
#define IOCTL_SET_READ_CRC 34
|
||||
#define IOCTL_GET_READ_CRC 35
|
||||
#define IOCTL_GET_VOLUME 36
|
||||
#define IOCTL_SET_VOLUME 37
|
||||
#define IOCTL_SET_ALARM_ENABLE 38
|
||||
#define IOCTL_CMD_RESUME 39
|
||||
#define IOCTL_CMD_SUSPEND 40
|
||||
#define IOCTL_SET_BASE_ADDR 41
|
||||
#define IOCTL_SET_ASYNC_MODE 42
|
||||
#define IOCTL_GET_SPEED 43
|
||||
#define IOCTL_SET_ACTIVE_STATUS 44
|
||||
#define IOCTL_POWER_RESUME 45
|
||||
#define IOCTL_POWER_SUSPEND 46
|
||||
|
||||
|
||||
#define IOCTL_GET_ID 100
|
||||
#define IOCTL_GET_SECTOR_SIZE 101
|
||||
#define IOCTL_GET_BLOCK_SIZE 102
|
||||
#define IOCTL_GET_CAPACITY 103
|
||||
#define IOCTL_GET_WIDTH 104
|
||||
#define IOCTL_GET_HEIGHT 105
|
||||
#define IOCTL_GET_BLOCK_NUMBER 106
|
||||
#define IOCTL_CHECK_WRITE_PROTECT 107
|
||||
#define IOCTL_GET_STATUS 108
|
||||
#define IOCTL_GET_TYPE 109
|
||||
#define IOCTL_GET_MAX_LUN 110
|
||||
#define IOCTL_GET_CUR_LUN 111
|
||||
#define IOCTL_SET_CUR_LUN 112
|
||||
#define IOCTL_SET_FORCE_RESET 113
|
||||
#define IOCTL_SET_CAPACITY 114
|
||||
|
||||
|
||||
#define IOCTL_ERASE_SECTOR 200
|
||||
#define IOCTL_ERASE_BLOCK 201
|
||||
#define IOCTL_ERASE_CHIP 202
|
||||
#define IOCTL_SET_ENC_END 203
|
||||
#define IOCTL_ERASE_PAGE 204
|
||||
#define IOCTL_SDMMC_ERASE 205
|
||||
|
||||
|
||||
#define IOCTL_SET_DATA_CALLBACK 301
|
||||
|
||||
#define IOCTL_GET_PART_INFO 320
|
||||
|
||||
struct ioctl_irq_handler {
|
||||
void *priv;
|
||||
void *handler;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
53
include_lib/system/device/iokey.h
Normal file
53
include_lib/system/device/iokey.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef DEVICE_IOKEY_H
|
||||
#define DEVICE_IOKEY_H
|
||||
|
||||
#include "typedef.h"
|
||||
#include "device/device.h"
|
||||
|
||||
|
||||
// enum key_connect_way {
|
||||
// ONE_PORT_TO_LOW, //按键一个端口接低电平, 另一个端口接IO
|
||||
// ONE_PORT_TO_HIGH, //按键一个端口接高电平, 另一个端口接IO
|
||||
// DOUBLE_PORT_TO_IO, //按键两个端口接IO
|
||||
// };
|
||||
|
||||
|
||||
#define ONE_PORT_TO_LOW 0 //按键一个端口接低电平, 另一个端口接IO
|
||||
#define ONE_PORT_TO_HIGH 1 //按键一个端口接高电平, 另一个端口接IO
|
||||
#define DOUBLE_PORT_TO_IO 2 //按键两个端口接IO
|
||||
#define CUST_DOUBLE_PORT_TO_IO 3
|
||||
|
||||
|
||||
struct one_io_key {
|
||||
u8 port;
|
||||
};
|
||||
|
||||
struct two_io_key {
|
||||
u8 in_port;
|
||||
u8 out_port;
|
||||
};
|
||||
|
||||
union key_type {
|
||||
struct one_io_key one_io;
|
||||
struct two_io_key two_io;
|
||||
};
|
||||
|
||||
struct iokey_port {
|
||||
union key_type key_type;
|
||||
u8 connect_way;
|
||||
u8 key_value;
|
||||
};
|
||||
|
||||
struct iokey_platform_data {
|
||||
u8 enable;
|
||||
u8 num;
|
||||
const struct iokey_port *port;
|
||||
};
|
||||
|
||||
//IOKEY API:
|
||||
extern int iokey_init(const struct iokey_platform_data *iokey_data);
|
||||
extern u8 io_get_key_value(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
15
include_lib/system/device/irkey.h
Normal file
15
include_lib/system/device/irkey.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef DEVICE_IRKEY_H
|
||||
#define DEVICE_IRKEY_H
|
||||
|
||||
#include "typedef.h"
|
||||
|
||||
struct irkey_platform_data {
|
||||
u8 enable;
|
||||
u8 port;
|
||||
};
|
||||
|
||||
extern u8 ir_get_key_value(void);
|
||||
extern int irkey_init(const struct irkey_platform_data *irkey_data);
|
||||
|
||||
#endif
|
||||
|
||||
70
include_lib/system/device/key_driver.h
Normal file
70
include_lib/system/device/key_driver.h
Normal file
@ -0,0 +1,70 @@
|
||||
#ifndef SYS_KEY_DRIVER_H
|
||||
#define SYS_KEY_DRIVER_H
|
||||
|
||||
#include "typedef.h"
|
||||
|
||||
|
||||
|
||||
typedef enum __KEY_DRIVER_TYPE {
|
||||
KEY_DRIVER_TYPE_IO = 0x0,
|
||||
KEY_DRIVER_TYPE_AD,
|
||||
KEY_DRIVER_TYPE_RTCVDD_AD,
|
||||
KEY_DRIVER_TYPE_IR,
|
||||
KEY_DRIVER_TYPE_TOUCH,
|
||||
KEY_DRIVER_TYPE_CTMU_TOUCH,
|
||||
KEY_DRIVER_TYPE_RDEC,
|
||||
KEY_DRIVER_TYPE_SLIDEKEY,
|
||||
KEY_DRIVER_TYPE_SOFTKEY,
|
||||
KEY_DRIVER_TYPE_BRIGHTNESS,
|
||||
KEY_DRIVER_TYPE_VOICE,
|
||||
|
||||
KEY_DRIVER_TYPE_MAX,
|
||||
} KEY_DRIVER_TYPE;
|
||||
|
||||
|
||||
|
||||
#define NO_KEY 0xff
|
||||
|
||||
|
||||
#define KEY_NOT_SUPPORT 0x01
|
||||
|
||||
|
||||
struct key_driver_para {
|
||||
const u32 scan_time; //按键扫描频率, 单位ms
|
||||
u8 last_key; //上一次get_value按键值
|
||||
//== 用于消抖类参数
|
||||
u8 filter_value; //用于按键消抖
|
||||
u8 filter_cnt; //用于按键消抖时的累加值
|
||||
const u8 filter_time; //当filter_cnt累加到base_cnt值时, 消抖有效
|
||||
//== 用于判定长按和HOLD事件参数
|
||||
const u8 long_time; //按键判定长按数量
|
||||
const u8 hold_time; //按键判定HOLD数量
|
||||
u8 press_cnt; //与long_time和hold_time对比, 判断long_event和hold_event
|
||||
//== 用于判定连击事件参数
|
||||
u8 click_cnt; //单击次数
|
||||
u8 click_delay_cnt; //按键被抬起后等待连击事件延时计数
|
||||
const u8 click_delay_time; ////按键被抬起后等待连击事件延时数量
|
||||
u8 notify_value; //在延时的待发送按键值
|
||||
u8 key_type;
|
||||
u8(*get_value)(void);
|
||||
};
|
||||
|
||||
//组合按键映射按键值
|
||||
struct key_remap {
|
||||
u8 bit_value;
|
||||
u8 remap_value;
|
||||
};
|
||||
|
||||
struct key_remap_data {
|
||||
u8 remap_num;
|
||||
const struct key_remap *table;
|
||||
};
|
||||
|
||||
// key_driver API:
|
||||
extern int key_driver_init(void);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
12
include_lib/system/device/rdec_key.h
Normal file
12
include_lib/system/device/rdec_key.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef RDEC_KEY_H
|
||||
#define RDEC_KEY_H
|
||||
|
||||
#include "typedef.h"
|
||||
|
||||
#include "asm/rdec.h"
|
||||
|
||||
int rdec_key_init(const struct rdec_platform_data *rdec_key_data);
|
||||
s8 get_rdec_rdat(int i);
|
||||
|
||||
#endif
|
||||
|
||||
31
include_lib/system/device/slidekey.h
Normal file
31
include_lib/system/device/slidekey.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef DEVICE_SLIDEKEY_H
|
||||
#define DEVICE_SLIDEKEY_H
|
||||
|
||||
#include "typedef.h"
|
||||
#include "device/device.h"
|
||||
#include "asm/adc_api.h"
|
||||
|
||||
|
||||
struct slidekey_port {
|
||||
u8 io;
|
||||
u8 io_up_en; //是否用外部上拉,1:用外部上拉, 0:用内部上拉10K
|
||||
u32 level;
|
||||
u32 ad_channel;
|
||||
int msg;
|
||||
};
|
||||
|
||||
struct slidekey_platform_data {
|
||||
u8 enable;
|
||||
u8 num;
|
||||
const struct slidekey_port *port;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//API:
|
||||
extern int slidekey_init(const struct slidekey_platform_data *slidekey_data);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
18
include_lib/system/device/tent600_key.h
Normal file
18
include_lib/system/device/tent600_key.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef DEVICE_TENT600_KEY_H
|
||||
#define DEVICE_TENT600_KEY_H
|
||||
#include "typedef.h"
|
||||
#include "asm/adc_api.h"
|
||||
|
||||
|
||||
struct tent600_key_platform_data {
|
||||
u8 enalbe;
|
||||
u8 tent600_key_pin;
|
||||
u8 extern_up_en;
|
||||
u32 ad_channel;
|
||||
};
|
||||
|
||||
|
||||
int tent600_key_init(const struct tent600_key_platform_data *tent600_key_data);
|
||||
u8 tent600_get_key_value(void);
|
||||
|
||||
#endif
|
||||
16
include_lib/system/device/touch_key.h
Normal file
16
include_lib/system/device/touch_key.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef DEVICE_TOUCH_KEY_H
|
||||
#define DEVICE_TOUCH_KEY_H
|
||||
|
||||
#include "typedef.h"
|
||||
#include "asm/plcnt.h"
|
||||
|
||||
/* =========== touch key API ============= */
|
||||
//触摸按键初始化
|
||||
int touch_key_init(const struct touch_key_platform_data *touch_key_data);
|
||||
|
||||
//获取触摸按键键值
|
||||
u8 touch_key_get_value(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
60
include_lib/system/device/vm.h
Normal file
60
include_lib/system/device/vm.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef _VM_H_
|
||||
#define _VM_H_
|
||||
|
||||
#include "ioctl.h"
|
||||
#include "device/device.h"
|
||||
|
||||
#define IOCTL_SET_VM_INFO _IOW('V', 1, 1)
|
||||
#define IOCTL_GET_VM_INFO _IOW('V', 2, 1)
|
||||
// enum {
|
||||
// #<{(|
|
||||
// * 用户自定义配置项 (0-64)
|
||||
// |)}>#
|
||||
// #<{(| ... |)}>#
|
||||
// }
|
||||
|
||||
// VM define and api
|
||||
typedef u16 vm_hdl;
|
||||
|
||||
struct vm_table {
|
||||
u16 index;
|
||||
u16 value_byte;
|
||||
int value; //cache value which value_byte <= 4
|
||||
};
|
||||
|
||||
typedef enum _vm_err {
|
||||
VM_ERR_NONE = 0,
|
||||
VM_INDEX_ERR = -0x100,
|
||||
VM_INDEX_EXIST, //0xFF
|
||||
VM_DATA_LEN_ERR, //0xFE
|
||||
VM_READ_NO_INDEX, //0xFD
|
||||
VM_READ_DATA_ERR, //0xFC
|
||||
VM_WRITE_OVERFLOW, //0xFB
|
||||
VM_NOT_INIT,
|
||||
VM_INIT_ALREADY,
|
||||
VM_DEFRAG_ERR,
|
||||
VM_ERR_INIT,
|
||||
VM_ERR_PROTECT
|
||||
} VM_ERR;
|
||||
|
||||
|
||||
// vm api
|
||||
VM_ERR vm_eraser(void);
|
||||
VM_ERR vm_init(void *dev_hdl, u32 vm_addr, u32 vm_len, u8 vm_mode);
|
||||
//VM_ERR vm_db_create_table(const struct vm_table *table, int num);
|
||||
void vm_check_all(u8 level); //level : default 0
|
||||
u8 get_vm_statu(void);
|
||||
// io api
|
||||
//s32 vm_read(vm_hdl hdl, void *data_buf, u16 len);
|
||||
//s32 vm_write(vm_hdl hdl, const void *data_buf, u16 len);
|
||||
|
||||
void spi_port_hd(u8 level);
|
||||
|
||||
bool sfc_erase_zone(u32 addr, u32 len);
|
||||
|
||||
void vm_api_write_mult(u16 start_id, u16 end_id, void *buf, u16 len, u32 delay);
|
||||
int vm_api_read_mult(u16 start_id, u16 end_id, void *buf, u16 len);
|
||||
|
||||
|
||||
#endif //_VM_H_
|
||||
|
||||
Reference in New Issue
Block a user