beautypg.com

Appendix b, Digital input/output control – Lanner LVC-2000 User Manual

Page 29

background image

29

Digital Input/Output Control

Appendix B

Embedded and Industrial Computing

#include
#include

#endif

#endif

/* local include file */
#include “../include/ioaccess.h”

#if (defined(MODULE) || defined(DIRECT_IO_ACCESS) ||

defined(KLD_MODULE))

/*
*---------------------------------------------------------------------------

---
* LEB-5000 Version V1.0
*output3-0 = GPIO 03-00, input3-0= GPIO 53-50
*---------------------------------------------------------------------------

--------
*/

/*
* Device Depend Definition :
*/

#define INDEX_PORT

0x2E

#define DATA_PORT

0x2F

void enter_SIO_config(void)
{
outportb(INDEX_PORT, 0x87); // Must Do It Twice
outportb(INDEX_PORT, 0x87);
return;
}

void exit_SIO_config(void)
{

outportb(INDEX_PORT, 0xAA);
return;
}

unsigned char read_SIO_reg(int LDN, int reg)
{

outportb(INDEX_PORT, 0x07); //LDN register

delay(5);
outportb(DATA_PORT, LDN);
delay(5);
outportb(INDEX_PORT, reg);
delay(5);
return(inportb(DATA_PORT));
}

void write_SIO_reg(int LDN, int reg, int value)
{

outportb(INDEX_PORT, 0x07); //LDN register
delay(5);
outportb(DATA_PORT, LDN);
delay(5);
outportb(INDEX_PORT, reg);
delay(5);
outportb(DATA_PORT, value);
return;
}

void dio_gpio_init(void)
{
enter_SIO_config();

write_SIO_reg(0x6, 0x30,0x01);

//enable GPIO

Port

write_SIO_reg(0x6, 0xf0,((read_SIO_reg(0x6,

0xf0)& 0xF0)|0x0f)); //RxF0[3-0]=1111b, output

write_SIO_reg(0x6, 0xA0, (read_SIO_reg(0x6,

0xA0)& 0xF0)); //RxA0[3-0]=0000b,

input