VLSI Solution Oy VLSI Solution Oy Evaluation MP3 Player Source Code Documentation

Main Page | Class List | File List | Class Members | File Members | Related Pages

board.h File Reference

Definitions for target PCB hardware (VS1002/11 Eval V1.6 SK). More...

#include "AT89C51ED2-SFR.h"

Include dependency graph for board.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Classes

union  Temp
 Generic temp variable for non-reentrant main routines. More...


Defines

#define MP3_XRESET   P2_4
 Chip Reset.

#define Mp3PutInReset()   {MP3_XRESET=0;}
 Put the MP3 player chip in reset.

#define Mp3ReleaseFromReset()   {MP3_XRESET=1;}
 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_2
 Data Request: Player asks for more data.

#define RED_LED   P3_3
 Red LED in multicolor LED, 0 = on, 1 = off.

#define GREEN_LED   P3_7
 Green LED in multicolor LED, 0 = on, 1 = off.

#define LED_ON   0
 LED is active low.

#define LED_OFF   1
 LED is inactive high.

#define KEY_BUTTON   !(P1_2)
 Center push-button, 1 when pressed.

#define KEY_FARRIGHT   !(P1_1)
 Far-left key, 1 when pressed.

#define KEY_RIGHT   !(P1_0)
 Left key, 1 when pressed.

#define KEY_LEFT   !(P1_3)
 Right key, 1 when pressed.

#define KEY_FARLEFT   !(P3_4)
 Far-right key, 1 when pressed.

#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 MMC_OFF   P2_7
 MMC Off (MMC Power Off).

#define MMC_XCS   P2_6
 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()   {MMC_XCS = MMC_SELECTED;}
 Pull the VS10xx Data Chip Select line Low.

#define MMCDeselect()   {MMC_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=0x71;} /* 0x73 is much slower*/
 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


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

Temp temp
 Generic temp variable for non-reentrant main routines.


Detailed Description

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

Definition in file board.h.


Define Documentation

 
#define ClearPCAOverflow  )     {CCON &= 0x7f;}
 

Clear PCA core counter overflow flag.

Definition at line 191 of file board.h.

#define GREEN_LED   P3_7
 

Green LED in multicolor LED, 0 = on, 1 = off.

Definition at line 81 of file board.h.

Referenced by GetAVIBlock(), PlayDiskSectors(), Record(), and VsSineTest().

#define InitiateDelay microseconds   )     {PCAHaltAndClearOV(); SetPCADelayValue(microseconds); PCARun();}
 

Initiate Delay of n microseconds.

Definition at line 210 of file board.h.

Referenced by Delay(), InitBoard(), LcdFadeIn(), LcdFadeOut(), LcdPutChar(), and LcdReset().

#define KEY_BUTTON   !(P1_2)
 

Center push-button, 1 when pressed.

Definition at line 95 of file board.h.

Referenced by AvailableProcessorTime(), ConsoleDecipherMMCResponse(), main(), and Record().

#define KEY_FARLEFT   !(P3_4)
 

Far-right key, 1 when pressed.

Definition at line 110 of file board.h.

Referenced by AvailableProcessorTime(), and main().

#define KEY_FARRIGHT   !(P1_1)
 

Far-left key, 1 when pressed.

Definition at line 98 of file board.h.

Referenced by AvailableProcessorTime(), and main().

#define KEY_LEFT   !(P1_3)
 

Right key, 1 when pressed.

Definition at line 104 of file board.h.

Referenced by main().

#define KEY_RIGHT   !(P1_0)
 

Left key, 1 when pressed.

Definition at line 101 of file board.h.

Referenced by main().

#define LCD_COMMAND_MODE   0
 

LCD RS is 0 in LCD Command Mode.

Definition at line 135 of file board.h.

Referenced by LcdPutCommand().

#define LCD_DATA_MODE   1
 

LCD RS is 1 in LCD Data Mode.

Definition at line 138 of file board.h.

Referenced by LcdPutChar().

#define LCD_DATABUS   P0
 

LCD Data pins are connected to DATA bus (P0).

Definition at line 123 of file board.h.

Referenced by LcdPutChar(), and LcdPutCommand().

#define LCD_ENABLE   P2_2
 

LCD Clock Pulse (Active high).

Definition at line 129 of file board.h.

Referenced by LcdPutChar(), LcdPutCommand(), and LcdReset().

#define LCD_RS   P2_0
 

LCD Register Select: 0=Control, 1=Data.

Definition at line 126 of file board.h.

Referenced by LcdPutChar(), and LcdPutCommand().

#define LCD_RW   0
 

LCD is only in write mode, read not possible.

Definition at line 132 of file board.h.

#define LED_OFF   1
 

LED is inactive high.

Definition at line 87 of file board.h.

Referenced by GetAVIBlock(), PlayDiskSectors(), Record(), and VsSineTest().

#define LED_ON   0
 

LED is active low.

Definition at line 84 of file board.h.

Referenced by GetAVIBlock(), PlayDiskSectors(), Record(), and VsSineTest().

#define MMC_NOT_SELECTED   1
 

MMC is not selected when MMC_XCS is high.

Definition at line 171 of file board.h.

#define MMC_OFF   P2_7
 

MMC Off (MMC Power Off).

Definition at line 162 of file board.h.

Referenced by InitBoard(), and InitMMC().

#define MMC_SELECTED   0
 

MMC is selected when MMC_XCS is low.

Definition at line 168 of file board.h.

#define MMC_XCS   P2_6
 

MMC Chip Select (Active Low).

Definition at line 165 of file board.h.

 
#define MMCDeselect  )     {MMC_XCS = MMC_NOT_SELECTED;}
 

Pull the VS10xx Data Chip Select line High.

Definition at line 178 of file board.h.

Referenced by InitMMC(), MmcCommand(), MmcWaitForData(), ReadPhysicalSector(), SeekSector(), and WritePhysicalSector().

 
#define MMCSelect  )     {MMC_XCS = MMC_SELECTED;}
 

Pull the VS10xx Data Chip Select line Low.

Definition at line 175 of file board.h.

Referenced by InitMMC(), MmcCommand(), and ReadPhysicalSector().

#define MP3_DREQ   P3_2
 

Data Request: Player asks for more data.

Definition at line 70 of file board.h.

Referenced by GetAVIBlock(), Mp3Reset(), Mp3SoftReset(), PlayDiskSectors(), SendZerosToVS10xx(), and VsSineTest().

#define MP3_XCS   P2_3
 

Control Chip Select (for accessing SPI Control/Status registers).

Definition at line 46 of file board.h.

#define MP3_XDCS   P2_5
 

Data Chip Select / BSYNC.

Definition at line 55 of file board.h.

Referenced by GetAVIBlock().

#define MP3_XRESET   P2_4
 

Chip Reset.

Definition at line 25 of file board.h.

 
#define Mp3DeselectControl  )     {MP3_XCS=1;}
 

Pull the VS10xx Control Chip Select line High.

Definition at line 52 of file board.h.

Referenced by Mp3ReadRegister(), Mp3Reset(), Record(), and VsSineTest().

 
#define Mp3DeselectData  )     {MP3_XDCS=1;}
 

Pull the VS10xx Data Chip Select line High.

Definition at line 61 of file board.h.

Referenced by GetAVIBlock(), Mp3Reset(), Mp3SoftReset(), PlayDiskSectors(), SendZerosToVS10xx(), and VsSineTest().

 
#define Mp3PutInReset  )     {MP3_XRESET=0;}
 

Put the MP3 player chip in reset.

Definition at line 38 of file board.h.

Referenced by InitBoard(), Mp3Reset(), and VsSineTest().

 
#define Mp3ReleaseFromReset  )     {MP3_XRESET=1;}
 

Release the MP3 player chip from reset.

Definition at line 41 of file board.h.

Referenced by Mp3Reset(), and VsSineTest().

 
#define Mp3SelectControl  )     {MP3_XCS=0;}
 

Pull the VS10xx Control Chip Select line Low.

Definition at line 49 of file board.h.

Referenced by Mp3ReadRegister(), and VsSineTest().

 
#define Mp3SelectData  )     {MP3_XDCS=0;}
 

Pull the VS10xx Data Chip Select line Low.

Definition at line 58 of file board.h.

Referenced by GetAVIBlock(), Mp3SoftReset(), PlayDiskSectors(), SendZerosToVS10xx(), and VsSineTest().

#define NO   0
 

NO = 0.

Definition at line 159 of file board.h.

Referenced by InitMMC().

 
#define PCAHalt  )     {CCON &= 0xBF;}
 

Stop Programmable Counter Array core counter.

Definition at line 197 of file board.h.

 
#define PCAHaltAndClearOV  )     {CCON &= 0x3F;}
 

Stop PCA core counter and clear overflow flag.

Definition at line 200 of file board.h.

 
#define PCARun  )     {CCON |= 0x40;}
 

Start Programmable Counter Array core counter.

Definition at line 194 of file board.h.

#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

Definition at line 280 of file board.h.

Referenced by BuildFragmentTable(), DumpDiskSector(), FGetChar(), InitFileSystem(), InitMMC(), InitStorage(), OpenFile(), PrepareToReadDiskSector(), ReadDiskSector(), ReadPhysicalSector(), SeekSector(), and WriteDiskSector().

#define RED_LED   P3_3
 

Red LED in multicolor LED, 0 = on, 1 = off.

Definition at line 78 of file board.h.

Referenced by VsSineTest().

#define RSEN   P2_1
 

RS-232 Buffer Enable.

Definition at line 146 of file board.h.

#define SetPCADelayValue microseconds   )     {SetPCAValue(65535-(unsigned int)((microseconds)/0.4069010));}
 

Calculate and set Time-Until-Overflow to PCA in microseconds.

Definition at line 207 of file board.h.

#define SetPCAValue  )     {CH = ((unsigned)(v)) >> 8; CL = (v) & 0xff;}
 

Set PCA core counter value.

Definition at line 204 of file board.h.

#define SPI_RESULT_BYTE   SPDAT
 

SPI data return register.

Definition at line 241 of file board.h.

Referenced by MmcCommand(), Mp3ReadRegister(), PerformBlockRead(), and SPIGetChar().

#define SPIPutChar  )     {SPIWait();SPDAT=(c);}
 

Wait for SPI ready, then initiate character sending.

Definition at line 235 of file board.h.

Referenced by AvailableProcessorTime(), GetAVIBlock(), InitMMC(), MmcCommand(), Mp3ReadRegister(), Mp3SoftReset(), PlayDiskSectors(), SendZerosToVS10xx(), and VsSineTest().

#define SPIPutCharWithoutWaiting  )     {SPDAT=(c);}
 

Initiate SPI character sending.

Definition at line 238 of file board.h.

Referenced by GetAVIBlock(), InitMMC(), MmcCommand(), Mp3ReadRegister(), Mp3Reset(), Mp3SoftReset(), PerformBlockRead(), PlayDiskSectors(), SendZerosToVS10xx(), SPI8Clocks(), SPIGetChar(), VsSineTest(), and WritePhysicalSector().

 
#define SPISetFastClock  )     {SPCON=0x71;} /* 0x73 is much slower*/
 

switch to fast SPI Clock

Definition at line 228 of file board.h.

Referenced by Mp3Reset().

 
#define SPIWait  )     {while(!(SPSTA & 0x80));;}
 

Wait for SPI ready to send a new character (previous sent).

Definition at line 232 of file board.h.

Referenced by AvailableProcessorTime(), GetAVIBlock(), InitMMC(), MmcCommand(), Mp3ReadRegister(), Mp3SoftReset(), PerformBlockRead(), PlayDiskSectors(), SendZerosToVS10xx(), SPI8Clocks(), SPIGetChar(), VsSineTest(), and WritePhysicalSector().

 
#define WaitOutDelay  )     {while (!(CCON & 0x80));}
 

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!

Definition at line 221 of file board.h.

Referenced by Delay(), LcdPutChar(), LcdPutCommand(), and LcdReset().

#define YES   1
 

YES = 1.

Definition at line 156 of file board.h.

Referenced by InitMMC().


Function Documentation

void Delay int  milliseconds  ) 
 

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(), Record(), and VsSineTest().

00036 { 00037 for (;milliseconds;milliseconds--){ /* for n times do: */ 00038 InitiateDelay (1000); 00039 WaitOutDelay(); /* 1 ms delay */ 00040 } 00041 }

void InitBoard  ) 
 

Startup initialization of the microcontroller board.

Definition at line 44 of file board.c.

References InitiateDelay, MMC_OFF, and Mp3PutInReset.

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 MMC_OFF = 1; /* Turn mmc power off */ 00053 00054 00055 SPCON = 0xF2; /* Set slow spi clock */ 00056 CKCON0 = 0x01; /* CPU x 2, timer2 x 1 */ 00057 IEN0 = 0; /* Disable all interrupts */ 00058 00059 BDRCON = 0x1F; /* Set uart for 115200,8n1 */ 00060 PCON = 0x80; /* Double Baud Rate */ 00061 BRL = 248; /* 248 for 115200 */ 00062 SCON = 0x50; /* Serial Port Control Register */ 00063 TI = 1; 00064 00065 ConsoleWrite ("\r\r\rBoard: Console is up.\r"); 00066 00067 00068 TMOD = 1; 00069 00070 00071 RCAP2H = 143; /* Set timer2 for 128 interrupts in second */ 00072 RCAP2L = 89; 00073 TH2 = 143; 00074 TL2 = 89; 00075 T2CON = 0; 00076 T2MOD = 0; 00077 00078 TR2 = 1; /* Start timer2 */ 00079 // ET2 = 1; /* Enable timer2 interrupts */ 00080 00081 // P2 = 0xEF; 00082 //P3 = 0xFF; 00083 00084 InitiateDelay(0); /* Initialize the Delay System */ 00085 00086 ConsoleWrite ("Init: Board; supports: AT89C51RD2, MMC, VS10xx, RS232\r"); 00087 00088 00089 // EA = 1; /* Global enable for interrupts */ 00090 }

void SPI8Clocks unsigned char  nClocks  ) 
 

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(), and WritePhysicalSector().

00026 { 00027 while (nClocks--){ 00028 SPIPutCharWithoutWaiting(0xff); 00029 SPIWait(); 00030 } 00031 }

unsigned char SPIGetChar  ) 
 

Send 8 ones to SPI bus and receive the result byte.

Definition at line 18 of file board.c.

References SPI_RESULT_BYTE, SPIPutCharWithoutWaiting, and SPIWait.

Referenced by ConsoleDecipherMMCResponse(), 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 }


Variable Documentation

union Temp temp
 

Generic temp variable for non-reentrant main routines.


All software copyright 2000-2004 VLSI Solution OY. Redistribution of these software modules are limited to promotional use only and only with the VS1011 / VS1002 / VS1003 MP3-Evakit evaluation boards. Free or commercial use of these software modules in MP3 players is ok if the product includes MP3 decoder chip(s) from VLSI. You can request the complete (compilable) package from mp3@vlsi.fi