📄 main.c
字号:
#include "def.h"
#include "option.h"
#include "sfr6410.h"
#include "System.h"
#include "Nand.h"
#include "Uart.h"
#define BUTTON_Init() rGPNCON &= ~(0xff)
#define PRESS !(rGPNDAT & 0x1)
#define UNPRESS rGPNDAT & 0x1
#define DOWNLOAD_ADDRESS (0x53e00000)
int main(void)
{
//main start
u32 i, block, page_size, block_count;
u8 *downPt = (u8 *)(DOWNLOAD_ADDRESS);
void (*run)(void) = (void (*)(void))(DOWNLOAD_ADDRESS);
// Hardware Init
SYSTEM_EnableICache();
BUTTON_Init();
Uart_Init(1);
// Button Check..
if(UNPRESS)
{
DownloadImageThruUart(downPt);
}
else
{
#if (NAND_TYPE == NORMAL_8BIT)
page_size = 32;
#elif (NAND_TYPE == ADVANCED_8BIT)
page_size = 64;
#elif (NAND_TYPE == MLC_8BIT)
page_size = 128;
#endif
NF8_Init();
block = 1;
NF8_ReadPage(block, 0, (unsigned char *)downPt);
block_count = *(u32*)downPt;
for(i=1;i<=block_count;i++)
{
if(!(i%page_size)) block++;
if(!NF8_ReadPage(block, i % page_size, (unsigned char *)downPt))
{
Uart_puts("\nnand error\n");
while(1);
}
#if (NAND_TYPE == NORMAL_8BIT)
downPt += 512; // Next page
#elif (NAND_TYPE == ADVANCED_8BIT)
downPt += 2048; // Next page
#elif (NAND_TYPE == MLC_8BIT)
downPt += 2048; // Next page
#endif
}
}
run();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -