#include "AT89C51ED2-SFR.h"
Include dependency graph for board.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Classes | |
union | Temp |
Generic temp variable for non-reentrant main routines. More... | |
Defines | |
#define | MP3_RESET P2_4 |
Chip Reset. | |
#define | Mp3PutInReset() {MP3_RESET=1;} |
Put the MP3 player chip in reset. | |
#define | Mp3ReleaseFromReset() {MP3_RESET=0;} |
Release the MP3 player chip from reset. | |
#define | MP3_XCS P2_3 |
Control Chip Select (for accessing SPI Control/Status registers). | |
#define | Mp3SelectControl() {MP3_XCS=0;} |
Pull the VS10xx Control Chip Select line Low. | |
#define | Mp3DeselectControl() {MP3_XCS=1;} |
Pull the VS10xx Control Chip Select line High. | |
#define | MP3_XDCS P2_5 |
Data Chip Select / BSYNC. | |
#define | Mp3SelectData() {MP3_XDCS=0;} |
Pull the VS10xx Data Chip Select line Low. | |
#define | Mp3DeselectData() {MP3_XDCS=1;} |
Pull the VS10xx Data Chip Select line High. | |
#define | MP3_DREQ P3_3 |
Data Request: Player asks for more data. | |
#define | LED_ON 0 |
LED is active low. | |
#define | LED_OFF 1 |
LED is inactive high. | |
#define | KEY_BUTTON (!(P1_0)) |
Center push-button, 1 when pressed. | |
#define | KEY_UP (!(P1_0)) |
#define | KEY_DOWN (!(P1_1)) |
#define | KEY_LEFT (!(P1_2)) |
#define | KEY_RIGHT (!(P1_3)) |
#define | LCD_DATABUS P0 |
LCD Data pins are connected to DATA bus (P0). | |
#define | LCD_RS P2_0 |
LCD Register Select: 0=Control, 1=Data. | |
#define | LCD_ENABLE P2_2 |
LCD Clock Pulse (Active high). | |
#define | LCD_RW 0 |
LCD is only in write mode, read not possible. | |
#define | LCD_COMMAND_MODE 0 |
LCD RS is 0 in LCD Command Mode. | |
#define | LCD_DATA_MODE 1 |
LCD RS is 1 in LCD Data Mode. | |
#define | RSEN P2_1 |
RS-232 Buffer Enable. | |
#define | YES 1 |
YES = 1. | |
#define | NO 0 |
NO = 0. | |
#define | MOSI_TO_MMC P2_0 |
MOSI to MMC datapath active. | |
#define | MMC_A_XCS P2_6 |
MMC Chip Select (Active Low). | |
#define | MMC_B_XCS P2_7 |
Recording MMC Chip Select (Active Low). | |
#define | MMC_SELECTED 0 |
MMC is selected when MMC_XCS is low. | |
#define | MMC_NOT_SELECTED 1 |
MMC is not selected when MMC_XCS is high. | |
#define | MMCSelect() {if (currentDisk) {MMC_B_XCS = MMC_SELECTED;} else {MMC_A_XCS = MMC_SELECTED;}} |
Pull the VS10xx Data Chip Select line Low. | |
#define | MMCDeselect() {MMC_A_XCS = MMC_NOT_SELECTED; MMC_B_XCS = MMC_NOT_SELECTED;} |
Pull the VS10xx Data Chip Select line High. | |
#define | ClearPCAOverflow() {CCON &= 0x7f;} |
Clear PCA core counter overflow flag. | |
#define | PCARun() {CCON |= 0x40;} |
Start Programmable Counter Array core counter. | |
#define | PCAHalt() {CCON &= 0xBF;} |
Stop Programmable Counter Array core counter. | |
#define | PCAHaltAndClearOV() {CCON &= 0x3F;} |
Stop PCA core counter and clear overflow flag. | |
#define | SetPCAValue(v) {CH = ((unsigned)(v)) >> 8; CL = (v) & 0xff;} |
Set PCA core counter value. | |
#define | SetPCADelayValue(microseconds) {SetPCAValue(65535-(unsigned int)((microseconds)/0.4069010));} |
Calculate and set Time-Until-Overflow to PCA in microseconds. | |
#define | InitiateDelay(microseconds) {PCAHaltAndClearOV(); SetPCADelayValue(microseconds); PCARun();} |
Initiate Delay of n microseconds. | |
#define | WaitOutDelay() {while (!(CCON & 0x80));} |
Busy loop until the end of the delay time. | |
#define | SPISetFastClock() {SPCON=0x70;} |
switch to fast SPI Clock | |
#define | SPISetSlowClock() {SPCON=0x73;} |
switch to fast SPI Clock | |
#define | SPIWait() {while(!(SPSTA & 0x80));;} |
Wait for SPI ready to send a new character (previous sent). | |
#define | SPIPutChar(c) {SPIWait();SPDAT=(c);} |
Wait for SPI ready, then initiate character sending. | |
#define | SPIPutCharWithoutWaiting(c) {SPDAT=(c);} |
Initiate SPI character sending. | |
#define | SPI_RESULT_BYTE SPDAT |
SPI data return register. | |
#define | Public |
"Public" has no code meaning but it is meant for the programmer to remember that this function is called from outside the module | |
#define | LED1 P1_4 |
#define | RED_LED P3_7 |
#define | GREEN_LED P3_6 |
Functions | |
unsigned char | SPIGetChar () |
Send 8 ones to SPI bus and receive the result byte. | |
void | SPI8Clocks (unsigned char nClocks) |
Send nClocks x 8 clock transitions with MOSI=1 (0xff). | |
void | Delay (int milliseconds) |
Busy loop delay function. | |
void | InitBoard () |
Startup initialization of the microcontroller board. | |
Variables | |
bit | currentDisk |
Temp | temp |
Generic temp variable for non-reentrant main routines. |
--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
Definition in file board.h.
|
Clear PCA core counter overflow flag.
|
|
Definition at line 262 of file board.h. Referenced by PlayerTaskHandler(). |
|
Initiate Delay of n microseconds.
Definition at line 183 of file board.h. Referenced by Delay(), InitBoard(), LcdFadeIn(), LcdFadeOut(), LcdPutChar(), LcdPutCommand(), and LcdReset(). |
|
Center push-button, 1 when pressed.
|
|
Definition at line 77 of file board.h. Referenced by AvailableProcessorTime(). |
|
Definition at line 78 of file board.h. Referenced by AvailableProcessorTime(). |
|
|
|
Definition at line 76 of file board.h. Referenced by AvailableProcessorTime(). |
|
LCD RS is 0 in LCD Command Mode.
|
|
LCD RS is 1 in LCD Data Mode.
|
|
LCD Data pins are connected to DATA bus (P0).
Definition at line 91 of file board.h. Referenced by LcdPutChar(), and LcdPutCommand(). |
|
LCD Clock Pulse (Active high).
Definition at line 97 of file board.h. Referenced by LcdPutChar(), LcdPutCommand(), and LcdReset(). |
|
LCD Register Select: 0=Control, 1=Data.
Definition at line 94 of file board.h. Referenced by LcdPutChar(), and LcdPutCommand(). |
|
LCD is only in write mode, read not possible.
|
|
Definition at line 259 of file board.h. Referenced by PlayerTaskHandler(). |
|
LED is inactive high.
|
|
LED is active low.
|
|
MMC Chip Select (Active Low).
|
|
Recording MMC Chip Select (Active Low).
|
|
MMC is not selected when MMC_XCS is high.
|
|
MMC is selected when MMC_XCS is low.
|
|
Pull the VS10xx Data Chip Select line High.
Definition at line 151 of file board.h. Referenced by InitMMC(), MmcCommand(), MmcWaitForData(), ReadPhysicalSector(), SeekSector(), TransferSectorSCI(), TransferSectorSDI(), and WritePhysicalSector(). |
|
Pull the VS10xx Data Chip Select line Low.
Definition at line 148 of file board.h. Referenced by InitMMC(), MmcCommand(), ReadPhysicalSector(), TransferSectorSCI(), and TransferSectorSDI(). |
|
MOSI to MMC datapath active.
Definition at line 130 of file board.h. Referenced by InitStorage(), ReadDiskSector(), TransferSectorSCI(), TransferSectorSDI(), and WriteDiskSector(). |
|
Data Request: Player asks for more data.
|
|
Chip Reset.
|
|
Control Chip Select (for accessing SPI Control/Status registers).
|
|
Data Chip Select / BSYNC.
|
|
Pull the VS10xx Control Chip Select line High.
Definition at line 40 of file board.h. Referenced by Mp3ReadRegister(), Mp3Reset(), PlayerTaskHandler(), TransferSectorSCI(), TransferSectorSDI(), and VsSineTest(). |
|
Pull the VS10xx Data Chip Select line High.
Definition at line 49 of file board.h. Referenced by EchoEnable(), Mp3Reset(), Mp3SoftReset(), PlayerTaskHandler(), SendZerosToVS10xx(), TransferSectorSCI(), TransferSectorSDI(), and VsSineTest(). |
|
Put the MP3 player chip in reset.
Definition at line 28 of file board.h. Referenced by InitBoard(), Mp3Reset(), and VsSineTest(). |
|
Release the MP3 player chip from reset.
Definition at line 31 of file board.h. Referenced by Mp3Reset(), and VsSineTest(). |
|
Pull the VS10xx Control Chip Select line Low.
Definition at line 37 of file board.h. Referenced by Mp3ReadRegister(), PlayerTaskHandler(), TransferSectorSCI(), and VsSineTest(). |
|
Pull the VS10xx Data Chip Select line Low.
Definition at line 46 of file board.h. Referenced by EchoEnable(), Mp3SoftReset(), PlayerTaskHandler(), SendZerosToVS10xx(), TransferSectorSDI(), and VsSineTest(). |
|
NO = 0.
|
|
Stop Programmable Counter Array core counter.
|
|
Stop PCA core counter and clear overflow flag.
|
|
Start Programmable Counter Array core counter.
|
|
"Public" has no code meaning but it is meant for the programmer to remember that this function is called from outside the module
Definition at line 256 of file board.h. Referenced by BuildFragmentTable(), DumpDiskSector(), FGetChar(), InitMMC(), InitStorage(), ReadDiskSector(), ReadPhysicalSector(), SeekSector(), and WriteDiskSector(). |
|
Definition at line 261 of file board.h. Referenced by main(), and PlayerTaskHandler(). |
|
RS-232 Buffer Enable.
|
|
Calculate and set Time-Until-Overflow to PCA in microseconds.
|
|
Set PCA core counter value.
|
|
SPI data return register.
|
|
Wait for SPI ready, then initiate character sending.
Definition at line 211 of file board.h. Referenced by InitMMC(), MmcCommand(), Mp3ReadRegister(), Mp3SoftReset(), SendZerosToVS10xx(), and VsSineTest(). |
|
Initiate SPI character sending.
Definition at line 214 of file board.h. Referenced by EchoEnable(), InitMMC(), MmcCommand(), Mp3ReadRegister(), Mp3Reset(), Mp3SoftReset(), PerformBlockRead(), PlayerTaskHandler(), SendZerosToVS10xx(), SPI8Clocks(), SPIGetChar(), TransferSectorSCI(), TransferSectorSDI(), VsSineTest(), and WritePhysicalSector(). |
|
switch to fast SPI Clock
Definition at line 201 of file board.h. Referenced by InitBoard(), and Mp3Reset(). |
|
switch to fast SPI Clock
Definition at line 204 of file board.h. Referenced by Mp3Reset(). |
|
Wait for SPI ready to send a new character (previous sent).
Definition at line 208 of file board.h. Referenced by EchoEnable(), InitMMC(), MmcCommand(), Mp3ReadRegister(), Mp3SoftReset(), PerformBlockRead(), PlayerTaskHandler(), SendZerosToVS10xx(), SPI8Clocks(), SPIGetChar(), TransferSectorSCI(), TransferSectorSDI(), VsSineTest(), and WritePhysicalSector(). |
|
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.
Definition at line 194 of file board.h. Referenced by Delay(), LcdPutChar(), LcdPutCommand(), and LcdReset(). |
|
YES = 1.
|
|
Busy loop delay function. Creates n times 1 ms hardware delays Definition at line 36 of file board.c. References InitiateDelay, and WaitOutDelay. Referenced by InitMMC(), LcdPrintGenericResult(), LoadPatch(), MmcCommand(), Mp3Reset(), Mp3SoftReset(), RebootMMC(), and VsSineTest(). 00036 { 00037 for (;milliseconds;milliseconds--){ /* for n times do: */ 00038 InitiateDelay (1000); 00039 WaitOutDelay(); /* 1 ms delay */ 00040 } 00041 }
|
|
Startup initialization of the microcontroller board.
Definition at line 44 of file board.c. References ConsoleWrite, InitiateDelay, Mp3PutInReset, and SPISetFastClock. Referenced by main(). 00045 { 00046 AUXR = 0x11; /* Take full memory into use */ 00047 00048 Mp3PutInReset(); 00049 00050 // MP3_XRESET = 0; /* Put the MP3 chip into reset */ 00051 00052 00053 SPCON = 0xF2; /* Set slow spi clock */ 00054 CKCON0 = 0x01; /* CPU x 2, timer2 x 1 */ 00055 IEN0 = 0; /* Disable all interrupts */ 00056 00057 BDRCON = 0x1F; /* Set uart for 115200,8n1 */ 00058 PCON = 0x80; /* Double Baud Rate */ 00059 BRL = 248; /* 248 for 115200 */ 00060 SCON = 0x50; /* Serial Port Control Register */ 00061 TI = 1; 00062 00063 ConsoleWrite ("\r\r\rBoard: Console is up.\r"); 00064 00065 00066 //Timer1: make interrupt for each up-pulse 00067 //Accomplish this by setting counter auto-reload mode 00068 //with 0xff as auto-reload value 00069 TMOD = 0x61; 00070 TH1 = 0xFF; 00071 TL1 = 0xFF; 00072 ET1 = 1; //Enable Interrupt 00073 00074 00075 00076 TR1 = 1; 00077 00078 00079 RCAP2H = 143; /* Set timer2 for 128 interrupts in second */ 00080 RCAP2L = 89; 00081 TH2 = 143; 00082 TL2 = 89; 00083 T2CON = 0; 00084 T2MOD = 0; 00085 00086 TR2 = 1; /* Start timer2 */ 00087 // ET2 = 1; /* Enable timer2 interrupts */ 00088 00089 // P2 = 0xEF; 00090 //P3 = 0xFF; 00091 00092 InitiateDelay(0); /* Initialize the Delay System */ 00093 00094 SPISetFastClock(); // Switch to fast SPI clock 00095 00096 ConsoleWrite ("Init: Board; supports: AT89C51RD2, MMC, VS10xx, RS232\r"); 00097 00098 00099 00100 // EA = 1; /* Global enable for interrupts */ 00101 }
|
|
Send nClocks x 8 clock transitions with MOSI=1 (0xff).
Definition at line 26 of file board.c. References SPIPutCharWithoutWaiting, and SPIWait. Referenced by MmcCommand(), MmcWaitForData(), ReadPhysicalSector(), RebootMMC(), TransferSectorSCI(), TransferSectorSDI(), and WritePhysicalSector(). 00026 { 00027 while (nClocks--){ 00028 SPIPutCharWithoutWaiting(0xff); 00029 SPIWait(); 00030 } 00031 }
|
|
Send 8 ones to SPI bus and receive the result byte.
Definition at line 18 of file board.c. References SPIPutCharWithoutWaiting, and SPIWait. Referenced by MmcCommand(), MmcGetData(), MmcWaitForData(), and WritePhysicalSector(). 00018 { 00019 SPIPutCharWithoutWaiting(0xff); /* send 0xff */ 00020 SPIWait(); /* wait for the byte to transfer */ 00021 return SPI_RESULT_BYTE; /* Return the received byte */ 00022 }
|
|
Definition at line 43 of file filesys.c. Referenced by InitFileSystem(), and SelectDisk(). |
|
Generic temp variable for non-reentrant main routines.
|