📄 board.c
字号:
/** \file board.c * Board related utility functions such as delay() */#include "board.h"#include "lcd.h"/** Generic temp variable for non-reentrant main routines */union Temp { unsigned char c; unsigned int i; unsigned long l;} temp;/** Read and return an octet from SPI port*/unsigned char SPIGetChar(){ SPIPutCharWithoutWaiting(0xff); /* send 0xff */ SPIWait(); /* wait for the byte to transfer */ return SPI_RESULT_BYTE; /* Return the received byte */} /** Send nClocks x 8 clock transitions with MOSI=1 (0xff) */void SPI8Clocks(unsigned char nClocks){ while (nClocks--){ SPIPutCharWithoutWaiting(0xff); SPIWait(); }}/** Busy loop delay function. Creates n times 1 ms hardware delays*/void Delay(int milliseconds){ for (;milliseconds;milliseconds--){ /* for n times do: */ InitiateDelay (1000); WaitOutDelay(); /* 1 ms delay */ }} /** Startup initialization of the microcontroller board */void InitBoard(){ AUXR = 0x11; /* Take full memory into use */ Mp3PutInReset(); // MP3_XRESET = 0; /* Put the MP3 chip into reset */ MMC_OFF = 1; /* Turn mmc power off */ SPCON = 0xF2; /* Set slow spi clock */ CKCON0 = 0x01; /* CPU x 2, timer2 x 1 */ IEN0 = 0; /* Disable all interrupts */ BDRCON = 0x1F; /* Set uart for 115200,8n1 */ PCON = 0x80; /* Double Baud Rate */ BRL = 248; /* 248 for 115200 */ SCON = 0x50; /* Serial Port Control Register */ TI = 1; ConsoleWrite ("\r\r\rBoard: Console is up.\r"); TMOD = 1; RCAP2H = 143; /* Set timer2 for 128 interrupts in second */ RCAP2L = 89; TH2 = 143; TL2 = 89; T2CON = 0; T2MOD = 0; TR2 = 1; /* Start timer2 */ // ET2 = 1; /* Enable timer2 interrupts */ // P2 = 0xEF; //P3 = 0xFF; InitiateDelay(0); /* Initialize the Delay System */ ConsoleWrite ("Init: Board; supports: AT89C51RD2, MMC, VS10xx, RS232\r"); // EA = 1; /* Global enable for interrupts */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -