传说中的stm32F20x ?
不再是传说了,Keil 4.1中已经有203,205,207了,估计今年会量产。
看 207ZG
ARM 32-bit Cortex-M3 Microcontroller, 120MHz, 1MB Flash, 128kB SRAM,
PLL, Embedded Internal RC 16MHz and 32kHz, Real-Time Clock,
Nested Interrupt Controller, Power Saving Modes, JTAG and SWD, 16-ch DMA,
up to 12 16-bit & 2 32-bit timers, with up to 4 IC/OC/PWM or pulse counter
and quadrature (incremental) encoder input, 10/100 Ethernet MAC with dedicated DMA, 8- to 14-bit parallel camera interface, cryptographic acceleration,
3 SPI/I2S, 3 I2C, 6 USART, USB 2.0 full-speed & high-speed device/host/OTG,
2 CAN 2.0B Active, 3 12-bit 24-ch A/D Converter, 12-bit 2-ch D/A Converter,
SDIO, Fast I/O Ports
"USB驱动中会有USB DEVICE中断的处理函数",下面就是:
// Process a SC2440 interrupt.
static
VOID
HandleUSBEvent(
PCTRLR_PDD_CONTEXT pContext
)
{
SETFNAME();
FUNCTION_ENTER_MSG();
ValidateContext(pContext);
BYTE bEpIrqStat = ReadReg(pContext, EP_INT_REG_OFFSET);
BYTE bUSBBusIrqStat = ReadReg(pContext, USB_INT_REG_OFFSET);
if (bUSBBusIrqStat) {
RETAILMSG(1, (_T("%s USB_INT_REG = 0x%02x\r\n"),
pszFname, bUSBBusIrqStat));
HandleUSBBusIrq(pContext, bUSBBusIrqStat);
}
if (bEpIrqStat) {
RETAILMSG(1, (_T("%s EP_INT_REG = 0x%02x\r\n"),
pszFname, bEpIrqStat));
if (bEpIrqStat & EP0_INT_INTR) {
// RETAILMSG(ZONE_COMMENT, (_T("%s now call HandleEndpoint0Event()\r\n"),pszFname));
HandleEndpoint0Event(pContext);
}
// Process All Other (besides EP0) Endpoints
for (DWORD dwEndpoint = 1; dwEndpoint < ENDPOINT_COUNT; ++dwEndpoint) {
// Check the Interrupt Mask
// Check the Interrupt Status
// RETAILMSG(ZONE_COMMENT, (_T("%s now call EpToIrqStatBit()\r\n"),pszFname));
BYTE bEpBit = EpToIrqStatBit(dwEndpoint);
if (bEpIrqStat & bEpBit) {
HandleEndpointEvent(pContext, dwEndpoint, bEpIrqStat);
}
}
}
bEpIrqStat = ReadReg(pContext, EP_INT_REG_OFFSET);
bUSBBusIrqStat = ReadReg(pContext, USB_INT_REG_OFFSET);
// }
FUNCTION_LEAVE_MSG();
}
复制代码
“当USB线插入有复位等操作时就先禁用USB功能,”,下面就是判断 复位 的
// Process USB Bus interrupt
static
VOID
HandleUSBBusIrq(
PCTRLR_PDD_CONTEXT pContext,
BYTE bUSBBusIrqStat
)
{
SETFNAME();
FUNCTION_ENTER_MSG();
if (bUSBBusIrqStat & USB_RESET_INTR) {
WriteReg(pContext, USB_INT_REG_OFFSET, USB_RESET_INTR);
RETAILMSG(ZONE_USB_EVENTS, (_T("%s Reset\r\n"), pszFname));
pContext->fSpeedReported = FALSE;
// for checking usb cable plug or unplug +chandolp+
if (pContext->isattachedusbcable == FALSE) {
if (pContext->attachedState == UFN_DETACH) {
pContext->pfnNotify(pContext->pvMddContext, UFN_MSG_BUS_EVENTS, UFN_ATTACH);
pContext->attachedState = UFN_ATTACH;
RETAILMSG(1, (_T("%s UFN_ATTACH\r\n"), pszFname));
}
}
else {
if (pContext->attachedState == UFN_ATTACH) {
pContext->pfnNotify(pContext->pvMddContext, UFN_MSG_BUS_EVENTS, UFN_DETACH);
pContext->attachedState = UFN_DETACH;
pContext->isattachedusbcable = FALSE;
RETAILMSG(1, (_T("%s UFN_DETACH\r\n"), pszFname));
}
}
pContext->Ep0State = EP0_STATE_IDLE;
pContext->pfnNotify(pContext->pvMddContext, UFN_MSG_BUS_EVENTS, UFN_RESET);
// Enable the Suspend interrupt...
// SetClearReg(pContext, USB_INT_EN_REG_OFFSET, USB_SUSPEND_INTR, SET);
}
FUNCTION_LEAVE_MSG();
}
复制代码
禁用USB功能?
怎么禁用,实在费解?