00001 
00016 
#ifndef BOARD_H
00017 
#define BOARD_H
00018 
00019 
00020 
#include "AT89C51ED2-SFR.h"
00021 
00022 
00023 
00025 #define MP3_XRESET P2_4
00026 
00028 #define Mp3PutInReset(){MP3_XRESET=0;}
00029 
00031 #define Mp3ReleaseFromReset(){MP3_XRESET=1;}
00032 
00034 #define MP3_XCS P2_3
00035 
00037 #define Mp3SelectControl(){MP3_XCS=0;}
00038 
00040 #define Mp3DeselectControl(){MP3_XCS=1;}
00041 
00043 #define MP3_XDCS P2_5
00044 
00046 #define Mp3SelectData(){MP3_XDCS=0;}
00047 
00049 #define Mp3DeselectData(){MP3_XDCS=1;}
00050 
00051 
00052 
00053 
00055 
#ifdef PCB2
00056 
#define MP3_DREQ P3_4
00057 
#else
00058 #define MP3_DREQ P3_2
00059 
#endif
00060 
00061 
00062 
00063 
00064 
00066 #define RED_LED P3_3
00067 
00069 #define GREEN_LED P3_7
00070 
00072 #define LED_ON 0
00073 
00075 #define LED_OFF 1
00076 
00077 
00078 
00079 
00080 
00081 
00083 #define KEY_BUTTON !(P1_2)
00084 
00086 #define KEY_FARRIGHT !(P1_1)
00087 
00089 #define KEY_RIGHT !(P1_0)
00090 
00092 #define KEY_LEFT !(P1_3)
00093 
00095 
#ifdef PCB2
00096 
#define KEY_FARLEFT !(P3_2)
00097 
#else
00098 #define KEY_FARLEFT !(P3_4)
00099 
#endif
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00111 #define LCD_DATABUS P0
00112 
00114 #define LCD_RS P2_0
00115 
00117 #define LCD_ENABLE P2_2
00118 
00120 #define LCD_RW 0
00121 
00123 #define LCD_COMMAND_MODE 0
00124 
00126 #define LCD_DATA_MODE 1
00127 
00128 
00129 
00130 
00131 
00132 
00134 #define RSEN P2_1
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00144 #define YES 1
00145 
00147 #define NO 0
00148 
00150 #define MMC_OFF P2_7
00151 
00153 #define MMC_XCS P2_6
00154 
00156 #define MMC_SELECTED 0
00157 
00159 #define MMC_NOT_SELECTED 1
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00173 #define ClearPCAOverflow() {CCON &= 0x7f;}
00174 
00176 #define PCARun() {CCON |= 0x40;}
00177 
00179 #define PCAHalt() {CCON &= 0xBF;}
00180 
00182 #define PCAHaltAndClearOV() {CCON &= 0x3F;}
00183 
00184 
00186 #define SetPCAValue(v) {CH = ((unsigned)(v)) >> 8;  CL = (v) & 0xff;}
00187 
00189 #define SetPCADelayValue(microseconds) {SetPCAValue(65535-(unsigned int)((microseconds)/0.4069010));}
00190 
00192 #define InitiateDelay(microseconds) {PCAHaltAndClearOV(); SetPCADelayValue(microseconds); PCARun();}
00193 
00203 #define WaitOutDelay(){while (!(CCON & 0x80));}
00204 
00205 
00206 
00207 
00208 
00210 #define SPISetFastClock(){SPCON=0x71;}  
00211 
00212 
00214 #define SPIWait(){while(!(SPSTA & 0x80));;}
00215 
00217 #define SPIPutChar(c){SPIWait();SPDAT=(c);}
00218 
00220 #define SPIPutCharWithoutWaiting(c){SPDAT=(c);}
00221 
00223 #define SPI_RESULT_BYTE SPDAT
00224 
00226 
unsigned char SPIGetChar();
00227 
00229 
void SPI8Clocks(
unsigned char nClocks);
00230 
00231 
00232 
00234 
extern union Temp {
00235   unsigned char c;
00236   unsigned int i;
00237   unsigned long l;
00238   
struct {
00239     unsigned char b0;
00240     unsigned char b1;
00241     unsigned char b2;
00242     unsigned char b3;
00243   } b;
00244 } 
temp;
00245 
00246 
00247 
00248 
00249 
00250 
00251 
00253 
void Delay (
int milliseconds);
00254 
00256 
void InitBoard();
00257 
00258 
00259 
00262 #define Public
00263 
00264 
00265 
00266 
#endif