00001
00016 #ifndef BOARD_H
00017 #define BOARD_H
00018
00019
00020 #include "AT89C51ED2-SFR.h"
00021
00022
00023
00025 #define MP3_RESET P2_4
00026
00028 #define Mp3PutInReset(){MP3_RESET=1;}
00029
00031 #define Mp3ReleaseFromReset(){MP3_RESET=0;}
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 #define MP3_DREQ P3_3
00056
00057
00058
00059
00060
00061
00063 #define LED_ON 0
00064
00066 #define LED_OFF 1
00067
00068
00069
00070
00071
00072
00074 #define KEY_BUTTON (!(P1_0))
00075
00076 #define KEY_UP (!(P1_0))
00077 #define KEY_DOWN (!(P1_1))
00078 #define KEY_LEFT (!(P1_2))
00079 #define KEY_RIGHT (!(P1_3))
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00091 #define LCD_DATABUS P0
00092
00094 #define LCD_RS P2_0
00095
00097 #define LCD_ENABLE P2_2
00098
00100 #define LCD_RW 0
00101
00103 #define LCD_COMMAND_MODE 0
00104
00106 #define LCD_DATA_MODE 1
00107
00108
00109
00110
00111
00112
00114 #define RSEN P2_1
00115
00116
00117
00118
00119
00120
00121
00122
00124 #define YES 1
00125
00127 #define NO 0
00128
00130 #define MOSI_TO_MMC P2_0
00131
00133 #define MMC_A_XCS P2_6
00134
00136 #define MMC_B_XCS P2_7
00137
00139 #define MMC_SELECTED 0
00140
00142 #define MMC_NOT_SELECTED 1
00143
00144
00145 extern bit currentDisk;
00146
00148 #define MMCSelect(){if (currentDisk) {MMC_B_XCS = MMC_SELECTED;} else {MMC_A_XCS = MMC_SELECTED;}}
00149
00151 #define MMCDeselect(){MMC_A_XCS = MMC_NOT_SELECTED; MMC_B_XCS = MMC_NOT_SELECTED;}
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00164 #define ClearPCAOverflow() {CCON &= 0x7f;}
00165
00167 #define PCARun() {CCON |= 0x40;}
00168
00170 #define PCAHalt() {CCON &= 0xBF;}
00171
00173 #define PCAHaltAndClearOV() {CCON &= 0x3F;}
00174
00175
00177 #define SetPCAValue(v) {CH = ((unsigned)(v)) >> 8; CL = (v) & 0xff;}
00178
00180 #define SetPCADelayValue(microseconds) {SetPCAValue(65535-(unsigned int)((microseconds)/0.4069010));}
00181
00183 #define InitiateDelay(microseconds) {PCAHaltAndClearOV(); SetPCADelayValue(microseconds); PCARun();}
00184
00194 #define WaitOutDelay(){while (!(CCON & 0x80));}
00195
00196
00197
00198
00199
00201 #define SPISetFastClock(){SPCON=0x70;}
00202
00204 #define SPISetSlowClock(){SPCON=0x73;}
00205
00206
00208 #define SPIWait(){while(!(SPSTA & 0x80));;}
00209
00211 #define SPIPutChar(c){SPIWait();SPDAT=(c);}
00212
00214 #define SPIPutCharWithoutWaiting(c){SPDAT=(c);}
00215
00217 #define SPI_RESULT_BYTE SPDAT
00218
00220 unsigned char SPIGetChar();
00221
00223 void SPI8Clocks(unsigned char nClocks);
00224
00225
00226
00228 extern union Temp {
00229 unsigned char c;
00230 unsigned int i;
00231 unsigned long l;
00232 struct {
00233 unsigned char b0;
00234 unsigned char b1;
00235 unsigned char b2;
00236 unsigned char b3;
00237 } b;
00238 } temp;
00239
00240
00241
00242
00243
00244
00245
00247 void Delay (int milliseconds);
00248
00250 void InitBoard();
00251
00252
00253
00256 #define Public
00257
00258
00259 #define LED1 P1_4
00260
00261 #define RED_LED P3_7
00262 #define GREEN_LED P3_6
00263
00264 #endif