dev_tp.c
上传用户:zbk8730
上传日期:2017-08-10
资源大小:12168k
文件大小:1k
- #include "panel.h"
- #include "paneldrv.h"
- #include "err.h"
- #ifndef NULL
- #define NULL 0
- #endif
- #define CYGNUM_HAL_INTERRUPT_TOUCH 3
- ts_info TsInfo = {CYGNUM_HAL_INTERRUPT_TOUCH};
- int ts_open(void* priv)
- {
- // Key related state,variable init.
- InitPanelQueue();
- InitTouchPen();
- return 0;
- }
- int ts_set_callback(void* priv,HDEV hdev, DEV_CALLBACK callback) /* BIOS notify OS, called it in DSR typically */
- {
- TsInfo.hdev = hdev;
- TsInfo.callback = callback;
- return 0;
- }
- int ts_read(void* priv,unsigned char* buf, unsigned int* len)
- {
- ts_event *ts_buffer = (ts_event *)buf;
- if( ts_buffer == NULL )
- {
- if( Is_penexist() )
- *len = sizeof(ts_event);
- else
- *len = 0;
- return 0;
- }
-
- /* may get multipl keys */
- if ( *len < sizeof(ts_event) )
- return -EINTR;
-
- cyg_scheduler_lock(); // Prevent interaction with DSR code
- if(GetPanelInf((PANEL_STRUC *)ts_buffer))
- {
- *len = sizeof(ts_event);
- cyg_scheduler_unlock(); // Allow DSRs again
- return ENOERR;
- }
- else
- {
- *len = 0;
- cyg_scheduler_unlock(); // Allow DSRs again
- return -EAGAIN;
- }
- }
- int ts_setopt(unsigned int type, void *argp, unsigned int size)
- {
- return ENOERR;
- }
- void ts_init(void){;}
- BIOS_DEVIO_TABLE( ts,
- ts_open,
- NULL,
- ts_set_callback,
- ts_read,
- NULL,
- ts_setopt,
- NULL,
- NULL,
- NULL)
-
- BIOS_DEVTAB_ENTRY(ts, DEV_SYNC_MODE_NONE,0)