?? board.h
字號:
/** \file board.h * Definitions for target PCB hardware (VS1002/11 Eval V1.6 SK). * --Define PCB2 for Evakit PCB V2.0+ * Board related utility functions such as delay() * * Required modules: - * * Board Description: * * VLSI Solution VS1011/VS1012/ * Standard LCD Module: Tianma TM161A * */#ifndef BOARD_H#define BOARD_H/* Include processor definition */#include "AT89C51ED2-SFR.h"/* MP3 Player Chip Connections *//** Chip Reset */#define MP3_XRESET P2_4/** Put the MP3 player chip in reset */#define Mp3PutInReset(){MP3_XRESET=0;}/** Release the MP3 player chip from reset */#define Mp3ReleaseFromReset(){MP3_XRESET=1;}/** Control Chip Select (for accessing SPI Control/Status registers) */#define MP3_XCS P2_3/** Pull the VS10xx Control Chip Select line Low */#define Mp3SelectControl(){MP3_XCS=0;}/** Pull the VS10xx Control Chip Select line High */#define Mp3DeselectControl(){MP3_XCS=1;}/** Data Chip Select / BSYNC */#define MP3_XDCS P2_5/** Pull the VS10xx Data Chip Select line Low */#define Mp3SelectData(){MP3_XDCS=0;}/** Pull the VS10xx Data Chip Select line High */#define Mp3DeselectData(){MP3_XDCS=1;}/** Data Request: Player asks for more data */#ifdef PCB2#define MP3_DREQ P3_4#else#define MP3_DREQ P3_2#endif/* * LED Connections *//** Red LED in multicolor LED, 0 = on, 1 = off. */#define RED_LED P3_3/** Green LED in multicolor LED, 0 = on, 1 = off. */#define GREEN_LED P3_7/** LED is active low */#define LED_ON 0/** LED is inactive high */#define LED_OFF 1/* * Button connections *//** Center push-button, 1 when pressed */#define KEY_BUTTON !(P1_2)/** Far-left key, 1 when pressed */#define KEY_FARRIGHT !(P1_1)/** Left key, 1 when pressed */#define KEY_RIGHT !(P1_0)/** Right key, 1 when pressed */#define KEY_LEFT !(P1_3)/** Far-right key, 1 when pressed */#ifdef PCB2#define KEY_FARLEFT !(P3_2)#else#define KEY_FARLEFT !(P3_4)#endif/* * LCD Connections * * Standard LCD Module: Tianma TM161A * *//** LCD Data pins are connected to DATA bus (P0) */#define LCD_DATABUS P0/** LCD Register Select: 0=Control, 1=Data */#define LCD_RS P2_0/** LCD Clock Pulse (Active high) */#define LCD_ENABLE P2_2/** LCD is only in write mode, read not possible */#define LCD_RW 0/** LCD RS is 0 in LCD Command Mode */#define LCD_COMMAND_MODE 0/** LCD RS is 1 in LCD Data Mode */#define LCD_DATA_MODE 1/* * Various connections *//** RS-232 Buffer Enable */ #define RSEN P2_1/* * MMC connections *//** YES = 1 */#define YES 1/** NO = 0 */#define NO 0/** MMC Off (MMC Power Off) */#define MMC_OFF P2_7/** MMC Chip Select (Active Low)*/#define MMC_XCS P2_6/** MMC is selected when MMC_XCS is low */#define MMC_SELECTED 0/** MMC is not selected when MMC_XCS is high */#define MMC_NOT_SELECTED 1/* Utility macros *//* Delay system *//** Clear PCA core counter overflow flag */#define ClearPCAOverflow() {CCON &= 0x7f;}/** Start Programmable Counter Array core counter. */#define PCARun() {CCON |= 0x40;}/** Stop Programmable Counter Array core counter. */#define PCAHalt() {CCON &= 0xBF;}/** Stop PCA core counter and clear overflow flag. */#define PCAHaltAndClearOV() {CCON &= 0x3F;}/** Set PCA core counter value */#define SetPCAValue(v) {CH = ((unsigned)(v)) >> 8; CL = (v) & 0xff;}/** Calculate and set Time-Until-Overflow to PCA in microseconds */#define SetPCADelayValue(microseconds) {SetPCAValue(65535-(unsigned int)((microseconds)/0.4069010));}/** Initiate Delay of n microseconds */#define InitiateDelay(microseconds) {PCAHaltAndClearOV(); SetPCADelayValue(microseconds); PCARun();}/** Busy loop until the end of the delay time. * In the delay system, the PCA core counter is used for hardware timing. * First call InitiateDelay to put the counter running. Next do whatever * work you can do while the delay is lasting. Lastly call WaitOutDelay to * busy loop until the hardware says that the delay time has passed. * This allows interrupt routines etc. to run during the delay without * wasting unnecessary cycles at the delay loop. * \warning Do not call from interrupt routines! */ #define WaitOutDelay(){while (!(CCON & 0x80));}/* SPI macros *//** switch to fast SPI Clock */#define SPISetFastClock(){SPCON=0x71;} /* 0x73 is much slower*//** Wait for SPI ready to send a new character (previous sent) */#define SPIWait(){while(!(SPSTA & 0x80));;}/** Wait for SPI ready, then initiate character sending */#define SPIPutChar(c){SPIWait();SPDAT=(c);}/** Initiate SPI character sending */#define SPIPutCharWithoutWaiting(c){SPDAT=(c);}/** SPI data return register */#define SPI_RESULT_BYTE SPDAT/** Send 8 ones to SPI bus and receive the result byte. */unsigned char SPIGetChar();/** Send nClocks x 8 clock transitions with MOSI=1 (0xff) */void SPI8Clocks(unsigned char nClocks);/** Generic temp variable for non-reentrant main routines */extern union Temp { unsigned char c; unsigned int i; unsigned long l; struct { unsigned char b0; unsigned char b1; unsigned char b2; unsigned char b3; } b;} temp;/* Utility functions *//** Busy loop delay function. Creates n times 1 ms hardware delays */void Delay (int milliseconds);/** Startup initialization of the microcontroller board */void InitBoard();/** "Public" has no code meaning but it is meant for the programmer * to remember that this function is called from outside the module */#define Public#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -