Analog input example – ADLINK CM1-86DX2 User Manual
Page 66

60
Using the Module
//set time counter register: 0xac, 0xab, 0xaa
outb
((
wdog_time
>>
16
) &
0xFF
,
0xac
);
//D23...D16
outb
((
wdog_time
>>
8
) &
0xFF
,
0xab
);
//D15...D8
outb
(
wdog_time
&
0xFF
,
0xaa
);
//D7...D0
//set trigger: 0xa9
trig
=
inb
(
0xa9
);
trig
&=
0x0F
;
trig
|=
0xD0
;
//0xD0 = system reset
outb
(
trig
,
0xa9
);
//enable wdog: 0xa8
wdog_en
=
inb
(
0xa8
);
wdog_en
|=
0x40
;
//bit6 = 1 --> enable WDT1
outb
(
wdog_en
,
0xa8
);
printf
(
"Watchdog active
,
resetting counter
,
Press CTRL
+
C to stop resetting
\
n"
);
//reset timer counter : 0xa8
while(
1
)
{
reset_cntr
=
inb
(
0xa8
);
reset_cntr
|=
0x40
;
//bit6 = 1 --> reset counter
outb
(
reset_cntr
,
0xa8
);
}
return
0
;
}
Analog Input Example
/*
########################################################################
########
#
FILE:
sai.c
#
AUTHOR:
FS for LiPPERT Adlink Technology GmbH
#
DESCRIPTIONActivates the ADC and reads the selected channel once
#
PARAMETERS:channel # (0 ... 7)
#
COMPILENAMEsai
########################################################################
########
*/
#include
#include
#include
#include
#include
#include "../../common/pci_conf_space/pcics.c"
#define TRUE 1
// Southbridge: path defines for both functions of device 7
#define SB_PCICS0 "/proc/bus/pci/00/07.0"
#define SB_PCICS1 "/proc/bus/pci/00/07.1"
// ADC specific defines of addresses and offsets
#define ADC_BASE_ADDR 0xFE00
//user defined base address for the ADC
Please note that this source code example is provided for a system running Linux. For
other operating systems, it may be necessary to adapt the source code regarding include
files or headers and the syntax of I/O out commands because Linux is using outb(value,
address) instead of outb(address, value).