void setupUSB (void) { #ifdef HAS_MAPLE_HARDWARE /* Setup USB DISC pin as output open drain */ SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC),(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC)) & crMask(USB_DISC)) | CR_OUTPUT_OD << CR_SHITF(LED_PIN)); gpio_write_bit(USB_DISC_BANK,USB_DISC,1); /* turn on the USB clock */ //pRCC->APB1ENR |= RCC_APB1ENR_USB_CLK;// done in setupCLK() gpio_write_bit(USB_DISC_BANK,USB_DISC,0); /* present ourselves to the host */ #else /* Generic boards don't have disconnect hardware, so we drive PA12 which is connected to the usb D+ line*/ #define USB_DISC_BANK GPIOA #define USB_DISC 12 SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC), (GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC)) & crMask(USB_DISC)) | CR_OUTPUT_PP << CR_SHITF(USB_DISC)); gpio_write_bit(USB_DISC_BANK,USB_DISC,0); /* present ourselves to the host */ volatile unsigned int delay; for(delay = 0;delay<256;delay++); // volatile unsigned x = 1024; do { ; }while(--x);// wait a moment /* turn on the USB clock */ SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC), (GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC)) & crMask(USB_DISC)) | CR_INPUT << CR_SHITF(USB_DISC)); //Sets the PA12 as floating input // pRCC->APB1ENR |= RCC_APB1ENR_USB_CLK; #endif /* initialize the usb application */ wTransferSize=getFlashPageSize(); u8_usbConfigDescriptorDFU[41]=(wTransferSize & 0x00FF); u8_usbConfigDescriptorDFU[42]=(wTransferSize & 0xFF00)>>8; u8_usbFunctionalDescriptor[5]=(wTransferSize & 0x00FF); u8_usbFunctionalDescriptor[6]=(wTransferSize & 0xFF00)>>8; usbAppInit(); }
CBitmap* COrnament::GetMask(void) { CDC *pDC = m_pContext->GetDC(); ASSERT(pDC != NULL); // If the mask bitmap is not valid give the current state, free the // current bitmap and build the new one. if (MaskNeeded()) { m_bmMask.DeleteObject(); } // Check if we need to build a new bitmap. if (m_bmMask.GetSafeHandle() == NULL) { // Create the bitmap for the mask. CRect crMask(0, 0, Max(CurrentState()->m_czExtent.cx, 1), Max(CurrentState()->m_czExtent.cy, 1)); if (m_bmMask.CreateBitmap(crMask.Width(), crMask.Height(), 1, 1, NULL)) { // Create a memory compatible DC and select the new bitmap into it. CDC MaskDC; if (MaskDC.CreateCompatibleDC(pDC)) { CBrush cbTransparent(RGB(255,255,255)); int nContext; if ((nContext = MaskDC.SaveDC()) != 0) { MaskDC.SetMapMode(MM_TEXT); if (MaskDC.SelectObject(&m_bmMask) != NULL) { // Create the mask image. Pixels that should be masked out should // be set to zero (black). Pixels that should be transparent should // be set to one (white). MaskDC.FillRect(&crMask, &cbTransparent); DrawMask(&MaskDC); ClearMaskNeeded(); } MaskDC.RestoreDC(nContext); } } } } m_pContext->ReleaseDC(); ASSERT(m_bmMask.GetSafeHandle() != NULL); if (m_bmMask.GetSafeHandle() == NULL) { return NULL; } return &m_bmMask; }