资源简介
这是完整的USB项目。包含用keil写的C底层驱动 包含用C++写的上位机软件,能够完美实现USBbootloadr
代码片段和文件信息
/*
================================================================================
File Name : main.c
Author : LiYong
Date : 2008-12-9 12:30
Version : 1.0
Description : This file contains the main entry and some harware operations
Note : This Firmware used the flash space 0x2800-0x3FFF
================================================================================
*/
#define _MAIN_C_
#include “mytypedef.h“
#include “usb.H“
#include “F32x_USB_Register.h“
#define OFF_MSG_START 0//1byte;0x27
#define OFF_MSG_PAGE0 1//1byte
#define OFF_MSG_LENGTH 2//1byte
#define OFF_MSG_ATTR 3//1byte;0x14
#define OFF_MSG_DATA 4//26byte4-29
#define OFF_MSG_COMMAND 4//1byte
#define OFF_MSG_PAGE 5//1byte
#define OFF_MSG_PACKNUM 6//1byte
#define OFF_CONTENT 7// content of a file;7-29;23byte
#define OFF_CHECKSUM_H 30//1byte
#define OFF_CHECKSUM_L 31
#define REAL_DATA_LENTH 23
#define ERROR_CS 0xE0
#define ERROR_PACKET_MISS 0xE1
#define ERROR_PAGE_MISS 0xE3
#define DATA_OK 0xA5
#define PAGE_SIZE 512
#define APP_Marker_Addr 0x2800 //Put the APP marker at 0x2800
#define BLR_Start_Addr 0x2A00 //Put the bootloader start at 0x2C00
struct
{
INT8U Last;
INT8U Current;
}Page;
struct
{
INT8U Last;
INT8U Current;
}Packet;
INT8U USB_InBuff[EP1_PACKET_SIZE];
INT8U USB_OutBuff[EP2_PACKET_SIZE];
/*Initialize the system and USB clock*/
void Clock_Init( void );
/*Handle the bootloader data*/
INT8U BootloaderHandler( void );
/*
================================================================================
Function name : Clock_Init( )
Description : Initialize the system and USB clock
Input : None
Output : None
================================================================================
*/
void Clock_Init( void )
{
INT8U i;
if( ( CLKMUL & ( 1<<5 ) ) ) return;
CLKMUL = 0;
CLKMUL |= ( 1<<7 );
for( i = 0; i < 250; i ++ );
CLKMUL |= 0xC0;
for( i = 0; i < 250; i ++ );
while( !( CLKMUL & ( 1<<5 ) ) );
CLKSEL = ( 2<<0 );
}
/*
================================================================================
Function name : BootloaderHandler( )
Description : Handle the bootloader data
Input : None
Output : None
================================================================================
*/
static INT16U ByteAddr = 0;
static INT8U xdata *PagePointer = 0;
static INT8U APPStartVect[3];
INT8U BootloaderHandler( void )
{
INT8U data i;
Page.Current = USB_OutBuff[OFF_MSG_PAGE];
Packet.Current = USB_OutBuff[OFF_MSG_PACKNUM];
if( Packet.Current == 0 )
{
PagePointer = 0;
for( i = 0; i < Page.Current; i ++ )
{
PagePointer += PAGE_SIZE;
}
ByteAddr = 0;
//erase the current page
FLSCL = 0x90;
EA = 0;
PSCTL = 0x03;
FLKEY = 0xA5;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 91545 2005-09-22 10:18 USB 完整bootloader 例程\USB Bootloader\APPs\C51L.LIB
文件 16194 2006-10-24 08:09 USB 完整bootloader 例程\USB Bootloader\APPs\c8051F320.h
文件 6817 2010-04-22 16:37 USB 完整bootloader 例程\USB Bootloader\APPs\main.c
文件 7304 2009-03-30 15:34 USB 完整bootloader 例程\USB Bootloader\APPs\main.c.bak
文件 1753 2009-03-13 11:01 USB 完整bootloader 例程\USB Bootloader\APPs\MyTypeDef.h
文件 5253 2008-04-20 21:54 USB 完整bootloader 例程\USB Bootloader\APPs\STARTUP.A51
文件 176128 2009-04-03 09:48 USB 完整bootloader 例程\USB Bootloader\F320_USBbootLoader.exe
文件 176128 2009-04-03 09:48 USB 完整bootloader 例程\USB Bootloader\F320_USBLoader.exe
文件 2422 2018-03-21 08:43 USB 完整bootloader 例程\USB Bootloader\Project\F320Bootloader.Opt
文件 280 2009-03-30 13:23 USB 完整bootloader 例程\USB Bootloader\Project\F320Bootloader.plg
文件 2628 2009-09-04 18:26 USB 完整bootloader 例程\USB Bootloader\Project\F320Bootloader.Uv2
文件 2421 2018-03-19 16:39 USB 完整bootloader 例程\USB Bootloader\Project\F320Bootloader_Opt.Bak
文件 2628 2009-08-25 00:35 USB 完整bootloader 例程\USB Bootloader\Project\F320Bootloader_Uv2.Bak
文件 50350 2010-04-22 16:37 USB 完整bootloader 例程\USB Bootloader\Project\List\F320Bootloader.m51
文件 84327 2009-03-30 15:05 USB 完整bootloader 例程\USB Bootloader\Project\List\main.ls1
文件 13582 2010-04-22 16:37 USB 完整bootloader 例程\USB Bootloader\Project\List\main.lst
文件 12134 2009-07-05 19:27 USB 完整bootloader 例程\USB Bootloader\Project\List\STARTUP.lst
文件 63134 2009-07-05 19:27 USB 完整bootloader 例程\USB Bootloader\Project\List\USB.lst
文件 11664 2009-07-05 19:27 USB 完整bootloader 例程\USB Bootloader\Project\List\USB_HID_Desc
文件 19 2009-09-04 18:19 USB 完整bootloader 例程\USB Bootloader\Project\Output\ExtDll.iex
文件 80726 2010-04-22 16:37 USB 完整bootloader 例程\USB Bootloader\Project\Output\F320Bootloader
文件 11715 2010-04-22 16:37 USB 完整bootloader 例程\USB Bootloader\Project\Output\F320Bootloader.hex
文件 231 2010-04-22 16:37 USB 完整bootloader 例程\USB Bootloader\Project\Output\F320Bootloader.lnp
文件 416 2010-04-22 16:37 USB 完整bootloader 例程\USB Bootloader\Project\Output\F320Bootloader.plg
文件 22831 2010-04-22 16:37 USB 完整bootloader 例程\USB Bootloader\Project\Output\main.obj
文件 23355 2009-03-30 15:05 USB 完整bootloader 例程\USB Bootloader\Project\Output\main.SRC
文件 869 2009-07-05 19:27 USB 完整bootloader 例程\USB Bootloader\Project\Output\STARTUP.obj
文件 52148 2009-07-05 19:27 USB 完整bootloader 例程\USB Bootloader\Project\Output\USB.obj
文件 11566 2009-07-05 19:27 USB 完整bootloader 例程\USB Bootloader\Project\Output\USB_HID_Desc
文件 5388 2009-03-11 14:46 USB 完整bootloader 例程\USB Bootloader\USB_C8051F\F32x_USB_Register.h
............此处省略77个文件信息
- 上一篇:MFC编程85经典
- 下一篇:VC6.0_MFC画图demo小程序源码
评论
共有 条评论