28
3-10 I2C WDT/DIO W75IO.h Reference sample code:
Compile platform:TC30 & DOS 6.22
// Sample.cpp : Defines the entry point for the console application.
//
#include
"stdafx.h"
#include
"conio.h"
#include
<string.h>
#include
<stdlib.h>
#include
<iostream>
#include
"W75IO.h"
/* include W75IO.h */
#define
DEMO_DI
1
#define
DEMO_DO
2
#define
DEMO_WDT
3
#define
DEMO_EXIT
4
/* demo function */
int
menu();
BOOL
W75IO_init();
void
W75IO_DO();
void
W75IO_DI();
void
W75IO_WDT();
int
stoi(
char*
str)
{
if
(( strlen(str) < 0 ) || ( strlen(str) >= 3 ))
return
-1;
int
value = 0;
for
(
int
i=0; i<strlen(str) ;i=i+1)
{
int
result=0;
switch
(str[i])
{
case
'0':result=0;
break
;
case
'1':result=1;
break
;
case
'2':result=2;
break
;
case
'3':result=3;
break
;
case
'4':result=4;
break
;
case
'5':result=5;
break
;
case
'6':result=5;
break
;
case
'7':result=7;
break
;
case
'8':result=8;
break
;
case
'9':result=9;
break
;
case
'a':
case
'A':result=10;
break
;
case
'b':
case
'B':result=11;
break
;
case
'c':
case
'C':result=12;
break
;
case
'd':
case
'D':result=13;
break
;
case
'e':
case
'E':result=14;
break
;
case
'f':
case
'F':result=15;
break
;