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=1;}
00029
00031 #define Mp3ReleaseFromReset(){MP3_XRESET=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
00047
void Mp3SelectData();
00048
00050
00051
void Mp3DeselectData();
00052
00053
00054
00055
00057
#ifdef PCB2
00058
#define MP3_DREQ P3_4
00059
#else
00060 #define MP3_DREQ P3_2
00061
#endif
00062
00063
00064
00065
00066
00068 #define RED_LED P3_3
00069
00071 #define GREEN_LED P3_7
00072
00074 #define LED_ON 0
00075
00077 #define LED_OFF 1
00078
00079
00080
00081
00082
00083
00085 #define KEY_BUTTON !(P1_2)
00086
00088 #define KEY_FARRIGHT !(P1_1)
00089
00091 #define KEY_RIGHT !(P1_0)
00092
00094 #define KEY_LEFT !(P1_3)
00095
00097
#ifdef PCB2
00098
#define KEY_FARLEFT !(P3_2)
00099
#else
00100 #define KEY_FARLEFT !(P3_4)
00101
#endif
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00113 #define LCD_DATABUS P0
00114
00116 #define LCD_RS P2_0
00117
00119 #define LCD_ENABLE P2_2
00120
00122 #define LCD_RW 0
00123
00125 #define LCD_COMMAND_MODE 0
00126
00128 #define LCD_DATA_MODE 1
00129
00130
00131
00132
00133
00134
00136 #define RSEN P2_1
00137
00138
00139
00140
00141
00142
00143
00144
00146 #define YES 1
00147
00149 #define NO 0
00150
00152 #define MMC_OFF P2_7
00153
00155 #define MMC_XCS P2_6
00156
00158 #define MMC_SELECTED 0
00159
00161 #define MMC_NOT_SELECTED 1
00162
00163
00165 #define MMCSelect(){MMC_XCS = MMC_SELECTED;}
00166
00168 #define MMCDeselect(){MMC_XCS = MMC_NOT_SELECTED;}
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00181 #define ClearPCAOverflow() {CCON &= 0x7f;}
00182
00184 #define PCARun() {CCON |= 0x40;}
00185
00187 #define PCAHalt() {CCON &= 0xBF;}
00188
00190 #define PCAHaltAndClearOV() {CCON &= 0x3F;}
00191
00192
00194 #define SetPCAValue(v) {CH = ((unsigned)(v)) >> 8; CL = (v) & 0xff;}
00195
00197 #define SetPCADelayValue(microseconds) {SetPCAValue(65535-(unsigned int)((microseconds)/0.4069010));}
00198
00200 #define InitiateDelay(microseconds) {PCAHaltAndClearOV(); SetPCADelayValue(microseconds); PCARun();}
00201
00211 #define WaitOutDelay(){while (!(CCON & 0x80));}
00212
00213
00214
00215
00216
00218 #define SPISetFastClock(){SPCON=0x71;}
00219
00220
00222 #define SPIWait(){while(!(SPSTA & 0x80));;}
00223
00225 #define SPIPutChar(c){SPIWait();SPDAT=(c);}
00226
00228 #define SPIPutCharWithoutWaiting(c){SPDAT=(c);}
00229
00231 #define SPI_RESULT_BYTE SPDAT
00232
00234
unsigned char SPIGetChar();
00235
00237
void SPI8Clocks(
unsigned char nClocks);
00238
00239
00240
00242
extern union Temp {
00243 unsigned char c;
00244 unsigned int i;
00245 unsigned long l;
00246
struct {
00247 unsigned char b0;
00248 unsigned char b1;
00249 unsigned char b2;
00250 unsigned char b3;
00251 } b;
00252 }
temp;
00253
00254
00255
00256
00257
00258
00259
00261
void Delay (
int milliseconds);
00262
00264
void InitBoard();
00265
00266
00267
00270 #define Public
00271
00272
00273
00274
#endif