📄 dip4_driver.c
字号:
/*
* dip4_driver.c - dip4 driver ( low-level )
*
* Author: li ming <admin@lumit.org>
* Date: 2005-6-11
* Copyleft: http://www.lumit.org
*/
#include "dip4_driver.h"
/*
; hardware connection
; PIO0 PIO1 PIO2 PIO3 (gpio)
; 1 2 3 4 (dip4)
; so output value = 0x0000000f = (0b0000 0000 0000 0000 0000 0000 0000 1111)
*/
/* set dip4 related gpio */
int dip4_open( void )
{
// set gpio's direction: set IOPMOD register mode bit to 0 = input
IOPMOD = IOPMOD & (~0x0000000F);
return 0;
}
int dip4_read( char * buf, int count )
{
int i = 0;
int dip4_value;
// the count has exceeds the count of our board
if( count > DIP4_NUM )
return -1;
// get low-4-bits of IOPDATA
dip4_value = IOPDATA & 0x0F;
for( i = 0; i < count; i++ )
buf[i] = (dip4_value & ( 1 << i ))? 1 : 0;
return count;
}
int dip4_write( char * buf, int count )
{
// do nothing
return count;
}
int dip4_ioctl( unsigned int cmd, unsigned long arg )
{
// do nothing
return 0;
}
int dip4_release( void )
{
// do nothing
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -