h/w watchdog timer
- From: "Fizyq" <Fizyq@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 14 Feb 2006 01:37:27 -0800
Hello,
I want to use hardware watchdog.
I have sample code, but how implement this under WinCE5.0?
Should I write device driver?
Will this work if I use function: (READ/WRITE)_PORT_(UCHAR/ULONG) instead
(in/out)_port_(8/32)?
Will function pci_write_8 from sample code work?
Thanks,
Fizyq.
Fragment of sample code:
/* for 32-bit platforms: */
typedef unsigned char u8; /* unsigned 8-bit */
typedef unsigned short u16; /* unsigned 16-bit */
typedef unsigned long u32; /* unsigned 32-bit */
/* 8-bit input cycle from a port on x86 platform */
u8 in_port_8( u16 port )
{
u8 val;
_asm {
push dx
push ax
mov dx,
in al, dx
mov val, al
pop ax
pop dx
}
return val;
}
....
/* 8-bit write cycle to a PCI device */
void pci_write_8( u32 bus, u32 device, u32 function, u32 reg_index, u8 val )
{
out_port_32( 0xCF8, 0x80000000 | (bus << 16) | (device << 11) |
(function << 8) | (reg_index & 0xFC) );
out_port_8( 0xCFC | (reg_index & 0x3), val );
}
....
void enable_watchdog( u8 seconds )
{
u16 base;
disable_watchdog();
/* this sets up the watchdog timer reload value */
pci_write_8( 0, 0x7, 4, 0x5A, seconds );
/* */
base = pci_read_8( 0, 0x7, 4, 0x48 ) | (pci_read_8( 0, 0x7, 4, 0x49 ) *
256);
base &= 0xFFFC;
/* this enables the reset upon timer timeout */
out_port_8( base + 0x2B, in_port_8( base + 0x2B ) | 0x20 );
/* this starts the timer */
pci_write_8( 0, 0x7, 4, 0x58, (pci_read_8( 0, 0x7, 4, 0x58 ) & 0xF) | 0xA0
);
}
....
.
- Follow-Ups:
- Re: h/w watchdog timer
- From: Steve Maillet \(eMVP\)
- Re: h/w watchdog timer
- Prev by Date: Re: Driver for keypad.
- Next by Date: I'm Getting Junk while using MS Comm control in eVB
- Previous by thread: MCE i/f
- Next by thread: Re: h/w watchdog timer
- Index(es):
Relevant Pages
|