📄 usbbootloader.c
字号:
//----------------------------------------------------------------------------
// C main line
//----------------------------------------------------------------------------
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include "usb.h"
#include "bootloader.h"
#pragma interrupt_handler EP2InterruptHandler
void EP2InterruptHandler(void);
BYTE ReadBuffer[8];
WORD wCount;
BYTE bCount;
BYTE Ep2Count;
void main()
{
int x;
PWM_Start();
M8C_EnableGInt;
USBFS_1_Start(0,3);
while(!(USBFS_1_bGetConfiguration()));
USBFS_1_INT_REG |= (USBFS_1_INT_EP1_MASK | USBFS_1_INT_EP2_MASK);
USBFS_1_EnableOutEP(2);
while(1)
{
if(Ep2Count != 0)
{
wCount = USBFS_1_wGetEPCount(2);
bCount = USBFS_1_bReadOutEP(2, ReadBuffer, 8);
Ep2Count = 0;
USBFS_1_EnableOutEP(2);
if((ReadBuffer[0]==0x75) && (ReadBuffer[1]==0x20))
{
M8C_DisableGInt;
PWM_Stop();
USB_Stop();
EnterBootloader();
}
}
}
}
void EP2InterruptHandler(void)
{
Ep2Count++;
}
#pragma abs_address 0x3FFE
const int Checksum = 0xDD12;
#pragma end_abs_address
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -