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=1;}
 Put the MP3 player chip in reset.

#define Mp3ReleaseFromReset()   {MP3_XRESET=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 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 than 71*/
 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

void Mp3SelectData ()
 Pull the VS10xx Data Chip Select line Low.

void Mp3DeselectData ()
 Pull the VS10xx Data Chip Select line High.

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 181 of file board.h.

#define GREEN_LED   P3_7
 

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

Definition at line 71 of file board.h.

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

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

Initiate Delay of n microseconds.

Definition at line 200 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 85 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 100 of file board.h.

Referenced by AvailableProcessorTime(), and main().

#define KEY_FARRIGHT   !(P1_1)
 

Far-left key, 1 when pressed.

Definition at line 88 of file board.h.

Referenced by AvailableProcessorTime(), and main().

#define KEY_LEFT   !(P1_3)
 

Right key, 1 when pressed.

Definition at line 94 of file board.h.

Referenced by main().

#define KEY_RIGHT   !(P1_0)
 

Left key, 1 when pressed.

Definition at line 91 of file board.h.

Referenced by main().

#define LCD_COMMAND_MODE   0
 

LCD RS is 0 in LCD Command Mode.

Definition at line 125 of file board.h.

Referenced by LcdPutCommand().

#define LCD_DATA_MODE   1
 

LCD RS is 1 in LCD Data Mode.

Definition at line 128 of file board.h.

Referenced by LcdPutChar().

#define LCD_DATABUS   P0
 

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

Definition at line 113 of file board.h.

Referenced by LcdPutChar(), and LcdPutCommand().

#define LCD_ENABLE   P2_2
 

LCD Clock Pulse (Active high).

Definition at line 119 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 116 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 122 of file board.h.

#define LED_OFF   1
 

LED is inactive high.

Definition at line 77 of file board.h.

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

#define LED_ON   0
 

LED is active low.

Definition at line 74 of file board.h.

Referenced by GetAVIBlock(), and Record().

#define MMC_NOT_SELECTED   1
 

MMC is not selected when MMC_XCS is high.

Definition at line 161 of file board.h.

#define MMC_OFF   P2_7
 

MMC Off (MMC Power Off).

Definition at line 152 of file board.h.

Referenced by InitBoard(), and InitMMC().

#define MMC_SELECTED   0
 

MMC is selected when MMC_XCS is low.

Definition at line 158 of file board.h.

#define MMC_XCS   P2_6
 

MMC Chip Select (Active Low).

Definition at line 155 of file board.h.

 
#define MMCDeselect  )     {MMC_XCS = MMC_NOT_SELECTED;}
 

Pull the VS10xx Data Chip Select line High.

Definition at line 168 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 165 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 60 of file board.h.

Referenced by GetAVIBlock(), Mp3ReadRegister(), Mp3SoftReset(), and Record().

#define MP3_XCS   P2_3
 

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

Definition at line 34 of file board.h.

#define MP3_XDCS   P2_5
 

Data Chip Select / BSYNC.

Definition at line 43 of file board.h.

Referenced by GetAVIBlock().

#define MP3_XRESET   P2_4
 

Chip Reset.

Definition at line 25 of file board.h.

Referenced by InitBoard().

 
#define Mp3DeselectControl  )     {MP3_XCS=1;}
 

Pull the VS10xx Control Chip Select line High.

Definition at line 40 of file board.h.

Referenced by Mp3ReadRegister(), and Record().

 
#define Mp3PutInReset  )     {MP3_XRESET=1;}
 

Put the MP3 player chip in reset.

Definition at line 28 of file board.h.

Referenced by Mp3ReadRegister().

 
#define Mp3ReleaseFromReset  )     {MP3_XRESET=0;}
 

Release the MP3 player chip from reset.

Definition at line 31 of file board.h.

Referenced by Mp3ReadRegister().

 
#define Mp3SelectControl  )     {MP3_XCS=0;}
 

Pull the VS10xx Control Chip Select line Low.

Definition at line 37 of file board.h.

#define NO   0
 

NO = 0.

Definition at line 149 of file board.h.

Referenced by InitMMC().

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

Stop Programmable Counter Array core counter.

Definition at line 187 of file board.h.

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

Stop PCA core counter and clear overflow flag.

Definition at line 190 of file board.h.

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

Start Programmable Counter Array core counter.

Definition at line 184 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 270 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 68 of file board.h.

Referenced by Record(), and VsSineTest().

#define RSEN   P2_1
 

RS-232 Buffer Enable.

Definition at line 136 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 197 of file board.h.

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

Set PCA core counter value.

Definition at line 194 of file board.h.

#define SPI_RESULT_BYTE   SPDAT
 

SPI data return register.

Definition at line 231 of file board.h.

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

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

Wait for SPI ready, then initiate character sending.

Definition at line 225 of file board.h.

Referenced by AvailableProcessorTime(), GetAVIBlock(), InitMMC(), and MmcCommand().

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

Initiate SPI character sending.

Definition at line 228 of file board.h.

Referenced by GetAVIBlock(), InitMMC(), MmcCommand(), Mp3ReadRegister(), PerformBlockRead(), SPI8Clocks(), SPIGetChar(), and WritePhysicalSector().

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

switch to fast SPI Clock

Definition at line 218 of file board.h.

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

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

Definition at line 222 of file board.h.

Referenced by AvailableProcessorTime(), GetAVIBlock(), InitMMC(), MmcCommand(), PerformBlockRead(), SPI8Clocks(), SPIGetChar(), 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 211 of file board.h.

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

#define YES   1
 

YES = 1.

Definition at line 146 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 35 of file board.c.

References InitiateDelay, and WaitOutDelay.

Referenced by InitMMC(), LcdPrintGenericResult(), LoadPatch(), MmcCommand(), Mp3ReadRegister(), RebootMMC(), and Record().

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

void InitBoard  ) 
 

Startup initialization of the microcontroller board.

Definition at line 43 of file board.c.

References InitiateDelay, MMC_OFF, and MP3_XRESET.

Referenced by main().

00044 { 00045 AUXR = 0x11; /* Take full memory into use */ 00046 MP3_XRESET = 0; /* Put the MP3 chip into reset */ 00047 MMC_OFF = 1; /* Turn mmc power off */ 00048 00049 00050 SPCON = 0xF2; /* Set slow spi clock */ 00051 CKCON0 = 0x01; /* CPU x 2, timer2 x 1 */ 00052 IEN0 = 0; /* Disable all interrupts */ 00053 00054 BDRCON = 0x1F; /* Set uart for 115200,8n1 */ 00055 PCON = 0x80; /* Double Baud Rate */ 00056 BRL = 248; 00057 SCON = 0x50; /* Serial Port Control Register */ 00058 TI = 1; 00059 00060 ConsoleWrite ("\r\r\rBoard: Console is up.\r"); 00061 00062 00063 TMOD = 1; 00064 00065 00066 RCAP2H = 143; /* Set timer2 for 128 interrupts in second */ 00067 RCAP2L = 89; 00068 TH2 = 143; 00069 TL2 = 89; 00070 T2CON = 0; 00071 T2MOD = 0; 00072 00073 TR2 = 1; /* Start timer2 */ 00074 // ET2 = 1; /* Enable timer2 interrupts */ 00075 00076 P2 = 0xEF; 00077 P3 = 0xFF; 00078 00079 InitiateDelay(0); /* Initialize the Delay System */ 00080 00081 ConsoleWrite ("Init: Board; supports: AT89C51RD2, MMC, VS10xx, RS232\r"); 00082 00083 00084 // EA = 1; /* Global enable for interrupts */ 00085 }

void Mp3DeselectData  ) 
 

Pull the VS10xx Data Chip Select line High.

Definition at line 92 of file board.c.

References Mp3WriteRegister, and SPI_MODE.

Referenced by GetAVIBlock(), and Mp3ReadRegister().

00092 { 00093 Mp3WriteRegister (SPI_MODE, 0x08, 0x00); /* Newmode */ 00094 }

void Mp3SelectData  ) 
 

Pull the VS10xx Data Chip Select line Low.

Definition at line 87 of file board.c.

References Mp3WriteRegister, and SPI_MODE.

Referenced by GetAVIBlock().

00087 { 00088 Mp3WriteRegister (SPI_MODE, 0x0C, 0x00); /* Newmode, Sharedmode */ 00089 }

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