USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev) { #if 0 // fastpath, done on the L4 for MOAR SPEED /* Open EP0 OUT */ USBD_LL_OpenEP(pdev, 0x00, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE); /* Open EP0 IN */ USBD_LL_OpenEP(pdev, 0x80, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE); #endif // 0 pdev->ep_out[0].maxpacket = USB_MAX_EP0_SIZE; pdev->ep_in[0].maxpacket = USB_MAX_EP0_SIZE; /* Upon Reset call user call back */ pdev->dev_state = USBD_STATE_DEFAULT; if (pdev->pClass) { ((DeInit_t)PIC(pdev->pClass->DeInit))(pdev, pdev->dev_config); } return USBD_OK; }
/** * @brief USBD_ClrClassConfig * Clear current configuration * @param pdev: device instance * @param cfgidx: configuration index * @retval status: USBD_StatusTypeDef */ USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx) { /* Clear configuration and De-initialize the Class process*/ if(pdev->pClass != NULL) { ((DeInit_t)PIC(pdev->pClass->DeInit))(pdev, cfgidx); } return USBD_OK; }
/** * @brief USBD_DataOutStage * Handle data OUT stage * @param pdev: device instance * @param epnum: endpoint index * @retval status */ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata) { USBD_EndpointTypeDef *pep; if(epnum == 0) { pep = &pdev->ep_out[0]; if ( pdev->ep0_state == USBD_EP0_DATA_OUT) { if(pep->rem_length > pep->maxpacket) { pep->rem_length -= pep->maxpacket; USBD_CtlContinueRx (pdev, pdata, MIN(pep->rem_length ,pep->maxpacket)); } else { uint8_t intf; for (intf =0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if(usbd_is_valid_intf(pdev, intf) && (pdev->interfacesClass[intf].pClass->EP0_RxReady != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { ((EP0_RxReady_t)PIC(pdev->interfacesClass[intf].pClass->EP0_RxReady))(pdev); } } USBD_CtlSendStatus(pdev); } } } else { uint8_t intf; for (intf =0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if( usbd_is_valid_intf(pdev, intf) && (pdev->interfacesClass[intf].pClass->DataOut != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { ((DataOut_t)PIC(pdev->interfacesClass[intf].pClass->DataOut))(pdev, epnum, pdata); } } } return USBD_OK; }
/** * @brief USBD_ClrClassConfig * Clear current configuration * @param pdev: device instance * @param cfgidx: configuration index * @retval status: USBD_StatusTypeDef */ USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx) { /* Clear configuration and De-initialize the Class process*/ uint8_t intf; for (intf =0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if(usbd_is_valid_intf(pdev, intf)) { ((DeInit_t)PIC(pdev->interfacesClass[intf].pClass->DeInit))(pdev, cfgidx); } } return USBD_OK; }
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev) { if(pdev->dev_state == USBD_STATE_CONFIGURED) { if(pdev->pClass->SOF != NULL) { ((SOF_t)PIC(pdev->pClass->SOF))(pdev); } } return USBD_OK; }
/** * @brief USBD_Stop * Stop the USB Device Core. * @param pdev: Device Handle * @retval USBD Status */ USBD_StatusTypeDef USBD_Stop (USBD_HandleTypeDef *pdev) { /* Free Class Resources */ if(pdev->pClass != NULL) { ((DeInit_t)PIC(pdev->pClass->DeInit))(pdev, pdev->dev_config); } /* Stop the low level driver */ USBD_LL_Stop(pdev); return USBD_OK; }
USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx) { /* Set configuration and Start the Class*/ uint8_t intf; for (intf =0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if(usbd_is_valid_intf(pdev, intf)) { ((Init_t)PIC(pdev->interfacesClass[intf].pClass->Init))(pdev, cfgidx); } } return USBD_OK; }
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev) { if(pdev->dev_state == USBD_STATE_CONFIGURED) { uint8_t intf; for (intf =0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if( usbd_is_valid_intf(pdev, intf) && pdev->interfacesClass[intf].pClass->SOF != NULL) { ((SOF_t)PIC(pdev->interfacesClass[intf].pClass->SOF))(pdev); } } } return USBD_OK; }
USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx) { USBD_StatusTypeDef ret = USBD_FAIL; if(pdev->pClass != NULL) { /* Set configuration and Start the Class*/ if(((Init_t)PIC(pdev->pClass->Init))(pdev, cfgidx) == 0) { ret = USBD_OK; } } return ret; }
/** * @brief USBD_Stop * Stop the USB Device Core. * @param pdev: Device Handle * @retval USBD Status */ USBD_StatusTypeDef USBD_Stop (USBD_HandleTypeDef *pdev) { /* Free Class Resources */ uint8_t intf; for (intf =0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if(usbd_is_valid_intf(pdev, intf)) { ((DeInit_t)PIC(pdev->interfacesClass[intf].pClass->DeInit))(pdev, pdev->dev_config); } } /* Stop the low level driver */ USBD_LL_Stop(pdev); return USBD_OK; }
/** * @brief USBD_DataOutStage * Handle data OUT stage * @param pdev: device instance * @param epnum: endpoint index * @retval status */ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata) { USBD_EndpointTypeDef *pep; if(epnum == 0) { pep = &pdev->ep_out[0]; if ( pdev->ep0_state == USBD_EP0_DATA_OUT) { if(pep->rem_length > pep->maxpacket) { pep->rem_length -= pep->maxpacket; USBD_CtlContinueRx (pdev, pdata, MIN(pep->rem_length ,pep->maxpacket)); } else { if((pdev->pClass->EP0_RxReady != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { ((EP0_RxReady_t)PIC(pdev->pClass->EP0_RxReady))(pdev); } USBD_CtlSendStatus(pdev); } } } else if((pdev->pClass->DataOut != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { ((DataOut_t)PIC(pdev->pClass->DataOut))(pdev, epnum, pdata); } return USBD_OK; }
void paint_component_with_txt(const bagl_component_t *component, const char *text) { unsigned int text_adr = (unsigned int)text; if (text_adr >= (unsigned int)&_text) { text_adr = PIC(text_adr); } unsigned short length = sizeof(bagl_component_t) + strlen((unsigned char *)text_adr); G_io_seproxyhal_spi_buffer[0] = SEPROXYHAL_TAG_SCREEN_DISPLAY_STATUS; G_io_seproxyhal_spi_buffer[1] = length >> 8; G_io_seproxyhal_spi_buffer[2] = length; os_memcpy(&G_io_seproxyhal_spi_buffer[3], component, sizeof(bagl_component_t)); os_memcpy(&G_io_seproxyhal_spi_buffer[3 + sizeof(bagl_component_t)], (unsigned char *)text_adr, strlen((unsigned char *)text_adr)); io_seproxyhal_spi_send(G_io_seproxyhal_spi_buffer, length + 3); }
/** * @brief USBD_DeInit * Re-Initialize th device library * @param pdev: device instance * @retval status: status */ USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev) { /* Set Default State */ pdev->dev_state = USBD_STATE_DEFAULT; /* Free Class Resources */ if(pdev->pClass != NULL) { ((DeInit_t)PIC(pdev->pClass->DeInit))(pdev, pdev->dev_config); } /* Stop the low level driver */ USBD_LL_Stop(pdev); /* Initialize low level driver */ USBD_LL_DeInit(pdev); return USBD_OK; }
USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev) { pdev->ep_out[0].maxpacket = USB_MAX_EP0_SIZE; pdev->ep_in[0].maxpacket = USB_MAX_EP0_SIZE; /* Upon Reset call user call back */ pdev->dev_state = USBD_STATE_DEFAULT; uint8_t intf; for (intf =0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if( usbd_is_valid_intf(pdev, intf)) { ((DeInit_t)PIC(pdev->interfacesClass[intf].pClass->DeInit))(pdev, pdev->dev_config); } } return USBD_OK; }
/** * @brief USBD_DeInit * Re-Initialize th device library * @param pdev: device instance * @retval status: status */ USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev) { /* Set Default State */ pdev->dev_state = USBD_STATE_DEFAULT; /* Free Class Resources */ uint8_t intf; for (intf =0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if(pdev->interfacesClass[intf].pClass != NULL) { ((DeInit_t)PIC(pdev->interfacesClass[intf].pClass->DeInit))(pdev, pdev->dev_config); } } /* Stop the low level driver */ USBD_LL_Stop(pdev); /* Initialize low level driver */ USBD_LL_DeInit(pdev); return USBD_OK; }
bool SafeCheck(int matrix[N][N], int row, int col, int num) // Checks if it is safe for a number to get placed. { return !PIR(matrix, row, num) && !PIC(matrix, col, num) && !PIB(matrix, row - row%3 , col - col%3, num); }
/** * @brief USBD_DataInStage * Handle data in stage * @param pdev: device instance * @param epnum: endpoint index * @retval status */ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev ,uint8_t epnum, uint8_t *pdata) { USBD_EndpointTypeDef *pep; if(epnum == 0) { pep = &pdev->ep_in[0]; if ( pdev->ep0_state == USBD_EP0_DATA_IN) { if(pep->rem_length > pep->maxpacket) { pep->rem_length -= pep->maxpacket; USBD_CtlContinueSendData (pdev, pdata, pep->rem_length); /* Prepare endpoint for premature end of transfer */ USBD_LL_PrepareReceive (pdev, 0, 0); } else { /* last packet is MPS multiple, so send ZLP packet */ if((pep->total_length % pep->maxpacket == 0) && (pep->total_length >= pep->maxpacket) && (pep->total_length < pdev->ep0_data_len )) { USBD_CtlContinueSendData(pdev , NULL, 0); pdev->ep0_data_len = 0; /* Prepare endpoint for premature end of transfer */ USBD_LL_PrepareReceive (pdev, 0, 0); } else { if(pdev->pClass != NULL && (pdev->pClass->EP0_TxSent != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { ((EP0_TxSent_t)PIC(pdev->pClass->EP0_TxSent))(pdev); } USBD_CtlReceiveStatus(pdev); } } } if (pdev->dev_test_mode == 1) { USBD_RunTestMode(pdev); pdev->dev_test_mode = 0; } } else if(pdev->pClass != NULL && (pdev->pClass->DataIn != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { ((DataIn_t)PIC(pdev->pClass->DataIn))(pdev, epnum); } return USBD_OK; }
/** * @brief USBD_DataInStage * Handle data in stage * @param pdev: device instance * @param epnum: endpoint index * @retval status */ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev ,uint8_t epnum, uint8_t *pdata) { USBD_EndpointTypeDef *pep; UNUSED(pdata); if(epnum == 0) { pep = &pdev->ep_in[0]; if ( pdev->ep0_state == USBD_EP0_DATA_IN) { if(pep->rem_length > pep->maxpacket) { pep->rem_length -= pep->maxpacket; pdev->pData += pep->maxpacket; /* Prepare endpoint for premature end of transfer */ /* USBD_LL_PrepareReceive (pdev, 0, 0); */ USBD_CtlContinueSendData (pdev, pdev->pData, pep->rem_length); } else { /* last packet is MPS multiple, so send ZLP packet */ if((pep->total_length % pep->maxpacket == 0) && (pep->total_length >= pep->maxpacket) && (pep->total_length < pdev->ep0_data_len )) { /* Prepare endpoint for premature end of transfer */ /* USBD_LL_PrepareReceive (pdev, 0, 0); */ USBD_CtlContinueSendData(pdev , NULL, 0); pdev->ep0_data_len = 0; } else { uint8_t intf; for (intf =0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if(usbd_is_valid_intf(pdev, intf) && (pdev->interfacesClass[intf].pClass->EP0_TxSent != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { ((EP0_RxReady_t)PIC(pdev->interfacesClass[intf].pClass->EP0_TxSent))(pdev); } } USBD_CtlReceiveStatus(pdev); } } } if (pdev->dev_test_mode == 1) { USBD_RunTestMode(pdev); pdev->dev_test_mode = 0; } } else { uint8_t intf; for (intf = 0; intf < USBD_MAX_NUM_INTERFACES; intf++) { if( usbd_is_valid_intf(pdev, intf) && (pdev->interfacesClass[intf].pClass->DataIn != NULL)&& (pdev->dev_state == USBD_STATE_CONFIGURED)) { ((DataIn_t)PIC(pdev->interfacesClass[intf].pClass->DataIn))(pdev, epnum); } } } return USBD_OK; }