Watchdog0 example, Example – ADLINK CM1-86DX2 User Manual

Page 64

Advertising
background image

58

Using the Module

#set direction of RS232/485 mode switch GPIOs to output
dir_reg=$(./dx2_gp

3

d g)

echo "RAW Value for dir_reg: 0x$dir_reg"
dir_reg

=$(printf %02x $((0x$dir_reg|0xc0)))

echo "new Value for dir_reg: 0x$dir_reg"
./dx2_gp

3

d

$dir_reg

#set RS485 mode: output=1
data_reg=$(./dx2_gp

3

i

1

)

echo "RAW Value for data_reg: 0x$data_reg"
data_reg

=$(printf %02x $((0x$data_reg&0x3F)))

echo "new Value for data_reg: 0x$data_reg"
./dx2_gp

3

o

$data_reg

#######################################################
# GPA6 (COM3) and GPA7 (COM4)
#######################################################

#set direction of RS232/485 mode switch GPIOs to output
dir_reg=$(./dx2_gp a d g)
echo "RAW Value for dir_reg: 0x$dir_reg"
dir_reg

=$(printf %02x $((0x$dir_reg|0xc0)))

echo "new Value for dir_reg: 0x$dir_reg"
./dx2_gp a d

$dir_reg

#set RS485 mode: output=1
data_reg=$(./dx2_gp a i 1)
echo "RAW Value for data_reg: 0x$data_reg"
data_reg

=$(printf %02x $((0x$data_reg&0x3F)))

echo "new Value for data_reg: 0x$data_reg"
./dx2_gp a o

$data_reg

Watchdog0

Example

#include

<

sys

/

io

.

h

>

#include

<

stdio

.

h

>

#define WDT0_INDEX 0x22
#define WDT0_DATA 0x23

int

main

()

{

unsigned int

wdog_time

= (

0x20L

*

0x500L

);

unsigned char

trig

=

0

,

wdog_en

=

0

,

reset_cntr

=

0

;

if (

iopl

(

3

) !=

0

)

{
printf

(

"IOPL error

\

n"

);

return

1

;

}
//Unlock sequence
outb

(

0x13

,

WDT0_INDEX

);

Please note that this shell script example is provided for a system running a bash with
Linux. It is using some proprietary software developed at ADLINK Technology, which is
based on the code example given for GPIO programming.

Advertising