?? main.c
字號:
/****************************************Copyright (c)****************************************************
** Guangzhou ZLGMCU Development Co., LTD
**
** http://www.zlgmcu.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name: main.c
** Last modified Date: 2010-02-04
** Last Version: V1.0
** Descriptions: The main() function example template
**
**--------------------------------------------------------------------------------------------------------
** Created by: Li Baihua
** Created date: 2010-09-10
** Version: V1.00
** Descriptions: 整理模板,添加用戶應用程序
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
** Rechecked by:
*********************************************************************************************************/
#include "LPC11xx.h" /* LPC11xx外設寄存器 */
#include "..\MX25L1602Drv\MX25L1602Drv.h"
/*********************************************************************************************************
變量與宏定義
*********************************************************************************************************/
#define BEEP (1 << 7 ) /* 蜂鳴器P0.11 */
#define BEEPOFF() LPC_GPIO2->DIR |= BEEP;LPC_GPIO2->DATA |= BEEP /* 蜂鳴器關 */
#define BEEPON() LPC_GPIO2->DIR |= BEEP;LPC_GPIO2->DATA &= ~BEEP /* 蜂鳴器開 */
/*
* 讀操作函數入口參數的宏
*/
#define RDADDR 4090
#define NOBYTES 20
#define RCVBUFPT GucRdBuf
/*
* 寫操作函數入口參數的宏
*/
#define WRADDR 4090
#define SNDBUFPT GucWrBuf
#define WRNOBYTES 20
INT32U GulChipID = 0;
INT8U GucWrBuf[20] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
INT8U GucRdBuf[20];
/*********************************************************************************************************
** Function name: sysTimeDelay
** Descriptions: ulNum: 為n,BEEP就鳴叫n次
** input parameters: ulNum: 鳴叫次數
** output parameters: 無
** Returned value: 無
*********************************************************************************************************/
void sysTimeDelay (INT32U ulTime)
{
INT32U i = 0;
while(ulTime--) {
for(i=0; i < 5000; i++);
}
}
/*********************************************************************************************************
** Function name: beepNum
** Descriptions: ulNum: 為n,BEEP就鳴叫n次
** input parameters: ulNum: 鳴叫次數
** output parameters: 無
** Returned value: 無
*********************************************************************************************************/
void beepNum (INT32U ulNum)
{
INT32U i;
for (i = 0; i < ulNum; i++) {
BEEPON();
sysTimeDelay(100);
BEEPOFF();
sysTimeDelay(100);
}
}
/*********************************************************************************************************
** Function name: main
** Descriptions: SSP讀寫NorFlash例程。
** 跳線連接:分別將P0.2與SSEL、P0.6與SCK、P0.8與MISO、P0.9與MOSI短接;
** 操作方法:下載并運行程序;
** 現 象: 選擇單步運行到102行,在TKStudio里查看GuiChipID為0x00c22015;然后全速運行,
** 若SPI讀寫NorFlash錯誤,則蜂鳴器響一聲,否則不響。
** input parameters: 無
** output parameters: 無
** Returned value: 無
*********************************************************************************************************/
int main (void)
{
INT32U i = 0;
SystemInit();
SSP_Init();
MX25L1602_RdID(Jedec_ID, &GulChipID); /* 單步運行到此處時,在IAR里查看 */
/* GuiChipID的值是否0x00c22015 */
GulChipID &= ~0xff000000; /* 僅保留低24位數據 */
if (GulChipID != 0x00C22015) {
while(1);
}
MX25L1602_Erase(0, 511); /* 擦除芯片 */
MX25L1602_WR(WRADDR, SNDBUFPT, WRNOBYTES); /* 以0x2007為起始地址,將WrBuf */
/* 數組里的20個數據寫入芯片 */
MX25L1602_RD(RDADDR, NOBYTES, RCVBUFPT); /* 以0x2007為起始地址,讀20個 */
/* 數據到RdBuf中 */
for (i = 0;i < 19;i++) {
if (GucRdBuf[i] != GucWrBuf[i] ) { /* 若SPI讀寫不正確則程序就一直 */
/* 鳴叫,否則SPI讀寫正確 */
BEEPON();
while (1);
}
}
beepNum(3);
while (1);
}
/*********************************************************************************************************
End Of File
*********************************************************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -