// defs.h
#ifndef _DEFS_
#define _DEFS_

#define ExternalCrystal

#include <ADuC7021.h>

#include <ctype.h>
#include <math.h>
#include <stdlib.h>

#include "rprintf.h"

typedef unsigned char u8;
typedef unsigned int  u16;
typedef unsigned long u32;

typedef volatile unsigned char vu8;
typedef volatile unsigned int  vu16;
typedef volatile unsigned long vu32;

typedef enum {
  False = 0,
  True = !0
} Bool;


#define UCLK	(41780000/8)
#define TiksPerUs (UCLK/1000000)

#define ESC		0x1B

#define Bit(b)	(1 << b)

#define PowerEN	0x00040000	/* P1.2 */
#define TXEN	0x00800000	/* P0.7 */

//#define Watchdog
void FeedWatchdog(void);
void delay(u32 duration /*us*/);

// System.c
void InitController(void);

// Serial.c
void InitSerial(void);
int putchar(int ch);
int getchar(void);
int write(int file, char * ptr, int len);
int received(void);


#endif
