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
00027
#ifdef VER29
00028
00030
#define Mp3PutInReset(){MP3_XRESET=1;}
00031
00033
#define Mp3ReleaseFromReset(){MP3_XRESET=0;}
00034
00035
#else
00036
00038 #define Mp3PutInReset(){MP3_XRESET=0;}
00039
00041 #define Mp3ReleaseFromReset(){MP3_XRESET=1;}
00042
00043
#endif
00044
00046 #define MP3_XCS P2_3
00047
00049 #define Mp3SelectControl(){MP3_XCS=0;}
00050
00052 #define Mp3DeselectControl(){MP3_XCS=1;}
00053
00055 #define MP3_XDCS P2_5
00056
00058 #define Mp3SelectData(){MP3_XDCS=0;}
00059
00061 #define Mp3DeselectData(){MP3_XDCS=1;}
00062
00063
00064
00065
00067
#ifdef PCB2
00068
#define MP3_DREQ P3_4
00069
#else
00070 #define MP3_DREQ P3_2
00071
#endif
00072
00073
00074
00075
00076
00078 #define RED_LED P3_3
00079
00081 #define GREEN_LED P3_7
00082
00084 #define LED_ON 0
00085
00087 #define LED_OFF 1
00088
00089
00090
00091
00092
00093
00095 #define KEY_BUTTON !(P1_2)
00096
00098 #define KEY_FARRIGHT !(P1_1)
00099
00101 #define KEY_RIGHT !(P1_0)
00102
00104 #define KEY_LEFT !(P1_3)
00105
00107
#ifdef PCB2
00108
#define KEY_FARLEFT !(P3_2)
00109
#else
00110 #define KEY_FARLEFT !(P3_4)
00111
#endif
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00123 #define LCD_DATABUS P0
00124
00126 #define LCD_RS P2_0
00127
00129 #define LCD_ENABLE P2_2
00130
00132 #define LCD_RW 0
00133
00135 #define LCD_COMMAND_MODE 0
00136
00138 #define LCD_DATA_MODE 1
00139
00140
00141
00142
00143
00144
00146 #define RSEN P2_1
00147
00148
00149
00150
00151
00152
00153
00154
00156 #define YES 1
00157
00159 #define NO 0
00160
00162 #define MMC_OFF P2_7
00163
00165 #define MMC_XCS P2_6
00166
00168 #define MMC_SELECTED 0
00169
00171 #define MMC_NOT_SELECTED 1
00172
00173
00175 #define MMCSelect(){MMC_XCS = MMC_SELECTED;}
00176
00178 #define MMCDeselect(){MMC_XCS = MMC_NOT_SELECTED;}
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00191 #define ClearPCAOverflow() {CCON &= 0x7f;}
00192
00194 #define PCARun() {CCON |= 0x40;}
00195
00197 #define PCAHalt() {CCON &= 0xBF;}
00198
00200 #define PCAHaltAndClearOV() {CCON &= 0x3F;}
00201
00202
00204 #define SetPCAValue(v) {CH = ((unsigned)(v)) >> 8; CL = (v) & 0xff;}
00205
00207 #define SetPCADelayValue(microseconds) {SetPCAValue(65535-(unsigned int)((microseconds)/0.4069010));}
00208
00210 #define InitiateDelay(microseconds) {PCAHaltAndClearOV(); SetPCADelayValue(microseconds); PCARun();}
00211
00221 #define WaitOutDelay(){while (!(CCON & 0x80));}
00222
00223
00224
00225
00226
00228 #define SPISetFastClock(){SPCON=0x71;}
00229
00230
00232 #define SPIWait(){while(!(SPSTA & 0x80));;}
00233
00235 #define SPIPutChar(c){SPIWait();SPDAT=(c);}
00236
00238 #define SPIPutCharWithoutWaiting(c){SPDAT=(c);}
00239
00241 #define SPI_RESULT_BYTE SPDAT
00242
00244
unsigned char SPIGetChar();
00245
00247
void SPI8Clocks(
unsigned char nClocks);
00248
00249
00250
00252
extern union Temp {
00253 unsigned char c;
00254 unsigned int i;
00255 unsigned long l;
00256
struct {
00257 unsigned char b0;
00258 unsigned char b1;
00259 unsigned char b2;
00260 unsigned char b3;
00261 } b;
00262 }
temp;
00263
00264
00265
00266
00267
00268
00269
00271
void Delay (
int milliseconds);
00272
00274
void InitBoard();
00275
00276
00277
00280 #define Public
00281
00282
00283
00284
#endif