📄 main.c
字号:
/****************************************Copyright (c)**************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: main.c
** Last modified Date: 2005-6-8
** Last Version: 1.0
** Descriptions: The LPC214x USB Simple Example main.c file
** LPC214x USB 最简单例子 main.c 文件
**------------------------------------------------------------------------------------------------------
** Created by: 郑明远
** Created date: 2005-6-8
** Version: 1.0
** Descriptions: The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"
#include "USBConfig.h" /* 加入USB相关头文件 */
#include "USBCI.h"
#include "USBDriver.h"
/***************************************************************************************
** 函数名称 : Init_USBInterrupt()
** 功能描述 : 配置USB设备控制器的中断向量和中断优先级
****************************************************************************************/
void Init_USBInterrupt(void)
{
VICVectCntl0 = (0x20 | 22); /* USB中断分配到中断向量0 */
VICVectAddr0 = (INT32U)Usb_Exception; /* USB中断服务程序地址 */
VICIntEnable = 1 << 22; /* 使能USB中断 */
}
/***************************************************************************************
** 主 函 数 : main()
***************************************************************************************/
int main (void)
{
INT8U err;
err = USB_Initialize(); /* 初始化USB控制器 */
if (err != 0)
while(1); /* 初始化失败,程序停止执行 */
Init_USBInterrupt(); /* 配置USB中断向量 */
IRQEnable(); /* 允许CPU的IRQ中断 */
/****************** 主函数是一个无限循环结构 **************/
while(1)
{
usbserve(); /* 处理USB事件,如USB控制传输,USB总线复位等等 */
if (bEPPflags.bits.configuration == 1)
{
if (bEPPflags.bits.ep1_rxdone == 1)
{ /* 逻辑端点1收到数据 */
DISABLE();
bEPPflags.bits.ep1_rxdone = 0; /* 清除逻辑端点1收到数据标志 */
USB_WriteEndpoint(3, 10, GenEpBuf); /* 发送10个字节到PC */
ENABLE();
}
}
}
return 0;
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -