code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_istr.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : ISTR events interrupt service routines ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "usb_type.h" #include "usb_regs.h" #include "usb_pwr.h" #include "usb_istr.h" #include "usb_init.h" #ifndef STM32F10X_CL #include "usb_int.h" #else #include "otgd_fs_int.h" #endif /* STM32F10X_CL */ #include "usb_lib.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ __IO uint16_t wIstr; /* ISTR register last read value */ __IO uint8_t bIntPackSOF = 0; /* SOFs received between 2 consecutive packets */ /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /* function pointers to non-control endpoints service routines */ void (*pEpInt_IN[7])(void) = { EP1_IN_Callback, EP2_IN_Callback, EP3_IN_Callback, EP4_IN_Callback, EP5_IN_Callback, EP6_IN_Callback, EP7_IN_Callback, }; void (*pEpInt_OUT[7])(void) = { EP1_OUT_Callback, EP2_OUT_Callback, EP3_OUT_Callback, EP4_OUT_Callback, EP5_OUT_Callback, EP6_OUT_Callback, EP7_OUT_Callback, }; #ifndef STM32F10X_CL /******************************************************************************* * Function Name : USB_Istr * Description : ISTR events interrupt service routine * Input : None. * Output : None. * Return : None. *******************************************************************************/ void USB_Istr(void) { wIstr = _GetISTR(); #if (IMR_MSK & ISTR_CTR) if (wIstr & ISTR_CTR & wInterrupt_Mask) { /* servicing of the endpoint correct transfer interrupt */ /* clear of the CTR flag into the sub */ CTR_LP(); #ifdef CTR_CALLBACK CTR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_RESET) if (wIstr & ISTR_RESET & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_RESET); Device_Property.Reset(); #ifdef RESET_CALLBACK RESET_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_DOVR) if (wIstr & ISTR_DOVR & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_DOVR); #ifdef DOVR_CALLBACK DOVR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_ERR) if (wIstr & ISTR_ERR & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_ERR); #ifdef ERR_CALLBACK ERR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_WKUP) if (wIstr & ISTR_WKUP & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_WKUP); Resume(RESUME_EXTERNAL); #ifdef WKUP_CALLBACK WKUP_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_SUSP) if (wIstr & ISTR_SUSP & wInterrupt_Mask) { /* check if SUSPEND is possible */ if (fSuspendEnabled) { Suspend(); } else { /* if not possible then resume after xx ms */ Resume(RESUME_LATER); } /* clear of the ISTR bit must be done after setting of CNTR_FSUSP */ _SetISTR((uint16_t)CLR_SUSP); #ifdef SUSP_CALLBACK SUSP_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_SOF) if (wIstr & ISTR_SOF & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_SOF); bIntPackSOF++; #ifdef SOF_CALLBACK SOF_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_ESOF) if (wIstr & ISTR_ESOF & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_ESOF); /* resume handling timing is made with ESOFs */ Resume(RESUME_ESOF); /* request without change of the machine state */ #ifdef ESOF_CALLBACK ESOF_Callback(); #endif } #endif } /* USB_Istr */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #else /* STM32F10X_CL */ /******************************************************************************* * Function Name : STM32_PCD_OTG_ISR_Handler * Description : Handles all USB Device Interrupts * Input : None * Output : None * Return : status *******************************************************************************/ u32 STM32_PCD_OTG_ISR_Handler (void) { USB_OTG_GINTSTS_TypeDef gintr_status; u32 retval = 0; if (USBD_FS_IsDeviceMode()) /* ensure that we are in device mode */ { gintr_status.d32 = OTGD_FS_ReadCoreItr(); /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* If there is no interrupt pending exit the interrupt routine */ if (!gintr_status.d32) { return 0; } /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Early Suspend interrupt */ #ifdef INTR_ERLYSUSPEND if (gintr_status.b.erlysuspend) { retval |= OTGD_FS_Handle_EarlySuspend_ISR(); } #endif /* INTR_ERLYSUSPEND */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* End of Periodic Frame interrupt */ #ifdef INTR_EOPFRAME if (gintr_status.b.eopframe) { retval |= OTGD_FS_Handle_EOPF_ISR(); } #endif /* INTR_EOPFRAME */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Non Periodic Tx FIFO Emty interrupt */ #ifdef INTR_NPTXFEMPTY if (gintr_status.b.nptxfempty) { retval |= OTGD_FS_Handle_NPTxFE_ISR(); } #endif /* INTR_NPTXFEMPTY */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Wakeup or RemoteWakeup interrupt */ #ifdef INTR_WKUPINTR if (gintr_status.b.wkupintr) { /* Update the Resume State machine */ Resume(RESUME_EXTERNAL); retval |= OTGD_FS_Handle_Wakeup_ISR(); } #endif /* INTR_WKUPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Suspend interrupt */ #ifdef INTR_USBSUSPEND if (gintr_status.b.usbsuspend) { /* check if SUSPEND is possible */ if (fSuspendEnabled) { Suspend(); } else { /* if not possible then resume after xx ms */ Resume(RESUME_LATER); /* This case shouldn't happen in OTG Device mode because there's no ESOF interrupt to increment the ResumeS.bESOFcnt in the Resume state machine */ } retval |= OTGD_FS_Handle_USBSuspend_ISR(); } #endif /* INTR_USBSUSPEND */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Start of Frame interrupt */ #ifdef INTR_SOFINTR if (gintr_status.b.sofintr) { /* Update the frame number variable */ bIntPackSOF++; retval |= OTGD_FS_Handle_Sof_ISR(); } #endif /* INTR_SOFINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Receive FIFO Queue Status Level interrupt */ #ifdef INTR_RXSTSQLVL if (gintr_status.b.rxstsqlvl) { retval |= OTGD_FS_Handle_RxStatusQueueLevel_ISR(); } #endif /* INTR_RXSTSQLVL */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Enumeration Done interrupt */ #ifdef INTR_ENUMDONE if (gintr_status.b.enumdone) { retval |= OTGD_FS_Handle_EnumDone_ISR(); } #endif /* INTR_ENUMDONE */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Reset interrutp */ #ifdef INTR_USBRESET if (gintr_status.b.usbreset) { retval |= OTGD_FS_Handle_UsbReset_ISR(); } #endif /* INTR_USBRESET */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* IN Endpoint interrupt */ #ifdef INTR_INEPINTR if (gintr_status.b.inepint) { retval |= OTGD_FS_Handle_InEP_ISR(); } #endif /* INTR_INEPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* OUT Endpoint interrupt */ #ifdef INTR_OUTEPINTR if (gintr_status.b.outepintr) { retval |= OTGD_FS_Handle_OutEP_ISR(); } #endif /* INTR_OUTEPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Mode Mismatch interrupt */ #ifdef INTR_MODEMISMATCH if (gintr_status.b.modemismatch) { retval |= OTGD_FS_Handle_ModeMismatch_ISR(); } #endif /* INTR_MODEMISMATCH */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Global IN Endpoints NAK Effective interrupt */ #ifdef INTR_GINNAKEFF if (gintr_status.b.ginnakeff) { retval |= OTGD_FS_Handle_GInNakEff_ISR(); } #endif /* INTR_GINNAKEFF */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Global OUT Endpoints NAK effective interrupt */ #ifdef INTR_GOUTNAKEFF if (gintr_status.b.goutnakeff) { retval |= OTGD_FS_Handle_GOutNakEff_ISR(); } #endif /* INTR_GOUTNAKEFF */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Isochrounous Out packet Dropped interrupt */ #ifdef INTR_ISOOUTDROP if (gintr_status.b.isooutdrop) { retval |= OTGD_FS_Handle_IsoOutDrop_ISR(); } #endif /* INTR_ISOOUTDROP */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Endpoint Mismatch error interrupt */ #ifdef INTR_EPMISMATCH if (gintr_status.b.epmismatch) { retval |= OTGD_FS_Handle_EPMismatch_ISR(); } #endif /* INTR_EPMISMATCH */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Incomplete Isochrous IN tranfer error interrupt */ #ifdef INTR_INCOMPLISOIN if (gintr_status.b.incomplisoin) { retval |= OTGD_FS_Handle_IncomplIsoIn_ISR(); } #endif /* INTR_INCOMPLISOIN */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Incomplete Isochrous OUT tranfer error interrupt */ #ifdef INTR_INCOMPLISOOUT if (gintr_status.b.outepintr) { retval |= OTGD_FS_Handle_IncomplIsoOut_ISR(); } #endif /* INTR_INCOMPLISOOUT */ } return retval; } #endif /* STM32F10X_CL */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/usb_istr.c
C
asf20
12,014
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_scsi.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : All processing related to the SCSI commands ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "hw_config.h" #include "usb_scsi.h" #include "mass_mal.h" #include "usb_bot.h" #include "usb_regs.h" #include "memory.h" #include "nand_if.h" #include "platform_config.h" #include "usb_lib.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* External variables --------------------------------------------------------*/ extern uint8_t Bulk_Data_Buff[BULK_MAX_PACKET_SIZE]; /* data buffer*/ extern uint8_t Bot_State; extern Bulk_Only_CBW CBW; extern Bulk_Only_CSW CSW; extern uint32_t Mass_Memory_Size[2]; extern uint32_t Mass_Block_Size[2]; extern uint32_t Mass_Block_Count[2]; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : SCSI_Inquiry_Cmd * Description : SCSI Inquiry Command routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_Inquiry_Cmd(uint8_t lun) { uint8_t* Inquiry_Data; uint16_t Inquiry_Data_Length; if (CBW.CB[1] & 0x01)/*Evpd is set*/ { Inquiry_Data = Page00_Inquiry_Data; Inquiry_Data_Length = 5; } else { if ( lun == 0) { Inquiry_Data = Standard_Inquiry_Data; } else { Inquiry_Data = Standard_Inquiry_Data2; } if (CBW.CB[4] <= STANDARD_INQUIRY_DATA_LEN) Inquiry_Data_Length = CBW.CB[4]; else Inquiry_Data_Length = STANDARD_INQUIRY_DATA_LEN; } Transfer_Data_Request(Inquiry_Data, Inquiry_Data_Length); } /******************************************************************************* * Function Name : SCSI_ReadFormatCapacity_Cmd * Description : SCSI ReadFormatCapacity Command routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_ReadFormatCapacity_Cmd(uint8_t lun) { if (MAL_GetStatus(lun) != 0 ) { Set_Scsi_Sense_Data(CBW.bLUN, NOT_READY, MEDIUM_NOT_PRESENT); Set_CSW (CSW_CMD_FAILED, SEND_CSW_ENABLE); Bot_Abort(DIR_IN); return; } ReadFormatCapacity_Data[4] = (uint8_t)(Mass_Block_Count[lun] >> 24); ReadFormatCapacity_Data[5] = (uint8_t)(Mass_Block_Count[lun] >> 16); ReadFormatCapacity_Data[6] = (uint8_t)(Mass_Block_Count[lun] >> 8); ReadFormatCapacity_Data[7] = (uint8_t)(Mass_Block_Count[lun]); ReadFormatCapacity_Data[9] = (uint8_t)(Mass_Block_Size[lun] >> 16); ReadFormatCapacity_Data[10] = (uint8_t)(Mass_Block_Size[lun] >> 8); ReadFormatCapacity_Data[11] = (uint8_t)(Mass_Block_Size[lun]); Transfer_Data_Request(ReadFormatCapacity_Data, READ_FORMAT_CAPACITY_DATA_LEN); } /******************************************************************************* * Function Name : SCSI_ReadCapacity10_Cmd * Description : SCSI ReadCapacity10 Command routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_ReadCapacity10_Cmd(uint8_t lun) { if (MAL_GetStatus(lun)) { Set_Scsi_Sense_Data(CBW.bLUN, NOT_READY, MEDIUM_NOT_PRESENT); Set_CSW (CSW_CMD_FAILED, SEND_CSW_ENABLE); Bot_Abort(DIR_IN); return; } ReadCapacity10_Data[0] = (uint8_t)((Mass_Block_Count[lun] - 1) >> 24); ReadCapacity10_Data[1] = (uint8_t)((Mass_Block_Count[lun] - 1) >> 16); ReadCapacity10_Data[2] = (uint8_t)((Mass_Block_Count[lun] - 1) >> 8); ReadCapacity10_Data[3] = (uint8_t)(Mass_Block_Count[lun] - 1); ReadCapacity10_Data[4] = (uint8_t)(Mass_Block_Size[lun] >> 24); ReadCapacity10_Data[5] = (uint8_t)(Mass_Block_Size[lun] >> 16); ReadCapacity10_Data[6] = (uint8_t)(Mass_Block_Size[lun] >> 8); ReadCapacity10_Data[7] = (uint8_t)(Mass_Block_Size[lun]); Transfer_Data_Request(ReadCapacity10_Data, READ_CAPACITY10_DATA_LEN); } /******************************************************************************* * Function Name : SCSI_ModeSense6_Cmd * Description : SCSI ModeSense6 Command routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_ModeSense6_Cmd (uint8_t lun) { Transfer_Data_Request(Mode_Sense6_data, MODE_SENSE6_DATA_LEN); } /******************************************************************************* * Function Name : SCSI_ModeSense10_Cmd * Description : SCSI ModeSense10 Command routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_ModeSense10_Cmd (uint8_t lun) { Transfer_Data_Request(Mode_Sense10_data, MODE_SENSE10_DATA_LEN); } /******************************************************************************* * Function Name : SCSI_RequestSense_Cmd * Description : SCSI RequestSense Command routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_RequestSense_Cmd (uint8_t lun) { uint8_t Request_Sense_data_Length; if (CBW.CB[4] <= REQUEST_SENSE_DATA_LEN) { Request_Sense_data_Length = CBW.CB[4]; } else { Request_Sense_data_Length = REQUEST_SENSE_DATA_LEN; } Transfer_Data_Request(Scsi_Sense_Data, Request_Sense_data_Length); } /******************************************************************************* * Function Name : Set_Scsi_Sense_Data * Description : Set Scsi Sense Data routine. * Input : uint8_t Sens_Key uint8_t Asc. * Output : None. * Return : None. *******************************************************************************/ void Set_Scsi_Sense_Data(uint8_t lun, uint8_t Sens_Key, uint8_t Asc) { Scsi_Sense_Data[2] = Sens_Key; Scsi_Sense_Data[12] = Asc; } /******************************************************************************* * Function Name : SCSI_Start_Stop_Unit_Cmd * Description : SCSI Start_Stop_Unit Command routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_Start_Stop_Unit_Cmd(uint8_t lun) { Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE); } /******************************************************************************* * Function Name : SCSI_Read10_Cmd * Description : SCSI Read10 Command routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_Read10_Cmd(uint8_t lun , uint32_t LBA , uint32_t BlockNbr) { if (Bot_State == BOT_IDLE) { if (!(SCSI_Address_Management(CBW.bLUN, SCSI_READ10, LBA, BlockNbr)))/*address out of range*/ { return; } if ((CBW.bmFlags & 0x80) != 0) { Bot_State = BOT_DATA_IN; Read_Memory(lun, LBA , BlockNbr); } else { Bot_Abort(BOTH_DIR); Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND); Set_CSW (CSW_CMD_FAILED, SEND_CSW_ENABLE); } return; } else if (Bot_State == BOT_DATA_IN) { Read_Memory(lun , LBA , BlockNbr); } } /******************************************************************************* * Function Name : SCSI_Write10_Cmd * Description : SCSI Write10 Command routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_Write10_Cmd(uint8_t lun , uint32_t LBA , uint32_t BlockNbr) { if (Bot_State == BOT_IDLE) { if (!(SCSI_Address_Management(CBW.bLUN, SCSI_WRITE10 , LBA, BlockNbr)))/*address out of range*/ { return; } if ((CBW.bmFlags & 0x80) == 0) { Bot_State = BOT_DATA_OUT; #ifndef STM32F10X_CL SetEPRxStatus(ENDP2, EP_RX_VALID); #endif /* STM32F10X_CL */ } else { Bot_Abort(DIR_IN); Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND); Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE); } return; } else if (Bot_State == BOT_DATA_OUT) { Write_Memory(lun , LBA , BlockNbr); } } /******************************************************************************* * Function Name : SCSI_Verify10_Cmd * Description : SCSI Verify10 Command routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_Verify10_Cmd(uint8_t lun) { if ((CBW.dDataLength == 0) && !(CBW.CB[1] & BLKVFY))/* BLKVFY not set*/ { Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE); } else { Bot_Abort(BOTH_DIR); Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND); Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE); } } /******************************************************************************* * Function Name : SCSI_Valid_Cmd * Description : Valid Commands routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_Valid_Cmd(uint8_t lun) { if (CBW.dDataLength != 0) { Bot_Abort(BOTH_DIR); Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_COMMAND); Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE); } else Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE); } /******************************************************************************* * Function Name : SCSI_Valid_Cmd * Description : Valid Commands routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_TestUnitReady_Cmd(uint8_t lun) { if (MAL_GetStatus(lun)) { Set_Scsi_Sense_Data(CBW.bLUN, NOT_READY, MEDIUM_NOT_PRESENT); Set_CSW (CSW_CMD_FAILED, SEND_CSW_ENABLE); Bot_Abort(DIR_IN); return; } else { Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE); } } /******************************************************************************* * Function Name : SCSI_Format_Cmd * Description : Format Commands routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_Format_Cmd(uint8_t lun) { if (MAL_GetStatus(lun)) { Set_Scsi_Sense_Data(CBW.bLUN, NOT_READY, MEDIUM_NOT_PRESENT); Set_CSW (CSW_CMD_FAILED, SEND_CSW_ENABLE); Bot_Abort(DIR_IN); return; } #ifdef USE_STM3210E_EVAL else { NAND_Format(); Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE); } #endif } /******************************************************************************* * Function Name : SCSI_Invalid_Cmd * Description : Invalid Commands routine * Input : None. * Output : None. * Return : None. *******************************************************************************/ void SCSI_Invalid_Cmd(uint8_t lun) { if (CBW.dDataLength == 0) { Bot_Abort(DIR_IN); } else { if ((CBW.bmFlags & 0x80) != 0) { Bot_Abort(DIR_IN); } else { Bot_Abort(BOTH_DIR); } } Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_COMMAND); Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE); } /******************************************************************************* * Function Name : SCSI_Address_Management * Description : Test the received address. * Input : uint8_t Cmd : the command can be SCSI_READ10 or SCSI_WRITE10. * Output : None. * Return : Read\Write status (bool). *******************************************************************************/ bool SCSI_Address_Management(uint8_t lun , uint8_t Cmd , uint32_t LBA , uint32_t BlockNbr) { if ((LBA + BlockNbr) > Mass_Block_Count[lun] ) { if (Cmd == SCSI_WRITE10) { Bot_Abort(BOTH_DIR); } Bot_Abort(DIR_IN); Set_Scsi_Sense_Data(lun, ILLEGAL_REQUEST, ADDRESS_OUT_OF_RANGE); Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE); return (FALSE); } if (CBW.dDataLength != BlockNbr * Mass_Block_Size[lun]) { if (Cmd == SCSI_WRITE10) { Bot_Abort(BOTH_DIR); } else { Bot_Abort(DIR_IN); } Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND); Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE); return (FALSE); } return (TRUE); } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/usb_scsi.c
C
asf20
14,489
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : scsi_data.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Initialization of the SCSI data ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_scsi.h" #include "memory.h" uint8_t Page00_Inquiry_Data[] = { 0x00, /* PERIPHERAL QUALIFIER & PERIPHERAL DEVICE TYPE*/ 0x00, 0x00, 0x00, 0x00 /* Supported Pages 00*/ }; uint8_t Standard_Inquiry_Data[] = { 0x00, /* Direct Access Device */ 0x80, /* RMB = 1: Removable Medium */ 0x02, /* Version: No conformance claim to standard */ 0x02, 36 - 4, /* Additional Length */ 0x00, /* SCCS = 1: Storage Controller Component */ 0x00, 0x00, /* Vendor Identification */ 'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Product Identification */ 'S', 'D', ' ', 'F', 'l', 'a', 's', 'h', ' ', 'D', 'i', 's', 'k', ' ', ' ', ' ', /* Product Revision Level */ '1', '.', '0', ' ' }; uint8_t Standard_Inquiry_Data2[] = { 0x00, /* Direct Access Device */ 0x80, /* RMB = 1: Removable Medium */ 0x02, /* Version: No conformance claim to standard */ 0x02, 36 - 4, /* Additional Length */ 0x00, /* SCCS = 1: Storage Controller Component */ 0x00, 0x00, /* Vendor Identification */ 'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Product Identification */ 'N', 'A', 'N', 'D', ' ', 'F', 'l', 'a', 's', 'h', ' ', 'D', 'i', 's', 'k', ' ', /* Product Revision Level */ '1', '.', '0', ' ' }; /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ uint8_t Mode_Sense6_data[] = { 0x03, 0x00, 0x00, 0x00, }; /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ uint8_t Mode_Sense10_data[] = { 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; uint8_t Scsi_Sense_Data[] = { 0x70, /*RespCode*/ 0x00, /*SegmentNumber*/ NO_SENSE, /* Sens_Key*/ 0x00, 0x00, 0x00, 0x00, /*Information*/ 0x0A, /*AdditionalSenseLength*/ 0x00, 0x00, 0x00, 0x00, /*CmdInformation*/ NO_SENSE, /*Asc*/ 0x00, /*ASCQ*/ 0x00, /*FRUC*/ 0x00, /*TBD*/ 0x00, 0x00 /*SenseKeySpecific*/ }; uint8_t ReadCapacity10_Data[] = { /* Last Logical Block */ 0, 0, 0, 0, /* Block Length */ 0, 0, 0, 0 }; uint8_t ReadFormatCapacity_Data [] = { 0x00, 0x00, 0x00, 0x08, /* Capacity List Length */ /* Block Count */ 0, 0, 0, 0, /* Block Length */ 0x02,/* Descriptor Code: Formatted Media */ 0, 0, 0 }; /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/scsi_data.c
C
asf20
3,761
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : main.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Mass Storage demo main file ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "usb_lib.h" #include "hw_config.h" #include "usb_pwr.h" extern uint16_t MAL_Init (uint8_t lun); /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : main. * Description : Main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { Set_System(); Set_USBClock(); Led_Config(); USB_Interrupts_Config(); USB_Init(); while (bDeviceState != CONFIGURED); USB_Configured_LED(); while (1) {} } #ifdef USE_FULL_ASSERT /******************************************************************************* * Function Name : assert_failed * Description : Reports the name of the source file and the source line number * where the assert_param error has occurred. * Input : - file: pointer to the source file name * - line: assert_param error line source number * Output : None * Return : None *******************************************************************************/ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) {} } #endif /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/main.c
C
asf20
3,107
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : hw_config.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Hardware Configuration & Setup ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x_it.h" #include "hw_config.h" #if defined(STM32F10X_HD) || defined(STM32F10X_XL) #include "stm32_eval_sdio_sd.h" #endif /* STM32F10X_HD | STM32F10X_XL*/ #include "platform_config.h" #include "mass_mal.h" #include "usb_desc.h" #include "usb_pwr.h" #include "usb_lib.h" #include "stm32_eval.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ ErrorStatus HSEStartUpStatus; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static void RCC_Config(void); static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len); /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : Set_System * Description : Configures Main system clocks & power * Input : None. * Return : None. *******************************************************************************/ void Set_System(void) { /* RCC configuration */ RCC_Config(); #if defined (USE_STM3210B_EVAL) || defined (USE_STM3210E_EVAL) /* Enable and Disconnect Line GPIO clock */ USB_Disconnect_Config(); #endif /* (USE_STM3210B_EVAL) || (USE_STM3210E_EVAL) */ /* MAL configuration */ MAL_Config(); } /******************************************************************************* * Function Name : Set_USBClock * Description : Configures USB Clock input (48MHz) * Input : None. * Return : None. *******************************************************************************/ void Set_USBClock(void) { #ifdef USE_STM3210C_EVAL /* Select USBCLK source */ RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3); /* Enable the USB clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE) ; #else /* Select USBCLK source */ RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5); /* Enable the USB clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE); #endif } /******************************************************************************* * Function Name : Enter_LowPowerMode * Description : Power-off system clocks and power while entering suspend mode * Input : None. * Return : None. *******************************************************************************/ void Enter_LowPowerMode(void) { /* Set the device state to suspend */ bDeviceState = SUSPENDED; } /******************************************************************************* * Function Name : Leave_LowPowerMode * Description : Restores system clocks and power while exiting suspend mode * Input : None. * Return : None. *******************************************************************************/ void Leave_LowPowerMode(void) { DEVICE_INFO *pInfo = &Device_Info; /* Set the device state to the correct state */ if (pInfo->Current_Configuration != 0) { /* Device configured */ bDeviceState = CONFIGURED; } else { bDeviceState = ATTACHED; } } /******************************************************************************* * Function Name : USB_Interrupts_Config * Description : Configures the USB interrupts * Input : None. * Return : None. *******************************************************************************/ void USB_Interrupts_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); #ifdef STM32F10X_CL NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); #else NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = USB_HP_CAN1_TX_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); #endif /* STM32F10X_CL */ #if defined(STM32F10X_HD) || defined(STM32F10X_XL) NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_Init(&NVIC_InitStructure); #endif /* USE_STM3210E_EVAL */ } /******************************************************************************* * Function Name : Led_Config * Description : configure the Read/Write LEDs. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Led_Config(void) { /* Configure the LEDs */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); } /******************************************************************************* * Function Name : Led_RW_ON * Description : Turn ON the Read/Write LEDs. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Led_RW_ON(void) { STM_EVAL_LEDOn(LED3); } /******************************************************************************* * Function Name : Led_RW_OFF * Description : Turn off the Read/Write LEDs. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Led_RW_OFF(void) { STM_EVAL_LEDOff(LED3); } /******************************************************************************* * Function Name : USB_Configured_LED * Description : Turn ON the Read/Write LEDs. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void USB_Configured_LED(void) { STM_EVAL_LEDOn(LED1); } /******************************************************************************* * Function Name : USB_NotConfigured_LED * Description : Turn off the Read/Write LEDs. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void USB_NotConfigured_LED(void) { STM_EVAL_LEDOff(LED1); } /******************************************************************************* * Function Name : USB_Cable_Config * Description : Software Connection/Disconnection of USB Cable. * Input : None. * Return : Status *******************************************************************************/ void USB_Cable_Config (FunctionalState NewState) { #ifdef USE_STM3210C_EVAL if (NewState != DISABLE) { USB_DevConnect(); } else { USB_DevDisconnect(); } #else /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ if (NewState != DISABLE) { GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN); } else { GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN); } #endif /* USE_STM3210C_EVAL */ } /******************************************************************************* * Function Name : Get_SerialNum. * Description : Create the serial number string descriptor. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Get_SerialNum(void) { uint32_t Device_Serial0, Device_Serial1, Device_Serial2; Device_Serial0 = *(__IO uint32_t*)(0x1FFFF7E8); Device_Serial1 = *(__IO uint32_t*)(0x1FFFF7EC); Device_Serial2 = *(__IO uint32_t*)(0x1FFFF7F0); Device_Serial0 += Device_Serial2; if (Device_Serial0 != 0) { IntToUnicode (Device_Serial0, &MASS_StringSerial[2] , 8); IntToUnicode (Device_Serial1, &MASS_StringSerial[18], 4); } } /******************************************************************************* * Function Name : HexToChar. * Description : Convert Hex 32Bits value into char. * Input : None. * Output : None. * Return : None. *******************************************************************************/ static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len) { uint8_t idx = 0; for( idx = 0 ; idx < len ; idx ++) { if( ((value >> 28)) < 0xA ) { pbuf[ 2* idx] = (value >> 28) + '0'; } else { pbuf[2* idx] = (value >> 28) + 'A' - 10; } value = value << 4; pbuf[ 2* idx + 1] = 0; } } /******************************************************************************* * Function Name : RCC_Config * Description : Configures Main system clocks & power * Input : None. * Return : None. *******************************************************************************/ static void RCC_Config(void) { /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/ /* RCC system reset(for debug purpose) */ RCC_DeInit(); /* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON); /* Wait till HSE is ready */ HSEStartUpStatus = RCC_WaitForHSEStartUp(); if (HSEStartUpStatus == SUCCESS) { /* Enable Prefetch Buffer */ FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); /* Flash 2 wait state */ FLASH_SetLatency(FLASH_Latency_2); /* HCLK = SYSCLK */ RCC_HCLKConfig(RCC_SYSCLK_Div1); /* PCLK2 = HCLK */ RCC_PCLK2Config(RCC_HCLK_Div1); /* PCLK1 = HCLK/2 */ RCC_PCLK1Config(RCC_HCLK_Div2); #ifdef STM32F10X_CL /* Configure PLLs *********************************************************/ /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */ RCC_PREDIV2Config(RCC_PREDIV2_Div5); RCC_PLL2Config(RCC_PLL2Mul_8); /* Enable PLL2 */ RCC_PLL2Cmd(ENABLE); /* Wait till PLL2 is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET) {} /* PLL configuration: PLLCLK = (PLL2 / 5) * 9 = 72 MHz */ RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div5); RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_9); #else /* PLLCLK = 8MHz * 9 = 72 MHz */ RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); #endif /* Enable PLL */ RCC_PLLCmd(ENABLE); /* Wait till PLL is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) { } /* Select PLL as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); /* Wait till PLL is used as system clock source */ while(RCC_GetSYSCLKSource() != 0x08) { } } else { /* If HSE fails to start-up, the application will have wrong clock configuration. User can add here some code to deal with this error */ /* Go to infinite loop */ while (1) { } } } /******************************************************************************* * Function Name : MAL_Config * Description : MAL_layer configuration * Input : None. * Return : None. *******************************************************************************/ void MAL_Config(void) { MAL_Init(0); #if defined(STM32F10X_HD) || defined(STM32F10X_XL) /* Enable the FSMC Clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); MAL_Init(1); #endif /* STM32F10X_HD | STM32F10X_XL */ } #if defined (USE_STM3210B_EVAL) || defined (USE_STM3210E_EVAL) /******************************************************************************* * Function Name : USB_Disconnect_Config * Description : Disconnect pin configuration * Input : None. * Return : None. *******************************************************************************/ void USB_Disconnect_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Enable USB_DISCONNECT GPIO clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_DISCONNECT, ENABLE); /* USB_DISCONNECT_PIN used as USB pull-up */ GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure); } #endif /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ #ifdef STM32F10X_CL /******************************************************************************* * Function Name : USB_OTG_BSP_uDelay. * Description : provide delay. * Input : Delay in micro seconds. * Output : None. * Return : None. *******************************************************************************/ void USB_OTG_BSP_uDelay (const uint32_t usec) { RCC_ClocksTypeDef RCC_Clocks; /* Configure HCLK clock as SysTick clock source */ SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(usec * (RCC_Clocks.HCLK_Frequency / 1000000)); SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk ; while (!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)); } #endif /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/hw_config.c
C
asf20
14,971
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : fsmc_nand.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : This file provides a set of functions needed to drive the * NAND512W3A2 memory mounted on STM3210E-EVAL board. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "fsmc_nand.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define FSMC_Bank_NAND FSMC_Bank2_NAND #define Bank_NAND_ADDR Bank2_NAND_ADDR #define Bank2_NAND_ADDR ((uint32_t)0x70000000) /* Private macro -------------------------------------------------------------*/ #define ROW_ADDRESS (Address.Page + (Address.Block + (Address.Zone * NAND_ZONE_SIZE)) * NAND_BLOCK_SIZE) /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : FSMC_NAND_Init * Description : Configures the FSMC and GPIOs to interface with the NAND memory. * This function must be called before any write/read operation * on the NAND. * Input : None * Output : None * Return : None *******************************************************************************/ void FSMC_NAND_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; FSMC_NANDInitTypeDef FSMC_NANDInitStructure; FSMC_NAND_PCCARDTimingInitTypeDef p; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG, ENABLE); /*-- GPIO Configuration ------------------------------------------------------*/ /* CLE, ALE, D0->D3, NOE, NWE and NCE2 NAND pin configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_14 | GPIO_Pin_15 | GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOD, &GPIO_InitStructure); /* D4->D7 NAND pin configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10; GPIO_Init(GPIOE, &GPIO_InitStructure); /* NWAIT NAND pin configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(GPIOD, &GPIO_InitStructure); /* INT2 NAND pin configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_Init(GPIOG, &GPIO_InitStructure); /*-- FSMC Configuration ------------------------------------------------------*/ p.FSMC_SetupTime = 0x1; p.FSMC_WaitSetupTime = 0x3; p.FSMC_HoldSetupTime = 0x2; p.FSMC_HiZSetupTime = 0x1; FSMC_NANDInitStructure.FSMC_Bank = FSMC_Bank2_NAND; FSMC_NANDInitStructure.FSMC_Waitfeature = FSMC_Waitfeature_Enable; FSMC_NANDInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; FSMC_NANDInitStructure.FSMC_ECC = FSMC_ECC_Enable; FSMC_NANDInitStructure.FSMC_ECCPageSize = FSMC_ECCPageSize_512Bytes; FSMC_NANDInitStructure.FSMC_TCLRSetupTime = 0x00; FSMC_NANDInitStructure.FSMC_TARSetupTime = 0x00; FSMC_NANDInitStructure.FSMC_CommonSpaceTimingStruct = &p; FSMC_NANDInitStructure.FSMC_AttributeSpaceTimingStruct = &p; FSMC_NANDInit(&FSMC_NANDInitStructure); /* FSMC NAND Bank Cmd Test */ FSMC_NANDCmd(FSMC_Bank2_NAND, ENABLE); } /****************************************************************************** * Function Name : FSMC_NAND_ReadID * Description : Reads NAND memory's ID. * Input : - NAND_ID: pointer to a NAND_IDTypeDef structure which will hold * the Manufacturer and Device ID. * Output : None * Return : None *******************************************************************************/ void FSMC_NAND_ReadID(NAND_IDTypeDef* NAND_ID) { uint32_t data = 0; /* Send Command to the command area */ *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = 0x90; *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = 0x00; /* Sequence to read ID from NAND flash */ data = *(__IO uint32_t *)(Bank_NAND_ADDR | DATA_AREA); NAND_ID->Maker_ID = ADDR_1st_CYCLE (data); NAND_ID->Device_ID = ADDR_2nd_CYCLE (data); NAND_ID->Third_ID = ADDR_3rd_CYCLE (data); NAND_ID->Fourth_ID = ADDR_4th_CYCLE (data); } /****************************************************************************** * Function Name : FSMC_NAND_WriteSmallPage * Description : This routine is for writing one or several 512 Bytes Page size. * Input : - pBuffer: pointer on the Buffer containing data to be written * - Address: First page address * - NumPageToWrite: Number of page to write * Output : None * Return : New status of the NAND operation. This parameter can be: * - NAND_TIMEOUT_ERROR: when the previous operation generate * a Timeout error * - NAND_READY: when memory is ready for the next operation * And the new status of the increment address operation. It can be: * - NAND_VALID_ADDRESS: When the new address is valid address * - NAND_INVALID_ADDRESS: When the new address is invalid address *******************************************************************************/ uint32_t FSMC_NAND_WriteSmallPage(uint8_t *pBuffer, NAND_ADDRESS Address, uint32_t NumPageToWrite) { uint32_t index = 0x00, numpagewritten = 0x00, addressstatus = NAND_VALID_ADDRESS; uint32_t status = NAND_READY, size = 0x00; while((NumPageToWrite != 0x00) && (addressstatus == NAND_VALID_ADDRESS) && (status == NAND_READY)) { /* Page write command and address */ *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_AREA_A; *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_WRITE0; *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = 0x00; *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_1st_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_2nd_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_3rd_CYCLE(ROW_ADDRESS); /* Calculate the size */ size = NAND_PAGE_SIZE + (NAND_PAGE_SIZE * numpagewritten); /* Write data */ for(; index < size; index++) { *(__IO uint8_t *)(Bank_NAND_ADDR | DATA_AREA) = pBuffer[index]; } *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_WRITE_TRUE1; /* Check status for successful operation */ status = FSMC_NAND_GetStatus(); if(status == NAND_READY) { numpagewritten++; NumPageToWrite--; /* Calculate Next small page Address */ addressstatus = FSMC_NAND_AddressIncrement(&Address); } } return (status | addressstatus); } /****************************************************************************** * Function Name : FSMC_NAND_ReadSmallPage * Description : This routine is for sequential read from one or several * 512 Bytes Page size. * Input : - pBuffer: pointer on the Buffer to fill * - Address: First page address * - NumPageToRead: Number of page to read * Output : None * Return : New status of the NAND operation. This parameter can be: * - NAND_TIMEOUT_ERROR: when the previous operation generate * a Timeout error * - NAND_READY: when memory is ready for the next operation * And the new status of the increment address operation. It can be: * - NAND_VALID_ADDRESS: When the new address is valid address * - NAND_INVALID_ADDRESS: When the new address is invalid address *******************************************************************************/ uint32_t FSMC_NAND_ReadSmallPage(uint8_t *pBuffer, NAND_ADDRESS Address, uint32_t NumPageToRead) { uint32_t index = 0x00, numpageread = 0x00, addressstatus = NAND_VALID_ADDRESS; uint32_t status = NAND_READY, size = 0x00; while((NumPageToRead != 0x0) && (addressstatus == NAND_VALID_ADDRESS)) { /* Page Read command and page address */ *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_AREA_A; *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = 0x00; *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_1st_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_2nd_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_3rd_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_AREA_TRUE1; /* Calculate the size */ size = NAND_PAGE_SIZE + (NAND_PAGE_SIZE * numpageread); /* Get Data into Buffer */ for(; index < size; index++) { pBuffer[index]= *(__IO uint8_t *)(Bank_NAND_ADDR | DATA_AREA); } numpageread++; NumPageToRead--; /* Calculate page address */ addressstatus = FSMC_NAND_AddressIncrement(&Address); } status = FSMC_NAND_GetStatus(); return (status | addressstatus); } /****************************************************************************** * Function Name : FSMC_NAND_WriteSpareArea * Description : This routine write the spare area information for the specified * pages addresses. * Input : - pBuffer: pointer on the Buffer containing data to be written * - Address: First page address * - NumSpareAreaTowrite: Number of Spare Area to write * Output : None * Return : New status of the NAND operation. This parameter can be: * - NAND_TIMEOUT_ERROR: when the previous operation generate * a Timeout error * - NAND_READY: when memory is ready for the next operation * And the new status of the increment address operation. It can be: * - NAND_VALID_ADDRESS: When the new address is valid address * - NAND_INVALID_ADDRESS: When the new address is invalid address *******************************************************************************/ uint32_t FSMC_NAND_WriteSpareArea(uint8_t *pBuffer, NAND_ADDRESS Address, uint32_t NumSpareAreaTowrite) { uint32_t index = 0x00, numsparesreawritten = 0x00, addressstatus = NAND_VALID_ADDRESS; uint32_t status = NAND_READY, size = 0x00; while((NumSpareAreaTowrite != 0x00) && (addressstatus == NAND_VALID_ADDRESS) && (status == NAND_READY)) { /* Page write Spare area command and address */ *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_AREA_C; *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_WRITE0; *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = 0x00; *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_1st_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_2nd_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_3rd_CYCLE(ROW_ADDRESS); /* Calculate the size */ size = NAND_SPARE_AREA_SIZE + (NAND_SPARE_AREA_SIZE * numsparesreawritten); /* Write the data */ for(; index < size; index++) { *(__IO uint8_t *)(Bank_NAND_ADDR | DATA_AREA) = pBuffer[index]; } *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_WRITE_TRUE1; /* Check status for successful operation */ status = FSMC_NAND_GetStatus(); if(status == NAND_READY) { numsparesreawritten++; NumSpareAreaTowrite--; /* Calculate Next page Address */ addressstatus = FSMC_NAND_AddressIncrement(&Address); } } return (status | addressstatus); } /****************************************************************************** * Function Name : FSMC_NAND_ReadSpareArea * Description : This routine read the spare area information from the specified * pages addresses. * Input : - pBuffer: pointer on the Buffer to fill * - Address: First page address * - NumSpareAreaToRead: Number of Spare Area to read * Output : None * Return : New status of the NAND operation. This parameter can be: * - NAND_TIMEOUT_ERROR: when the previous operation generate * a Timeout error * - NAND_READY: when memory is ready for the next operation * And the new status of the increment address operation. It can be: * - NAND_VALID_ADDRESS: When the new address is valid address * - NAND_INVALID_ADDRESS: When the new address is invalid address *******************************************************************************/ uint32_t FSMC_NAND_ReadSpareArea(uint8_t *pBuffer, NAND_ADDRESS Address, uint32_t NumSpareAreaToRead) { uint32_t numsparearearead = 0x00, index = 0x00, addressstatus = NAND_VALID_ADDRESS; uint32_t status = NAND_READY, size = 0x00; while((NumSpareAreaToRead != 0x0) && (addressstatus == NAND_VALID_ADDRESS)) { /* Page Read command and page address */ *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_AREA_C; *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = 0x00; *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_1st_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_2nd_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_3rd_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_AREA_TRUE1; /* Data Read */ size = NAND_SPARE_AREA_SIZE + (NAND_SPARE_AREA_SIZE * numsparearearead); /* Get Data into Buffer */ for ( ;index < size; index++) { pBuffer[index] = *(__IO uint8_t *)(Bank_NAND_ADDR | DATA_AREA); } numsparearearead++; NumSpareAreaToRead--; /* Calculate page address */ addressstatus = FSMC_NAND_AddressIncrement(&Address); } status = FSMC_NAND_GetStatus(); return (status | addressstatus); } /****************************************************************************** * Function Name : FSMC_NAND_EraseBlock * Description : This routine erase complete block from NAND FLASH * Input : - Address: Any address into block to be erased * Output : None * Return : New status of the NAND operation. This parameter can be: * - NAND_TIMEOUT_ERROR: when the previous operation generate * a Timeout error * - NAND_READY: when memory is ready for the next operation *******************************************************************************/ uint32_t FSMC_NAND_EraseBlock(NAND_ADDRESS Address) { *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_ERASE0; *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_1st_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_2nd_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA) = ADDR_3rd_CYCLE(ROW_ADDRESS); *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_ERASE1; return (FSMC_NAND_GetStatus()); } /****************************************************************************** * Function Name : FSMC_NAND_Reset * Description : This routine reset the NAND FLASH * Input : None * Output : None * Return : NAND_READY *******************************************************************************/ uint32_t FSMC_NAND_Reset(void) { *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_RESET; return (NAND_READY); } /****************************************************************************** * Function Name : FSMC_NAND_GetStatus * Description : Get the NAND operation status * Input : None * Output : None * Return : New status of the NAND operation. This parameter can be: * - NAND_TIMEOUT_ERROR: when the previous operation generate * a Timeout error * - NAND_READY: when memory is ready for the next operation *******************************************************************************/ uint32_t FSMC_NAND_GetStatus(void) { uint32_t timeout = 0x1000000, status = NAND_READY; status = FSMC_NAND_ReadStatus(); /* Wait for a NAND operation to complete or a TIMEOUT to occur */ while ((status != NAND_READY) &&( timeout != 0x00)) { status = FSMC_NAND_ReadStatus(); timeout --; } if(timeout == 0x00) { status = NAND_TIMEOUT_ERROR; } /* Return the operation status */ return (status); } /****************************************************************************** * Function Name : FSMC_NAND_ReadStatus * Description : Reads the NAND memory status using the Read status command * Input : None * Output : None * Return : The status of the NAND memory. This parameter can be: * - NAND_BUSY: when memory is busy * - NAND_READY: when memory is ready for the next operation * - NAND_ERROR: when the previous operation gererates error *******************************************************************************/ uint32_t FSMC_NAND_ReadStatus(void) { uint32_t data = 0x00, status = NAND_BUSY; /* Read status operation ------------------------------------ */ *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_STATUS; data = *(__IO uint8_t *)(Bank_NAND_ADDR); if((data & NAND_ERROR) == NAND_ERROR) { status = NAND_ERROR; } else if((data & NAND_READY) == NAND_READY) { status = NAND_READY; } else { status = NAND_BUSY; } return (status); } /****************************************************************************** * Function Name : NAND_AddressIncrement * Description : Increment the NAND memory address * Input : - Address: address to be incremented. * Output : None * Return : The new status of the increment address operation. It can be: * - NAND_VALID_ADDRESS: When the new address is valid address * - NAND_INVALID_ADDRESS: When the new address is invalid address *******************************************************************************/ uint32_t FSMC_NAND_AddressIncrement(NAND_ADDRESS* Address) { uint32_t status = NAND_VALID_ADDRESS; Address->Page++; if(Address->Page == NAND_BLOCK_SIZE) { Address->Page = 0; Address->Block++; if(Address->Block == NAND_ZONE_SIZE) { Address->Block = 0; Address->Zone++; if(Address->Zone == NAND_MAX_ZONE) { status = NAND_INVALID_ADDRESS; } } } return (status); } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/fsmc_nand.c
C
asf20
20,582
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : memory.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Memory management layer ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "memory.h" #include "usb_scsi.h" #include "usb_bot.h" #include "usb_regs.h" #include "usb_mem.h" #include "usb_conf.h" #include "hw_config.h" #include "mass_mal.h" #include "usb_lib.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ __IO uint32_t Block_Read_count = 0; __IO uint32_t Block_offset; __IO uint32_t Counter = 0; uint32_t Idx; uint32_t Data_Buffer[BULK_MAX_PACKET_SIZE *2]; /* 512 bytes*/ uint8_t TransferState = TXFR_IDLE; /* Extern variables ----------------------------------------------------------*/ extern uint8_t Bulk_Data_Buff[BULK_MAX_PACKET_SIZE]; /* data buffer*/ extern uint16_t Data_Len; extern uint8_t Bot_State; extern Bulk_Only_CBW CBW; extern Bulk_Only_CSW CSW; extern uint32_t Mass_Memory_Size[2]; extern uint32_t Mass_Block_Size[2]; /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : Read_Memory * Description : Handle the Read operation from the microSD card. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Read_Memory(uint8_t lun, uint32_t Memory_Offset, uint32_t Transfer_Length) { static uint32_t Offset, Length; if (TransferState == TXFR_IDLE ) { Offset = Memory_Offset * Mass_Block_Size[lun]; Length = Transfer_Length * Mass_Block_Size[lun]; TransferState = TXFR_ONGOING; } if (TransferState == TXFR_ONGOING ) { if (!Block_Read_count) { MAL_Read(lun , Offset , Data_Buffer, Mass_Block_Size[lun]); USB_SIL_Write(EP1_IN, (uint8_t *)Data_Buffer, BULK_MAX_PACKET_SIZE); Block_Read_count = Mass_Block_Size[lun] - BULK_MAX_PACKET_SIZE; Block_offset = BULK_MAX_PACKET_SIZE; } else { USB_SIL_Write(EP1_IN, (uint8_t *)Data_Buffer + Block_offset, BULK_MAX_PACKET_SIZE); Block_Read_count -= BULK_MAX_PACKET_SIZE; Block_offset += BULK_MAX_PACKET_SIZE; } SetEPTxCount(ENDP1, BULK_MAX_PACKET_SIZE); #ifndef USE_STM3210C_EVAL SetEPTxStatus(ENDP1, EP_TX_VALID); #endif Offset += BULK_MAX_PACKET_SIZE; Length -= BULK_MAX_PACKET_SIZE; CSW.dDataResidue -= BULK_MAX_PACKET_SIZE; Led_RW_ON(); } if (Length == 0) { Block_Read_count = 0; Block_offset = 0; Offset = 0; Bot_State = BOT_DATA_IN_LAST; TransferState = TXFR_IDLE; Led_RW_OFF(); } } /******************************************************************************* * Function Name : Write_Memory * Description : Handle the Write operation to the microSD card. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Write_Memory (uint8_t lun, uint32_t Memory_Offset, uint32_t Transfer_Length) { static uint32_t W_Offset, W_Length; uint32_t temp = Counter + 64; if (TransferState == TXFR_IDLE ) { W_Offset = Memory_Offset * Mass_Block_Size[lun]; W_Length = Transfer_Length * Mass_Block_Size[lun]; TransferState = TXFR_ONGOING; } if (TransferState == TXFR_ONGOING ) { for (Idx = 0 ; Counter < temp; Counter++) { *((uint8_t *)Data_Buffer + Counter) = Bulk_Data_Buff[Idx++]; } W_Offset += Data_Len; W_Length -= Data_Len; if (!(W_Length % Mass_Block_Size[lun])) { Counter = 0; MAL_Write(lun , W_Offset - Mass_Block_Size[lun], Data_Buffer, Mass_Block_Size[lun]); } CSW.dDataResidue -= Data_Len; #ifndef STM32F10X_CL SetEPRxStatus(ENDP2, EP_RX_VALID); /* enable the next transaction*/ #endif /* STM32F10X_CL */ Led_RW_ON(); } if ((W_Length == 0) || (Bot_State == BOT_CSW_Send)) { Counter = 0; Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE); TransferState = TXFR_IDLE; Led_RW_OFF(); } } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/memory.c
C
asf20
5,656
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : stm32f10x_it.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Main Interrupt Service Routines. * This file provides template for all exceptions handler * and peripherals interrupt service routine. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x_it.h" #include "usb_lib.h" #include "usb_istr.h" #include "usb_pwr.h" #if defined(STM32F10X_HD) || defined(STM32F10X_XL) #include "stm32_eval_sdio_sd.h" #endif /* STM32F10X_HD | STM32F10X_XL*/ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /******************************************************************************* * Function Name : NMI_Handler * Description : This function handles NMI exception. * Input : None * Output : None * Return : None *******************************************************************************/ void NMI_Handler(void) { } /******************************************************************************* * Function Name : HardFault_Handler * Description : This function handles Hard Fault exception. * Input : None * Output : None * Return : None *******************************************************************************/ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /******************************************************************************* * Function Name : MemManage_Handler * Description : This function handles Memory Manage exception. * Input : None * Output : None * Return : None *******************************************************************************/ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /******************************************************************************* * Function Name : BusFault_Handler * Description : This function handles Bus Fault exception. * Input : None * Output : None * Return : None *******************************************************************************/ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /******************************************************************************* * Function Name : UsageFault_Handler * Description : This function handles Usage Fault exception. * Input : None * Output : None * Return : None *******************************************************************************/ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /******************************************************************************* * Function Name : SVC_Handler * Description : This function handles SVCall exception. * Input : None * Output : None * Return : None *******************************************************************************/ void SVC_Handler(void) { } /******************************************************************************* * Function Name : DebugMon_Handler * Description : This function handles Debug Monitor exception. * Input : None * Output : None * Return : None *******************************************************************************/ void DebugMon_Handler(void) { } /******************************************************************************* * Function Name : PendSV_Handler * Description : This function handles PendSVC exception. * Input : None * Output : None * Return : None *******************************************************************************/ void PendSV_Handler(void) { } /******************************************************************************* * Function Name : SysTick_Handler * Description : This function handles SysTick Handler. * Input : None * Output : None * Return : None *******************************************************************************/ void SysTick_Handler(void) { } /******************************************************************************/ /* STM32F10x Peripherals Interrupt Handlers */ /******************************************************************************/ #ifndef STM32F10X_CL /******************************************************************************* * Function Name : USB_HP_CAN1_TX_IRQHandler * Description : This function handles USB High Priority or CAN TX interrupts requests * requests. * Input : None * Output : None * Return : None *******************************************************************************/ void USB_HP_CAN1_TX_IRQHandler(void) { CTR_HP(); } /******************************************************************************* * Function Name : USB_LP_CAN1_RX0_IRQHandler * Description : This function handles USB Low Priority or CAN RX0 interrupts * requests. * Input : None * Output : None * Return : None *******************************************************************************/ void USB_LP_CAN1_RX0_IRQHandler(void) { USB_Istr(); } #endif /* STM32F10X_CL */ #if defined(STM32F10X_HD) || defined(STM32F10X_XL) /******************************************************************************* * Function Name : SDIO_IRQHandler * Description : This function handles SDIO global interrupt request. * requests. * Input : None * Output : None * Return : None *******************************************************************************/ void SDIO_IRQHandler(void) { /* Process All SDIO Interrupt Sources */ SD_ProcessIRQSrc(); } #endif /* STM32F10X_HD | STM32F10X_XL*/ #ifdef STM32F10X_CL /******************************************************************************* * Function Name : OTG_FS_IRQHandler * Description : This function handles USB-On-The-Go FS global interrupt request. * requests. * Input : None * Output : None * Return : None *******************************************************************************/ void OTG_FS_IRQHandler(void) { STM32_PCD_OTG_ISR_Handler(); } #endif /* STM32F10X_CL */ /******************************************************************************/ /* STM32F10x Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f10x_xx.s). */ /******************************************************************************/ /******************************************************************************* * Function Name : PPP_IRQHandler * Description : This function handles PPP interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ /*void PPP_IRQHandler(void) { }*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/stm32f10x_it.c
C
asf20
9,081
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : mass_mal.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Medium Access Layer interface ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "platform_config.h" #ifdef USE_STM3210E_EVAL #include "stm32_eval_sdio_sd.h" #else #include "stm32_eval_spi_sd.h" #endif /* USE_STM3210E_EVAL */ #include "fsmc_nand.h" #include "nand_if.h" #include "mass_mal.h" #include "stm32_eval.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint32_t Mass_Memory_Size[2]; uint32_t Mass_Block_Size[2]; uint32_t Mass_Block_Count[2]; __IO uint32_t Status = 0; #ifdef USE_STM3210E_EVAL SD_CardInfo SDCardInfo; #endif /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : MAL_Init * Description : Initializes the Media on the STM32 * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t MAL_Init(uint8_t lun) { uint16_t status = MAL_OK; switch (lun) { case 0: Status = SD_Init(); break; #ifdef USE_STM3210E_EVAL case 1: NAND_Init(); break; #endif default: return MAL_FAIL; } return status; } /******************************************************************************* * Function Name : MAL_Write * Description : Write sectors * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t MAL_Write(uint8_t lun, uint32_t Memory_Offset, uint32_t *Writebuff, uint16_t Transfer_Length) { switch (lun) { case 0: Status = SD_WriteBlock((uint8_t*)Writebuff, Memory_Offset, Transfer_Length); #ifdef USE_STM3210E_EVAL if ( Status != SD_OK ) { return MAL_FAIL; } #endif /* USE_STM3210E_EVAL */ break; #ifdef USE_STM3210E_EVAL case 1: NAND_Write(Memory_Offset, Writebuff, Transfer_Length); break; #endif /* USE_STM3210E_EVAL */ default: return MAL_FAIL; } return MAL_OK; } /******************************************************************************* * Function Name : MAL_Read * Description : Read sectors * Input : None * Output : None * Return : Buffer pointer *******************************************************************************/ uint16_t MAL_Read(uint8_t lun, uint32_t Memory_Offset, uint32_t *Readbuff, uint16_t Transfer_Length) { switch (lun) { case 0: Status = SD_ReadBlock((uint8_t*)Readbuff, Memory_Offset, Transfer_Length); #ifdef USE_STM3210E_EVAL if ( Status != SD_OK ) { return MAL_FAIL; } #endif /* USE_STM3210E_EVAL */ break; #ifdef USE_STM3210E_EVAL case 1: NAND_Read(Memory_Offset, Readbuff, Transfer_Length); ; break; #endif default: return MAL_FAIL; } return MAL_OK; } /******************************************************************************* * Function Name : MAL_GetStatus * Description : Get status * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t MAL_GetStatus (uint8_t lun) { #ifdef USE_STM3210E_EVAL NAND_IDTypeDef NAND_ID; uint32_t DeviceSizeMul = 0, NumberOfBlocks = 0; #else uint32_t temp_block_mul = 0; SD_CSD SD_csd; uint32_t DeviceSizeMul = 0; #endif /* USE_STM3210E_EVAL */ if (lun == 0) { #ifdef USE_STM3210E_EVAL if (SD_Init() == SD_OK) { SD_GetCardInfo(&SDCardInfo); SD_SelectDeselect((uint32_t) (SDCardInfo.RCA << 16)); DeviceSizeMul = (SDCardInfo.SD_csd.DeviceSizeMul + 2); if(SDCardInfo.CardType == SDIO_HIGH_CAPACITY_SD_CARD) { Mass_Block_Count[0] = (SDCardInfo.SD_csd.DeviceSize + 1) * 1024; } else { NumberOfBlocks = ((1 << (SDCardInfo.SD_csd.RdBlockLen)) / 512); Mass_Block_Count[0] = ((SDCardInfo.SD_csd.DeviceSize + 1) * (1 << DeviceSizeMul) << (NumberOfBlocks/2)); } Mass_Block_Size[0] = 512; Status = SD_SelectDeselect((uint32_t) (SDCardInfo.RCA << 16)); Status = SD_EnableWideBusOperation(SDIO_BusWide_4b); if ( Status != SD_OK ) { return MAL_FAIL; } Status = SD_SetDeviceMode(SD_DMA_MODE); if ( Status != SD_OK ) { return MAL_FAIL; } #else SD_GetCSDRegister(&SD_csd); DeviceSizeMul = SD_csd.DeviceSizeMul + 2; temp_block_mul = (1 << SD_csd.RdBlockLen)/ 512; Mass_Block_Count[0] = ((SD_csd.DeviceSize + 1) * (1 << (DeviceSizeMul))) * temp_block_mul; Mass_Block_Size[0] = 512; Mass_Memory_Size[0] = (Mass_Block_Count[0] * Mass_Block_Size[0]); #endif /* USE_STM3210E_EVAL */ Mass_Memory_Size[0] = Mass_Block_Count[0] * Mass_Block_Size[0]; STM_EVAL_LEDOn(LED2); return MAL_OK; #ifdef USE_STM3210E_EVAL } #endif /* USE_STM3210E_EVAL */ } #ifdef USE_STM3210E_EVAL else { FSMC_NAND_ReadID(&NAND_ID); if (NAND_ID.Device_ID != 0 ) { /* only one zone is used */ Mass_Block_Count[1] = NAND_ZONE_SIZE * NAND_BLOCK_SIZE * NAND_MAX_ZONE ; Mass_Block_Size[1] = NAND_PAGE_SIZE; Mass_Memory_Size[1] = (Mass_Block_Count[1] * Mass_Block_Size[1]); return MAL_OK; } } #endif /* USE_STM3210E_EVAL */ STM_EVAL_LEDOn(LED2); return MAL_FAIL; } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/mass_mal.c
C
asf20
7,010
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : nand_if.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : manage NAND operationx state machine ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ #include "platform_config.h" #ifdef USE_STM3210E_EVAL /* Includes ------------------------------------------------------------------*/ #include "nand_if.h" #include "mass_mal.h" #include "fsmc_nand.h" #include "memory.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* extern variables-----------------------------------------------------------*/ extern uint32_t SCSI_LBA; extern uint32_t SCSI_BlkLen; /* Private variables ---------------------------------------------------------*/ uint16_t LUT[1024]; //Look Up Table Buffer WRITE_STATE Write_State; BLOCK_STATE Block_State; NAND_ADDRESS wAddress, fAddress; uint16_t phBlock, LogAddress, Initial_Page, CurrentZone = 0; uint16_t Written_Pages = 0; uint16_t LUT[1024]; //Look Up Table Buffer /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ static uint16_t NAND_CleanLUT(uint8_t ZoneNbr); static NAND_ADDRESS NAND_GetAddress(uint32_t Address); static uint16_t NAND_GetFreeBlock(void); static uint16_t NAND_Write_Cleanup(void); SPARE_AREA ReadSpareArea(uint32_t address); static uint16_t NAND_Copy(NAND_ADDRESS Address_Src, NAND_ADDRESS Address_Dest, uint16_t PageToCopy); static NAND_ADDRESS NAND_ConvertPhyAddress(uint32_t Address); static uint16_t NAND_BuildLUT(uint8_t ZoneNbr); /******************************************************************************* * Function Name : NAND_Init * Description : Init NAND Interface * Input : None * Output : None * Return : Status *******************************************************************************/ uint16_t NAND_Init(void) { uint16_t Status = NAND_OK; FSMC_NAND_Init(); Status = NAND_BuildLUT(0); Write_State = WRITE_IDLE; return Status; } /******************************************************************************* * Function Name : NAND_Write * Description : write one sector by once * Input : None * Output : None * Return : Status *******************************************************************************/ uint16_t NAND_Write(uint32_t Memory_Offset, uint32_t *Writebuff, uint16_t Transfer_Length) { /* check block status and calculate start and end addreses */ wAddress = NAND_GetAddress(Memory_Offset / 512); /*check Zone: if second zone is requested build second LUT*/ if (wAddress.Zone != CurrentZone) { CurrentZone = wAddress.Zone; NAND_BuildLUT(CurrentZone); } phBlock = LUT[wAddress.Block]; /* Block Index + flags */ LogAddress = wAddress.Block ; /* save logical block */ /* IDLE state */ /****************/ if ( Write_State == WRITE_IDLE) {/* Idle state */ if (phBlock & USED_BLOCK) { /* USED BLOCK */ Block_State = OLD_BLOCK; /* Get a free Block for swap */ fAddress.Block = NAND_GetFreeBlock(); fAddress.Zone = wAddress.Zone; Initial_Page = fAddress.Page = wAddress.Page; /* write the new page */ FSMC_NAND_WriteSmallPage((uint8_t *)Writebuff, fAddress, PAGE_TO_WRITE); Written_Pages++; /* get physical block */ wAddress.Block = phBlock & 0x3FF; if (Written_Pages == SCSI_BlkLen) { NAND_Write_Cleanup(); Written_Pages = 0; return NAND_OK; } else { if (wAddress.Page == (NAND_BLOCK_SIZE - 1)) { NAND_Write_Cleanup(); return NAND_OK; } Write_State = WRITE_ONGOING; return NAND_OK; } } else {/* UNUSED BLOCK */ Block_State = UNUSED_BLOCK; /* write the new page */ wAddress.Block = phBlock & 0x3FF; FSMC_NAND_WriteSmallPage( (uint8_t *)Writebuff , wAddress, PAGE_TO_WRITE); Written_Pages++; if (Written_Pages == SCSI_BlkLen) { Written_Pages = 0; NAND_Write_Cleanup(); return NAND_OK; } else { Write_State = WRITE_ONGOING; return NAND_OK; } } } /* WRITE state */ /***************/ if ( Write_State == WRITE_ONGOING) {/* Idle state */ if (phBlock & USED_BLOCK) { /* USED BLOCK */ wAddress.Block = phBlock & 0x3FF; Block_State = OLD_BLOCK; fAddress.Page = wAddress.Page; /* check if next pages are in next block */ if (wAddress.Page == (NAND_BLOCK_SIZE - 1)) { /* write Last page */ FSMC_NAND_WriteSmallPage( (uint8_t *)Writebuff , fAddress, PAGE_TO_WRITE); Written_Pages++; if (Written_Pages == SCSI_BlkLen) { Written_Pages = 0; } /* Clean up and Update the LUT */ NAND_Write_Cleanup(); Write_State = WRITE_IDLE; return NAND_OK; } /* write next page */ FSMC_NAND_WriteSmallPage( (uint8_t *)Writebuff , fAddress, PAGE_TO_WRITE); Written_Pages++; if (Written_Pages == SCSI_BlkLen) { Write_State = WRITE_IDLE; NAND_Write_Cleanup(); Written_Pages = 0; } } else {/* UNUSED BLOCK */ wAddress.Block = phBlock & 0x3FF; /* check if it is the last page in prev block */ if (wAddress.Page == (NAND_BLOCK_SIZE - 1)) { /* write Last page */ FSMC_NAND_WriteSmallPage( (uint8_t *)Writebuff , wAddress, PAGE_TO_WRITE); Written_Pages++; if (Written_Pages == SCSI_BlkLen) { Written_Pages = 0; } /* Clean up and Update the LUT */ NAND_Write_Cleanup(); Write_State = WRITE_IDLE; return NAND_OK; } /* write next page in same block */ FSMC_NAND_WriteSmallPage( (uint8_t *)Writebuff , wAddress, PAGE_TO_WRITE); Written_Pages++; if (Written_Pages == SCSI_BlkLen) { Write_State = WRITE_IDLE; NAND_Write_Cleanup(); Written_Pages = 0; } } } return NAND_OK; } /******************************************************************************* * Function Name : NAND_Read * Description : Read sectors * Input : None * Output : None * Return : Status *******************************************************************************/ uint16_t NAND_Read(uint32_t Memory_Offset, uint32_t *Readbuff, uint16_t Transfer_Length) { NAND_ADDRESS phAddress; phAddress = NAND_GetAddress(Memory_Offset / 512); if (phAddress.Zone != CurrentZone) { CurrentZone = phAddress.Zone; NAND_BuildLUT(CurrentZone); } if (LUT [phAddress.Block] & BAD_BLOCK) { return NAND_FAIL; } else { phAddress.Block = LUT [phAddress.Block] & ~ (USED_BLOCK | VALID_BLOCK); FSMC_NAND_ReadSmallPage ( (uint8_t *)Readbuff , phAddress, Transfer_Length / 512); } return NAND_OK; } /******************************************************************************* * Function Name : NAND_CleanLUT * Description : Erase old blocks & rebuild the look up table * Input : None * Output : None * Return : Status *******************************************************************************/ static uint16_t NAND_CleanLUT (uint8_t ZoneNbr) { #ifdef WEAR_LEVELLING_SUPPORT uint16_t BlockIdx, LUT_Item; #endif /* Rebuild the LUT for the current zone */ NAND_BuildLUT (ZoneNbr); #ifdef WEAR_LEVELLING_SUPPORT /* Wear Leveling : circular use of free blocks */ LUT_Item = LUT [BlockIdx] for (BlockIdx == MAX_LOG_BLOCKS_PER_ZONE ; BlockIdx < MAX_LOG_BLOCKS_PER_ZONE + WEAR_DEPTH ; BlockIdx++) { LUT [BlockIdx] = LUT [BlockIdx + 1]; } LUT [ MAX_LOG_BLOCKS_PER_ZONE + WEAR_DEPTH - 1] = LUT_Item ; #endif return NAND_OK; } /******************************************************************************* * Function Name : NAND_GetAddress * Description : Translate logical address into a phy one * Input : None * Output : None * Return : Status *******************************************************************************/ static NAND_ADDRESS NAND_GetAddress (uint32_t Address) { NAND_ADDRESS Address_t; Address_t.Page = Address & (NAND_BLOCK_SIZE - 1); Address_t.Block = Address / NAND_BLOCK_SIZE; Address_t.Zone = 0; while (Address_t.Block >= MAX_LOG_BLOCKS_PER_ZONE) { Address_t.Block -= MAX_LOG_BLOCKS_PER_ZONE; Address_t.Zone++; } return Address_t; } /******************************************************************************* * Function Name : NAND_GetFreeBlock * Description : Look for a free block for data exchange * Input : None * Output : None * Return : Status *******************************************************************************/ static uint16_t NAND_GetFreeBlock (void) { return LUT[MAX_LOG_BLOCKS_PER_ZONE]& ~(USED_BLOCK | VALID_BLOCK); } /******************************************************************************* * Function Name : ReadSpareArea * Description : Check used block * Input : None * Output : None * Return : Status *******************************************************************************/ SPARE_AREA ReadSpareArea (uint32_t address) { SPARE_AREA t; uint8_t Buffer[16]; NAND_ADDRESS address_s; address_s = NAND_ConvertPhyAddress(address); FSMC_NAND_ReadSpareArea(Buffer , address_s, 1) ; t = *(SPARE_AREA *)Buffer; return t; } /******************************************************************************* * Function Name : NAND_Copy * Description : Copy page * Input : None * Output : None * Return : Status *******************************************************************************/ static uint16_t NAND_Copy (NAND_ADDRESS Address_Src, NAND_ADDRESS Address_Dest, uint16_t PageToCopy) { uint8_t Copybuff[512]; for ( ; PageToCopy > 0 ; PageToCopy-- ) { FSMC_NAND_ReadSmallPage ((uint8_t *)Copybuff, Address_Src , 1 ); FSMC_NAND_WriteSmallPage ((uint8_t *)Copybuff, Address_Dest, 1); FSMC_NAND_AddressIncrement(&Address_Src); FSMC_NAND_AddressIncrement(&Address_Dest); } return NAND_OK; } /******************************************************************************* * Function Name : NAND_Format * Description : Format the entire NAND flash * Input : None * Output : None * Return : Status *******************************************************************************/ uint16_t NAND_Format (void) { NAND_ADDRESS phAddress; SPARE_AREA SpareArea; uint32_t BlockIndex; for (BlockIndex = 0 ; BlockIndex < NAND_ZONE_SIZE * NAND_MAX_ZONE; BlockIndex++) { phAddress = NAND_ConvertPhyAddress(BlockIndex * NAND_BLOCK_SIZE ); SpareArea = ReadSpareArea(BlockIndex * NAND_BLOCK_SIZE); if((SpareArea.DataStatus != 0)||(SpareArea.BlockStatus != 0)){ FSMC_NAND_EraseBlock (phAddress); } } NAND_BuildLUT(0); return NAND_OK; } /******************************************************************************* * Function Name : NAND_Write_Cleanup * Description : None * Input : None * Output : None * Return : Status *******************************************************************************/ static uint16_t NAND_Write_Cleanup (void) { uint16_t tempSpareArea [8]; uint16_t Page_Back; if ( Block_State == OLD_BLOCK ) { /* precopy old first pages */ if (Initial_Page != 0) { Page_Back = wAddress.Page; fAddress.Page = wAddress.Page = 0; NAND_Copy (wAddress, fAddress, Initial_Page); wAddress.Page = Page_Back ; } /* postcopy remaining pages */ if ((NAND_BLOCK_SIZE - (wAddress.Page + 1)) != 0) { FSMC_NAND_AddressIncrement(&wAddress); fAddress.Page = wAddress.Page; NAND_Copy (wAddress, fAddress, NAND_BLOCK_SIZE - wAddress.Page); } /* assign logical address to new block */ tempSpareArea [0] = LogAddress | USED_BLOCK ; tempSpareArea [1] = 0xFFFF; tempSpareArea [2] = 0xFFFF; fAddress.Page = 0x00; FSMC_NAND_WriteSpareArea( (uint8_t *)tempSpareArea , fAddress , 1); /* erase old block */ FSMC_NAND_EraseBlock(wAddress); NAND_CleanLUT(wAddress.Zone); } else {/* unused block case */ /* assign logical address to the new used block */ tempSpareArea [0] = LogAddress | USED_BLOCK ; tempSpareArea [1] = 0xFFFF; tempSpareArea [2] = 0xFFFF; wAddress.Page = 0x00; FSMC_NAND_WriteSpareArea((uint8_t *)tempSpareArea , wAddress, 1); NAND_CleanLUT(wAddress.Zone); } return NAND_OK; } /******************************************************************************* * Function Name : NAND_ConvertPhyAddress * Description : None * Input : physical Address * Output : None * Return : Status *******************************************************************************/ static NAND_ADDRESS NAND_ConvertPhyAddress (uint32_t Address) { NAND_ADDRESS Address_t; Address_t.Page = Address & (NAND_BLOCK_SIZE - 1); Address_t.Block = Address / NAND_BLOCK_SIZE; Address_t.Zone = 0; while (Address_t.Block >= MAX_PHY_BLOCKS_PER_ZONE) { Address_t.Block -= MAX_PHY_BLOCKS_PER_ZONE; Address_t.Zone++; } return Address_t; } /******************************************************************************* * Function Name : NAND_BuildLUT * Description : Build the look up table * Input : None * Output : None * Return : Status * !!!! NOTE : THIS ALGORITHM IS A SUBJECT OF PATENT FOR STMICROELECTRONICS !!!!! *******************************************************************************/ static uint16_t NAND_BuildLUT (uint8_t ZoneNbr) { uint16_t pBadBlock, pCurrentBlock, pFreeBlock; SPARE_AREA SpareArea; /***************************************************************************** 1st step : Init. *****************************************************************************/ /*Init the LUT (assume all blocks free) */ for (pCurrentBlock = 0 ; pCurrentBlock < MAX_PHY_BLOCKS_PER_ZONE ; pCurrentBlock++) { LUT[pCurrentBlock] = FREE_BLOCK; /* 12th bit is set to 1 */ } /* Init Pointers */ pBadBlock = MAX_PHY_BLOCKS_PER_ZONE - 1; pCurrentBlock = 0; /***************************************************************************** 2nd step : locate used and bad blocks *****************************************************************************/ while (pCurrentBlock < MAX_PHY_BLOCKS_PER_ZONE) { SpareArea = ReadSpareArea(pCurrentBlock * NAND_BLOCK_SIZE + (ZoneNbr * NAND_BLOCK_SIZE * MAX_PHY_BLOCKS_PER_ZONE)); if ((SpareArea.DataStatus == 0) || (SpareArea.BlockStatus == 0)) { LUT[pBadBlock--] |= pCurrentBlock | (uint16_t)BAD_BLOCK ; LUT[pCurrentBlock] &= (uint16_t)~FREE_BLOCK; if (pBadBlock == MAX_LOG_BLOCKS_PER_ZONE) { return NAND_FAIL; } } else if (SpareArea.LogicalIndex != 0xFFFF) { LUT[SpareArea.LogicalIndex & 0x3FF] |= pCurrentBlock | VALID_BLOCK | USED_BLOCK; LUT[pCurrentBlock] &= (uint16_t)( ~FREE_BLOCK); } pCurrentBlock++ ; } /***************************************************************************** 3rd step : locate Free Blocks by scanning the LUT already built partially *****************************************************************************/ pFreeBlock = 0; for (pCurrentBlock = 0 ; pCurrentBlock < MAX_PHY_BLOCKS_PER_ZONE ; pCurrentBlock++ ) { if ( !(LUT[pCurrentBlock]& USED_BLOCK)) { do { if (LUT[pFreeBlock] & FREE_BLOCK) { LUT [pCurrentBlock] |= pFreeBlock; LUT [pFreeBlock] &= ~FREE_BLOCK; break; } pFreeBlock++; } while ( pFreeBlock < MAX_PHY_BLOCKS_PER_ZONE ); } } return NAND_OK; } #endif /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/nand_if.c
C
asf20
17,581
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_pwr.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Connection/disconnection & power management ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "usb_lib.h" #include "usb_conf.h" #include "usb_pwr.h" #include "hw_config.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ __IO uint32_t bDeviceState = UNCONNECTED; /* USB device status */ __IO bool fSuspendEnabled = TRUE; /* true when suspend is possible */ struct { __IO RESUME_STATE eState; __IO uint8_t bESOFcnt; } ResumeS; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : PowerOn * Description : * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ RESULT PowerOn(void) { #ifndef STM32F10X_CL u16 wRegVal; /*** cable plugged-in ? ***/ /*while(!CablePluggedIn());*/ USB_Cable_Config(ENABLE); /*** CNTR_PWDN = 0 ***/ wRegVal = CNTR_FRES; _SetCNTR(wRegVal); /*** CNTR_FRES = 0 ***/ wInterrupt_Mask = 0; _SetCNTR(wInterrupt_Mask); /*** Clear pending interrupts ***/ _SetISTR(0); /*** Set interrupt mask ***/ wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM; _SetCNTR(wInterrupt_Mask); #endif /* STM32F10X_CL */ return USB_SUCCESS; } /******************************************************************************* * Function Name : PowerOff * Description : handles switch-off conditions * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ RESULT PowerOff() { #ifndef STM32F10X_CL /* disable all ints and force USB reset */ _SetCNTR(CNTR_FRES); /* clear interrupt status register */ _SetISTR(0); /* Disable the Pull-Up*/ USB_Cable_Config(DISABLE); /* switch-off device */ _SetCNTR(CNTR_FRES + CNTR_PDWN); /* sw variables reset */ /* ... */ #endif /* STM32F10X_CL */ return USB_SUCCESS; } /******************************************************************************* * Function Name : Suspend * Description : sets suspend mode operating conditions * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ void Suspend(void) { /* suspend preparation */ /* ... */ #ifndef STM32F10X_CL uint16_t wCNTR; /* macrocell enters suspend mode */ wCNTR = _GetCNTR(); wCNTR |= CNTR_FSUSP; _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */ /* power reduction */ /* ... on connected devices */ #ifndef STM32F10X_CL /* force low-power mode in the macrocell */ wCNTR = _GetCNTR(); wCNTR |= CNTR_LPMODE; _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ /* switch-off the clocks */ /* ... */ Enter_LowPowerMode(); } /******************************************************************************* * Function Name : Resume_Init * Description : Handles wake-up restoring normal operations * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ void Resume_Init(void) { /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */ /* restart the clocks */ /* ... */ #ifndef STM32F10X_CL u16 wCNTR; /* CNTR_LPMODE = 0 */ wCNTR = _GetCNTR(); wCNTR &= (~CNTR_LPMODE); _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ /* restore full power */ /* ... on connected devices */ Leave_LowPowerMode(); #ifndef STM32F10X_CL /* reset FSUSP bit */ _SetCNTR(IMR_MSK); #endif /* STM32F10X_CL */ /* reverse suspend preparation */ /* ... */ } /******************************************************************************* * Function Name : Resume * Description : This is the state machine handling resume operations and * timing sequence. The control is based on the Resume structure * variables and on the ESOF interrupt calling this subroutine * without changing machine state. * Input : a state machine value (RESUME_STATE) * RESUME_ESOF doesn't change ResumeS.eState allowing * decrementing of the ESOF counter in different states. * Output : None. * Return : None. *******************************************************************************/ void Resume(RESUME_STATE eResumeSetVal) { #ifndef STM32F10X_CL u16 wCNTR; #endif /* STM32F10X_CL */ if (eResumeSetVal != RESUME_ESOF) ResumeS.eState = eResumeSetVal; switch (ResumeS.eState) { case RESUME_EXTERNAL: Resume_Init(); ResumeS.eState = RESUME_OFF; break; case RESUME_INTERNAL: Resume_Init(); ResumeS.eState = RESUME_START; break; case RESUME_LATER: ResumeS.bESOFcnt = 2; ResumeS.eState = RESUME_WAIT; break; case RESUME_WAIT: ResumeS.bESOFcnt--; if (ResumeS.bESOFcnt == 0) ResumeS.eState = RESUME_START; break; case RESUME_START: #ifdef STM32F10X_CL OTGD_FS_SetRemoteWakeup(); #else wCNTR = _GetCNTR(); wCNTR |= CNTR_RESUME; _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ ResumeS.eState = RESUME_ON; ResumeS.bESOFcnt = 10; break; case RESUME_ON: #ifndef STM32F10X_CL ResumeS.bESOFcnt--; if (ResumeS.bESOFcnt == 0) { #endif /* STM32F10X_CL */ #ifdef STM32F10X_CL OTGD_FS_ResetRemoteWakeup(); #else wCNTR = _GetCNTR(); wCNTR &= (~CNTR_RESUME); _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ ResumeS.eState = RESUME_OFF; #ifndef STM32F10X_CL } #endif /* STM32F10X_CL */ break; case RESUME_OFF: case RESUME_ESOF: default: ResumeS.eState = RESUME_OFF; break; } } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/usb_pwr.c
C
asf20
7,811
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_prop.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : All processing related to Mass Storage Demo ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_lib.h" #include "usb_desc.h" #include "usb_pwr.h" #include "usb_bot.h" #include "hw_config.h" #include "memory.h" #include "mass_mal.h" #include "usb_prop.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ #ifdef USE_STM3210B_EVAL u32 Max_Lun = 0; #elif defined (USE_STM3210E_EVAL) u32 Max_Lun = 1; #elif defined (USE_STM3210C_EVAL) u32 Max_Lun = 0; #endif DEVICE Device_Table = { EP_NUM, 1 }; DEVICE_PROP Device_Property = { MASS_init, MASS_Reset, MASS_Status_In, MASS_Status_Out, MASS_Data_Setup, MASS_NoData_Setup, MASS_Get_Interface_Setting, MASS_GetDeviceDescriptor, MASS_GetConfigDescriptor, MASS_GetStringDescriptor, 0, 0x40 /*MAX PACKET SIZE*/ }; USER_STANDARD_REQUESTS User_Standard_Requests = { Mass_Storage_GetConfiguration, Mass_Storage_SetConfiguration, Mass_Storage_GetInterface, Mass_Storage_SetInterface, Mass_Storage_GetStatus, Mass_Storage_ClearFeature, Mass_Storage_SetEndPointFeature, Mass_Storage_SetDeviceFeature, Mass_Storage_SetDeviceAddress }; ONE_DESCRIPTOR Device_Descriptor = { (uint8_t*)MASS_DeviceDescriptor, MASS_SIZ_DEVICE_DESC }; ONE_DESCRIPTOR Config_Descriptor = { (uint8_t*)MASS_ConfigDescriptor, MASS_SIZ_CONFIG_DESC }; ONE_DESCRIPTOR String_Descriptor[5] = { {(uint8_t*)MASS_StringLangID, MASS_SIZ_STRING_LANGID}, {(uint8_t*)MASS_StringVendor, MASS_SIZ_STRING_VENDOR}, {(uint8_t*)MASS_StringProduct, MASS_SIZ_STRING_PRODUCT}, {(uint8_t*)MASS_StringSerial, MASS_SIZ_STRING_SERIAL}, {(uint8_t*)MASS_StringInterface, MASS_SIZ_STRING_INTERFACE}, }; /* Extern variables ----------------------------------------------------------*/ extern unsigned char Bot_State; extern Bulk_Only_CBW CBW; /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : MASS_init * Description : Mass Storage init routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void MASS_init() { /* Update the serial number string descriptor with the data from the unique ID*/ Get_SerialNum(); pInformation->Current_Configuration = 0; /* Connect the device */ PowerOn(); /* Perform basic device initialization operations */ USB_SIL_Init(); bDeviceState = UNCONNECTED; } /******************************************************************************* * Function Name : MASS_Reset * Description : Mass Storage reset routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void MASS_Reset() { /* Set the device as not configured */ Device_Info.Current_Configuration = 0; /* Current Feature initialization */ pInformation->Current_Feature = MASS_ConfigDescriptor[7]; #ifdef STM32F10X_CL /* EP0 is already configured by USB_SIL_Init() function */ /* Init EP1 IN as Bulk endpoint */ OTG_DEV_EP_Init(EP1_IN, OTG_DEV_EP_TYPE_BULK, BULK_MAX_PACKET_SIZE); /* Init EP2 OUT as Bulk endpoint */ OTG_DEV_EP_Init(EP2_OUT, OTG_DEV_EP_TYPE_BULK, BULK_MAX_PACKET_SIZE); #else SetBTABLE(BTABLE_ADDRESS); /* Initialize Endpoint 0 */ SetEPType(ENDP0, EP_CONTROL); SetEPTxStatus(ENDP0, EP_TX_NAK); SetEPRxAddr(ENDP0, ENDP0_RXADDR); SetEPRxCount(ENDP0, Device_Property.MaxPacketSize); SetEPTxAddr(ENDP0, ENDP0_TXADDR); Clear_Status_Out(ENDP0); SetEPRxValid(ENDP0); /* Initialize Endpoint 1 */ SetEPType(ENDP1, EP_BULK); SetEPTxAddr(ENDP1, ENDP1_TXADDR); SetEPTxStatus(ENDP1, EP_TX_NAK); SetEPRxStatus(ENDP1, EP_RX_DIS); /* Initialize Endpoint 2 */ SetEPType(ENDP2, EP_BULK); SetEPRxAddr(ENDP2, ENDP2_RXADDR); SetEPRxCount(ENDP2, Device_Property.MaxPacketSize); SetEPRxStatus(ENDP2, EP_RX_VALID); SetEPTxStatus(ENDP2, EP_TX_DIS); SetEPRxCount(ENDP0, Device_Property.MaxPacketSize); SetEPRxValid(ENDP0); /* Set the device to response on default address */ SetDeviceAddress(0); #endif /* STM32F10X_CL */ bDeviceState = ATTACHED; CBW.dSignature = BOT_CBW_SIGNATURE; Bot_State = BOT_IDLE; USB_NotConfigured_LED(); } /******************************************************************************* * Function Name : Mass_Storage_SetConfiguration * Description : Handle the SetConfiguration request. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Mass_Storage_SetConfiguration(void) { if (pInformation->Current_Configuration != 0) { /* Device configured */ bDeviceState = CONFIGURED; #ifdef STM32F10X_CL /* Init EP1 IN as Bulk endpoint */ OTG_DEV_EP_Init(EP1_IN, OTG_DEV_EP_TYPE_BULK, BULK_MAX_PACKET_SIZE); /* Init EP2 OUT as Bulk endpoint */ OTG_DEV_EP_Init(EP2_OUT, OTG_DEV_EP_TYPE_BULK, BULK_MAX_PACKET_SIZE); #else ClearDTOG_TX(ENDP1); ClearDTOG_RX(ENDP2); #endif /* STM32F10X_CL */ Bot_State = BOT_IDLE; /* set the Bot state machine to the IDLE state */ } } /******************************************************************************* * Function Name : Mass_Storage_ClearFeature * Description : Handle the ClearFeature request. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Mass_Storage_ClearFeature(void) { /* when the host send a CBW with invalid signature or invalid length the two Endpoints (IN & OUT) shall stall until receiving a Mass Storage Reset */ if (CBW.dSignature != BOT_CBW_SIGNATURE) Bot_Abort(BOTH_DIR); } /******************************************************************************* * Function Name : Mass_Storage_SetConfiguration. * Description : Udpade the device state to addressed. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Mass_Storage_SetDeviceAddress (void) { bDeviceState = ADDRESSED; } /******************************************************************************* * Function Name : MASS_Status_In * Description : Mass Storage Status IN routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void MASS_Status_In(void) { return; } /******************************************************************************* * Function Name : MASS_Status_Out * Description : Mass Storage Status OUT routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void MASS_Status_Out(void) { return; } /******************************************************************************* * Function Name : MASS_Data_Setup. * Description : Handle the data class specific requests.. * Input : RequestNo. * Output : None. * Return : RESULT. *******************************************************************************/ RESULT MASS_Data_Setup(uint8_t RequestNo) { uint8_t *(*CopyRoutine)(uint16_t); CopyRoutine = NULL; if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) && (RequestNo == GET_MAX_LUN) && (pInformation->USBwValue == 0) && (pInformation->USBwIndex == 0) && (pInformation->USBwLength == 0x01)) { CopyRoutine = Get_Max_Lun; } else { return USB_UNSUPPORT; } if (CopyRoutine == NULL) { return USB_UNSUPPORT; } pInformation->Ctrl_Info.CopyData = CopyRoutine; pInformation->Ctrl_Info.Usb_wOffset = 0; (*CopyRoutine)(0); return USB_SUCCESS; } /******************************************************************************* * Function Name : MASS_NoData_Setup. * Description : Handle the no data class specific requests. * Input : RequestNo. * Output : None. * Return : RESULT. *******************************************************************************/ RESULT MASS_NoData_Setup(uint8_t RequestNo) { if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) && (RequestNo == MASS_STORAGE_RESET) && (pInformation->USBwValue == 0) && (pInformation->USBwIndex == 0) && (pInformation->USBwLength == 0x00)) { #ifdef STM32F10X_CL /* Init EP1 IN as Bulk endpoint */ OTG_DEV_EP_Init(EP1_IN, OTG_DEV_EP_TYPE_BULK, BULK_MAX_PACKET_SIZE); /* Init EP2 OUT as Bulk endpoint */ OTG_DEV_EP_Init(EP2_OUT, OTG_DEV_EP_TYPE_BULK, BULK_MAX_PACKET_SIZE); #else /* Initialize Endpoint 1 */ ClearDTOG_TX(ENDP1); /* Initialize Endpoint 2 */ ClearDTOG_RX(ENDP2); #endif /* STM32F10X_CL */ /*intialise the CBW signature to enable the clear feature*/ CBW.dSignature = BOT_CBW_SIGNATURE; Bot_State = BOT_IDLE; return USB_SUCCESS; } return USB_UNSUPPORT; } /******************************************************************************* * Function Name : MASS_Get_Interface_Setting * Description : Test the interface and the alternate setting according to the * supported one. * Input : uint8_t Interface, uint8_t AlternateSetting. * Output : None. * Return : RESULT. *******************************************************************************/ RESULT MASS_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting) { if (AlternateSetting > 0) { return USB_UNSUPPORT;/* in this application we don't have AlternateSetting*/ } else if (Interface > 0) { return USB_UNSUPPORT;/*in this application we have only 1 interfaces*/ } return USB_SUCCESS; } /******************************************************************************* * Function Name : MASS_GetDeviceDescriptor * Description : Get the device descriptor. * Input : uint16_t Length. * Output : None. * Return : None. *******************************************************************************/ uint8_t *MASS_GetDeviceDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Device_Descriptor ); } /******************************************************************************* * Function Name : MASS_GetConfigDescriptor * Description : Get the configuration descriptor. * Input : uint16_t Length. * Output : None. * Return : None. *******************************************************************************/ uint8_t *MASS_GetConfigDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Config_Descriptor ); } /******************************************************************************* * Function Name : MASS_GetStringDescriptor * Description : Get the string descriptors according to the needed index. * Input : uint16_t Length. * Output : None. * Return : None. *******************************************************************************/ uint8_t *MASS_GetStringDescriptor(uint16_t Length) { uint8_t wValue0 = pInformation->USBwValue0; if (wValue0 > 5) { return NULL; } else { return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]); } } /******************************************************************************* * Function Name : Get_Max_Lun * Description : Handle the Get Max Lun request. * Input : uint16_t Length. * Output : None. * Return : None. *******************************************************************************/ uint8_t *Get_Max_Lun(uint16_t Length) { if (Length == 0) { pInformation->Ctrl_Info.Usb_wLength = LUN_DATA_LENGTH; return 0; } else { return((uint8_t*)(&Max_Lun)); } } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/usb_prop.c
C
asf20
13,937
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_desc.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Descriptors for Mass Storage Device ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_desc.h" const uint8_t MASS_DeviceDescriptor[MASS_SIZ_DEVICE_DESC] = { 0x12, /* bLength */ 0x01, /* bDescriptorType */ 0x00, /* bcdUSB, version 2.00 */ 0x02, 0x00, /* bDeviceClass : each interface define the device class */ 0x00, /* bDeviceSubClass */ 0x00, /* bDeviceProtocol */ 0x40, /* bMaxPacketSize0 0x40 = 64 */ 0x83, /* idVendor (0483) */ 0x04, 0x20, /* idProduct */ 0x57, 0x00, /* bcdDevice 2.00*/ 0x02, 1, /* index of string Manufacturer */ /**/ 2, /* index of string descriptor of product*/ /* */ 3, /* */ /* */ /* */ 0x01 /*bNumConfigurations */ }; const uint8_t MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC] = { 0x09, /* bLength: Configuation Descriptor size */ 0x02, /* bDescriptorType: Configuration */ MASS_SIZ_CONFIG_DESC, 0x00, 0x01, /* bNumInterfaces: 1 interface */ 0x01, /* bConfigurationValue: */ /* Configuration value */ 0x00, /* iConfiguration: */ /* Index of string descriptor */ /* describing the configuration */ 0xC0, /* bmAttributes: */ /* bus powered */ 0x32, /* MaxPower 100 mA */ /******************** Descriptor of Mass Storage interface ********************/ /* 09 */ 0x09, /* bLength: Interface Descriptor size */ 0x04, /* bDescriptorType: */ /* Interface descriptor type */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints*/ 0x08, /* bInterfaceClass: MASS STORAGE Class */ 0x06, /* bInterfaceSubClass : SCSI transparent*/ 0x50, /* nInterfaceProtocol */ 4, /* iInterface: */ /* 18 */ 0x07, /*Endpoint descriptor length = 7*/ 0x05, /*Endpoint descriptor type */ 0x81, /*Endpoint address (IN, address 1) */ 0x02, /*Bulk endpoint type */ 0x40, /*Maximum packet size (64 bytes) */ 0x00, 0x00, /*Polling interval in milliseconds */ /* 25 */ 0x07, /*Endpoint descriptor length = 7 */ 0x05, /*Endpoint descriptor type */ 0x02, /*Endpoint address (OUT, address 2) */ 0x02, /*Bulk endpoint type */ 0x40, /*Maximum packet size (64 bytes) */ 0x00, 0x00 /*Polling interval in milliseconds*/ /*32*/ }; const uint8_t MASS_StringLangID[MASS_SIZ_STRING_LANGID] = { MASS_SIZ_STRING_LANGID, 0x03, 0x09, 0x04 } ; /* LangID = 0x0409: U.S. English */ const uint8_t MASS_StringVendor[MASS_SIZ_STRING_VENDOR] = { MASS_SIZ_STRING_VENDOR, /* Size of manufaturer string */ 0x03, /* bDescriptorType = String descriptor */ /* Manufacturer: "STMicroelectronics" */ 'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0, 'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0, 'c', 0, 's', 0 }; const uint8_t MASS_StringProduct[MASS_SIZ_STRING_PRODUCT] = { MASS_SIZ_STRING_PRODUCT, 0x03, /* Product name: "STM32F10x:USB Mass Storage" */ 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'M', 0, 'a', 0, 's', 0, 's', 0, ' ', 0, 'S', 0, 't', 0, 'o', 0, 'r', 0, 'a', 0, 'g', 0, 'e', 0 }; uint8_t MASS_StringSerial[MASS_SIZ_STRING_SERIAL] = { MASS_SIZ_STRING_SERIAL, 0x03, /* Serial number*/ 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, '1', 0, '0', 0 }; const uint8_t MASS_StringInterface[MASS_SIZ_STRING_INTERFACE] = { MASS_SIZ_STRING_INTERFACE, 0x03, /* Interface 0: "ST Mass" */ 'S', 0, 'T', 0, ' ', 0, 'M', 0, 'a', 0, 's', 0, 's', 0 }; /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/usb_desc.c
C
asf20
4,891
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_bot.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : BOT State Machine management ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_scsi.h" #include "hw_config.h" #include "usb_regs.h" #include "usb_mem.h" #include "usb_conf.h" #include "usb_bot.h" #include "memory.h" #include "usb_lib.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint8_t Bot_State; uint8_t Bulk_Data_Buff[BULK_MAX_PACKET_SIZE]; /* data buffer*/ uint16_t Data_Len; Bulk_Only_CBW CBW; Bulk_Only_CSW CSW; uint32_t SCSI_LBA , SCSI_BlkLen; extern uint32_t Max_Lun; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : Mass_Storage_In * Description : Mass Storage IN transfer. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Mass_Storage_In (void) { switch (Bot_State) { case BOT_CSW_Send: case BOT_ERROR: Bot_State = BOT_IDLE; #ifndef STM32F10X_CL SetEPRxStatus(ENDP2, EP_RX_VALID);/* enable the Endpoint to recive the next cmd*/ #else if (GetEPRxStatus(EP2_OUT) == EP_RX_STALL) { SetEPRxStatus(EP2_OUT, EP_RX_VALID);/* enable the Endpoint to recive the next cmd*/ } #endif /* STM32F10X_CL */ break; case BOT_DATA_IN: switch (CBW.CB[0]) { case SCSI_READ10: SCSI_Read10_Cmd(CBW.bLUN , SCSI_LBA , SCSI_BlkLen); break; } break; case BOT_DATA_IN_LAST: Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE); #ifndef STM32F10X_CL SetEPRxStatus(ENDP2, EP_RX_VALID); #else if (GetEPRxStatus(EP2_OUT) == EP_RX_STALL) { SetEPRxStatus(EP2_OUT, EP_RX_VALID);/* enable the Endpoint to recive the next cmd*/ } #endif /* STM32F10X_CL */ break; default: break; } } /******************************************************************************* * Function Name : Mass_Storage_Out * Description : Mass Storage OUT transfer. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Mass_Storage_Out (void) { uint8_t CMD; CMD = CBW.CB[0]; Data_Len = USB_SIL_Read(EP2_OUT, Bulk_Data_Buff); switch (Bot_State) { case BOT_IDLE: CBW_Decode(); break; case BOT_DATA_OUT: if (CMD == SCSI_WRITE10) { SCSI_Write10_Cmd(CBW.bLUN , SCSI_LBA , SCSI_BlkLen); break; } Bot_Abort(DIR_OUT); Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND); Set_CSW (CSW_PHASE_ERROR, SEND_CSW_DISABLE); break; default: Bot_Abort(BOTH_DIR); Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND); Set_CSW (CSW_PHASE_ERROR, SEND_CSW_DISABLE); break; } } /******************************************************************************* * Function Name : CBW_Decode * Description : Decode the received CBW and call the related SCSI command * routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void CBW_Decode(void) { uint32_t Counter; for (Counter = 0; Counter < Data_Len; Counter++) { *((uint8_t *)&CBW + Counter) = Bulk_Data_Buff[Counter]; } CSW.dTag = CBW.dTag; CSW.dDataResidue = CBW.dDataLength; if (Data_Len != BOT_CBW_PACKET_LENGTH) { Bot_Abort(BOTH_DIR); /* reset the CBW.dSignature to desible the clear feature until receiving a Mass storage reset*/ CBW.dSignature = 0; Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, PARAMETER_LIST_LENGTH_ERROR); Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE); return; } if ((CBW.CB[0] == SCSI_READ10 ) || (CBW.CB[0] == SCSI_WRITE10 )) { /* Calculate Logical Block Address */ SCSI_LBA = (CBW.CB[2] << 24) | (CBW.CB[3] << 16) | (CBW.CB[4] << 8) | CBW.CB[5]; /* Calculate the Number of Blocks to transfer */ SCSI_BlkLen = (CBW.CB[7] << 8) | CBW.CB[8]; } if (CBW.dSignature == BOT_CBW_SIGNATURE) { /* Valid CBW */ if ((CBW.bLUN > Max_Lun) || (CBW.bCBLength < 1) || (CBW.bCBLength > 16)) { Bot_Abort(BOTH_DIR); Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND); Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE); } else { switch (CBW.CB[0]) { case SCSI_REQUEST_SENSE: SCSI_RequestSense_Cmd (CBW.bLUN); break; case SCSI_INQUIRY: SCSI_Inquiry_Cmd(CBW.bLUN); break; case SCSI_START_STOP_UNIT: SCSI_Start_Stop_Unit_Cmd(CBW.bLUN); break; case SCSI_ALLOW_MEDIUM_REMOVAL: SCSI_Start_Stop_Unit_Cmd(CBW.bLUN); break; case SCSI_MODE_SENSE6: SCSI_ModeSense6_Cmd (CBW.bLUN); break; case SCSI_MODE_SENSE10: SCSI_ModeSense10_Cmd (CBW.bLUN); break; case SCSI_READ_FORMAT_CAPACITIES: SCSI_ReadFormatCapacity_Cmd(CBW.bLUN); break; case SCSI_READ_CAPACITY10: SCSI_ReadCapacity10_Cmd(CBW.bLUN); break; case SCSI_TEST_UNIT_READY: SCSI_TestUnitReady_Cmd(CBW.bLUN); break; case SCSI_READ10: SCSI_Read10_Cmd(CBW.bLUN, SCSI_LBA , SCSI_BlkLen); break; case SCSI_WRITE10: SCSI_Write10_Cmd(CBW.bLUN, SCSI_LBA , SCSI_BlkLen); break; case SCSI_VERIFY10: SCSI_Verify10_Cmd(CBW.bLUN); break; case SCSI_FORMAT_UNIT: SCSI_Format_Cmd(CBW.bLUN); break; /*Unsupported command*/ case SCSI_MODE_SELECT10: SCSI_Mode_Select10_Cmd(CBW.bLUN); break; case SCSI_MODE_SELECT6: SCSI_Mode_Select6_Cmd(CBW.bLUN); break; case SCSI_SEND_DIAGNOSTIC: SCSI_Send_Diagnostic_Cmd(CBW.bLUN); break; case SCSI_READ6: SCSI_Read6_Cmd(CBW.bLUN); break; case SCSI_READ12: SCSI_Read12_Cmd(CBW.bLUN); break; case SCSI_READ16: SCSI_Read16_Cmd(CBW.bLUN); break; case SCSI_READ_CAPACITY16: SCSI_READ_CAPACITY16_Cmd(CBW.bLUN); break; case SCSI_WRITE6: SCSI_Write6_Cmd(CBW.bLUN); break; case SCSI_WRITE12: SCSI_Write12_Cmd(CBW.bLUN); break; case SCSI_WRITE16: SCSI_Write16_Cmd(CBW.bLUN); break; case SCSI_VERIFY12: SCSI_Verify12_Cmd(CBW.bLUN); break; case SCSI_VERIFY16: SCSI_Verify16_Cmd(CBW.bLUN); break; default: { Bot_Abort(BOTH_DIR); Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_COMMAND); Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE); } } } } else { /* Invalid CBW */ Bot_Abort(BOTH_DIR); Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_COMMAND); Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE); } } /******************************************************************************* * Function Name : Transfer_Data_Request * Description : Send the request response to the PC HOST. * Input : uint8_t* Data_Address : point to the data to transfer. * uint16_t Data_Length : the nember of Bytes to transfer. * Output : None. * Return : None. *******************************************************************************/ void Transfer_Data_Request(uint8_t* Data_Pointer, uint16_t Data_Len) { USB_SIL_Write(EP1_IN, Data_Pointer, Data_Len); #ifndef USE_STM3210C_EVAL SetEPTxStatus(ENDP1, EP_TX_VALID); #endif Bot_State = BOT_DATA_IN_LAST; CSW.dDataResidue -= Data_Len; CSW.bStatus = CSW_CMD_PASSED; } /******************************************************************************* * Function Name : Set_CSW * Description : Set the SCW with the needed fields. * Input : uint8_t CSW_Status this filed can be CSW_CMD_PASSED,CSW_CMD_FAILED, * or CSW_PHASE_ERROR. * Output : None. * Return : None. *******************************************************************************/ void Set_CSW (uint8_t CSW_Status, uint8_t Send_Permission) { CSW.dSignature = BOT_CSW_SIGNATURE; CSW.bStatus = CSW_Status; USB_SIL_Write(EP1_IN, ((uint8_t *)& CSW), CSW_DATA_LENGTH); Bot_State = BOT_ERROR; if (Send_Permission) { Bot_State = BOT_CSW_Send; #ifndef USE_STM3210C_EVAL SetEPTxStatus(ENDP1, EP_TX_VALID); #endif } } /******************************************************************************* * Function Name : Bot_Abort * Description : Stall the needed Endpoint according to the selected direction. * Input : Endpoint direction IN, OUT or both directions * Output : None. * Return : None. *******************************************************************************/ void Bot_Abort(uint8_t Direction) { switch (Direction) { case DIR_IN : SetEPTxStatus(ENDP1, EP_TX_STALL); break; case DIR_OUT : SetEPRxStatus(ENDP2, EP_RX_STALL); break; case BOTH_DIR : SetEPTxStatus(ENDP1, EP_TX_STALL); SetEPRxStatus(ENDP2, EP_RX_STALL); break; default: break; } } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/src/usb_bot.c
C
asf20
11,366
;; NOTE: To allow the use of this file for both ARMv6M and ARMv7M, ;; we will only use 16-bit Thumb intructions. .extern _lc_ub_stack ; usr/sys mode stack pointer .extern _lc_ue_stack ; symbol required by debugger .extern _lc_ub_table ; ROM to RAM copy table .extern main .extern _Exit .extern exit .weak exit .global __get_argcv .weak __get_argcv .extern __argcvbuf .weak __argcvbuf .extern __init_hardware .extern __init_vector_table .extern SystemInit .if @defined('__PROF_ENABLE__') .extern __prof_init .endif .if @defined('__POSIX__') .extern posix_main .extern _posix_boot_stack_top .endif .global _START .section .text.cstart .thumb _START: ;; anticipate possible ROM/RAM remapping ;; by loading the 'real' program address ldr r1,=_Next bx r1 _Next: ;; initialize the stack pointer ldr r1,=_lc_ub_stack ; TODO: make this part of the vector table mov sp,r1 ;; call a user function which initializes hardware ;; such as ROM/RAM re-mapping or MMU configuration bl __init_hardware ;ldr r0, =SystemInit ;bx r0 bl SystemInit ;; copy initialized sections from ROM to RAM ;; and clear uninitialized data sections in RAM ldr r3,=_lc_ub_table movs r0,#0 cploop: ldr r4,[r3,#0] ; load type ldr r5,[r3,#4] ; dst address ldr r6,[r3,#8] ; src address ldr r7,[r3,#12] ; size cmp r4,#1 beq copy cmp r4,#2 beq clear b done copy: subs r7,r7,#1 ldrb r1,[r6,r7] strb r1,[r5,r7] bne copy adds r3,r3,#16 b cploop clear: subs r7,r7,#1 strb r0,[r5,r7] bne clear adds r3,r3,#16 b cploop done: ;; initialize or copy the vector table bl __init_vector_table .if @defined('__POSIX__') ;; posix stack buffer for system upbringing ldr r0,=_posix_boot_stack_top ldr r0, [r0] mov sp,r0 .else ;; load r10 with end of USR/SYS stack, which is ;; needed in case stack overflow checking is on ;; NOTE: use 16-bit instructions only, for ARMv6M ldr r0,=_lc_ue_stack mov r10,r0 .endif .if @defined('__PROF_ENABLE__') bl __prof_init .endif .if @defined('__POSIX__') ;; call posix_main with no arguments bl posix_main .else ;; retrieve argc and argv (default argv[0]==NULL & argc==0) bl __get_argcv ldr r1,=__argcvbuf ;; call main bl main .endif ;; call exit using the return value from main() ;; Note. Calling exit will also run all functions ;; that were supplied through atexit(). bl exit __get_argcv: ; weak definition movs r0,#0 bx lr .ltorg .endsec .calls '_START','__init_hardware' .calls '_START','__init_vector_table' .if @defined('__PROF_ENABLE__') .calls '_START','__prof_init' .endif .if @defined('__POSIX__') .calls '_START','posix_main' .else .calls '_START','__get_argcv' .calls '_START','main' .endif .calls '_START','exit' .calls '_START','',0 .end
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210E-EVAL_XL/cstart_thumb2.asm
Assembly
asf20
3,949
//////////////////////////////////////////////////////////////////////////// // // File : stm32f103_cmsis.lsl // // Version : @(#)stm32f103_cmsis.lsl 1.2 09/06/04 // // Description : LSL file for the STMicroelectronics STM32F103, CMSIS version // // Copyright 2009 Altium BV // // NOTE: // This file is derived from cm3.lsl and stm32f103.lsl. // It is assumed that the user works with the ARMv7M architecture. // Other architectures will not work with this lsl file. // //////////////////////////////////////////////////////////////////////////// // // We do not want the vectors as defined in arm_arch.lsl // #define __NO_DEFAULT_AUTO_VECTORS 1 #define __NR_OF_VECTORS 76 #ifndef __STACK # define __STACK 8k #endif #ifndef __HEAP # define __HEAP 2k #endif #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x08000000 #endif #ifndef __XVWBUF #define __XVWBUF 256 /* buffer used by CrossView */ #endif #include <arm_arch.lsl> //////////////////////////////////////////////////////////////////////////// // // In the STM32F10x, 3 different boot modes can be selected // - User Flash memory is selected as boot space // - SystemMemory is selected as boot space // - Embedded SRAM is selected as boot space // // This aliases the physical memory associated with each boot mode to Block // 000 (0x00000000 boot memory). Even when aliased in the boot memory space, // the related memory (Flash memory or SRAM) is still accessible at its // original memory space. // // If no memory is defined yet use the following memory settings // #ifndef __MEMORY memory stm32f103flash { mau = 8; type = rom; size = 0x100000; map ( size = 0x100000, dest_offset=0x08000000, dest=bus:ARM:local_bus); } memory stm32f103ram { mau = 8; type = ram; size = 96k; map ( size = 96k, dest_offset=0x20000000, dest=bus:ARM:local_bus); } #endif /* __MEMORY */ // // Custom vector table defines interrupts according to CMSIS standard // # if defined(__CPU_ARMV7M__) section_setup ::linear { // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); vector ( id = 2, optional, fill = "NMI_Handler" ); vector ( id = 3, optional, fill = "HardFault_Handler" ); vector ( id = 4, optional, fill = "MemManage_Handler" ); vector ( id = 5, optional, fill = "BusFault_Handler" ); vector ( id = 6, optional, fill = "UsageFault_Handler" ); vector ( id = 11, optional, fill = "SVC_Handler" ); vector ( id = 12, optional, fill = "DebugMon_Handler" ); vector ( id = 14, optional, fill = "PendSV_Handler" ); vector ( id = 15, optional, fill = "SysTick_Handler" ); // External Interrupts : vector ( id = 16, optional, fill = "WWDG_IRQHandler" ); // Window Watchdog vector ( id = 17, optional, fill = "PVD_IRQHandler" ); // PVD through EXTI Line detect vector ( id = 18, optional, fill = "TAMPER_IRQHandler" ); // Tamper vector ( id = 19, optional, fill = "RTC_IRQHandler" ); // RTC vector ( id = 20, optional, fill = "FLASH_IRQHandler" ); // Flash vector ( id = 21, optional, fill = "RCC_IRQHandler" ); // RCC vector ( id = 22, optional, fill = "EXTI0_IRQHandler" ); // EXTI Line 0 vector ( id = 23, optional, fill = "EXTI1_IRQHandler" ); // EXTI Line 1 vector ( id = 24, optional, fill = "EXTI2_IRQHandler" ); // EXTI Line 2 vector ( id = 25, optional, fill = "EXTI3_IRQHandler" ); // EXTI Line 3 vector ( id = 26, optional, fill = "EXTI4_IRQHandler" ); // EXTI Line 4 vector ( id = 27, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMA1_Channel2_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMA1_Channel3_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMA1_Channel4_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMA1_Channel5_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMA1_Channel6_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMA1_Channel7_IRQHandler" ); // DMA Channel 7 vector ( id = 34, optional, fill = "ADC1_2_IRQHandler" ); // ADC1 and ADC2 vector ( id = 35, optional, fill = "USB_HP_CAN1_TX_IRQHandler" ); // USB High Priority or CAN1 TX vector ( id = 36, optional, fill = "USB_LP_CAN1_RX0_IRQHandler" ); // USB LowPriority or CAN1 RX0 vector ( id = 37, optional, fill = "CAN1_RX1_IRQHandler" ); // CAN1 RX1 vector ( id = 38, optional, fill = "CAN1_SCE_IRQHandler" ); // CAN1 SCE vector ( id = 39, optional, fill = "EXTI9_5_IRQHandler" ); // EXTI Line 9..5 vector ( id = 40, optional, fill = "TIM1_BRK_TIM9_IRQHandler" ); // TIM1 Break vector ( id = 41, optional, fill = "TIM1_UP_TIM10_IRQHandler" ); // TIM1 Update vector ( id = 42, optional, fill = "TIM1_TRG_COM_TIM11_IRQHandler" ); // TIM1 Trigger and Commutation vector ( id = 43, optional, fill = "TIM1_CC_IRQHandler" ); // TIM1 Capture Compare vector ( id = 44, optional, fill = "TIM2_IRQHandler" ); // TIM2 vector ( id = 45, optional, fill = "TIM3_IRQHandler" ); // TIM3 vector ( id = 46, optional, fill = "TIM4_IRQHandler" ); // TIM4 vector ( id = 47, optional, fill = "I2C1_EV_IRQHandler" ); // I2C1 Event vector ( id = 48, optional, fill = "I2C1_ER_IRQHandler" ); // I2C1 Error vector ( id = 49, optional, fill = "I2C2_EV_IRQHandler" ); // I2C2 Event vector ( id = 50, optional, fill = "I2C2_ER_IRQHandler" ); // I2C2 Error vector ( id = 51, optional, fill = "SPI1_IRQHandler" ); // SPI1 vector ( id = 52, optional, fill = "SPI2_IRQHandler" ); // SPI2 vector ( id = 53, optional, fill = "USART1_IRQHandler" ); // USART1 vector ( id = 54, optional, fill = "USART2_IRQHandler" ); // USART2 vector ( id = 55, optional, fill = "USART3_IRQHandler" ); // USART3 vector ( id = 56, optional, fill = "EXTI15_10_IRQHandler" ); // EXTI Line 15..10 vector ( id = 57, optional, fill = "RTCAlarm_IRQHandler" ); // RTC Alarm through EXTI Line vector ( id = 58, optional, fill = "USBWakeUp_IRQHandler" ); // USB Wakeup from suspend vector ( id = 59, optional, fill = "TIM8_BRK_TIM12_IRQHandler" ); // TIM8 Break vector ( id = 60, optional, fill = "TIM8_UP_TIM13_IRQHandler" ); // TIM8 Update vector ( id = 61, optional, fill = "TIM8_TRG_COM_TIM14_IRQHandler" ); // TIM8 Trigger and Commutation vector ( id = 62, optional, fill = "TIM8_CC_IRQHandler" ); // TIM8 Capture Compare vector ( id = 63, optional, fill = "ADC3_IRQHandler" ); // ADC3 vector ( id = 64, optional, fill = "FSMC_IRQHandler" ); // FSMC vector ( id = 65, optional, fill = "SDIO_IRQHandler" ); // SDIO vector ( id = 66, optional, fill = "TIM5_IRQHandler" ); // TIM5 vector ( id = 67, optional, fill = "SPI3_IRQHandler" ); // SPI3 vector ( id = 68, optional, fill = "UART4_IRQHandler" ); // UART4 vector ( id = 69, optional, fill = "UART5_IRQHandler" ); // UART5 vector ( id = 70, optional, fill = "TIM6_IRQHandler" ); // TIM6 vector ( id = 71, optional, fill = "TIM7_IRQHandler" ); // TIM7 vector ( id = 72, optional, fill = "DMA2_Channel1_IRQHandler" ); // DMA2 Channel1 vector ( id = 73, optional, fill = "DMA2_Channel2_IRQHandler" ); // DMA2 Channel2 vector ( id = 74, optional, fill = "DMA2_Channel3_IRQHandler" ); // DMA2 Channel3 vector ( id = 75, optional, fill = "DMA2_Channel4_5_IRQHandler" ); // DMA2 Channel4 and DMA2 Channel5 } } # endif
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210E-EVAL_XL/Settings/STM32F10x_XL.lsl
LSL
asf20
10,633
//////////////////////////////////////////////////////////////////////////// // // File : arm_arch.lsl // // Version : @(#)arm_arch.lsl 1.4 09/04/17 // // Description : Generic LSL file for ARM architectures // // Copyright 2008-2009 Altium BV // //////////////////////////////////////////////////////////////////////////// #ifndef __STACK # define __STACK 32k #endif #ifndef __HEAP # define __HEAP 32k #endif #ifndef __STACK_FIQ # define __STACK_FIQ 8 #endif #ifndef __STACK_IRQ # define __STACK_IRQ 8 #endif #ifndef __STACK_SVC # define __STACK_SVC 8 #endif #ifndef __STACK_ABT # define __STACK_ABT 8 #endif #ifndef __STACK_UND # define __STACK_UND 8 #endif #ifndef __PROCESSOR_MODE # define __PROCESSOR_MODE 0x1F /* SYS mode */ #endif #ifndef __IRQ_BIT # define __IRQ_BIT 0x80 /* IRQ interrupts disabled */ #endif #ifndef __FIQ_BIT # define __FIQ_BIT 0x40 /* FIQ interrupts disabled */ #endif #define __APPLICATION_MODE (__PROCESSOR_MODE | __IRQ_BIT | __FIQ_BIT) #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x00000000 #endif #ifndef __VECTOR_TABLE_RAM_ADDR # define __VECTOR_TABLE_RAM_ADDR 0x00000000 #endif #if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) # ifndef __NR_OF_VECTORS # define __NR_OF_VECTORS 16 # endif # define __VECTOR_TABLE_SIZE (__NR_OF_VECTORS * 4) #else # ifdef __PIC_VECTORS # define __VECTOR_TABLE_SIZE 64 # else # ifdef __FIQ_HANDLER_INLINE # define __VECTOR_TABLE_SIZE 28 # define __NR_OF_VECTORS 7 # else # define __VECTOR_TABLE_SIZE 32 # define __NR_OF_VECTORS 8 # endif # endif #endif #ifndef __VECTOR_TABLE_RAM_SPACE # undef __VECTOR_TABLE_RAM_COPY #endif #ifndef __XVWBUF # define __XVWBUF 0 /* buffer used by CrossView Pro */ #endif #define BOUNDS_GROUP_NAME grp_bounds #define BOUNDS_GROUP_SELECT "bounds" architecture ARM { endianness { little; big; } space linear { id = 1; mau = 8; map (size = 4G, dest = bus:local_bus); copytable ( align = 4, copy_unit = 1, dest = linear ); start_address ( // It is not strictly necessary to define a run_addr for _START // because hardware starts execution at address 0x0 which should // be the vector table with a jump to the relocatable _START, but // an absolute address can prevent the branch to be out-of-range. // Or _START may be the entry point at reset and the reset handler // copies the vector table to address 0x0 after some ROM/RAM memory // re-mapping. In that case _START should be at a fixed address // in ROM, specifically the alias of address 0x0 before memory // re-mapping. #ifdef __START run_addr = __START, #endif symbol = "_START" ); stack "stack" ( #ifdef __STACK_FIXED fixed, #endif align = 4, min_size = __STACK, grows = high_to_low ); heap "heap" ( #ifdef __HEAP_FIXED fixed, #endif align = 4, min_size=__HEAP ); #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) stack "stack_fiq" ( fixed, align = 4, min_size = __STACK_FIQ, grows = high_to_low ); stack "stack_irq" ( fixed, align = 4, min_size = __STACK_IRQ, grows = high_to_low ); stack "stack_svc" ( fixed, align = 4, min_size = __STACK_SVC, grows = high_to_low ); stack "stack_abt" ( fixed, align = 4, min_size = __STACK_ABT, grows = high_to_low ); stack "stack_und" ( fixed, align = 4, min_size = __STACK_UND, grows = high_to_low ); #endif #if !defined(__NO_AUTO_VECTORS) && !defined(__NO_DEFAULT_AUTO_VECTORS) # if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); } # else # ifdef __PIC_VECTORS // vector table with ldrpc instructions from handler table vector_table "vector_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_ldrpc", template_symbol = "_lc_vector_ldrpc", vector_prefix = "_vector_ldrpc_", fill = loop ) { } // subsequent vector table (data pool) with addresses of handlers vector_table "handler_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR + 32, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop[-32], no_inline ) { vector ( id = 0, fill = "_START" ); } # else // vector table with branch instructions to handlers vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_branch", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop ) { vector ( id = 0, fill = "_START" ); } # endif # endif #endif section_layout { #if defined(__NO_AUTO_VECTORS) "_lc_ub_vector_table" = __VECTOR_TABLE_ROM_ADDR; "_lc_ue_vector_table" = __VECTOR_TABLE_ROM_ADDR + __VECTOR_TABLE_SIZE; #endif #ifdef __VECTOR_TABLE_RAM_SPACE // reserve space to copy vector table from ROM to RAM group ( ordered, run_addr = __VECTOR_TABLE_RAM_ADDR ) reserved "vector_table_space" ( size = __VECTOR_TABLE_SIZE, attributes = rwx ); #endif #ifdef __VECTOR_TABLE_RAM_COPY // provide copy address symbols for copy routine "_lc_ub_vector_table_copy" := "_lc_ub_vector_table_space"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table_space"; #else // prevent copy: copy address equals orig address "_lc_ub_vector_table_copy" := "_lc_ub_vector_table"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table"; #endif // define buffer for string input via Crossview Pro debugger group ( align = 4 ) reserved "xvwbuffer" (size=__XVWBUF, attributes=rw ); // define labels for bounds begin and end as used in C library #ifndef BOUNDS_GROUP_REDEFINED group BOUNDS_GROUP_NAME (ordered, contiguous) { select BOUNDS_GROUP_SELECT; } #endif "_lc_ub_bounds" := addressof(group:BOUNDS_GROUP_NAME); "_lc_ue_bounds" := addressof(group:BOUNDS_GROUP_NAME) + sizeof(group:BOUNDS_GROUP_NAME); #ifdef __HEAPADDR group ( ordered, run_addr=__HEAPADDR ) { select "heap"; } #endif #ifdef __STACKADDR group ( ordered, run_addr=__STACKADDR ) { select "stack"; } #endif #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) // symbol to set mode bits and interrupt disable bits // in cstart module before calling the application (main) "_APPLICATION_MODE_" = __APPLICATION_MODE; #endif } } bus local_bus { mau = 8; width = 32; } }
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210E-EVAL_XL/Settings/arm_arch.lsl
LSL
asf20
10,931
;; NOTE: To allow the use of this file for both ARMv6M and ARMv7M, ;; we will only use 16-bit Thumb intructions. .extern _lc_ub_stack ; usr/sys mode stack pointer .extern _lc_ue_stack ; symbol required by debugger .extern _lc_ub_table ; ROM to RAM copy table .extern main .extern _Exit .extern exit .weak exit .global __get_argcv .weak __get_argcv .extern __argcvbuf .weak __argcvbuf .extern __init_hardware .extern __init_vector_table .extern SystemInit .if @defined('__PROF_ENABLE__') .extern __prof_init .endif .if @defined('__POSIX__') .extern posix_main .extern _posix_boot_stack_top .endif .global _START .section .text.cstart .thumb _START: ;; anticipate possible ROM/RAM remapping ;; by loading the 'real' program address ldr r1,=_Next bx r1 _Next: ;; initialize the stack pointer ldr r1,=_lc_ub_stack ; TODO: make this part of the vector table mov sp,r1 ;; call a user function which initializes hardware ;; such as ROM/RAM re-mapping or MMU configuration bl __init_hardware ;ldr r0, =SystemInit ;bx r0 bl SystemInit ;; copy initialized sections from ROM to RAM ;; and clear uninitialized data sections in RAM ldr r3,=_lc_ub_table movs r0,#0 cploop: ldr r4,[r3,#0] ; load type ldr r5,[r3,#4] ; dst address ldr r6,[r3,#8] ; src address ldr r7,[r3,#12] ; size cmp r4,#1 beq copy cmp r4,#2 beq clear b done copy: subs r7,r7,#1 ldrb r1,[r6,r7] strb r1,[r5,r7] bne copy adds r3,r3,#16 b cploop clear: subs r7,r7,#1 strb r0,[r5,r7] bne clear adds r3,r3,#16 b cploop done: ;; initialize or copy the vector table bl __init_vector_table .if @defined('__POSIX__') ;; posix stack buffer for system upbringing ldr r0,=_posix_boot_stack_top ldr r0, [r0] mov sp,r0 .else ;; load r10 with end of USR/SYS stack, which is ;; needed in case stack overflow checking is on ;; NOTE: use 16-bit instructions only, for ARMv6M ldr r0,=_lc_ue_stack mov r10,r0 .endif .if @defined('__PROF_ENABLE__') bl __prof_init .endif .if @defined('__POSIX__') ;; call posix_main with no arguments bl posix_main .else ;; retrieve argc and argv (default argv[0]==NULL & argc==0) bl __get_argcv ldr r1,=__argcvbuf ;; call main bl main .endif ;; call exit using the return value from main() ;; Note. Calling exit will also run all functions ;; that were supplied through atexit(). bl exit __get_argcv: ; weak definition movs r0,#0 bx lr .ltorg .endsec .calls '_START','__init_hardware' .calls '_START','__init_vector_table' .if @defined('__PROF_ENABLE__') .calls '_START','__prof_init' .endif .if @defined('__POSIX__') .calls '_START','posix_main' .else .calls '_START','__get_argcv' .calls '_START','main' .endif .calls '_START','exit' .calls '_START','',0 .end
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210C-EVAL/cstart_thumb2.asm
Assembly
asf20
3,949
//////////////////////////////////////////////////////////////////////////// // // File : stm32f103_cmsis.lsl // // Version : @(#)stm32f103_cmsis.lsl 1.2 09/06/04 // // Description : LSL file for the STMicroelectronics STM32F103, CMSIS version // // Copyright 2009 Altium BV // // NOTE: // This file is derived from cm3.lsl and stm32f103.lsl. // It is assumed that the user works with the ARMv7M architecture. // Other architectures will not work with this lsl file. // //////////////////////////////////////////////////////////////////////////// // // We do not want the vectors as defined in arm_arch.lsl // #define __NO_DEFAULT_AUTO_VECTORS 1 #define __NR_OF_VECTORS 84 #ifndef __STACK # define __STACK 2k #endif #ifndef __HEAP # define __HEAP 1k #endif #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x08000000 #endif #ifndef __XVWBUF #define __XVWBUF 256 /* buffer used by CrossView */ #endif #include <arm_arch.lsl> //////////////////////////////////////////////////////////////////////////// // // In the STM32F10x, 3 different boot modes can be selected // - User Flash memory is selected as boot space // - SystemMemory is selected as boot space // - Embedded SRAM is selected as boot space // // This aliases the physical memory associated with each boot mode to Block // 000 (0x00000000 boot memory). Even when aliased in the boot memory space, // the related memory (Flash memory or SRAM) is still accessible at its // original memory space. // // If no memory is defined yet use the following memory settings // #ifndef __MEMORY memory stm32f103flash { mau = 8; type = rom; size = 256k; map ( size = 256k, dest_offset=0x08000000, dest=bus:ARM:local_bus); } memory stm32f103ram { mau = 8; type = ram; size = 64k; map ( size = 64k, dest_offset=0x20000000, dest=bus:ARM:local_bus); } #endif /* __MEMORY */ // // Custom vector table defines interrupts according to CMSIS standard // # if defined(__CPU_ARMV7M__) section_setup ::linear { // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); vector ( id = 2, optional, fill = "NMI_Handler" ); vector ( id = 3, optional, fill = "HardFault_Handler" ); vector ( id = 4, optional, fill = "MemManage_Handler" ); vector ( id = 5, optional, fill = "BusFault_Handler" ); vector ( id = 6, optional, fill = "UsageFault_Handler" ); vector ( id = 11, optional, fill = "SVC_Handler" ); vector ( id = 12, optional, fill = "DebugMon_Handler" ); vector ( id = 14, optional, fill = "PendSV_Handler" ); vector ( id = 15, optional, fill = "SysTick_Handler" ); // External Interrupts : vector ( id = 16, optional, fill = "WWDG_IRQHandler" ); // Window Watchdog vector ( id = 17, optional, fill = "PVD_IRQHandler" ); // PVD through EXTI Line detect vector ( id = 18, optional, fill = "TAMPER_IRQHandler" ); // Tamper vector ( id = 19, optional, fill = "RTC_IRQHandler" ); // RTC vector ( id = 20, optional, fill = "FLASH_IRQHandler" ); // Flash vector ( id = 21, optional, fill = "RCC_IRQHandler" ); // RCC vector ( id = 22, optional, fill = "EXTI0_IRQHandler" ); // EXTI Line 0 vector ( id = 23, optional, fill = "EXTI1_IRQHandler" ); // EXTI Line 1 vector ( id = 24, optional, fill = "EXTI2_IRQHandler" ); // EXTI Line 2 vector ( id = 25, optional, fill = "EXTI3_IRQHandler" ); // EXTI Line 3 vector ( id = 26, optional, fill = "EXTI4_IRQHandler" ); // EXTI Line 4 vector ( id = 27, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMA1_Channel2_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMA1_Channel3_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMA1_Channel4_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMA1_Channel5_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMA1_Channel6_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMA1_Channel7_IRQHandler" ); // DMA Channel 7 vector ( id = 34, optional, fill = "ADC1_2_IRQHandler" ); // ADC1 and ADC2 vector ( id = 35, optional, fill = "CAN1_TX_IRQHandler" ); // CAN1 TX vector ( id = 36, optional, fill = "CAN1_RX0_IRQHandler" ); // CAN1 RX0 vector ( id = 37, optional, fill = "CAN1_RX1_IRQHandler" ); // CAN1 RX1 vector ( id = 38, optional, fill = "CAN1_SCE_IRQHandler" ); // CAN1 SCE vector ( id = 39, optional, fill = "EXTI9_5_IRQHandler" ); // EXTI Line 9..5 vector ( id = 40, optional, fill = "TIM1_BRK_IRQHandler" ); // TIM1 Break vector ( id = 41, optional, fill = "TIM1_UP_IRQHandler" ); // TIM1 Update vector ( id = 42, optional, fill = "TIM1_TRG_COM_IRQHandler" ); // TIM1 Trigger and Commutation vector ( id = 43, optional, fill = "TIM1_CC_IRQHandler" ); // TIM1 Capture Compare vector ( id = 44, optional, fill = "TIM2_IRQHandler" ); // TIM2 vector ( id = 45, optional, fill = "TIM3_IRQHandler" ); // TIM3 vector ( id = 46, optional, fill = "TIM4_IRQHandler" ); // TIM4 vector ( id = 47, optional, fill = "I2C1_EV_IRQHandler" ); // I2C1 Event vector ( id = 48, optional, fill = "I2C1_ER_IRQHandler" ); // I2C1 Error vector ( id = 49, optional, fill = "I2C2_EV_IRQHandler" ); // I2C2 Event vector ( id = 50, optional, fill = "I2C2_ER_IRQHandler" ); // I2C2 Error vector ( id = 51, optional, fill = "SPI1_IRQHandler" ); // SPI1 vector ( id = 52, optional, fill = "SPI2_IRQHandler" ); // SPI2 vector ( id = 53, optional, fill = "USART1_IRQHandler" ); // USART1 vector ( id = 54, optional, fill = "USART2_IRQHandler" ); // USART2 vector ( id = 55, optional, fill = "USART3_IRQHandler" ); // USART3 vector ( id = 56, optional, fill = "EXTI15_10_IRQHandler" ); // EXTI Line 15..10 vector ( id = 57, optional, fill = "RTCAlarm_IRQHandler" ); // RTC Alarm through EXTI Line vector ( id = 58, optional, fill = "OTG_FS_WKUP_IRQHandler" ); // USB OTG FS Wakeup through EXTI line vector ( id = 66, optional, fill = "TIM5_IRQHandler" ); // TIM5 vector ( id = 67, optional, fill = "SPI3_IRQHandler" ); // SPI3 vector ( id = 68, optional, fill = "UART4_IRQHandler" ); // UART4 vector ( id = 69, optional, fill = "UART5_IRQHandler" ); // UART5 vector ( id = 70, optional, fill = "TIM6_IRQHandler" ); // TIM6 vector ( id = 71, optional, fill = "TIM7_IRQHandler" ); // TIM7 vector ( id = 72, optional, fill = "DMA2_Channel1_IRQHandler" ); // DMA2 Channel1 vector ( id = 73, optional, fill = "DMA2_Channel2_IRQHandler" ); // DMA2 Channel2 vector ( id = 74, optional, fill = "DMA2_Channel3_IRQHandler" ); // DMA2 Channel3 vector ( id = 75, optional, fill = "DMA2_Channel4_IRQHandler" ); // DMA2 Channel4 vector ( id = 76, optional, fill = "DMA2_Channel5_IRQHandler" ); // DMA2 Channel5 vector ( id = 77, optional, fill = "ETH_IRQHandler" ); // Ethernet vector ( id = 78, optional, fill = "ETH_WKUP_IRQHandler" ); // ETH_WKUP_IRQHandler vector ( id = 79, optional, fill = "CAN2_TX_IRQHandler " ); // CAN2 TX vector ( id = 80, optional, fill = "CAN2_RX0_IRQHandler" ); // CAN2 RX0 vector ( id = 81, optional, fill = "CAN2_RX1_IRQHandler" ); // CAN2 RX1 vector ( id = 82, optional, fill = "CAN2_SCE_IRQHandler" ); // CAN2 SCE vector ( id = 83, optional, fill = "OTG_FS_IRQHandler" ); // USB OTG FS } } # endif
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210C-EVAL/Settings/STM32F10x_cl.lsl
LSL
asf20
10,566
//////////////////////////////////////////////////////////////////////////// // // File : arm_arch.lsl // // Version : @(#)arm_arch.lsl 1.4 09/04/17 // // Description : Generic LSL file for ARM architectures // // Copyright 2008-2009 Altium BV // //////////////////////////////////////////////////////////////////////////// #ifndef __STACK # define __STACK 32k #endif #ifndef __HEAP # define __HEAP 32k #endif #ifndef __STACK_FIQ # define __STACK_FIQ 8 #endif #ifndef __STACK_IRQ # define __STACK_IRQ 8 #endif #ifndef __STACK_SVC # define __STACK_SVC 8 #endif #ifndef __STACK_ABT # define __STACK_ABT 8 #endif #ifndef __STACK_UND # define __STACK_UND 8 #endif #ifndef __PROCESSOR_MODE # define __PROCESSOR_MODE 0x1F /* SYS mode */ #endif #ifndef __IRQ_BIT # define __IRQ_BIT 0x80 /* IRQ interrupts disabled */ #endif #ifndef __FIQ_BIT # define __FIQ_BIT 0x40 /* FIQ interrupts disabled */ #endif #define __APPLICATION_MODE (__PROCESSOR_MODE | __IRQ_BIT | __FIQ_BIT) #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x00000000 #endif #ifndef __VECTOR_TABLE_RAM_ADDR # define __VECTOR_TABLE_RAM_ADDR 0x00000000 #endif #if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) # ifndef __NR_OF_VECTORS # define __NR_OF_VECTORS 16 # endif # define __VECTOR_TABLE_SIZE (__NR_OF_VECTORS * 4) #else # ifdef __PIC_VECTORS # define __VECTOR_TABLE_SIZE 64 # else # ifdef __FIQ_HANDLER_INLINE # define __VECTOR_TABLE_SIZE 28 # define __NR_OF_VECTORS 7 # else # define __VECTOR_TABLE_SIZE 32 # define __NR_OF_VECTORS 8 # endif # endif #endif #ifndef __VECTOR_TABLE_RAM_SPACE # undef __VECTOR_TABLE_RAM_COPY #endif #ifndef __XVWBUF # define __XVWBUF 0 /* buffer used by CrossView Pro */ #endif #define BOUNDS_GROUP_NAME grp_bounds #define BOUNDS_GROUP_SELECT "bounds" architecture ARM { endianness { little; big; } space linear { id = 1; mau = 8; map (size = 4G, dest = bus:local_bus); copytable ( align = 4, copy_unit = 1, dest = linear ); start_address ( // It is not strictly necessary to define a run_addr for _START // because hardware starts execution at address 0x0 which should // be the vector table with a jump to the relocatable _START, but // an absolute address can prevent the branch to be out-of-range. // Or _START may be the entry point at reset and the reset handler // copies the vector table to address 0x0 after some ROM/RAM memory // re-mapping. In that case _START should be at a fixed address // in ROM, specifically the alias of address 0x0 before memory // re-mapping. #ifdef __START run_addr = __START, #endif symbol = "_START" ); stack "stack" ( #ifdef __STACK_FIXED fixed, #endif align = 4, min_size = __STACK, grows = high_to_low ); heap "heap" ( #ifdef __HEAP_FIXED fixed, #endif align = 4, min_size=__HEAP ); #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) stack "stack_fiq" ( fixed, align = 4, min_size = __STACK_FIQ, grows = high_to_low ); stack "stack_irq" ( fixed, align = 4, min_size = __STACK_IRQ, grows = high_to_low ); stack "stack_svc" ( fixed, align = 4, min_size = __STACK_SVC, grows = high_to_low ); stack "stack_abt" ( fixed, align = 4, min_size = __STACK_ABT, grows = high_to_low ); stack "stack_und" ( fixed, align = 4, min_size = __STACK_UND, grows = high_to_low ); #endif #if !defined(__NO_AUTO_VECTORS) && !defined(__NO_DEFAULT_AUTO_VECTORS) # if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); } # else # ifdef __PIC_VECTORS // vector table with ldrpc instructions from handler table vector_table "vector_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_ldrpc", template_symbol = "_lc_vector_ldrpc", vector_prefix = "_vector_ldrpc_", fill = loop ) { } // subsequent vector table (data pool) with addresses of handlers vector_table "handler_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR + 32, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop[-32], no_inline ) { vector ( id = 0, fill = "_START" ); } # else // vector table with branch instructions to handlers vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_branch", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop ) { vector ( id = 0, fill = "_START" ); } # endif # endif #endif section_layout { #if defined(__NO_AUTO_VECTORS) "_lc_ub_vector_table" = __VECTOR_TABLE_ROM_ADDR; "_lc_ue_vector_table" = __VECTOR_TABLE_ROM_ADDR + __VECTOR_TABLE_SIZE; #endif #ifdef __VECTOR_TABLE_RAM_SPACE // reserve space to copy vector table from ROM to RAM group ( ordered, run_addr = __VECTOR_TABLE_RAM_ADDR ) reserved "vector_table_space" ( size = __VECTOR_TABLE_SIZE, attributes = rwx ); #endif #ifdef __VECTOR_TABLE_RAM_COPY // provide copy address symbols for copy routine "_lc_ub_vector_table_copy" := "_lc_ub_vector_table_space"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table_space"; #else // prevent copy: copy address equals orig address "_lc_ub_vector_table_copy" := "_lc_ub_vector_table"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table"; #endif // define buffer for string input via Crossview Pro debugger group ( align = 4 ) reserved "xvwbuffer" (size=__XVWBUF, attributes=rw ); // define labels for bounds begin and end as used in C library #ifndef BOUNDS_GROUP_REDEFINED group BOUNDS_GROUP_NAME (ordered, contiguous) { select BOUNDS_GROUP_SELECT; } #endif "_lc_ub_bounds" := addressof(group:BOUNDS_GROUP_NAME); "_lc_ue_bounds" := addressof(group:BOUNDS_GROUP_NAME) + sizeof(group:BOUNDS_GROUP_NAME); #ifdef __HEAPADDR group ( ordered, run_addr=__HEAPADDR ) { select "heap"; } #endif #ifdef __STACKADDR group ( ordered, run_addr=__STACKADDR ) { select "stack"; } #endif #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) // symbol to set mode bits and interrupt disable bits // in cstart module before calling the application (main) "_APPLICATION_MODE_" = __APPLICATION_MODE; #endif } } bus local_bus { mau = 8; width = 32; } }
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210C-EVAL/Settings/arm_arch.lsl
LSL
asf20
10,931
;; NOTE: To allow the use of this file for both ARMv6M and ARMv7M, ;; we will only use 16-bit Thumb intructions. .extern _lc_ub_stack ; usr/sys mode stack pointer .extern _lc_ue_stack ; symbol required by debugger .extern _lc_ub_table ; ROM to RAM copy table .extern main .extern _Exit .extern exit .weak exit .global __get_argcv .weak __get_argcv .extern __argcvbuf .weak __argcvbuf .extern __init_hardware .extern __init_vector_table .extern SystemInit .if @defined('__PROF_ENABLE__') .extern __prof_init .endif .if @defined('__POSIX__') .extern posix_main .extern _posix_boot_stack_top .endif .global _START .section .text.cstart .thumb _START: ;; anticipate possible ROM/RAM remapping ;; by loading the 'real' program address ldr r1,=_Next bx r1 _Next: ;; initialize the stack pointer ldr r1,=_lc_ub_stack ; TODO: make this part of the vector table mov sp,r1 ;; call a user function which initializes hardware ;; such as ROM/RAM re-mapping or MMU configuration bl __init_hardware ;ldr r0, =SystemInit ;bx r0 bl SystemInit ;; copy initialized sections from ROM to RAM ;; and clear uninitialized data sections in RAM ldr r3,=_lc_ub_table movs r0,#0 cploop: ldr r4,[r3,#0] ; load type ldr r5,[r3,#4] ; dst address ldr r6,[r3,#8] ; src address ldr r7,[r3,#12] ; size cmp r4,#1 beq copy cmp r4,#2 beq clear b done copy: subs r7,r7,#1 ldrb r1,[r6,r7] strb r1,[r5,r7] bne copy adds r3,r3,#16 b cploop clear: subs r7,r7,#1 strb r0,[r5,r7] bne clear adds r3,r3,#16 b cploop done: ;; initialize or copy the vector table bl __init_vector_table .if @defined('__POSIX__') ;; posix stack buffer for system upbringing ldr r0,=_posix_boot_stack_top ldr r0, [r0] mov sp,r0 .else ;; load r10 with end of USR/SYS stack, which is ;; needed in case stack overflow checking is on ;; NOTE: use 16-bit instructions only, for ARMv6M ldr r0,=_lc_ue_stack mov r10,r0 .endif .if @defined('__PROF_ENABLE__') bl __prof_init .endif .if @defined('__POSIX__') ;; call posix_main with no arguments bl posix_main .else ;; retrieve argc and argv (default argv[0]==NULL & argc==0) bl __get_argcv ldr r1,=__argcvbuf ;; call main bl main .endif ;; call exit using the return value from main() ;; Note. Calling exit will also run all functions ;; that were supplied through atexit(). bl exit __get_argcv: ; weak definition movs r0,#0 bx lr .ltorg .endsec .calls '_START','__init_hardware' .calls '_START','__init_vector_table' .if @defined('__PROF_ENABLE__') .calls '_START','__prof_init' .endif .if @defined('__POSIX__') .calls '_START','posix_main' .else .calls '_START','__get_argcv' .calls '_START','main' .endif .calls '_START','exit' .calls '_START','',0 .end
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210E-EVAL/cstart_thumb2.asm
Assembly
asf20
3,949
//////////////////////////////////////////////////////////////////////////// // // File : stm32f103_cmsis.lsl // // Version : @(#)stm32f103_cmsis.lsl 1.2 09/06/04 // // Description : LSL file for the STMicroelectronics STM32F103, CMSIS version // // Copyright 2009 Altium BV // // NOTE: // This file is derived from cm3.lsl and stm32f103.lsl. // It is assumed that the user works with the ARMv7M architecture. // Other architectures will not work with this lsl file. // //////////////////////////////////////////////////////////////////////////// // // We do not want the vectors as defined in arm_arch.lsl // #define __NO_DEFAULT_AUTO_VECTORS 1 #define __NR_OF_VECTORS 76 #ifndef __STACK # define __STACK 8k #endif #ifndef __HEAP # define __HEAP 2k #endif #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x08000000 #endif #ifndef __XVWBUF #define __XVWBUF 256 /* buffer used by CrossView */ #endif #include <arm_arch.lsl> //////////////////////////////////////////////////////////////////////////// // // In the STM32F10x, 3 different boot modes can be selected // - User Flash memory is selected as boot space // - SystemMemory is selected as boot space // - Embedded SRAM is selected as boot space // // This aliases the physical memory associated with each boot mode to Block // 000 (0x00000000 boot memory). Even when aliased in the boot memory space, // the related memory (Flash memory or SRAM) is still accessible at its // original memory space. // // If no memory is defined yet use the following memory settings // #ifndef __MEMORY memory stm32f103flash { mau = 8; type = rom; size = 512k; map ( size = 512k, dest_offset=0x08000000, dest=bus:ARM:local_bus); } memory stm32f103ram { mau = 8; type = ram; size = 64k; map ( size = 64k, dest_offset=0x20000000, dest=bus:ARM:local_bus); } #endif /* __MEMORY */ // // Custom vector table defines interrupts according to CMSIS standard // # if defined(__CPU_ARMV7M__) section_setup ::linear { // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); vector ( id = 2, optional, fill = "NMI_Handler" ); vector ( id = 3, optional, fill = "HardFault_Handler" ); vector ( id = 4, optional, fill = "MemManage_Handler" ); vector ( id = 5, optional, fill = "BusFault_Handler" ); vector ( id = 6, optional, fill = "UsageFault_Handler" ); vector ( id = 11, optional, fill = "SVC_Handler" ); vector ( id = 12, optional, fill = "DebugMon_Handler" ); vector ( id = 14, optional, fill = "PendSV_Handler" ); vector ( id = 15, optional, fill = "SysTick_Handler" ); // External Interrupts : vector ( id = 16, optional, fill = "WWDG_IRQHandler" ); // Window Watchdog vector ( id = 17, optional, fill = "PVD_IRQHandler" ); // PVD through EXTI Line detect vector ( id = 18, optional, fill = "TAMPER_IRQHandler" ); // Tamper vector ( id = 19, optional, fill = "RTC_IRQHandler" ); // RTC vector ( id = 20, optional, fill = "FLASH_IRQHandler" ); // Flash vector ( id = 21, optional, fill = "RCC_IRQHandler" ); // RCC vector ( id = 22, optional, fill = "EXTI0_IRQHandler" ); // EXTI Line 0 vector ( id = 23, optional, fill = "EXTI1_IRQHandler" ); // EXTI Line 1 vector ( id = 24, optional, fill = "EXTI2_IRQHandler" ); // EXTI Line 2 vector ( id = 25, optional, fill = "EXTI3_IRQHandler" ); // EXTI Line 3 vector ( id = 26, optional, fill = "EXTI4_IRQHandler" ); // EXTI Line 4 vector ( id = 27, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 7 vector ( id = 34, optional, fill = "ADC1_2_IRQHandler" ); // ADC1 and ADC2 vector ( id = 35, optional, fill = "USB_HP_CAN1_TX_IRQHandler" ); // USB High Priority or CAN1 TX vector ( id = 36, optional, fill = "USB_LP_CAN1_RX0_IRQHandler" ); // USB LowPriority or CAN1 RX0 vector ( id = 37, optional, fill = "CAN_RX1_IRQHandler" ); // CAN RX1 vector ( id = 38, optional, fill = "CAN_SCE_IRQHandler" ); // CAN SCE vector ( id = 39, optional, fill = "EXTI9_5_IRQHandler" ); // EXTI Line 9..5 vector ( id = 40, optional, fill = "TIM1_BRK_IRQHandler" ); // TIM1 Break vector ( id = 41, optional, fill = "TIM1_UP_IRQHandler" ); // TIM1 Update vector ( id = 42, optional, fill = "TIM1_TRG_COM_IRQHandler" ); // TIM1 Trigger and Commutation vector ( id = 43, optional, fill = "TIM1_CC_IRQHandler" ); // TIM1 Capture Compare vector ( id = 44, optional, fill = "TIM2_IRQHandler" ); // TIM2 vector ( id = 45, optional, fill = "TIM3_IRQHandler" ); // TIM3 vector ( id = 46, optional, fill = "TIM4_IRQHandler" ); // TIM4 vector ( id = 47, optional, fill = "I2C1_EV_IRQHandler" ); // I2C1 Event vector ( id = 48, optional, fill = "I2C1_ER_IRQHandler" ); // I2C1 Error vector ( id = 49, optional, fill = "I2C2_EV_IRQHandler" ); // I2C2 Event vector ( id = 50, optional, fill = "I2C2_ER_IRQHandler" ); // I2C2 Error vector ( id = 51, optional, fill = "SPI1_IRQHandler" ); // SPI1 vector ( id = 52, optional, fill = "SPI2_IRQHandler" ); // SPI2 vector ( id = 53, optional, fill = "USART1_IRQHandler" ); // USART1 vector ( id = 54, optional, fill = "USART2_IRQHandler" ); // USART2 vector ( id = 55, optional, fill = "USART3_IRQHandler" ); // USART3 vector ( id = 56, optional, fill = "EXTI15_10_IRQHandler" ); // EXTI Line 15..10 vector ( id = 57, optional, fill = "RTCAlarm_IRQHandler" ); // RTC Alarm through EXTI Line vector ( id = 58, optional, fill = "USBWakeUp_IRQHandler" ); // USB Wakeup from suspend vector ( id = 59, optional, fill = "TIM8_BRK_IRQHandler" ); // TIM8 Break vector ( id = 60, optional, fill = "TIM8_UP_IRQHandler" ); // TIM8 Update vector ( id = 61, optional, fill = "TIM8_TRG_COM_IRQHandler" ); // TIM8 Trigger and Commutation vector ( id = 62, optional, fill = "TIM8_CC_IRQHandler" ); // TIM8 Capture Compare vector ( id = 63, optional, fill = "ADC3_IRQHandler" ); // ADC3 vector ( id = 64, optional, fill = "FSMC_IRQHandler" ); // FSMC vector ( id = 65, optional, fill = "SDIO_IRQHandler" ); // SDIO vector ( id = 66, optional, fill = "TIM5_IRQHandler" ); // TIM5 vector ( id = 67, optional, fill = "SPI3_IRQHandler" ); // SPI3 vector ( id = 68, optional, fill = "UART4_IRQHandler" ); // UART4 vector ( id = 69, optional, fill = "UART5_IRQHandler" ); // UART5 vector ( id = 70, optional, fill = "TIM6_IRQHandler" ); // TIM6 vector ( id = 71, optional, fill = "TIM7_IRQHandler" ); // TIM7 vector ( id = 72, optional, fill = "DMA2_Channel1_IRQHandler" ); // DMA2 Channel1 vector ( id = 73, optional, fill = "DMA2_Channel2_IRQHandler" ); // DMA2 Channel2 vector ( id = 74, optional, fill = "DMA2_Channel3_IRQHandler" ); // DMA2 Channel3 vector ( id = 75, optional, fill = "DMA2_Channel4_5_IRQHandler" ); // DMA2 Channel4 and DMA2 Channel5 } } # endif
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210E-EVAL/Settings/STM32F10x_hd.lsl
LSL
asf20
10,586
//////////////////////////////////////////////////////////////////////////// // // File : arm_arch.lsl // // Version : @(#)arm_arch.lsl 1.4 09/04/17 // // Description : Generic LSL file for ARM architectures // // Copyright 2008-2009 Altium BV // //////////////////////////////////////////////////////////////////////////// #ifndef __STACK # define __STACK 32k #endif #ifndef __HEAP # define __HEAP 32k #endif #ifndef __STACK_FIQ # define __STACK_FIQ 8 #endif #ifndef __STACK_IRQ # define __STACK_IRQ 8 #endif #ifndef __STACK_SVC # define __STACK_SVC 8 #endif #ifndef __STACK_ABT # define __STACK_ABT 8 #endif #ifndef __STACK_UND # define __STACK_UND 8 #endif #ifndef __PROCESSOR_MODE # define __PROCESSOR_MODE 0x1F /* SYS mode */ #endif #ifndef __IRQ_BIT # define __IRQ_BIT 0x80 /* IRQ interrupts disabled */ #endif #ifndef __FIQ_BIT # define __FIQ_BIT 0x40 /* FIQ interrupts disabled */ #endif #define __APPLICATION_MODE (__PROCESSOR_MODE | __IRQ_BIT | __FIQ_BIT) #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x00000000 #endif #ifndef __VECTOR_TABLE_RAM_ADDR # define __VECTOR_TABLE_RAM_ADDR 0x00000000 #endif #if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) # ifndef __NR_OF_VECTORS # define __NR_OF_VECTORS 16 # endif # define __VECTOR_TABLE_SIZE (__NR_OF_VECTORS * 4) #else # ifdef __PIC_VECTORS # define __VECTOR_TABLE_SIZE 64 # else # ifdef __FIQ_HANDLER_INLINE # define __VECTOR_TABLE_SIZE 28 # define __NR_OF_VECTORS 7 # else # define __VECTOR_TABLE_SIZE 32 # define __NR_OF_VECTORS 8 # endif # endif #endif #ifndef __VECTOR_TABLE_RAM_SPACE # undef __VECTOR_TABLE_RAM_COPY #endif #ifndef __XVWBUF # define __XVWBUF 0 /* buffer used by CrossView Pro */ #endif #define BOUNDS_GROUP_NAME grp_bounds #define BOUNDS_GROUP_SELECT "bounds" architecture ARM { endianness { little; big; } space linear { id = 1; mau = 8; map (size = 4G, dest = bus:local_bus); copytable ( align = 4, copy_unit = 1, dest = linear ); start_address ( // It is not strictly necessary to define a run_addr for _START // because hardware starts execution at address 0x0 which should // be the vector table with a jump to the relocatable _START, but // an absolute address can prevent the branch to be out-of-range. // Or _START may be the entry point at reset and the reset handler // copies the vector table to address 0x0 after some ROM/RAM memory // re-mapping. In that case _START should be at a fixed address // in ROM, specifically the alias of address 0x0 before memory // re-mapping. #ifdef __START run_addr = __START, #endif symbol = "_START" ); stack "stack" ( #ifdef __STACK_FIXED fixed, #endif align = 4, min_size = __STACK, grows = high_to_low ); heap "heap" ( #ifdef __HEAP_FIXED fixed, #endif align = 4, min_size=__HEAP ); #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) stack "stack_fiq" ( fixed, align = 4, min_size = __STACK_FIQ, grows = high_to_low ); stack "stack_irq" ( fixed, align = 4, min_size = __STACK_IRQ, grows = high_to_low ); stack "stack_svc" ( fixed, align = 4, min_size = __STACK_SVC, grows = high_to_low ); stack "stack_abt" ( fixed, align = 4, min_size = __STACK_ABT, grows = high_to_low ); stack "stack_und" ( fixed, align = 4, min_size = __STACK_UND, grows = high_to_low ); #endif #if !defined(__NO_AUTO_VECTORS) && !defined(__NO_DEFAULT_AUTO_VECTORS) # if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); } # else # ifdef __PIC_VECTORS // vector table with ldrpc instructions from handler table vector_table "vector_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_ldrpc", template_symbol = "_lc_vector_ldrpc", vector_prefix = "_vector_ldrpc_", fill = loop ) { } // subsequent vector table (data pool) with addresses of handlers vector_table "handler_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR + 32, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop[-32], no_inline ) { vector ( id = 0, fill = "_START" ); } # else // vector table with branch instructions to handlers vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_branch", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop ) { vector ( id = 0, fill = "_START" ); } # endif # endif #endif section_layout { #if defined(__NO_AUTO_VECTORS) "_lc_ub_vector_table" = __VECTOR_TABLE_ROM_ADDR; "_lc_ue_vector_table" = __VECTOR_TABLE_ROM_ADDR + __VECTOR_TABLE_SIZE; #endif #ifdef __VECTOR_TABLE_RAM_SPACE // reserve space to copy vector table from ROM to RAM group ( ordered, run_addr = __VECTOR_TABLE_RAM_ADDR ) reserved "vector_table_space" ( size = __VECTOR_TABLE_SIZE, attributes = rwx ); #endif #ifdef __VECTOR_TABLE_RAM_COPY // provide copy address symbols for copy routine "_lc_ub_vector_table_copy" := "_lc_ub_vector_table_space"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table_space"; #else // prevent copy: copy address equals orig address "_lc_ub_vector_table_copy" := "_lc_ub_vector_table"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table"; #endif // define buffer for string input via Crossview Pro debugger group ( align = 4 ) reserved "xvwbuffer" (size=__XVWBUF, attributes=rw ); // define labels for bounds begin and end as used in C library #ifndef BOUNDS_GROUP_REDEFINED group BOUNDS_GROUP_NAME (ordered, contiguous) { select BOUNDS_GROUP_SELECT; } #endif "_lc_ub_bounds" := addressof(group:BOUNDS_GROUP_NAME); "_lc_ue_bounds" := addressof(group:BOUNDS_GROUP_NAME) + sizeof(group:BOUNDS_GROUP_NAME); #ifdef __HEAPADDR group ( ordered, run_addr=__HEAPADDR ) { select "heap"; } #endif #ifdef __STACKADDR group ( ordered, run_addr=__STACKADDR ) { select "stack"; } #endif #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) // symbol to set mode bits and interrupt disable bits // in cstart module before calling the application (main) "_APPLICATION_MODE_" = __APPLICATION_MODE; #endif } } bus local_bus { mau = 8; width = 32; } }
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210E-EVAL/Settings/arm_arch.lsl
LSL
asf20
10,931
;; NOTE: To allow the use of this file for both ARMv6M and ARMv7M, ;; we will only use 16-bit Thumb intructions. .extern _lc_ub_stack ; usr/sys mode stack pointer .extern _lc_ue_stack ; symbol required by debugger .extern _lc_ub_table ; ROM to RAM copy table .extern main .extern _Exit .extern exit .weak exit .global __get_argcv .weak __get_argcv .extern __argcvbuf .weak __argcvbuf .extern __init_hardware .extern __init_vector_table .extern SystemInit .if @defined('__PROF_ENABLE__') .extern __prof_init .endif .if @defined('__POSIX__') .extern posix_main .extern _posix_boot_stack_top .endif .global _START .section .text.cstart .thumb _START: ;; anticipate possible ROM/RAM remapping ;; by loading the 'real' program address ldr r1,=_Next bx r1 _Next: ;; initialize the stack pointer ldr r1,=_lc_ub_stack ; TODO: make this part of the vector table mov sp,r1 ;; call a user function which initializes hardware ;; such as ROM/RAM re-mapping or MMU configuration bl __init_hardware ;ldr r0, =SystemInit ;bx r0 bl SystemInit ;; copy initialized sections from ROM to RAM ;; and clear uninitialized data sections in RAM ldr r3,=_lc_ub_table movs r0,#0 cploop: ldr r4,[r3,#0] ; load type ldr r5,[r3,#4] ; dst address ldr r6,[r3,#8] ; src address ldr r7,[r3,#12] ; size cmp r4,#1 beq copy cmp r4,#2 beq clear b done copy: subs r7,r7,#1 ldrb r1,[r6,r7] strb r1,[r5,r7] bne copy adds r3,r3,#16 b cploop clear: subs r7,r7,#1 strb r0,[r5,r7] bne clear adds r3,r3,#16 b cploop done: ;; initialize or copy the vector table bl __init_vector_table .if @defined('__POSIX__') ;; posix stack buffer for system upbringing ldr r0,=_posix_boot_stack_top ldr r0, [r0] mov sp,r0 .else ;; load r10 with end of USR/SYS stack, which is ;; needed in case stack overflow checking is on ;; NOTE: use 16-bit instructions only, for ARMv6M ldr r0,=_lc_ue_stack mov r10,r0 .endif .if @defined('__PROF_ENABLE__') bl __prof_init .endif .if @defined('__POSIX__') ;; call posix_main with no arguments bl posix_main .else ;; retrieve argc and argv (default argv[0]==NULL & argc==0) bl __get_argcv ldr r1,=__argcvbuf ;; call main bl main .endif ;; call exit using the return value from main() ;; Note. Calling exit will also run all functions ;; that were supplied through atexit(). bl exit __get_argcv: ; weak definition movs r0,#0 bx lr .ltorg .endsec .calls '_START','__init_hardware' .calls '_START','__init_vector_table' .if @defined('__PROF_ENABLE__') .calls '_START','__prof_init' .endif .if @defined('__POSIX__') .calls '_START','posix_main' .else .calls '_START','__get_argcv' .calls '_START','main' .endif .calls '_START','exit' .calls '_START','',0 .end
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210B-EVAL/cstart_thumb2.asm
Assembly
asf20
3,949
//////////////////////////////////////////////////////////////////////////// // // File : arm_arch.lsl // // Version : @(#)arm_arch.lsl 1.4 09/04/17 // // Description : Generic LSL file for ARM architectures // // Copyright 2008-2009 Altium BV // //////////////////////////////////////////////////////////////////////////// #ifndef __STACK # define __STACK 32k #endif #ifndef __HEAP # define __HEAP 32k #endif #ifndef __STACK_FIQ # define __STACK_FIQ 8 #endif #ifndef __STACK_IRQ # define __STACK_IRQ 8 #endif #ifndef __STACK_SVC # define __STACK_SVC 8 #endif #ifndef __STACK_ABT # define __STACK_ABT 8 #endif #ifndef __STACK_UND # define __STACK_UND 8 #endif #ifndef __PROCESSOR_MODE # define __PROCESSOR_MODE 0x1F /* SYS mode */ #endif #ifndef __IRQ_BIT # define __IRQ_BIT 0x80 /* IRQ interrupts disabled */ #endif #ifndef __FIQ_BIT # define __FIQ_BIT 0x40 /* FIQ interrupts disabled */ #endif #define __APPLICATION_MODE (__PROCESSOR_MODE | __IRQ_BIT | __FIQ_BIT) #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x00000000 #endif #ifndef __VECTOR_TABLE_RAM_ADDR # define __VECTOR_TABLE_RAM_ADDR 0x00000000 #endif #if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) # ifndef __NR_OF_VECTORS # define __NR_OF_VECTORS 16 # endif # define __VECTOR_TABLE_SIZE (__NR_OF_VECTORS * 4) #else # ifdef __PIC_VECTORS # define __VECTOR_TABLE_SIZE 64 # else # ifdef __FIQ_HANDLER_INLINE # define __VECTOR_TABLE_SIZE 28 # define __NR_OF_VECTORS 7 # else # define __VECTOR_TABLE_SIZE 32 # define __NR_OF_VECTORS 8 # endif # endif #endif #ifndef __VECTOR_TABLE_RAM_SPACE # undef __VECTOR_TABLE_RAM_COPY #endif #ifndef __XVWBUF # define __XVWBUF 0 /* buffer used by CrossView Pro */ #endif #define BOUNDS_GROUP_NAME grp_bounds #define BOUNDS_GROUP_SELECT "bounds" architecture ARM { endianness { little; big; } space linear { id = 1; mau = 8; map (size = 4G, dest = bus:local_bus); copytable ( align = 4, copy_unit = 1, dest = linear ); start_address ( // It is not strictly necessary to define a run_addr for _START // because hardware starts execution at address 0x0 which should // be the vector table with a jump to the relocatable _START, but // an absolute address can prevent the branch to be out-of-range. // Or _START may be the entry point at reset and the reset handler // copies the vector table to address 0x0 after some ROM/RAM memory // re-mapping. In that case _START should be at a fixed address // in ROM, specifically the alias of address 0x0 before memory // re-mapping. #ifdef __START run_addr = __START, #endif symbol = "_START" ); stack "stack" ( #ifdef __STACK_FIXED fixed, #endif align = 4, min_size = __STACK, grows = high_to_low ); heap "heap" ( #ifdef __HEAP_FIXED fixed, #endif align = 4, min_size=__HEAP ); #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) stack "stack_fiq" ( fixed, align = 4, min_size = __STACK_FIQ, grows = high_to_low ); stack "stack_irq" ( fixed, align = 4, min_size = __STACK_IRQ, grows = high_to_low ); stack "stack_svc" ( fixed, align = 4, min_size = __STACK_SVC, grows = high_to_low ); stack "stack_abt" ( fixed, align = 4, min_size = __STACK_ABT, grows = high_to_low ); stack "stack_und" ( fixed, align = 4, min_size = __STACK_UND, grows = high_to_low ); #endif #if !defined(__NO_AUTO_VECTORS) && !defined(__NO_DEFAULT_AUTO_VECTORS) # if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); } # else # ifdef __PIC_VECTORS // vector table with ldrpc instructions from handler table vector_table "vector_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_ldrpc", template_symbol = "_lc_vector_ldrpc", vector_prefix = "_vector_ldrpc_", fill = loop ) { } // subsequent vector table (data pool) with addresses of handlers vector_table "handler_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR + 32, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop[-32], no_inline ) { vector ( id = 0, fill = "_START" ); } # else // vector table with branch instructions to handlers vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_branch", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop ) { vector ( id = 0, fill = "_START" ); } # endif # endif #endif section_layout { #if defined(__NO_AUTO_VECTORS) "_lc_ub_vector_table" = __VECTOR_TABLE_ROM_ADDR; "_lc_ue_vector_table" = __VECTOR_TABLE_ROM_ADDR + __VECTOR_TABLE_SIZE; #endif #ifdef __VECTOR_TABLE_RAM_SPACE // reserve space to copy vector table from ROM to RAM group ( ordered, run_addr = __VECTOR_TABLE_RAM_ADDR ) reserved "vector_table_space" ( size = __VECTOR_TABLE_SIZE, attributes = rwx ); #endif #ifdef __VECTOR_TABLE_RAM_COPY // provide copy address symbols for copy routine "_lc_ub_vector_table_copy" := "_lc_ub_vector_table_space"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table_space"; #else // prevent copy: copy address equals orig address "_lc_ub_vector_table_copy" := "_lc_ub_vector_table"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table"; #endif // define buffer for string input via Crossview Pro debugger group ( align = 4 ) reserved "xvwbuffer" (size=__XVWBUF, attributes=rw ); // define labels for bounds begin and end as used in C library #ifndef BOUNDS_GROUP_REDEFINED group BOUNDS_GROUP_NAME (ordered, contiguous) { select BOUNDS_GROUP_SELECT; } #endif "_lc_ub_bounds" := addressof(group:BOUNDS_GROUP_NAME); "_lc_ue_bounds" := addressof(group:BOUNDS_GROUP_NAME) + sizeof(group:BOUNDS_GROUP_NAME); #ifdef __HEAPADDR group ( ordered, run_addr=__HEAPADDR ) { select "heap"; } #endif #ifdef __STACKADDR group ( ordered, run_addr=__STACKADDR ) { select "stack"; } #endif #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) // symbol to set mode bits and interrupt disable bits // in cstart module before calling the application (main) "_APPLICATION_MODE_" = __APPLICATION_MODE; #endif } } bus local_bus { mau = 8; width = 32; } }
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210B-EVAL/Settings/arm_arch.lsl
LSL
asf20
10,931
//////////////////////////////////////////////////////////////////////////// // // File : stm32f103_cmsis.lsl // // Version : @(#)stm32f103_cmsis.lsl 1.2 09/06/04 // // Description : LSL file for the STMicroelectronics STM32F103, CMSIS version // // Copyright 2009 Altium BV // // NOTE: // This file is derived from cm3.lsl and stm32f103.lsl. // It is assumed that the user works with the ARMv7M architecture. // Other architectures will not work with this lsl file. // //////////////////////////////////////////////////////////////////////////// // // We do not want the vectors as defined in arm_arch.lsl // #define __NO_DEFAULT_AUTO_VECTORS 1 #define __NR_OF_VECTORS 76 #ifndef __STACK # define __STACK 8k #endif #ifndef __HEAP # define __HEAP 2k #endif #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x08000000 #endif #ifndef __XVWBUF #define __XVWBUF 256 /* buffer used by CrossView */ #endif #include <arm_arch.lsl> //////////////////////////////////////////////////////////////////////////// // // In the STM32F10x, 3 different boot modes can be selected // - User Flash memory is selected as boot space // - SystemMemory is selected as boot space // - Embedded SRAM is selected as boot space // // This aliases the physical memory associated with each boot mode to Block // 000 (0x00000000 boot memory). Even when aliased in the boot memory space, // the related memory (Flash memory or SRAM) is still accessible at its // original memory space. // // If no memory is defined yet use the following memory settings // #ifndef __MEMORY memory stm32f103flash { mau = 8; type = rom; size = 128k; map ( size = 128k, dest_offset=0x08000000, dest=bus:ARM:local_bus); } memory stm32f103ram { mau = 8; type = ram; size = 20k; map ( size = 20k, dest_offset=0x20000000, dest=bus:ARM:local_bus); } #endif /* __MEMORY */ // // Custom vector table defines interrupts according to CMSIS standard // # if defined(__CPU_ARMV7M__) section_setup ::linear { // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); vector ( id = 2, optional, fill = "NMI_Handler" ); vector ( id = 3, optional, fill = "HardFault_Handler" ); vector ( id = 4, optional, fill = "MemManage_Handler" ); vector ( id = 5, optional, fill = "BusFault_Handler" ); vector ( id = 6, optional, fill = "UsageFault_Handler" ); vector ( id = 11, optional, fill = "SVC_Handler" ); vector ( id = 12, optional, fill = "DebugMon_Handler" ); vector ( id = 14, optional, fill = "PendSV_Handler" ); vector ( id = 15, optional, fill = "SysTick_Handler" ); // External Interrupts : vector ( id = 16, optional, fill = "WWDG_IRQHandler" ); // Window Watchdog vector ( id = 17, optional, fill = "PVD_IRQHandler" ); // PVD through EXTI Line detect vector ( id = 18, optional, fill = "TAMPER_IRQHandler" ); // Tamper vector ( id = 19, optional, fill = "RTC_IRQHandler" ); // RTC vector ( id = 20, optional, fill = "FLASH_IRQHandler" ); // Flash vector ( id = 21, optional, fill = "RCC_IRQHandler" ); // RCC vector ( id = 22, optional, fill = "EXTI0_IRQHandler" ); // EXTI Line 0 vector ( id = 23, optional, fill = "EXTI1_IRQHandler" ); // EXTI Line 1 vector ( id = 24, optional, fill = "EXTI2_IRQHandler" ); // EXTI Line 2 vector ( id = 25, optional, fill = "EXTI3_IRQHandler" ); // EXTI Line 3 vector ( id = 26, optional, fill = "EXTI4_IRQHandler" ); // EXTI Line 4 vector ( id = 27, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMA1_Channel2_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMA1_Channel3_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMA1_Channel4_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMA1_Channel5_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMA1_Channel6_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMA1_Channel7_IRQHandler" ); // DMA Channel 7 vector ( id = 34, optional, fill = "ADC1_2_IRQHandler" ); // ADC1 and ADC2 vector ( id = 35, optional, fill = "USB_HP_CAN1_TX_IRQHandler" ); // USB High Priority or CAN1 TX vector ( id = 36, optional, fill = "USB_LP_CAN1_RX0_IRQHandler" ); // USB LowPriority or CAN RX0 vector ( id = 37, optional, fill = "CAN_RX1_IRQHandler" ); // CAN RX1 vector ( id = 38, optional, fill = "CAN_SCE_IRQHandler" ); // CAN SCE vector ( id = 39, optional, fill = "EXTI9_5_IRQHandler" ); // EXTI Line 9..5 vector ( id = 40, optional, fill = "TIM1_BRK_IRQHandler" ); // TIM1 Break vector ( id = 41, optional, fill = "TIM1_UP_IRQHandler" ); // TIM1 Update vector ( id = 42, optional, fill = "TIM1_TRG_COM_IRQHandler" ); // TIM1 Trigger and Commutation vector ( id = 43, optional, fill = "TIM1_CC_IRQHandler" ); // TIM1 Capture Compare vector ( id = 44, optional, fill = "TIM2_IRQHandler" ); // TIM2 vector ( id = 45, optional, fill = "TIM3_IRQHandler" ); // TIM3 vector ( id = 46, optional, fill = "TIM4_IRQHandler" ); // TIM4 vector ( id = 47, optional, fill = "I2C1_EV_IRQHandler" ); // I2C1 Event vector ( id = 48, optional, fill = "I2C1_ER_IRQHandler" ); // I2C1 Error vector ( id = 49, optional, fill = "I2C2_EV_IRQHandler" ); // I2C2 Event vector ( id = 50, optional, fill = "I2C2_ER_IRQHandler" ); // I2C2 Error vector ( id = 51, optional, fill = "SPI1_IRQHandler" ); // SPI1 vector ( id = 52, optional, fill = "SPI2_IRQHandler" ); // SPI2 vector ( id = 53, optional, fill = "USART1_IRQHandler" ); // USART1 vector ( id = 54, optional, fill = "USART2_IRQHandler" ); // USART2 vector ( id = 55, optional, fill = "USART3_IRQHandler" ); // USART3 vector ( id = 56, optional, fill = "EXTI15_10_IRQHandler" ); // EXTI Line 15..10 vector ( id = 57, optional, fill = "RTCAlarm_IRQHandler" ); // RTC Alarm through EXTI Line vector ( id = 58, optional, fill = "USBWakeUp_IRQHandler" ); // USB Wakeup from suspend } } # endif
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Mass_Storage/HiTOP/STM3210B-EVAL/Settings/STM32F10x_md.lsl
LSL
asf20
8,716
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_pwr.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Connection/disconnection & power management header ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_PWR_H #define __USB_PWR_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ typedef enum _RESUME_STATE { RESUME_EXTERNAL, RESUME_INTERNAL, RESUME_LATER, RESUME_WAIT, RESUME_START, RESUME_ON, RESUME_OFF, RESUME_ESOF } RESUME_STATE; typedef enum _DEVICE_STATE { UNCONNECTED, ATTACHED, POWERED, SUSPENDED, ADDRESSED, CONFIGURED } DEVICE_STATE; /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void Suspend(void); void Resume_Init(void); void Resume(RESUME_STATE eResumeSetVal); RESULT PowerOn(void); RESULT PowerOff(void); /* External variables --------------------------------------------------------*/ extern __IO uint32_t bDeviceState; /* USB device status */ extern __IO bool fSuspendEnabled; /* true when suspend is possible */ #endif /*__USB_PWR_H*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/inc/usb_pwr.h
C
asf20
2,244
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : hw_config.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Hardware Configuration & Setup ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __HW_CONFIG_H #define __HW_CONFIG_H /* Includes ------------------------------------------------------------------*/ #include "usb_type.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported define -----------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void Set_System(void); void Set_USBClock(void); void Enter_LowPowerMode(void); void Leave_LowPowerMode(void); void USB_Interrupts_Config(void); void USB_Cable_Config (FunctionalState NewState); void GPIO_Configuration(void); void EXTI_Configuration(void); void ADC_Configuration(void); void Get_SerialNum(void); #endif /*__HW_CONFIG_H*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/inc/hw_config.h
C
asf20
1,994
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_desc.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Descriptor Header for Custom HID Demo ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_DESC_H #define __USB_DESC_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported define -----------------------------------------------------------*/ #define USB_DEVICE_DESCRIPTOR_TYPE 0x01 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 #define USB_STRING_DESCRIPTOR_TYPE 0x03 #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 #define HID_DESCRIPTOR_TYPE 0x21 #define CUSTOMHID_SIZ_HID_DESC 0x09 #define CUSTOMHID_OFF_HID_DESC 0x12 #define CUSTOMHID_SIZ_DEVICE_DESC 18 #define CUSTOMHID_SIZ_CONFIG_DESC 41 #define CUSTOMHID_SIZ_REPORT_DESC 163 #define CUSTOMHID_SIZ_STRING_LANGID 4 #define CUSTOMHID_SIZ_STRING_VENDOR 38 #define CUSTOMHID_SIZ_STRING_PRODUCT 32 #define CUSTOMHID_SIZ_STRING_SERIAL 26 #define STANDARD_ENDPOINT_DESC_SIZE 0x09 /* Exported functions ------------------------------------------------------- */ extern const uint8_t CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC]; extern const uint8_t CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC]; extern const uint8_t CustomHID_ReportDescriptor[CUSTOMHID_SIZ_REPORT_DESC]; extern const uint8_t CustomHID_StringLangID[CUSTOMHID_SIZ_STRING_LANGID]; extern const uint8_t CustomHID_StringVendor[CUSTOMHID_SIZ_STRING_VENDOR]; extern const uint8_t CustomHID_StringProduct[CUSTOMHID_SIZ_STRING_PRODUCT]; extern uint8_t CustomHID_StringSerial[CUSTOMHID_SIZ_STRING_SERIAL]; #endif /* __USB_DESC_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/inc/usb_desc.h
C
asf20
3,036
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_prop.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : All processings related to Custom HID demo ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_PROP_H #define __USB_PROP_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ typedef enum _HID_REQUESTS { GET_REPORT = 1, GET_IDLE, GET_PROTOCOL, SET_REPORT = 9, SET_IDLE, SET_PROTOCOL } HID_REQUESTS; /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void CustomHID_init(void); void CustomHID_Reset(void); void CustomHID_SetConfiguration(void); void CustomHID_SetDeviceAddress (void); void CustomHID_Status_In (void); void CustomHID_Status_Out (void); RESULT CustomHID_Data_Setup(uint8_t); RESULT CustomHID_NoData_Setup(uint8_t); RESULT CustomHID_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting); uint8_t *CustomHID_GetDeviceDescriptor(uint16_t ); uint8_t *CustomHID_GetConfigDescriptor(uint16_t); uint8_t *CustomHID_GetStringDescriptor(uint16_t); RESULT CustomHID_SetProtocol(void); uint8_t *CustomHID_GetProtocolValue(uint16_t Length); RESULT CustomHID_SetProtocol(void); uint8_t *CustomHID_GetReportDescriptor(uint16_t Length); uint8_t *CustomHID_GetHIDDescriptor(uint16_t Length); /* Exported define -----------------------------------------------------------*/ #define CustomHID_GetConfiguration NOP_Process //#define CustomHID_SetConfiguration NOP_Process #define CustomHID_GetInterface NOP_Process #define CustomHID_SetInterface NOP_Process #define CustomHID_GetStatus NOP_Process #define CustomHID_ClearFeature NOP_Process #define CustomHID_SetEndPointFeature NOP_Process #define CustomHID_SetDeviceFeature NOP_Process //#define CustomHID_SetDeviceAddress NOP_Process #define REPORT_DESCRIPTOR 0x22 #endif /* __USB_PROP_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/inc/usb_prop.h
C
asf20
3,146
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : stm32f10x_conf.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Library configuration file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F10x_CONF_H #define __STM32F10x_CONF_H /* Includes ------------------------------------------------------------------*/ /* Uncomment the line below to enable peripheral header file inclusion */ #include "stm32f10x_adc.h" /* #include "stm32f10x_bkp.h" */ /* #include "stm32f10x_can.h" */ /* #include "stm32f10x_crc.h" */ /* #include "stm32f10x_dac.h" */ /* #include "stm32f10x_dbgmcu.h" */ #include "stm32f10x_dma.h" #include "stm32f10x_exti.h" #include "stm32f10x_flash.h" /* #include "stm32f10x_fsmc.h" */ #include "stm32f10x_gpio.h" #include "stm32f10x_i2c.h" /* #include "stm32f10x_iwdg.h" */ /* #include "stm32f10x_pwr.h" */ #include "stm32f10x_rcc.h" /* #include "stm32f10x_rtc.h" */ /* #include "stm32f10x_sdio.h" */ /* #include "stm32f10x_spi.h" */ /* #include "stm32f10x_tim.h" */ #include "stm32f10x_usart.h" /* #include "stm32f10x_wwdg.h" */ #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Uncomment the line below to expanse the "assert_param" macro in the Standard Peripheral Library drivers code */ /* #define USE_FULL_ASSERT 1 */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /******************************************************************************* * Macro Name : assert_param * Description : The assert_param macro is used for function's parameters check. * Input : - expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * Return : None *******************************************************************************/ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0) #endif /* USE_FULL_ASSERT */ #endif /* __STM32F10x_CONF_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/inc/stm32f10x_conf.h
C
asf20
3,432
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : stm32f10x_it.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : This file contains the headers of the interrupt handlers. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F10x_IT_H #define __STM32F10x_IT_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); #ifndef STM32F10X_CL void USB_LP_CAN1_RX0_IRQHandler(void); #endif /* STM32F10X_CL */ void DMA1_Channel1_IRQHandler(void); void EXTI9_5_IRQHandler(void); void EXTI15_10_IRQHandler(void); #ifdef STM32F10X_CL void OTG_FS_IRQHandler(void); #endif /* STM32F10X_CL */ #endif /* __STM32F10x_IT_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/inc/stm32f10x_it.h
C
asf20
2,172
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : platform_config.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Evaluation board specific configuration file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __PLATFORM_CONFIG_H #define __PLATFORM_CONFIG_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Uncomment the line corresponding to the STMicroelectronics evaluation board used to run the example */ #if !defined (USE_STM3210B_EVAL) && !defined (USE_STM3210E_EVAL) && !defined (USE_STM3210C_EVAL) //#define USE_STM3210B_EVAL //#define USE_STM3210E_EVAL #define USE_STM3210C_EVAL #endif /* Define the STM32F10x hardware depending on the used evaluation board */ #ifdef USE_STM3210B_EVAL #define USB_DISCONNECT GPIOD #define USB_DISCONNECT_PIN GPIO_Pin_9 #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOD #elif defined (USE_STM3210E_EVAL) #define USB_DISCONNECT GPIOB #define USB_DISCONNECT_PIN GPIO_Pin_14 #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB #elif defined (USE_STM3210C_EVAL) #define USB_DISCONNECT 0 #define USB_DISCONNECT_PIN 0 #define RCC_APB2Periph_GPIO_DISCONNECT 0 #endif /* USE_STM3210B_EVAL */ #define RCC_APB2Periph_GPIO_IOAIN RCC_APB2Periph_GPIOC #define GPIO_IOAIN GPIOC #define GPIO_IOAIN_PIN GPIO_Pin_4 /* PC.04 */ #define ADC_AIN_CHANNEL ADC_Channel_14 /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #endif /* __PLATFORM_CONFIG_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/inc/platform_config.h
C
asf20
2,902
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_istr.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : This file includes the peripherals header files in the * user application. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_ISTR_H #define __USB_ISTR_H /* Includes ------------------------------------------------------------------*/ #include "usb_conf.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #ifndef STM32F10X_CL void USB_Istr(void); #else /* STM32F10X_CL */ u32 STM32_PCD_OTG_ISR_Handler(void); #endif /* STM32F10X_CL */ /* function prototypes Automatically built defining related macros */ void EP1_IN_Callback(void); void EP2_IN_Callback(void); void EP3_IN_Callback(void); void EP4_IN_Callback(void); void EP5_IN_Callback(void); void EP6_IN_Callback(void); void EP7_IN_Callback(void); void EP1_OUT_Callback(void); void EP2_OUT_Callback(void); void EP3_OUT_Callback(void); void EP4_OUT_Callback(void); void EP5_OUT_Callback(void); void EP6_OUT_Callback(void); void EP7_OUT_Callback(void); #ifndef STM32F10X_CL #ifdef CTR_CALLBACK void CTR_Callback(void); #endif #ifdef DOVR_CALLBACK void DOVR_Callback(void); #endif #ifdef ERR_CALLBACK void ERR_Callback(void); #endif #ifdef WKUP_CALLBACK void WKUP_Callback(void); #endif #ifdef SUSP_CALLBACK void SUSP_Callback(void); #endif #ifdef RESET_CALLBACK void RESET_Callback(void); #endif #ifdef SOF_CALLBACK void SOF_Callback(void); #endif #ifdef ESOF_CALLBACK void ESOF_Callback(void); #endif #else /* STM32F10X_CL */ /* Interrupt subroutines user callbacks prototypes. These callbacks are called into the respective interrupt sunroutine functinos and can be tailored for various user application purposes. Note: Make sure that the correspondant interrupt is enabled through the definition in usb_conf.h file */ void INTR_MODEMISMATCH_Callback(void); void INTR_SOFINTR_Callback(void); void INTR_RXSTSQLVL_Callback(void); void INTR_NPTXFEMPTY_Callback(void); void INTR_GINNAKEFF_Callback(void); void INTR_GOUTNAKEFF_Callback(void); void INTR_ERLYSUSPEND_Callback(void); void INTR_USBSUSPEND_Callback(void); void INTR_USBRESET_Callback(void); void INTR_ENUMDONE_Callback(void); void INTR_ISOOUTDROP_Callback(void); void INTR_EOPFRAME_Callback(void); void INTR_EPMISMATCH_Callback(void); void INTR_INEPINTR_Callback(void); void INTR_OUTEPINTR_Callback(void); void INTR_INCOMPLISOIN_Callback(void); void INTR_INCOMPLISOOUT_Callback(void); void INTR_WKUPINTR_Callback(void); /* Isochronous data update */ void INTR_RXSTSQLVL_ISODU_Callback(void); #endif /* STM32F10X_CL */ #endif /*__USB_ISTR_H*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/inc/usb_istr.h
C
asf20
3,903
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_conf.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Custom HID demo configuration file ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_CONF_H #define __USB_CONF_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ /* External variables --------------------------------------------------------*/ /*-------------------------------------------------------------*/ /* EP_NUM */ /* defines how many endpoints are used by the device */ /*-------------------------------------------------------------*/ #define EP_NUM (2) #ifndef STM32F10X_CL /*-------------------------------------------------------------*/ /* -------------- Buffer Description Table -----------------*/ /*-------------------------------------------------------------*/ /* buffer table base address */ /* buffer table base address */ #define BTABLE_ADDRESS (0x00) /* EP0 */ /* rx/tx buffer base address */ #define ENDP0_RXADDR (0x18) #define ENDP0_TXADDR (0x58) /* EP1 */ /* tx buffer base address */ #define ENDP1_TXADDR (0x100) #define ENDP1_RXADDR (0x104) /*-------------------------------------------------------------*/ /* ------------------- ISTR events -------------------------*/ /*-------------------------------------------------------------*/ /* IMR_MSK */ /* mask defining which events has to be handled */ /* by the device application software */ #define IMR_MSK (CNTR_CTRM | CNTR_WKUPM | CNTR_SUSPM | CNTR_ERRM | CNTR_SOFM \ | CNTR_ESOFM | CNTR_RESETM ) #endif /* STM32F10X_CL */ #ifdef STM32F10X_CL /******************************************************************************* * FIFO Size Configuration * * (i) Dedicated data FIFO SPRAM of 1.25 Kbytes = 1280 bytes = 320 32-bits words * available for the endpoints IN and OUT. * Device mode features: * -1 bidirectional CTRL EP 0 * -3 IN EPs to support any kind of Bulk, Interrupt or Isochronous transfer * -3 OUT EPs to support any kind of Bulk, Interrupt or Isochronous transfer * * ii) Receive data FIFO size = RAM for setup packets + * OUT endpoint control information + * data OUT packets + miscellaneous * Space = ONE 32-bits words * --> RAM for setup packets = 4 * n + 6 space * (n is the nbr of CTRL EPs the device core supports) * --> OUT EP CTRL info = 1 space * (one space for status information written to the FIFO along with each * received packet) * --> data OUT packets = (Largest Packet Size / 4) + 1 spaces * (MINIMUM to receive packets) * --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces * (if high-bandwidth EP is enabled or multiple isochronous EPs) * --> miscellaneous = 1 space per OUT EP * (one space for transfer complete status information also pushed to the * FIFO with each endpoint's last packet) * * (iii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for * that particular IN EP. More space allocated in the IN EP Tx FIFO results * in a better performance on the USB and can hide latencies on the AHB. * * (iv) TXn min size = 16 words. (n : Transmit FIFO index) * (v) When a TxFIFO is not used, the Configuration should be as follows: * case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) * --> Txm can use the space allocated for Txn. * case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) * --> Txn should be configured with the minimum space of 16 words * (vi) The FIFO is used optimally when used TxFIFOs are allocated in the top * of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. *******************************************************************************/ #define RX_FIFO_SIZE 128 #define TX0_FIFO_SIZE 64 #define TX1_FIFO_SIZE 64 #define TX2_FIFO_SIZE 16 #define TX3_FIFO_SIZE 16 /* OTGD-FS-DEVICE IP interrupts Enable definitions */ /* Uncomment the define to enable the selected interrupt */ //#define INTR_MODEMISMATCH #define INTR_SOFINTR #define INTR_RXSTSQLVL /* Mandatory */ //#define INTR_NPTXFEMPTY //#define INTR_GINNAKEFF //#define INTR_GOUTNAKEFF //#define INTR_ERLYSUSPEND #define INTR_USBSUSPEND /* Mandatory */ #define INTR_USBRESET /* Mandatory */ #define INTR_ENUMDONE /* Mandatory */ //#define INTR_ISOOUTDROP //#define INTR_EOPFRAME //#define INTR_EPMISMATCH #define INTR_INEPINTR /* Mandatory */ #define INTR_OUTEPINTR /* Mandatory */ //#define INTR_INCOMPLISOIN //#define INTR_INCOMPLISOOUT #define INTR_WKUPINTR /* Mandatory */ /* OTGD-FS-DEVICE IP interrupts subroutines */ /* Comment the define to enable the selected interrupt subroutine and replace it by user code */ #define INTR_MODEMISMATCH_Callback NOP_Process #define INTR_SOFINTR_Callback NOP_Process #define INTR_RXSTSQLVL_Callback NOP_Process #define INTR_NPTXFEMPTY_Callback NOP_Process #define INTR_NPTXFEMPTY_Callback NOP_Process #define INTR_GINNAKEFF_Callback NOP_Process #define INTR_GOUTNAKEFF_Callback NOP_Process #define INTR_ERLYSUSPEND_Callback NOP_Process #define INTR_USBSUSPEND_Callback NOP_Process #define INTR_USBRESET_Callback NOP_Process #define INTR_ENUMDONE_Callback NOP_Process #define INTR_ISOOUTDROP_Callback NOP_Process #define INTR_EOPFRAME_Callback NOP_Process #define INTR_EPMISMATCH_Callback NOP_Process #define INTR_INEPINTR_Callback NOP_Process #define INTR_OUTEPINTR_Callback NOP_Process #define INTR_INCOMPLISOIN_Callback NOP_Process #define INTR_INCOMPLISOOUT_Callback NOP_Process #define INTR_WKUPINTR_Callback NOP_Process /* Isochronous data update */ #define INTR_RXSTSQLVL_ISODU_Callback NOP_Process /* Isochronous transfer parameters */ /* Size of a single Isochronous buffer (size of a single transfer) */ #define ISOC_BUFFER_SZE 1 /* Number of sub-buffers (number of single buffers/transfers), should be even */ #define NUM_SUB_BUFFERS 2 #endif /* STM32F10X_CL */ /* CTR service routines */ /* associated to defined endpoints */ #define EP1_IN_Callback NOP_Process #define EP2_IN_Callback NOP_Process #define EP3_IN_Callback NOP_Process #define EP4_IN_Callback NOP_Process #define EP5_IN_Callback NOP_Process #define EP6_IN_Callback NOP_Process #define EP7_IN_Callback NOP_Process //#define EP1_OUT_Callback NOP_Process #define EP2_OUT_Callback NOP_Process #define EP3_OUT_Callback NOP_Process #define EP4_OUT_Callback NOP_Process #define EP5_OUT_Callback NOP_Process #define EP6_OUT_Callback NOP_Process #define EP7_OUT_Callback NOP_Process #endif /*__USB_CONF_H*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/inc/usb_conf.h
C
asf20
8,513
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_endp.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Endpoint routines ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "platform_config.h" #include "stm32f10x.h" #include "usb_lib.h" #include "usb_istr.h" #include "stm32_eval.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint8_t Receive_Buffer[2]; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : EP1_OUT_Callback. * Description : EP1 OUT Callback Routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void EP1_OUT_Callback(void) { BitAction Led_State; /* Read recieved data (2 bytes) */ USB_SIL_Read(EP1_OUT, Receive_Buffer); if (Receive_Buffer[1] == 0) { Led_State = Bit_RESET; } else { Led_State = Bit_SET; } switch (Receive_Buffer[0]) { case 1: /* Led 1 */ if (Led_State != Bit_RESET) { STM_EVAL_LEDOn(LED1); } else { STM_EVAL_LEDOff(LED1); } break; case 2: /* Led 2 */ if (Led_State != Bit_RESET) { STM_EVAL_LEDOn(LED2); } else { STM_EVAL_LEDOff(LED2); } break; case 3: /* Led 3 */ if (Led_State != Bit_RESET) { STM_EVAL_LEDOn(LED3); } else { STM_EVAL_LEDOff(LED3); } break; case 4: /* Led 4 */ if (Led_State != Bit_RESET) { STM_EVAL_LEDOn(LED4); } else { STM_EVAL_LEDOff(LED4); } break; default: STM_EVAL_LEDOff(LED1); STM_EVAL_LEDOff(LED2); STM_EVAL_LEDOff(LED3); STM_EVAL_LEDOff(LED4); break; } #ifndef STM32F10X_CL SetEPRxStatus(ENDP1, EP_RX_VALID); #endif /* STM32F10X_CL */ } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/src/usb_endp.c
C
asf20
3,287
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_istr.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : ISTR events interrupt service routines ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_lib.h" #include "usb_prop.h" #include "usb_pwr.h" #include "usb_istr.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ __IO uint16_t wIstr; /* ISTR register last read value */ __IO uint8_t bIntPackSOF = 0; /* SOFs received between 2 consecutive packets */ /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /* function pointers to non-control endpoints service routines */ void (*pEpInt_IN[7])(void) = { EP1_IN_Callback, EP2_IN_Callback, EP3_IN_Callback, EP4_IN_Callback, EP5_IN_Callback, EP6_IN_Callback, EP7_IN_Callback, }; void (*pEpInt_OUT[7])(void) = { EP1_OUT_Callback, EP2_OUT_Callback, EP3_OUT_Callback, EP4_OUT_Callback, EP5_OUT_Callback, EP6_OUT_Callback, EP7_OUT_Callback, }; #ifndef STM32F10X_CL /******************************************************************************* * Function Name : USB_Istr * Description : STR events interrupt service routine * Input : * Output : * Return : *******************************************************************************/ void USB_Istr(void) { wIstr = _GetISTR(); #if (IMR_MSK & ISTR_CTR) if (wIstr & ISTR_CTR & wInterrupt_Mask) { /* servicing of the endpoint correct transfer interrupt */ /* clear of the CTR flag into the sub */ CTR_LP(); #ifdef CTR_CALLBACK CTR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_RESET) if (wIstr & ISTR_RESET & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_RESET); Device_Property.Reset(); #ifdef RESET_CALLBACK RESET_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_DOVR) if (wIstr & ISTR_DOVR & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_DOVR); #ifdef DOVR_CALLBACK DOVR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_ERR) if (wIstr & ISTR_ERR & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_ERR); #ifdef ERR_CALLBACK ERR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_WKUP) if (wIstr & ISTR_WKUP & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_WKUP); Resume(RESUME_EXTERNAL); #ifdef WKUP_CALLBACK WKUP_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_SUSP) if (wIstr & ISTR_SUSP & wInterrupt_Mask) { /* check if SUSPEND is possible */ if (fSuspendEnabled) { Suspend(); } else { /* if not possible then resume after xx ms */ Resume(RESUME_LATER); } /* clear of the ISTR bit must be done after setting of CNTR_FSUSP */ _SetISTR((uint16_t)CLR_SUSP); #ifdef SUSP_CALLBACK SUSP_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_SOF) if (wIstr & ISTR_SOF & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_SOF); bIntPackSOF++; #ifdef SOF_CALLBACK SOF_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_ESOF) if (wIstr & ISTR_ESOF & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_ESOF); /* resume handling timing is made with ESOFs */ Resume(RESUME_ESOF); /* request without change of the machine state */ #ifdef ESOF_CALLBACK ESOF_Callback(); #endif } #endif } /* USB_Istr */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #else /* STM32F10X_CL */ /******************************************************************************* * Function Name : STM32_PCD_OTG_ISR_Handler * Description : Handles all USB Device Interrupts * Input : None * Output : None * Return : status *******************************************************************************/ u32 STM32_PCD_OTG_ISR_Handler (void) { USB_OTG_GINTSTS_TypeDef gintr_status; u32 retval = 0; if (USBD_FS_IsDeviceMode()) /* ensure that we are in device mode */ { gintr_status.d32 = OTGD_FS_ReadCoreItr(); /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* If there is no interrupt pending exit the interrupt routine */ if (!gintr_status.d32) { return 0; } /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Early Suspend interrupt */ #ifdef INTR_ERLYSUSPEND if (gintr_status.b.erlysuspend) { retval |= OTGD_FS_Handle_EarlySuspend_ISR(); } #endif /* INTR_ERLYSUSPEND */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* End of Periodic Frame interrupt */ #ifdef INTR_EOPFRAME if (gintr_status.b.eopframe) { retval |= OTGD_FS_Handle_EOPF_ISR(); } #endif /* INTR_EOPFRAME */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Non Periodic Tx FIFO Emty interrupt */ #ifdef INTR_NPTXFEMPTY if (gintr_status.b.nptxfempty) { retval |= OTGD_FS_Handle_NPTxFE_ISR(); } #endif /* INTR_NPTXFEMPTY */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Wakeup or RemoteWakeup interrupt */ #ifdef INTR_WKUPINTR if (gintr_status.b.wkupintr) { retval |= OTGD_FS_Handle_Wakeup_ISR(); } #endif /* INTR_WKUPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Suspend interrupt */ #ifdef INTR_USBSUSPEND if (gintr_status.b.usbsuspend) { /* check if SUSPEND is possible */ if (fSuspendEnabled) { Suspend(); } else { /* if not possible then resume after xx ms */ Resume(RESUME_LATER); /* This case shouldn't happen in OTG Device mode because there's no ESOF interrupt to increment the ResumeS.bESOFcnt in the Resume state machine */ } retval |= OTGD_FS_Handle_USBSuspend_ISR(); } #endif /* INTR_USBSUSPEND */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Start of Frame interrupt */ #ifdef INTR_SOFINTR if (gintr_status.b.sofintr) { /* Update the frame number variable */ bIntPackSOF++; retval |= OTGD_FS_Handle_Sof_ISR(); } #endif /* INTR_SOFINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Receive FIFO Queue Status Level interrupt */ #ifdef INTR_RXSTSQLVL if (gintr_status.b.rxstsqlvl) { retval |= OTGD_FS_Handle_RxStatusQueueLevel_ISR(); } #endif /* INTR_RXSTSQLVL */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Enumeration Done interrupt */ #ifdef INTR_ENUMDONE if (gintr_status.b.enumdone) { retval |= OTGD_FS_Handle_EnumDone_ISR(); } #endif /* INTR_ENUMDONE */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Reset interrutp */ #ifdef INTR_USBRESET if (gintr_status.b.usbreset) { retval |= OTGD_FS_Handle_UsbReset_ISR(); } #endif /* INTR_USBRESET */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* IN Endpoint interrupt */ #ifdef INTR_INEPINTR if (gintr_status.b.inepint) { retval |= OTGD_FS_Handle_InEP_ISR(); } #endif /* INTR_INEPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* OUT Endpoint interrupt */ #ifdef INTR_OUTEPINTR if (gintr_status.b.outepintr) { retval |= OTGD_FS_Handle_OutEP_ISR(); } #endif /* INTR_OUTEPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Mode Mismatch interrupt */ #ifdef INTR_MODEMISMATCH if (gintr_status.b.modemismatch) { retval |= OTGD_FS_Handle_ModeMismatch_ISR(); } #endif /* INTR_MODEMISMATCH */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Global IN Endpoints NAK Effective interrupt */ #ifdef INTR_GINNAKEFF if (gintr_status.b.ginnakeff) { retval |= OTGD_FS_Handle_GInNakEff_ISR(); } #endif /* INTR_GINNAKEFF */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Global OUT Endpoints NAK effective interrupt */ #ifdef INTR_GOUTNAKEFF if (gintr_status.b.goutnakeff) { retval |= OTGD_FS_Handle_GOutNakEff_ISR(); } #endif /* INTR_GOUTNAKEFF */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Isochrounous Out packet Dropped interrupt */ #ifdef INTR_ISOOUTDROP if (gintr_status.b.isooutdrop) { retval |= OTGD_FS_Handle_IsoOutDrop_ISR(); } #endif /* INTR_ISOOUTDROP */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Endpoint Mismatch error interrupt */ #ifdef INTR_EPMISMATCH if (gintr_status.b.epmismatch) { retval |= OTGD_FS_Handle_EPMismatch_ISR(); } #endif /* INTR_EPMISMATCH */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Incomplete Isochrous IN tranfer error interrupt */ #ifdef INTR_INCOMPLISOIN if (gintr_status.b.incomplisoin) { retval |= OTGD_FS_Handle_IncomplIsoIn_ISR(); } #endif /* INTR_INCOMPLISOIN */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Incomplete Isochrous OUT tranfer error interrupt */ #ifdef INTR_INCOMPLISOOUT if (gintr_status.b.outepintr) { retval |= OTGD_FS_Handle_IncomplIsoOut_ISR(); } #endif /* INTR_INCOMPLISOOUT */ } return retval; } #endif /* STM32F10X_CL */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/src/usb_istr.c
C
asf20
11,736
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : main.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Custom HID demo main file ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "usb_lib.h" #include "hw_config.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ void Delay(__IO uint32_t nCount); /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : main. * Description : main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { Set_System(); USB_Interrupts_Config(); Set_USBClock(); USB_Init(); while (1) { } } /******************************************************************************* * Function Name : Delay * Description : Inserts a delay time. * Input : nCount: specifies the delay time length. * Output : None * Return : None *******************************************************************************/ void Delay(__IO uint32_t nCount) { for(; nCount!= 0;nCount--); } #ifdef USE_FULL_ASSERT /******************************************************************************* * Function Name : assert_failed * Description : Reports the name of the source file and the source line number * where the assert_param error has occurred. * Input : - file: pointer to the source file name * - line: assert_param error line source number * Output : None * Return : None *******************************************************************************/ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while(1) { } } #endif /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/src/main.c
C
asf20
3,427
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : hw_config.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Hardware Configuration & Setup ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "platform_config.h" #include "hw_config.h" #include "usb_lib.h" #include "usb_desc.h" #include "usb_pwr.h" #include "stm32_eval.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define ADC1_DR_Address ((uint32_t)0x4001244C) /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ ErrorStatus HSEStartUpStatus; uint32_t ADC_ConvertedValueX = 0; uint32_t ADC_ConvertedValueX_1 = 0; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len); /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : Set_System * Description : Configures Main system clocks & power. * Input : None. * Return : None. *******************************************************************************/ void Set_System(void) { /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/ /* RCC system reset(for debug purpose) */ RCC_DeInit(); /* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON); /* Wait till HSE is ready */ HSEStartUpStatus = RCC_WaitForHSEStartUp(); if (HSEStartUpStatus == SUCCESS) { /* Enable Prefetch Buffer */ FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); /* Flash 2 wait state */ FLASH_SetLatency(FLASH_Latency_2); /* HCLK = SYSCLK */ RCC_HCLKConfig(RCC_SYSCLK_Div1); /* PCLK2 = HCLK */ RCC_PCLK2Config(RCC_HCLK_Div1); /* PCLK1 = HCLK/2 */ RCC_PCLK1Config(RCC_HCLK_Div2); /* ADCCLK = PCLK2/8 */ RCC_ADCCLKConfig(RCC_PCLK2_Div8); #ifdef STM32F10X_CL /* Configure PLLs *********************************************************/ /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */ RCC_PREDIV2Config(RCC_PREDIV2_Div5); RCC_PLL2Config(RCC_PLL2Mul_8); /* Enable PLL2 */ RCC_PLL2Cmd(ENABLE); /* Wait till PLL2 is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET) {} /* PLL configuration: PLLCLK = (PLL2 / 5) * 9 = 72 MHz */ RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div5); RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_9); #else /* PLLCLK = 8MHz * 9 = 72 MHz */ RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); #endif /* Enable PLL */ RCC_PLLCmd(ENABLE); /* Wait till PLL is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) { } /* Select PLL as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); /* Wait till PLL is used as system clock source */ while(RCC_GetSYSCLKSource() != 0x08) { } } else { /* If HSE fails to start-up, the application will have wrong clock configuration. User can add here some code to deal with this error */ /* Go to infinite loop */ while (1) { } } /* Configure the used GPIOs*/ GPIO_Configuration(); /* Configure the KEY button in EXTI mode */ STM_EVAL_PBInit(Button_KEY, Mode_EXTI); /* Configure the Tamper button in EXTI mode */ STM_EVAL_PBInit(Button_TAMPER, Mode_EXTI); /* Additional EXTI configuration (configure both edges) */ EXTI_Configuration(); /* Configure the LEDs */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); /* Configure the ADC*/ ADC_Configuration(); } /******************************************************************************* * Function Name : Set_USBClock * Description : Configures USB Clock input (48MHz). * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Set_USBClock(void) { #ifdef STM32F10X_CL /* Select USBCLK source */ RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3); /* Enable the USB clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE) ; #else /* Select USBCLK source */ RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5); /* Enable the USB clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE); #endif /* STM32F10X_CL */ } /******************************************************************************* * Function Name : Enter_LowPowerMode. * Description : Power-off system clocks and power while entering suspend mode. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Enter_LowPowerMode(void) { /* Set the device state to suspend */ bDeviceState = SUSPENDED; } /******************************************************************************* * Function Name : Leave_LowPowerMode. * Description : Restores system clocks and power while exiting suspend mode. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Leave_LowPowerMode(void) { DEVICE_INFO *pInfo = &Device_Info; /* Set the device state to the correct state */ if (pInfo->Current_Configuration != 0) { /* Device configured */ bDeviceState = CONFIGURED; } else { bDeviceState = ATTACHED; } } /******************************************************************************* * Function Name : USB_Interrupts_Config. * Description : Configures the USB interrupts. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void USB_Interrupts_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; /* 2 bit for pre-emption priority, 2 bits for subpriority */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); #ifdef STM32F10X_CL /* Enable the USB Interrupts */ NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); #else NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); #endif /* STM32F10X_CL */ /* Enable the EXTI9_5 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_Init(&NVIC_InitStructure); /* Enable the EXTI15_10 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_Init(&NVIC_InitStructure); /* Enable the DMA1 Channel1 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_Init(&NVIC_InitStructure); } /******************************************************************************* * Function Name : USB_Cable_Config. * Description : Software Connection/Disconnection of USB Cable. * Input : NewState: new state. * Output : None. * Return : None *******************************************************************************/ void USB_Cable_Config (FunctionalState NewState) { #ifdef USE_STM3210C_EVAL if (NewState != DISABLE) { USB_DevConnect(); } else { USB_DevDisconnect(); } #else /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ if (NewState != DISABLE) { GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN); } else { GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN); } #endif /* USE_STM3210C_EVAL */ } /******************************************************************************* * Function Name : GPIO_Configuration * Description : Configures the different GPIO ports. * Input : None * Output : None * Return : None *******************************************************************************/ void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_DISCONNECT | RCC_APB2Periph_GPIO_IOAIN , ENABLE); #ifndef USE_STM3210C_EVAL /* USB_DISCONNECT used as USB pull-up */ GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure); #endif /* USE_STM3210C_EVAL */ /* Configure Potentiometer IO as analog input */ GPIO_InitStructure.GPIO_Pin = GPIO_IOAIN_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIO_IOAIN, &GPIO_InitStructure); } /******************************************************************************* * Function Name : EXTI_Configuration. * Description : Configure the EXTI lines for Key and Tamper push buttons. * Input : None. * Output : None. * Return value : The direction value. *******************************************************************************/ void EXTI_Configuration(void) { EXTI_InitTypeDef EXTI_InitStructure; /* Configure Key EXTI line to generate an interrupt on rising & falling edges */ EXTI_InitStructure.EXTI_Line = KEY_BUTTON_EXTI_LINE; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Clear the Key EXTI line pending bit */ EXTI_ClearITPendingBit(KEY_BUTTON_EXTI_LINE); /* Configure Tamper EXTI Line to generate an interrupt rising & falling edges */ EXTI_InitStructure.EXTI_Line = TAMPER_BUTTON_EXTI_LINE; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Clear the Tamper EXTI line pending bit */ EXTI_ClearITPendingBit(TAMPER_BUTTON_EXTI_LINE); } /******************************************************************************* * Function Name : ADC_Configuration. * Description : Configure the ADC and DMA. * Input : None. * Output : None. * Return value : The direction value. *******************************************************************************/ void ADC_Configuration(void) { ADC_InitTypeDef ADC_InitStructure; DMA_InitTypeDef DMA_InitStructure; /* Enable DMA1 clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); /* Enable ADC1 clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); /* DMA1 channel1 configuration ---------------------------------------------*/ DMA_DeInit(DMA1_Channel1); DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&ADC_ConvertedValueX; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 1; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel1, &DMA_InitStructure); /* Enable DMA1 channel1 */ DMA_Cmd(DMA1_Channel1, ENABLE); /* Enable the DMA1 Channel1 Transfer complete interrupt */ DMA_ITConfig(DMA1_Channel1, DMA_IT_TC, ENABLE); /* ADC1 configuration ------------------------------------------------------*/ ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; ADC_InitStructure.ADC_ScanConvMode = ENABLE; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = 1; ADC_Init(ADC1, &ADC_InitStructure); /* ADC1 regular channel configuration */ ADC_RegularChannelConfig(ADC1, ADC_AIN_CHANNEL, 1, ADC_SampleTime_55Cycles5); /* Enable ADC1 DMA */ ADC_DMACmd(ADC1, ENABLE); /* Enable ADC1 */ ADC_Cmd(ADC1, ENABLE); /* Enable ADC1 reset calibaration register */ ADC_ResetCalibration(ADC1); /* Check the end of ADC1 reset calibration register */ while(ADC_GetResetCalibrationStatus(ADC1)); /* Start ADC1 calibaration */ ADC_StartCalibration(ADC1); /* Check the end of ADC1 calibration */ while(ADC_GetCalibrationStatus(ADC1)); } /******************************************************************************* * Function Name : Get_SerialNum. * Description : Create the serial number string descriptor. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Get_SerialNum(void) { uint32_t Device_Serial0, Device_Serial1, Device_Serial2; Device_Serial0 = *(__IO uint32_t*)(0x1FFFF7E8); Device_Serial1 = *(__IO uint32_t*)(0x1FFFF7EC); Device_Serial2 = *(__IO uint32_t*)(0x1FFFF7F0); Device_Serial0 += Device_Serial2; if (Device_Serial0 != 0) { IntToUnicode (Device_Serial0, &CustomHID_StringSerial[2] , 8); IntToUnicode (Device_Serial1, &CustomHID_StringSerial[18], 4); } } /******************************************************************************* * Function Name : HexToChar. * Description : Convert Hex 32Bits value into char. * Input : None. * Output : None. * Return : None. *******************************************************************************/ static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len) { uint8_t idx = 0; for( idx = 0 ; idx < len ; idx ++) { if( ((value >> 28)) < 0xA ) { pbuf[ 2* idx] = (value >> 28) + '0'; } else { pbuf[2* idx] = (value >> 28) + 'A' - 10; } value = value << 4; pbuf[ 2* idx + 1] = 0; } } #ifdef STM32F10X_CL /******************************************************************************* * Function Name : USB_OTG_BSP_uDelay. * Description : provide delay (usec). * Input : None. * Output : None. * Return : None. *******************************************************************************/ void USB_OTG_BSP_uDelay (const uint32_t usec) { RCC_ClocksTypeDef RCC_Clocks; /* Configure HCLK clock as SysTick clock source */ SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(usec * (RCC_Clocks.HCLK_Frequency / 1000000)); SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk ; while (!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)); } #endif /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/src/hw_config.c
C
asf20
16,810
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : stm32f10x_it.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Main Interrupt Service Routines. * This file provides template for all exceptions handler * and peripherals interrupt service routine. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "platform_config.h" #include "stm32f10x_it.h" #include "usb_lib.h" #include "usb_istr.h" #include "usb_pwr.h" #include "stm32_eval.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ __IO uint8_t Send_Buffer[2]; extern uint32_t ADC_ConvertedValueX; extern uint32_t ADC_ConvertedValueX_1; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /******************************************************************************* * Function Name : NMI_Handler * Description : This function handles NMI exception. * Input : None * Output : None * Return : None *******************************************************************************/ void NMI_Handler(void) { } /******************************************************************************* * Function Name : HardFault_Handler * Description : This function handles Hard Fault exception. * Input : None * Output : None * Return : None *******************************************************************************/ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /******************************************************************************* * Function Name : MemManage_Handler * Description : This function handles Memory Manage exception. * Input : None * Output : None * Return : None *******************************************************************************/ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /******************************************************************************* * Function Name : BusFault_Handler * Description : This function handles Bus Fault exception. * Input : None * Output : None * Return : None *******************************************************************************/ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /******************************************************************************* * Function Name : UsageFault_Handler * Description : This function handles Usage Fault exception. * Input : None * Output : None * Return : None *******************************************************************************/ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /******************************************************************************* * Function Name : SVC_Handler * Description : This function handles SVCall exception. * Input : None * Output : None * Return : None *******************************************************************************/ void SVC_Handler(void) { } /******************************************************************************* * Function Name : DebugMon_Handler * Description : This function handles Debug Monitor exception. * Input : None * Output : None * Return : None *******************************************************************************/ void DebugMon_Handler(void) { } /******************************************************************************* * Function Name : PendSV_Handler * Description : This function handles PendSVC exception. * Input : None * Output : None * Return : None *******************************************************************************/ void PendSV_Handler(void) { } /******************************************************************************* * Function Name : SysTick_Handler * Description : This function handles SysTick Handler. * Input : None * Output : None * Return : None *******************************************************************************/ void SysTick_Handler(void) { } /******************************************************************************/ /* STM32F10x Peripherals Interrupt Handlers */ /******************************************************************************/ #ifndef STM32F10X_CL /******************************************************************************* * Function Name : USB_LP_CAN1_RX0_IRQHandler * Description : This function handles USB Low Priority or CAN RX0 interrupts * requests. * Input : None * Output : None * Return : None *******************************************************************************/ void USB_LP_CAN1_RX0_IRQHandler(void) { USB_Istr(); } #endif /* STM32F10X_CL */ /******************************************************************************* * Function Name : DMA1_Channel1_IRQHandler * Description : This function handles DMA1 Channel 1 interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ void DMA1_Channel1_IRQHandler(void) { Send_Buffer[0] = 0x07; if((ADC_ConvertedValueX >>4) - (ADC_ConvertedValueX_1 >>4) > 4) { Send_Buffer[1] = (uint8_t)(ADC_ConvertedValueX >>4); /* Write the descriptor through the endpoint */ USB_SIL_Write(EP1_IN, (uint8_t*) Send_Buffer, 2); #ifndef STM32F10X_CL SetEPTxValid(ENDP1); #endif /* STM32F10X_CL */ ADC_ConvertedValueX_1 = ADC_ConvertedValueX; } DMA_ClearFlag(DMA1_FLAG_TC1); } /******************************************************************************* * Function Name : EXTI9_5_IRQHandler * Description : This function handles External lines 9 to 5 interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ void EXTI9_5_IRQHandler(void) { if(EXTI_GetITStatus(KEY_BUTTON_EXTI_LINE) != RESET) { Send_Buffer[0] = 0x05; if (STM_EVAL_PBGetState(Button_KEY) == Bit_RESET) { Send_Buffer[1] = 0x01; } else { Send_Buffer[1] = 0x00; } /* Write the descriptor through the endpoint */ USB_SIL_Write(EP1_IN, (uint8_t*) Send_Buffer, 2); #ifndef STM32F10X_CL SetEPTxValid(ENDP1); #endif /* STM32F10X_CL */ /* Clear the EXTI line pending bit */ EXTI_ClearITPendingBit(KEY_BUTTON_EXTI_LINE); } } /******************************************************************************* * Function Name : EXTI15_10_IRQHandler * Description : This function handles External lines 15 to 10 interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ void EXTI15_10_IRQHandler(void) { if(EXTI_GetITStatus(TAMPER_BUTTON_EXTI_LINE) != RESET) { Send_Buffer[0] = 0x06; if (STM_EVAL_PBGetState(Button_TAMPER) == Bit_RESET) { Send_Buffer[1] = 0x01; } else { Send_Buffer[1] = 0x00; } /* Write the descriptor through the endpoint */ USB_SIL_Write(EP1_IN, (uint8_t*) Send_Buffer, 2); #ifndef STM32F10X_CL SetEPTxValid(ENDP1); #endif /* STM32F10X_CL */ /* Clear the EXTI line 13 pending bit */ EXTI_ClearITPendingBit(TAMPER_BUTTON_EXTI_LINE); } } #ifdef STM32F10X_CL /******************************************************************************* * Function Name : OTG_FS_IRQHandler * Description : This function handles USB-On-The-Go FS global interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ void OTG_FS_IRQHandler(void) { STM32_PCD_OTG_ISR_Handler(); } #endif /* STM32F10X_CL */ /******************************************************************************/ /* STM32F10x Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f10x_xx.s). */ /******************************************************************************/ /******************************************************************************* * Function Name : PPP_IRQHandler * Description : This function handles PPP interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ /*void PPP_IRQHandler(void) { }*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/src/stm32f10x_it.c
C
asf20
10,836
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_pwr.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Connection/disconnection & power management ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "usb_lib.h" #include "usb_conf.h" #include "usb_pwr.h" #include "hw_config.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ __IO uint32_t bDeviceState = UNCONNECTED; /* USB device status */ __IO bool fSuspendEnabled = TRUE; /* true when suspend is possible */ struct { __IO RESUME_STATE eState; __IO uint8_t bESOFcnt; }ResumeS; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : PowerOn * Description : * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ RESULT PowerOn(void) { #ifndef STM32F10X_CL uint16_t wRegVal; /*** cable plugged-in ? ***/ USB_Cable_Config(ENABLE); /*** CNTR_PWDN = 0 ***/ wRegVal = CNTR_FRES; _SetCNTR(wRegVal); /*** CNTR_FRES = 0 ***/ wInterrupt_Mask = 0; _SetCNTR(wInterrupt_Mask); /*** Clear pending interrupts ***/ _SetISTR(0); /*** Set interrupt mask ***/ wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM; _SetCNTR(wInterrupt_Mask); #endif /* STM32F10X_CL */ return USB_SUCCESS; } /******************************************************************************* * Function Name : PowerOff * Description : handles switch-off conditions * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ RESULT PowerOff() { #ifndef STM32F10X_CL /* disable all ints and force USB reset */ _SetCNTR(CNTR_FRES); /* clear interrupt status register */ _SetISTR(0); /* Disable the Pull-Up*/ USB_Cable_Config(DISABLE); /* switch-off device */ _SetCNTR(CNTR_FRES + CNTR_PDWN); #endif /* STM32F10X_CL */ /* sw variables reset */ /* ... */ return USB_SUCCESS; } /******************************************************************************* * Function Name : Suspend * Description : sets suspend mode operating conditions * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ void Suspend(void) { #ifndef STM32F10X_CL uint16_t wCNTR; /* suspend preparation */ /* ... */ /* macrocell enters suspend mode */ wCNTR = _GetCNTR(); wCNTR |= CNTR_FSUSP; _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */ /* power reduction */ /* ... on connected devices */ #ifndef STM32F10X_CL /* force low-power mode in the macrocell */ wCNTR = _GetCNTR(); wCNTR |= CNTR_LPMODE; _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ /* switch-off the clocks */ /* ... */ Enter_LowPowerMode(); } /******************************************************************************* * Function Name : Resume_Init * Description : Handles wake-up restoring normal operations * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ void Resume_Init(void) { #ifndef STM32F10X_CL uint16_t wCNTR; #endif /* STM32F10X_CL */ /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */ /* restart the clocks */ /* ... */ #ifndef STM32F10X_CL /* CNTR_LPMODE = 0 */ wCNTR = _GetCNTR(); wCNTR &= (~CNTR_LPMODE); _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ /* restore full power */ /* ... on connected devices */ Leave_LowPowerMode(); #ifndef STM32F10X_CL /* reset FSUSP bit */ _SetCNTR(IMR_MSK); #endif /* STM32F10X_CL */ /* reverse suspend preparation */ /* ... */ } /******************************************************************************* * Function Name : Resume * Description : This is the state machine handling resume operations and * timing sequence. The control is based on the Resume structure * variables and on the ESOF interrupt calling this subroutine * without changing machine state. * Input : a state machine value (RESUME_STATE) * RESUME_ESOF doesn't change ResumeS.eState allowing * decrementing of the ESOF counter in different states. * Output : None. * Return : None. *******************************************************************************/ void Resume(RESUME_STATE eResumeSetVal) { #ifndef STM32F10X_CL uint16_t wCNTR; #endif /* STM32F10X_CL */ if (eResumeSetVal != RESUME_ESOF) ResumeS.eState = eResumeSetVal; switch (ResumeS.eState) { case RESUME_EXTERNAL: Resume_Init(); ResumeS.eState = RESUME_OFF; break; case RESUME_INTERNAL: Resume_Init(); ResumeS.eState = RESUME_START; break; case RESUME_LATER: ResumeS.bESOFcnt = 2; ResumeS.eState = RESUME_WAIT; break; case RESUME_WAIT: ResumeS.bESOFcnt--; if (ResumeS.bESOFcnt == 0) ResumeS.eState = RESUME_START; break; case RESUME_START: #ifdef STM32F10X_CL OTGD_FS_SetRemoteWakeup(); #else wCNTR = _GetCNTR(); wCNTR |= CNTR_RESUME; _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ ResumeS.eState = RESUME_ON; ResumeS.bESOFcnt = 10; break; case RESUME_ON: #ifndef STM32F10X_CL ResumeS.bESOFcnt--; if (ResumeS.bESOFcnt == 0) { #endif /* STM32F10X_CL */ #ifdef STM32F10X_CL OTGD_FS_ResetRemoteWakeup(); #else wCNTR = _GetCNTR(); wCNTR &= (~CNTR_RESUME); _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ ResumeS.eState = RESUME_OFF; #ifndef STM32F10X_CL } #endif /* STM32F10X_CL */ break; case RESUME_OFF: case RESUME_ESOF: default: ResumeS.eState = RESUME_OFF; break; } } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/src/usb_pwr.c
C
asf20
7,830
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_prop.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : All processings related to Custom HID Demo ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "usb_lib.h" #include "usb_conf.h" #include "usb_prop.h" #include "usb_desc.h" #include "usb_pwr.h" #include "hw_config.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint32_t ProtocolValue; __IO uint8_t EXTI_Enable; /* -------------------------------------------------------------------------- */ /* Structures initializations */ /* -------------------------------------------------------------------------- */ DEVICE Device_Table = { EP_NUM, 1 }; DEVICE_PROP Device_Property = { CustomHID_init, CustomHID_Reset, CustomHID_Status_In, CustomHID_Status_Out, CustomHID_Data_Setup, CustomHID_NoData_Setup, CustomHID_Get_Interface_Setting, CustomHID_GetDeviceDescriptor, CustomHID_GetConfigDescriptor, CustomHID_GetStringDescriptor, 0, 0x40 /*MAX PACKET SIZE*/ }; USER_STANDARD_REQUESTS User_Standard_Requests = { CustomHID_GetConfiguration, CustomHID_SetConfiguration, CustomHID_GetInterface, CustomHID_SetInterface, CustomHID_GetStatus, CustomHID_ClearFeature, CustomHID_SetEndPointFeature, CustomHID_SetDeviceFeature, CustomHID_SetDeviceAddress }; ONE_DESCRIPTOR Device_Descriptor = { (uint8_t*)CustomHID_DeviceDescriptor, CUSTOMHID_SIZ_DEVICE_DESC }; ONE_DESCRIPTOR Config_Descriptor = { (uint8_t*)CustomHID_ConfigDescriptor, CUSTOMHID_SIZ_CONFIG_DESC }; ONE_DESCRIPTOR CustomHID_Report_Descriptor = { (uint8_t *)CustomHID_ReportDescriptor, CUSTOMHID_SIZ_REPORT_DESC }; ONE_DESCRIPTOR CustomHID_Hid_Descriptor = { (uint8_t*)CustomHID_ConfigDescriptor + CUSTOMHID_OFF_HID_DESC, CUSTOMHID_SIZ_HID_DESC }; ONE_DESCRIPTOR String_Descriptor[4] = { {(uint8_t*)CustomHID_StringLangID, CUSTOMHID_SIZ_STRING_LANGID}, {(uint8_t*)CustomHID_StringVendor, CUSTOMHID_SIZ_STRING_VENDOR}, {(uint8_t*)CustomHID_StringProduct, CUSTOMHID_SIZ_STRING_PRODUCT}, {(uint8_t*)CustomHID_StringSerial, CUSTOMHID_SIZ_STRING_SERIAL} }; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : CustomHID_init. * Description : Custom HID init routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void CustomHID_init(void) { /* Update the serial number string descriptor with the data from the unique ID*/ Get_SerialNum(); pInformation->Current_Configuration = 0; /* Connect the device */ PowerOn(); /* Perform basic device initialization operations */ USB_SIL_Init(); bDeviceState = UNCONNECTED; } /******************************************************************************* * Function Name : CustomHID_Reset. * Description : Custom HID reset routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void CustomHID_Reset(void) { /* Set Joystick_DEVICE as not configured */ pInformation->Current_Configuration = 0; pInformation->Current_Interface = 0;/*the default Interface*/ /* Current Feature initialization */ pInformation->Current_Feature = CustomHID_ConfigDescriptor[7]; #ifdef STM32F10X_CL /* EP0 is already configured in DFU_Init() by USB_SIL_Init() function */ /* Init EP1 IN as Interrupt endpoint */ OTG_DEV_EP_Init(EP1_IN, OTG_DEV_EP_TYPE_INT, 2); /* Init EP1 OUT as Interrupt endpoint */ OTG_DEV_EP_Init(EP1_OUT, OTG_DEV_EP_TYPE_INT, 2); #else SetBTABLE(BTABLE_ADDRESS); /* Initialize Endpoint 0 */ SetEPType(ENDP0, EP_CONTROL); SetEPTxStatus(ENDP0, EP_TX_STALL); SetEPRxAddr(ENDP0, ENDP0_RXADDR); SetEPTxAddr(ENDP0, ENDP0_TXADDR); Clear_Status_Out(ENDP0); SetEPRxCount(ENDP0, Device_Property.MaxPacketSize); SetEPRxValid(ENDP0); /* Initialize Endpoint 1 */ SetEPType(ENDP1, EP_INTERRUPT); SetEPTxAddr(ENDP1, ENDP1_TXADDR); SetEPRxAddr(ENDP1, ENDP1_RXADDR); SetEPTxCount(ENDP1, 2); SetEPRxCount(ENDP1, 2); SetEPRxStatus(ENDP1, EP_RX_VALID); SetEPTxStatus(ENDP1, EP_TX_NAK); /* Set this device to response on default address */ SetDeviceAddress(0); #endif /* STM32F10X_CL */ bDeviceState = ATTACHED; } /******************************************************************************* * Function Name : CustomHID_SetConfiguration. * Description : Udpade the device state to configured and command the ADC * conversion. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void CustomHID_SetConfiguration(void) { if (pInformation->Current_Configuration != 0) { /* Device configured */ bDeviceState = CONFIGURED; /* Start ADC1 Software Conversion */ ADC_SoftwareStartConvCmd(ADC1, ENABLE); } } /******************************************************************************* * Function Name : CustomHID_SetConfiguration. * Description : Udpade the device state to addressed. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void CustomHID_SetDeviceAddress (void) { bDeviceState = ADDRESSED; } /******************************************************************************* * Function Name : CustomHID_Status_In. * Description : Joystick status IN routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void CustomHID_Status_In(void) { } /******************************************************************************* * Function Name : CustomHID_Status_Out * Description : Joystick status OUT routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void CustomHID_Status_Out (void) { } /******************************************************************************* * Function Name : CustomHID_Data_Setup * Description : Handle the data class specific requests. * Input : Request Nb. * Output : None. * Return : USB_UNSUPPORT or USB_SUCCESS. *******************************************************************************/ RESULT CustomHID_Data_Setup(uint8_t RequestNo) { uint8_t *(*CopyRoutine)(uint16_t); CopyRoutine = NULL; if ((RequestNo == GET_DESCRIPTOR) && (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT)) && (pInformation->USBwIndex0 == 0)) { if (pInformation->USBwValue1 == REPORT_DESCRIPTOR) { CopyRoutine = CustomHID_GetReportDescriptor; } else if (pInformation->USBwValue1 == HID_DESCRIPTOR_TYPE) { CopyRoutine = CustomHID_GetHIDDescriptor; } } /* End of GET_DESCRIPTOR */ /*** GET_PROTOCOL ***/ else if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) && RequestNo == GET_PROTOCOL) { CopyRoutine = CustomHID_GetProtocolValue; } if (CopyRoutine == NULL) { return USB_UNSUPPORT; } pInformation->Ctrl_Info.CopyData = CopyRoutine; pInformation->Ctrl_Info.Usb_wOffset = 0; (*CopyRoutine)(0); return USB_SUCCESS; } /******************************************************************************* * Function Name : CustomHID_NoData_Setup * Description : handle the no data class specific requests * Input : Request Nb. * Output : None. * Return : USB_UNSUPPORT or USB_SUCCESS. *******************************************************************************/ RESULT CustomHID_NoData_Setup(uint8_t RequestNo) { if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) && (RequestNo == SET_PROTOCOL)) { return CustomHID_SetProtocol(); } else { return USB_UNSUPPORT; } } /******************************************************************************* * Function Name : CustomHID_GetDeviceDescriptor. * Description : Gets the device descriptor. * Input : Length * Output : None. * Return : The address of the device descriptor. *******************************************************************************/ uint8_t *CustomHID_GetDeviceDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Device_Descriptor); } /******************************************************************************* * Function Name : CustomHID_GetConfigDescriptor. * Description : Gets the configuration descriptor. * Input : Length * Output : None. * Return : The address of the configuration descriptor. *******************************************************************************/ uint8_t *CustomHID_GetConfigDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Config_Descriptor); } /******************************************************************************* * Function Name : CustomHID_GetStringDescriptor * Description : Gets the string descriptors according to the needed index * Input : Length * Output : None. * Return : The address of the string descriptors. *******************************************************************************/ uint8_t *CustomHID_GetStringDescriptor(uint16_t Length) { uint8_t wValue0 = pInformation->USBwValue0; if (wValue0 > 4) { return NULL; } else { return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]); } } /******************************************************************************* * Function Name : CustomHID_GetReportDescriptor. * Description : Gets the HID report descriptor. * Input : Length * Output : None. * Return : The address of the configuration descriptor. *******************************************************************************/ uint8_t *CustomHID_GetReportDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &CustomHID_Report_Descriptor); } /******************************************************************************* * Function Name : CustomHID_GetHIDDescriptor. * Description : Gets the HID descriptor. * Input : Length * Output : None. * Return : The address of the configuration descriptor. *******************************************************************************/ uint8_t *CustomHID_GetHIDDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &CustomHID_Hid_Descriptor); } /******************************************************************************* * Function Name : CustomHID_Get_Interface_Setting. * Description : tests the interface and the alternate setting according to the * supported one. * Input : - Interface : interface number. * - AlternateSetting : Alternate Setting number. * Output : None. * Return : USB_SUCCESS or USB_UNSUPPORT. *******************************************************************************/ RESULT CustomHID_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting) { if (AlternateSetting > 0) { return USB_UNSUPPORT; } else if (Interface > 0) { return USB_UNSUPPORT; } return USB_SUCCESS; } /******************************************************************************* * Function Name : CustomHID_SetProtocol * Description : Joystick Set Protocol request routine. * Input : None. * Output : None. * Return : USB SUCCESS. *******************************************************************************/ RESULT CustomHID_SetProtocol(void) { uint8_t wValue0 = pInformation->USBwValue0; ProtocolValue = wValue0; return USB_SUCCESS; } /******************************************************************************* * Function Name : CustomHID_GetProtocolValue * Description : get the protocol value * Input : Length. * Output : None. * Return : address of the protcol value. *******************************************************************************/ uint8_t *CustomHID_GetProtocolValue(uint16_t Length) { if (Length == 0) { pInformation->Ctrl_Info.Usb_wLength = 1; return NULL; } else { return (uint8_t *)(&ProtocolValue); } } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/src/usb_prop.c
C
asf20
14,497
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_desc.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Descriptors for Custom HID Demo ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_lib.h" #include "usb_desc.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /* USB Standard Device Descriptor */ const uint8_t CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC] = { 0x12, /*bLength */ USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ 0x00, /*bcdUSB */ 0x02, 0x00, /*bDeviceClass*/ 0x00, /*bDeviceSubClass*/ 0x00, /*bDeviceProtocol*/ 0x40, /*bMaxPacketSize40*/ 0x83, /*idVendor (0x0483)*/ 0x04, 0x50, /*idProduct = 0x5750*/ 0x57, 0x00, /*bcdDevice rel. 2.00*/ 0x02, 1, /*Index of string descriptor describing manufacturer */ 2, /*Index of string descriptor describing product*/ 3, /*Index of string descriptor describing the device serial number */ 0x01 /*bNumConfigurations*/ } ; /* CustomHID_DeviceDescriptor */ /* USB Configuration Descriptor */ /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */ const uint8_t CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC] = { 0x09, /* bLength: Configuation Descriptor size */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */ CUSTOMHID_SIZ_CONFIG_DESC, /* wTotalLength: Bytes returned */ 0x00, 0x01, /* bNumInterfaces: 1 interface */ 0x01, /* bConfigurationValue: Configuration value */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration*/ 0xC0, /* bmAttributes: Bus powered */ 0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */ /************** Descriptor of Custom HID interface ****************/ /* 09 */ 0x09, /* bLength: Interface Descriptor size */ USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints */ 0x03, /* bInterfaceClass: HID */ 0x00, /* bInterfaceSubClass : 1=BOOT, 0=no boot */ 0x00, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ 0, /* iInterface: Index of string descriptor */ /******************** Descriptor of Custom HID HID ********************/ /* 18 */ 0x09, /* bLength: HID Descriptor size */ HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */ 0x10, /* bcdHID: HID Class Spec release number */ 0x01, 0x00, /* bCountryCode: Hardware target country */ 0x01, /* bNumDescriptors: Number of HID class descriptors to follow */ 0x22, /* bDescriptorType */ CUSTOMHID_SIZ_REPORT_DESC,/* wItemLength: Total length of Report descriptor */ 0x00, /******************** Descriptor of Custom HID endpoints ******************/ /* 27 */ 0x07, /* bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */ 0x81, /* bEndpointAddress: Endpoint Address (IN) */ 0x03, /* bmAttributes: Interrupt endpoint */ 0x02, /* wMaxPacketSize: 2 Bytes max */ 0x00, 0x20, /* bInterval: Polling Interval (32 ms) */ /* 34 */ 0x07, /* bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */ /* Endpoint descriptor type */ 0x01, /* bEndpointAddress: */ /* Endpoint Address (OUT) */ 0x03, /* bmAttributes: Interrupt endpoint */ 0x02, /* wMaxPacketSize: 2 Bytes max */ 0x00, 0x20, /* bInterval: Polling Interval (20 ms) */ /* 41 */ } ; /* CustomHID_ConfigDescriptor */ const uint8_t CustomHID_ReportDescriptor[CUSTOMHID_SIZ_REPORT_DESC] = { 0x06, 0xFF, 0x00, /* USAGE_PAGE (Vendor Page: 0xFF00) */ 0x09, 0x01, /* USAGE (Demo Kit) */ 0xa1, 0x01, /* COLLECTION (Application) */ /* 6 */ /* Led 1 */ 0x85, 0x01, /* REPORT_ID (1) */ 0x09, 0x01, /* USAGE (LED 1) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x01, /* REPORT_COUNT (1) */ 0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x85, 0x01, /* REPORT_ID (1) */ 0x09, 0x01, /* USAGE (LED 1) */ 0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */ /* 26 */ /* Led 2 */ 0x85, 0x02, /* REPORT_ID 2 */ 0x09, 0x02, /* USAGE (LED 2) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x01, /* REPORT_COUNT (1) */ 0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x85, 0x02, /* REPORT_ID (2) */ 0x09, 0x02, /* USAGE (LED 2) */ 0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */ /* 46 */ /* Led 3 */ 0x85, 0x03, /* REPORT_ID (3) */ 0x09, 0x03, /* USAGE (LED 3) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x01, /* REPORT_COUNT (1) */ 0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x85, 0x03, /* REPORT_ID (3) */ 0x09, 0x03, /* USAGE (LED 3) */ 0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */ /* 66 */ /* Led 4 */ 0x85, 0x04, /* REPORT_ID 4) */ 0x09, 0x04, /* USAGE (LED 4) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x01, /* REPORT_COUNT (1) */ 0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x85, 0x04, /* REPORT_ID (4) */ 0x09, 0x04, /* USAGE (LED 4) */ 0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */ /* 86 */ /* key Push Button */ 0x85, 0x05, /* REPORT_ID (5) */ 0x09, 0x05, /* USAGE (Push Button) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x01, /* REPORT_SIZE (1) */ 0x81, 0x82, /* INPUT (Data,Var,Abs,Vol) */ 0x09, 0x05, /* USAGE (Push Button) */ 0x75, 0x01, /* REPORT_SIZE (1) */ 0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x75, 0x07, /* REPORT_SIZE (7) */ 0x81, 0x83, /* INPUT (Cnst,Var,Abs,Vol) */ 0x85, 0x05, /* REPORT_ID (2) */ 0x75, 0x07, /* REPORT_SIZE (7) */ 0xb1, 0x83, /* FEATURE (Cnst,Var,Abs,Vol) */ /* 114 */ /* Tamper Push Button */ 0x85, 0x06, /* REPORT_ID (6) */ 0x09, 0x06, /* USAGE (Tamper Push Button) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x01, /* REPORT_SIZE (1) */ 0x81, 0x82, /* INPUT (Data,Var,Abs,Vol) */ 0x09, 0x06, /* USAGE (Tamper Push Button) */ 0x75, 0x01, /* REPORT_SIZE (1) */ 0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x75, 0x07, /* REPORT_SIZE (7) */ 0x81, 0x83, /* INPUT (Cnst,Var,Abs,Vol) */ 0x85, 0x06, /* REPORT_ID (6) */ 0x75, 0x07, /* REPORT_SIZE (7) */ 0xb1, 0x83, /* FEATURE (Cnst,Var,Abs,Vol) */ /* 142 */ /* ADC IN */ 0x85, 0x07, /* REPORT_ID (7) */ 0x09, 0x07, /* USAGE (ADC IN) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x26, 0xff, 0x00, /* LOGICAL_MAXIMUM (255) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x81, 0x82, /* INPUT (Data,Var,Abs,Vol) */ 0x85, 0x07, /* REPORT_ID (7) */ 0x09, 0x07, /* USAGE (ADC in) */ 0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ /* 161 */ 0xc0 /* END_COLLECTION */ }; /* CustomHID_ReportDescriptor */ /* USB String Descriptors (optional) */ const uint8_t CustomHID_StringLangID[CUSTOMHID_SIZ_STRING_LANGID] = { CUSTOMHID_SIZ_STRING_LANGID, USB_STRING_DESCRIPTOR_TYPE, 0x09, 0x04 } ; /* LangID = 0x0409: U.S. English */ const uint8_t CustomHID_StringVendor[CUSTOMHID_SIZ_STRING_VENDOR] = { CUSTOMHID_SIZ_STRING_VENDOR, /* Size of Vendor string */ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType*/ /* Manufacturer: "STMicroelectronics" */ 'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0, 'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0, 'c', 0, 's', 0 }; const uint8_t CustomHID_StringProduct[CUSTOMHID_SIZ_STRING_PRODUCT] = { CUSTOMHID_SIZ_STRING_PRODUCT, /* bLength */ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'C', 0, 'u', 0, 's', 0, 't', 0, 'm', 0, ' ', 0, 'H', 0, 'I', 0, 'D', 0 }; uint8_t CustomHID_StringSerial[CUSTOMHID_SIZ_STRING_SERIAL] = { CUSTOMHID_SIZ_STRING_SERIAL, /* bLength */ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ 'S', 0, 'T', 0, 'M', 0,'3', 0,'2', 0, '1', 0, '0', 0 }; /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/src/usb_desc.c
C
asf20
13,399
;; NOTE: To allow the use of this file for both ARMv6M and ARMv7M, ;; we will only use 16-bit Thumb intructions. .extern _lc_ub_stack ; usr/sys mode stack pointer .extern _lc_ue_stack ; symbol required by debugger .extern _lc_ub_table ; ROM to RAM copy table .extern main .extern _Exit .extern exit .weak exit .global __get_argcv .weak __get_argcv .extern __argcvbuf .weak __argcvbuf .extern __init_hardware .extern __init_vector_table .extern SystemInit .if @defined('__PROF_ENABLE__') .extern __prof_init .endif .if @defined('__POSIX__') .extern posix_main .extern _posix_boot_stack_top .endif .global _START .section .text.cstart .thumb _START: ;; anticipate possible ROM/RAM remapping ;; by loading the 'real' program address ldr r1,=_Next bx r1 _Next: ;; initialize the stack pointer ldr r1,=_lc_ub_stack ; TODO: make this part of the vector table mov sp,r1 ;; call a user function which initializes hardware ;; such as ROM/RAM re-mapping or MMU configuration bl __init_hardware ;ldr r0, =SystemInit ;bx r0 bl SystemInit ;; copy initialized sections from ROM to RAM ;; and clear uninitialized data sections in RAM ldr r3,=_lc_ub_table movs r0,#0 cploop: ldr r4,[r3,#0] ; load type ldr r5,[r3,#4] ; dst address ldr r6,[r3,#8] ; src address ldr r7,[r3,#12] ; size cmp r4,#1 beq copy cmp r4,#2 beq clear b done copy: subs r7,r7,#1 ldrb r1,[r6,r7] strb r1,[r5,r7] bne copy adds r3,r3,#16 b cploop clear: subs r7,r7,#1 strb r0,[r5,r7] bne clear adds r3,r3,#16 b cploop done: ;; initialize or copy the vector table bl __init_vector_table .if @defined('__POSIX__') ;; posix stack buffer for system upbringing ldr r0,=_posix_boot_stack_top ldr r0, [r0] mov sp,r0 .else ;; load r10 with end of USR/SYS stack, which is ;; needed in case stack overflow checking is on ;; NOTE: use 16-bit instructions only, for ARMv6M ldr r0,=_lc_ue_stack mov r10,r0 .endif .if @defined('__PROF_ENABLE__') bl __prof_init .endif .if @defined('__POSIX__') ;; call posix_main with no arguments bl posix_main .else ;; retrieve argc and argv (default argv[0]==NULL & argc==0) bl __get_argcv ldr r1,=__argcvbuf ;; call main bl main .endif ;; call exit using the return value from main() ;; Note. Calling exit will also run all functions ;; that were supplied through atexit(). bl exit __get_argcv: ; weak definition movs r0,#0 bx lr .ltorg .endsec .calls '_START','__init_hardware' .calls '_START','__init_vector_table' .if @defined('__PROF_ENABLE__') .calls '_START','__prof_init' .endif .if @defined('__POSIX__') .calls '_START','posix_main' .else .calls '_START','__get_argcv' .calls '_START','main' .endif .calls '_START','exit' .calls '_START','',0 .end
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210E-EVAL_XL/cstart_thumb2.asm
Assembly
asf20
3,949
//////////////////////////////////////////////////////////////////////////// // // File : stm32f103_cmsis.lsl // // Version : @(#)stm32f103_cmsis.lsl 1.2 09/06/04 // // Description : LSL file for the STMicroelectronics STM32F103, CMSIS version // // Copyright 2009 Altium BV // // NOTE: // This file is derived from cm3.lsl and stm32f103.lsl. // It is assumed that the user works with the ARMv7M architecture. // Other architectures will not work with this lsl file. // //////////////////////////////////////////////////////////////////////////// // // We do not want the vectors as defined in arm_arch.lsl // #define __NO_DEFAULT_AUTO_VECTORS 1 #define __NR_OF_VECTORS 76 #ifndef __STACK # define __STACK 8k #endif #ifndef __HEAP # define __HEAP 2k #endif #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x08000000 #endif #ifndef __XVWBUF #define __XVWBUF 256 /* buffer used by CrossView */ #endif #include <arm_arch.lsl> //////////////////////////////////////////////////////////////////////////// // // In the STM32F10x, 3 different boot modes can be selected // - User Flash memory is selected as boot space // - SystemMemory is selected as boot space // - Embedded SRAM is selected as boot space // // This aliases the physical memory associated with each boot mode to Block // 000 (0x00000000 boot memory). Even when aliased in the boot memory space, // the related memory (Flash memory or SRAM) is still accessible at its // original memory space. // // If no memory is defined yet use the following memory settings // #ifndef __MEMORY memory stm32f103flash { mau = 8; type = rom; size = 0x100000; map ( size = 0x100000, dest_offset=0x08000000, dest=bus:ARM:local_bus); } memory stm32f103ram { mau = 8; type = ram; size = 96k; map ( size = 96k, dest_offset=0x20000000, dest=bus:ARM:local_bus); } #endif /* __MEMORY */ // // Custom vector table defines interrupts according to CMSIS standard // # if defined(__CPU_ARMV7M__) section_setup ::linear { // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); vector ( id = 2, optional, fill = "NMI_Handler" ); vector ( id = 3, optional, fill = "HardFault_Handler" ); vector ( id = 4, optional, fill = "MemManage_Handler" ); vector ( id = 5, optional, fill = "BusFault_Handler" ); vector ( id = 6, optional, fill = "UsageFault_Handler" ); vector ( id = 11, optional, fill = "SVC_Handler" ); vector ( id = 12, optional, fill = "DebugMon_Handler" ); vector ( id = 14, optional, fill = "PendSV_Handler" ); vector ( id = 15, optional, fill = "SysTick_Handler" ); // External Interrupts : vector ( id = 16, optional, fill = "WWDG_IRQHandler" ); // Window Watchdog vector ( id = 17, optional, fill = "PVD_IRQHandler" ); // PVD through EXTI Line detect vector ( id = 18, optional, fill = "TAMPER_IRQHandler" ); // Tamper vector ( id = 19, optional, fill = "RTC_IRQHandler" ); // RTC vector ( id = 20, optional, fill = "FLASH_IRQHandler" ); // Flash vector ( id = 21, optional, fill = "RCC_IRQHandler" ); // RCC vector ( id = 22, optional, fill = "EXTI0_IRQHandler" ); // EXTI Line 0 vector ( id = 23, optional, fill = "EXTI1_IRQHandler" ); // EXTI Line 1 vector ( id = 24, optional, fill = "EXTI2_IRQHandler" ); // EXTI Line 2 vector ( id = 25, optional, fill = "EXTI3_IRQHandler" ); // EXTI Line 3 vector ( id = 26, optional, fill = "EXTI4_IRQHandler" ); // EXTI Line 4 vector ( id = 27, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMA1_Channel2_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMA1_Channel3_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMA1_Channel4_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMA1_Channel5_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMA1_Channel6_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMA1_Channel7_IRQHandler" ); // DMA Channel 7 vector ( id = 34, optional, fill = "ADC1_2_IRQHandler" ); // ADC1 and ADC2 vector ( id = 35, optional, fill = "USB_HP_CAN1_TX_IRQHandler" ); // USB High Priority or CAN1 TX vector ( id = 36, optional, fill = "USB_LP_CAN1_RX0_IRQHandler" ); // USB LowPriority or CAN1 RX0 vector ( id = 37, optional, fill = "CAN1_RX1_IRQHandler" ); // CAN1 RX1 vector ( id = 38, optional, fill = "CAN1_SCE_IRQHandler" ); // CAN1 SCE vector ( id = 39, optional, fill = "EXTI9_5_IRQHandler" ); // EXTI Line 9..5 vector ( id = 40, optional, fill = "TIM1_BRK_TIM9_IRQHandler" ); // TIM1 Break vector ( id = 41, optional, fill = "TIM1_UP_TIM10_IRQHandler" ); // TIM1 Update vector ( id = 42, optional, fill = "TIM1_TRG_COM_TIM11_IRQHandler" ); // TIM1 Trigger and Commutation vector ( id = 43, optional, fill = "TIM1_CC_IRQHandler" ); // TIM1 Capture Compare vector ( id = 44, optional, fill = "TIM2_IRQHandler" ); // TIM2 vector ( id = 45, optional, fill = "TIM3_IRQHandler" ); // TIM3 vector ( id = 46, optional, fill = "TIM4_IRQHandler" ); // TIM4 vector ( id = 47, optional, fill = "I2C1_EV_IRQHandler" ); // I2C1 Event vector ( id = 48, optional, fill = "I2C1_ER_IRQHandler" ); // I2C1 Error vector ( id = 49, optional, fill = "I2C2_EV_IRQHandler" ); // I2C2 Event vector ( id = 50, optional, fill = "I2C2_ER_IRQHandler" ); // I2C2 Error vector ( id = 51, optional, fill = "SPI1_IRQHandler" ); // SPI1 vector ( id = 52, optional, fill = "SPI2_IRQHandler" ); // SPI2 vector ( id = 53, optional, fill = "USART1_IRQHandler" ); // USART1 vector ( id = 54, optional, fill = "USART2_IRQHandler" ); // USART2 vector ( id = 55, optional, fill = "USART3_IRQHandler" ); // USART3 vector ( id = 56, optional, fill = "EXTI15_10_IRQHandler" ); // EXTI Line 15..10 vector ( id = 57, optional, fill = "RTCAlarm_IRQHandler" ); // RTC Alarm through EXTI Line vector ( id = 58, optional, fill = "USBWakeUp_IRQHandler" ); // USB Wakeup from suspend vector ( id = 59, optional, fill = "TIM8_BRK_TIM12_IRQHandler" ); // TIM8 Break vector ( id = 60, optional, fill = "TIM8_UP_TIM13_IRQHandler" ); // TIM8 Update vector ( id = 61, optional, fill = "TIM8_TRG_COM_TIM14_IRQHandler" ); // TIM8 Trigger and Commutation vector ( id = 62, optional, fill = "TIM8_CC_IRQHandler" ); // TIM8 Capture Compare vector ( id = 63, optional, fill = "ADC3_IRQHandler" ); // ADC3 vector ( id = 64, optional, fill = "FSMC_IRQHandler" ); // FSMC vector ( id = 65, optional, fill = "SDIO_IRQHandler" ); // SDIO vector ( id = 66, optional, fill = "TIM5_IRQHandler" ); // TIM5 vector ( id = 67, optional, fill = "SPI3_IRQHandler" ); // SPI3 vector ( id = 68, optional, fill = "UART4_IRQHandler" ); // UART4 vector ( id = 69, optional, fill = "UART5_IRQHandler" ); // UART5 vector ( id = 70, optional, fill = "TIM6_IRQHandler" ); // TIM6 vector ( id = 71, optional, fill = "TIM7_IRQHandler" ); // TIM7 vector ( id = 72, optional, fill = "DMA2_Channel1_IRQHandler" ); // DMA2 Channel1 vector ( id = 73, optional, fill = "DMA2_Channel2_IRQHandler" ); // DMA2 Channel2 vector ( id = 74, optional, fill = "DMA2_Channel3_IRQHandler" ); // DMA2 Channel3 vector ( id = 75, optional, fill = "DMA2_Channel4_5_IRQHandler" ); // DMA2 Channel4 and DMA2 Channel5 } } # endif
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210E-EVAL_XL/Settings/STM32F10x_XL.lsl
LSL
asf20
10,633
//////////////////////////////////////////////////////////////////////////// // // File : arm_arch.lsl // // Version : @(#)arm_arch.lsl 1.4 09/04/17 // // Description : Generic LSL file for ARM architectures // // Copyright 2008-2009 Altium BV // //////////////////////////////////////////////////////////////////////////// #ifndef __STACK # define __STACK 32k #endif #ifndef __HEAP # define __HEAP 32k #endif #ifndef __STACK_FIQ # define __STACK_FIQ 8 #endif #ifndef __STACK_IRQ # define __STACK_IRQ 8 #endif #ifndef __STACK_SVC # define __STACK_SVC 8 #endif #ifndef __STACK_ABT # define __STACK_ABT 8 #endif #ifndef __STACK_UND # define __STACK_UND 8 #endif #ifndef __PROCESSOR_MODE # define __PROCESSOR_MODE 0x1F /* SYS mode */ #endif #ifndef __IRQ_BIT # define __IRQ_BIT 0x80 /* IRQ interrupts disabled */ #endif #ifndef __FIQ_BIT # define __FIQ_BIT 0x40 /* FIQ interrupts disabled */ #endif #define __APPLICATION_MODE (__PROCESSOR_MODE | __IRQ_BIT | __FIQ_BIT) #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x00000000 #endif #ifndef __VECTOR_TABLE_RAM_ADDR # define __VECTOR_TABLE_RAM_ADDR 0x00000000 #endif #if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) # ifndef __NR_OF_VECTORS # define __NR_OF_VECTORS 16 # endif # define __VECTOR_TABLE_SIZE (__NR_OF_VECTORS * 4) #else # ifdef __PIC_VECTORS # define __VECTOR_TABLE_SIZE 64 # else # ifdef __FIQ_HANDLER_INLINE # define __VECTOR_TABLE_SIZE 28 # define __NR_OF_VECTORS 7 # else # define __VECTOR_TABLE_SIZE 32 # define __NR_OF_VECTORS 8 # endif # endif #endif #ifndef __VECTOR_TABLE_RAM_SPACE # undef __VECTOR_TABLE_RAM_COPY #endif #ifndef __XVWBUF # define __XVWBUF 0 /* buffer used by CrossView Pro */ #endif #define BOUNDS_GROUP_NAME grp_bounds #define BOUNDS_GROUP_SELECT "bounds" architecture ARM { endianness { little; big; } space linear { id = 1; mau = 8; map (size = 4G, dest = bus:local_bus); copytable ( align = 4, copy_unit = 1, dest = linear ); start_address ( // It is not strictly necessary to define a run_addr for _START // because hardware starts execution at address 0x0 which should // be the vector table with a jump to the relocatable _START, but // an absolute address can prevent the branch to be out-of-range. // Or _START may be the entry point at reset and the reset handler // copies the vector table to address 0x0 after some ROM/RAM memory // re-mapping. In that case _START should be at a fixed address // in ROM, specifically the alias of address 0x0 before memory // re-mapping. #ifdef __START run_addr = __START, #endif symbol = "_START" ); stack "stack" ( #ifdef __STACK_FIXED fixed, #endif align = 4, min_size = __STACK, grows = high_to_low ); heap "heap" ( #ifdef __HEAP_FIXED fixed, #endif align = 4, min_size=__HEAP ); #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) stack "stack_fiq" ( fixed, align = 4, min_size = __STACK_FIQ, grows = high_to_low ); stack "stack_irq" ( fixed, align = 4, min_size = __STACK_IRQ, grows = high_to_low ); stack "stack_svc" ( fixed, align = 4, min_size = __STACK_SVC, grows = high_to_low ); stack "stack_abt" ( fixed, align = 4, min_size = __STACK_ABT, grows = high_to_low ); stack "stack_und" ( fixed, align = 4, min_size = __STACK_UND, grows = high_to_low ); #endif #if !defined(__NO_AUTO_VECTORS) && !defined(__NO_DEFAULT_AUTO_VECTORS) # if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); } # else # ifdef __PIC_VECTORS // vector table with ldrpc instructions from handler table vector_table "vector_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_ldrpc", template_symbol = "_lc_vector_ldrpc", vector_prefix = "_vector_ldrpc_", fill = loop ) { } // subsequent vector table (data pool) with addresses of handlers vector_table "handler_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR + 32, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop[-32], no_inline ) { vector ( id = 0, fill = "_START" ); } # else // vector table with branch instructions to handlers vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_branch", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop ) { vector ( id = 0, fill = "_START" ); } # endif # endif #endif section_layout { #if defined(__NO_AUTO_VECTORS) "_lc_ub_vector_table" = __VECTOR_TABLE_ROM_ADDR; "_lc_ue_vector_table" = __VECTOR_TABLE_ROM_ADDR + __VECTOR_TABLE_SIZE; #endif #ifdef __VECTOR_TABLE_RAM_SPACE // reserve space to copy vector table from ROM to RAM group ( ordered, run_addr = __VECTOR_TABLE_RAM_ADDR ) reserved "vector_table_space" ( size = __VECTOR_TABLE_SIZE, attributes = rwx ); #endif #ifdef __VECTOR_TABLE_RAM_COPY // provide copy address symbols for copy routine "_lc_ub_vector_table_copy" := "_lc_ub_vector_table_space"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table_space"; #else // prevent copy: copy address equals orig address "_lc_ub_vector_table_copy" := "_lc_ub_vector_table"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table"; #endif // define buffer for string input via Crossview Pro debugger group ( align = 4 ) reserved "xvwbuffer" (size=__XVWBUF, attributes=rw ); // define labels for bounds begin and end as used in C library #ifndef BOUNDS_GROUP_REDEFINED group BOUNDS_GROUP_NAME (ordered, contiguous) { select BOUNDS_GROUP_SELECT; } #endif "_lc_ub_bounds" := addressof(group:BOUNDS_GROUP_NAME); "_lc_ue_bounds" := addressof(group:BOUNDS_GROUP_NAME) + sizeof(group:BOUNDS_GROUP_NAME); #ifdef __HEAPADDR group ( ordered, run_addr=__HEAPADDR ) { select "heap"; } #endif #ifdef __STACKADDR group ( ordered, run_addr=__STACKADDR ) { select "stack"; } #endif #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) // symbol to set mode bits and interrupt disable bits // in cstart module before calling the application (main) "_APPLICATION_MODE_" = __APPLICATION_MODE; #endif } } bus local_bus { mau = 8; width = 32; } }
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210E-EVAL_XL/Settings/arm_arch.lsl
LSL
asf20
10,931
;; NOTE: To allow the use of this file for both ARMv6M and ARMv7M, ;; we will only use 16-bit Thumb intructions. .extern _lc_ub_stack ; usr/sys mode stack pointer .extern _lc_ue_stack ; symbol required by debugger .extern _lc_ub_table ; ROM to RAM copy table .extern main .extern _Exit .extern exit .weak exit .global __get_argcv .weak __get_argcv .extern __argcvbuf .weak __argcvbuf .extern __init_hardware .extern __init_vector_table .extern SystemInit .if @defined('__PROF_ENABLE__') .extern __prof_init .endif .if @defined('__POSIX__') .extern posix_main .extern _posix_boot_stack_top .endif .global _START .section .text.cstart .thumb _START: ;; anticipate possible ROM/RAM remapping ;; by loading the 'real' program address ldr r1,=_Next bx r1 _Next: ;; initialize the stack pointer ldr r1,=_lc_ub_stack ; TODO: make this part of the vector table mov sp,r1 ;; call a user function which initializes hardware ;; such as ROM/RAM re-mapping or MMU configuration bl __init_hardware ;ldr r0, =SystemInit ;bx r0 bl SystemInit ;; copy initialized sections from ROM to RAM ;; and clear uninitialized data sections in RAM ldr r3,=_lc_ub_table movs r0,#0 cploop: ldr r4,[r3,#0] ; load type ldr r5,[r3,#4] ; dst address ldr r6,[r3,#8] ; src address ldr r7,[r3,#12] ; size cmp r4,#1 beq copy cmp r4,#2 beq clear b done copy: subs r7,r7,#1 ldrb r1,[r6,r7] strb r1,[r5,r7] bne copy adds r3,r3,#16 b cploop clear: subs r7,r7,#1 strb r0,[r5,r7] bne clear adds r3,r3,#16 b cploop done: ;; initialize or copy the vector table bl __init_vector_table .if @defined('__POSIX__') ;; posix stack buffer for system upbringing ldr r0,=_posix_boot_stack_top ldr r0, [r0] mov sp,r0 .else ;; load r10 with end of USR/SYS stack, which is ;; needed in case stack overflow checking is on ;; NOTE: use 16-bit instructions only, for ARMv6M ldr r0,=_lc_ue_stack mov r10,r0 .endif .if @defined('__PROF_ENABLE__') bl __prof_init .endif .if @defined('__POSIX__') ;; call posix_main with no arguments bl posix_main .else ;; retrieve argc and argv (default argv[0]==NULL & argc==0) bl __get_argcv ldr r1,=__argcvbuf ;; call main bl main .endif ;; call exit using the return value from main() ;; Note. Calling exit will also run all functions ;; that were supplied through atexit(). bl exit __get_argcv: ; weak definition movs r0,#0 bx lr .ltorg .endsec .calls '_START','__init_hardware' .calls '_START','__init_vector_table' .if @defined('__PROF_ENABLE__') .calls '_START','__prof_init' .endif .if @defined('__POSIX__') .calls '_START','posix_main' .else .calls '_START','__get_argcv' .calls '_START','main' .endif .calls '_START','exit' .calls '_START','',0 .end
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210C-EVAL/cstart_thumb2.asm
Assembly
asf20
3,949
//////////////////////////////////////////////////////////////////////////// // // File : stm32f103_cmsis.lsl // // Version : @(#)stm32f103_cmsis.lsl 1.2 09/06/04 // // Description : LSL file for the STMicroelectronics STM32F103, CMSIS version // // Copyright 2009 Altium BV // // NOTE: // This file is derived from cm3.lsl and stm32f103.lsl. // It is assumed that the user works with the ARMv7M architecture. // Other architectures will not work with this lsl file. // //////////////////////////////////////////////////////////////////////////// // // We do not want the vectors as defined in arm_arch.lsl // #define __NO_DEFAULT_AUTO_VECTORS 1 #define __NR_OF_VECTORS 84 #ifndef __STACK # define __STACK 2k #endif #ifndef __HEAP # define __HEAP 1k #endif #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x08000000 #endif #ifndef __XVWBUF #define __XVWBUF 256 /* buffer used by CrossView */ #endif #include <arm_arch.lsl> //////////////////////////////////////////////////////////////////////////// // // In the STM32F10x, 3 different boot modes can be selected // - User Flash memory is selected as boot space // - SystemMemory is selected as boot space // - Embedded SRAM is selected as boot space // // This aliases the physical memory associated with each boot mode to Block // 000 (0x00000000 boot memory). Even when aliased in the boot memory space, // the related memory (Flash memory or SRAM) is still accessible at its // original memory space. // // If no memory is defined yet use the following memory settings // #ifndef __MEMORY memory stm32f103flash { mau = 8; type = rom; size = 256k; map ( size = 256k, dest_offset=0x08000000, dest=bus:ARM:local_bus); } memory stm32f103ram { mau = 8; type = ram; size = 64k; map ( size = 64k, dest_offset=0x20000000, dest=bus:ARM:local_bus); } #endif /* __MEMORY */ // // Custom vector table defines interrupts according to CMSIS standard // # if defined(__CPU_ARMV7M__) section_setup ::linear { // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); vector ( id = 2, optional, fill = "NMI_Handler" ); vector ( id = 3, optional, fill = "HardFault_Handler" ); vector ( id = 4, optional, fill = "MemManage_Handler" ); vector ( id = 5, optional, fill = "BusFault_Handler" ); vector ( id = 6, optional, fill = "UsageFault_Handler" ); vector ( id = 11, optional, fill = "SVC_Handler" ); vector ( id = 12, optional, fill = "DebugMon_Handler" ); vector ( id = 14, optional, fill = "PendSV_Handler" ); vector ( id = 15, optional, fill = "SysTick_Handler" ); // External Interrupts : vector ( id = 16, optional, fill = "WWDG_IRQHandler" ); // Window Watchdog vector ( id = 17, optional, fill = "PVD_IRQHandler" ); // PVD through EXTI Line detect vector ( id = 18, optional, fill = "TAMPER_IRQHandler" ); // Tamper vector ( id = 19, optional, fill = "RTC_IRQHandler" ); // RTC vector ( id = 20, optional, fill = "FLASH_IRQHandler" ); // Flash vector ( id = 21, optional, fill = "RCC_IRQHandler" ); // RCC vector ( id = 22, optional, fill = "EXTI0_IRQHandler" ); // EXTI Line 0 vector ( id = 23, optional, fill = "EXTI1_IRQHandler" ); // EXTI Line 1 vector ( id = 24, optional, fill = "EXTI2_IRQHandler" ); // EXTI Line 2 vector ( id = 25, optional, fill = "EXTI3_IRQHandler" ); // EXTI Line 3 vector ( id = 26, optional, fill = "EXTI4_IRQHandler" ); // EXTI Line 4 vector ( id = 27, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMA1_Channel2_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMA1_Channel3_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMA1_Channel4_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMA1_Channel5_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMA1_Channel6_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMA1_Channel7_IRQHandler" ); // DMA Channel 7 vector ( id = 34, optional, fill = "ADC1_2_IRQHandler" ); // ADC1 and ADC2 vector ( id = 35, optional, fill = "CAN1_TX_IRQHandler" ); // CAN1 TX vector ( id = 36, optional, fill = "CAN1_RX0_IRQHandler" ); // CAN1 RX0 vector ( id = 37, optional, fill = "CAN1_RX1_IRQHandler" ); // CAN1 RX1 vector ( id = 38, optional, fill = "CAN1_SCE_IRQHandler" ); // CAN1 SCE vector ( id = 39, optional, fill = "EXTI9_5_IRQHandler" ); // EXTI Line 9..5 vector ( id = 40, optional, fill = "TIM1_BRK_IRQHandler" ); // TIM1 Break vector ( id = 41, optional, fill = "TIM1_UP_IRQHandler" ); // TIM1 Update vector ( id = 42, optional, fill = "TIM1_TRG_COM_IRQHandler" ); // TIM1 Trigger and Commutation vector ( id = 43, optional, fill = "TIM1_CC_IRQHandler" ); // TIM1 Capture Compare vector ( id = 44, optional, fill = "TIM2_IRQHandler" ); // TIM2 vector ( id = 45, optional, fill = "TIM3_IRQHandler" ); // TIM3 vector ( id = 46, optional, fill = "TIM4_IRQHandler" ); // TIM4 vector ( id = 47, optional, fill = "I2C1_EV_IRQHandler" ); // I2C1 Event vector ( id = 48, optional, fill = "I2C1_ER_IRQHandler" ); // I2C1 Error vector ( id = 49, optional, fill = "I2C2_EV_IRQHandler" ); // I2C2 Event vector ( id = 50, optional, fill = "I2C2_ER_IRQHandler" ); // I2C2 Error vector ( id = 51, optional, fill = "SPI1_IRQHandler" ); // SPI1 vector ( id = 52, optional, fill = "SPI2_IRQHandler" ); // SPI2 vector ( id = 53, optional, fill = "USART1_IRQHandler" ); // USART1 vector ( id = 54, optional, fill = "USART2_IRQHandler" ); // USART2 vector ( id = 55, optional, fill = "USART3_IRQHandler" ); // USART3 vector ( id = 56, optional, fill = "EXTI15_10_IRQHandler" ); // EXTI Line 15..10 vector ( id = 57, optional, fill = "RTCAlarm_IRQHandler" ); // RTC Alarm through EXTI Line vector ( id = 58, optional, fill = "OTG_FS_WKUP_IRQHandler" ); // USB OTG FS Wakeup through EXTI line vector ( id = 66, optional, fill = "TIM5_IRQHandler" ); // TIM5 vector ( id = 67, optional, fill = "SPI3_IRQHandler" ); // SPI3 vector ( id = 68, optional, fill = "UART4_IRQHandler" ); // UART4 vector ( id = 69, optional, fill = "UART5_IRQHandler" ); // UART5 vector ( id = 70, optional, fill = "TIM6_IRQHandler" ); // TIM6 vector ( id = 71, optional, fill = "TIM7_IRQHandler" ); // TIM7 vector ( id = 72, optional, fill = "DMA2_Channel1_IRQHandler" ); // DMA2 Channel1 vector ( id = 73, optional, fill = "DMA2_Channel2_IRQHandler" ); // DMA2 Channel2 vector ( id = 74, optional, fill = "DMA2_Channel3_IRQHandler" ); // DMA2 Channel3 vector ( id = 75, optional, fill = "DMA2_Channel4_IRQHandler" ); // DMA2 Channel4 vector ( id = 76, optional, fill = "DMA2_Channel5_IRQHandler" ); // DMA2 Channel5 vector ( id = 77, optional, fill = "ETH_IRQHandler" ); // Ethernet vector ( id = 78, optional, fill = "ETH_WKUP_IRQHandler" ); // ETH_WKUP_IRQHandler vector ( id = 79, optional, fill = "CAN2_TX_IRQHandler " ); // CAN2 TX vector ( id = 80, optional, fill = "CAN2_RX0_IRQHandler" ); // CAN2 RX0 vector ( id = 81, optional, fill = "CAN2_RX1_IRQHandler" ); // CAN2 RX1 vector ( id = 82, optional, fill = "CAN2_SCE_IRQHandler" ); // CAN2 SCE vector ( id = 83, optional, fill = "OTG_FS_IRQHandler" ); // USB OTG FS } } # endif
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210C-EVAL/Settings/STM32F10x_cl.lsl
LSL
asf20
10,566
//////////////////////////////////////////////////////////////////////////// // // File : arm_arch.lsl // // Version : @(#)arm_arch.lsl 1.4 09/04/17 // // Description : Generic LSL file for ARM architectures // // Copyright 2008-2009 Altium BV // //////////////////////////////////////////////////////////////////////////// #ifndef __STACK # define __STACK 32k #endif #ifndef __HEAP # define __HEAP 32k #endif #ifndef __STACK_FIQ # define __STACK_FIQ 8 #endif #ifndef __STACK_IRQ # define __STACK_IRQ 8 #endif #ifndef __STACK_SVC # define __STACK_SVC 8 #endif #ifndef __STACK_ABT # define __STACK_ABT 8 #endif #ifndef __STACK_UND # define __STACK_UND 8 #endif #ifndef __PROCESSOR_MODE # define __PROCESSOR_MODE 0x1F /* SYS mode */ #endif #ifndef __IRQ_BIT # define __IRQ_BIT 0x80 /* IRQ interrupts disabled */ #endif #ifndef __FIQ_BIT # define __FIQ_BIT 0x40 /* FIQ interrupts disabled */ #endif #define __APPLICATION_MODE (__PROCESSOR_MODE | __IRQ_BIT | __FIQ_BIT) #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x00000000 #endif #ifndef __VECTOR_TABLE_RAM_ADDR # define __VECTOR_TABLE_RAM_ADDR 0x00000000 #endif #if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) # ifndef __NR_OF_VECTORS # define __NR_OF_VECTORS 16 # endif # define __VECTOR_TABLE_SIZE (__NR_OF_VECTORS * 4) #else # ifdef __PIC_VECTORS # define __VECTOR_TABLE_SIZE 64 # else # ifdef __FIQ_HANDLER_INLINE # define __VECTOR_TABLE_SIZE 28 # define __NR_OF_VECTORS 7 # else # define __VECTOR_TABLE_SIZE 32 # define __NR_OF_VECTORS 8 # endif # endif #endif #ifndef __VECTOR_TABLE_RAM_SPACE # undef __VECTOR_TABLE_RAM_COPY #endif #ifndef __XVWBUF # define __XVWBUF 0 /* buffer used by CrossView Pro */ #endif #define BOUNDS_GROUP_NAME grp_bounds #define BOUNDS_GROUP_SELECT "bounds" architecture ARM { endianness { little; big; } space linear { id = 1; mau = 8; map (size = 4G, dest = bus:local_bus); copytable ( align = 4, copy_unit = 1, dest = linear ); start_address ( // It is not strictly necessary to define a run_addr for _START // because hardware starts execution at address 0x0 which should // be the vector table with a jump to the relocatable _START, but // an absolute address can prevent the branch to be out-of-range. // Or _START may be the entry point at reset and the reset handler // copies the vector table to address 0x0 after some ROM/RAM memory // re-mapping. In that case _START should be at a fixed address // in ROM, specifically the alias of address 0x0 before memory // re-mapping. #ifdef __START run_addr = __START, #endif symbol = "_START" ); stack "stack" ( #ifdef __STACK_FIXED fixed, #endif align = 4, min_size = __STACK, grows = high_to_low ); heap "heap" ( #ifdef __HEAP_FIXED fixed, #endif align = 4, min_size=__HEAP ); #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) stack "stack_fiq" ( fixed, align = 4, min_size = __STACK_FIQ, grows = high_to_low ); stack "stack_irq" ( fixed, align = 4, min_size = __STACK_IRQ, grows = high_to_low ); stack "stack_svc" ( fixed, align = 4, min_size = __STACK_SVC, grows = high_to_low ); stack "stack_abt" ( fixed, align = 4, min_size = __STACK_ABT, grows = high_to_low ); stack "stack_und" ( fixed, align = 4, min_size = __STACK_UND, grows = high_to_low ); #endif #if !defined(__NO_AUTO_VECTORS) && !defined(__NO_DEFAULT_AUTO_VECTORS) # if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); } # else # ifdef __PIC_VECTORS // vector table with ldrpc instructions from handler table vector_table "vector_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_ldrpc", template_symbol = "_lc_vector_ldrpc", vector_prefix = "_vector_ldrpc_", fill = loop ) { } // subsequent vector table (data pool) with addresses of handlers vector_table "handler_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR + 32, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop[-32], no_inline ) { vector ( id = 0, fill = "_START" ); } # else // vector table with branch instructions to handlers vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_branch", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop ) { vector ( id = 0, fill = "_START" ); } # endif # endif #endif section_layout { #if defined(__NO_AUTO_VECTORS) "_lc_ub_vector_table" = __VECTOR_TABLE_ROM_ADDR; "_lc_ue_vector_table" = __VECTOR_TABLE_ROM_ADDR + __VECTOR_TABLE_SIZE; #endif #ifdef __VECTOR_TABLE_RAM_SPACE // reserve space to copy vector table from ROM to RAM group ( ordered, run_addr = __VECTOR_TABLE_RAM_ADDR ) reserved "vector_table_space" ( size = __VECTOR_TABLE_SIZE, attributes = rwx ); #endif #ifdef __VECTOR_TABLE_RAM_COPY // provide copy address symbols for copy routine "_lc_ub_vector_table_copy" := "_lc_ub_vector_table_space"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table_space"; #else // prevent copy: copy address equals orig address "_lc_ub_vector_table_copy" := "_lc_ub_vector_table"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table"; #endif // define buffer for string input via Crossview Pro debugger group ( align = 4 ) reserved "xvwbuffer" (size=__XVWBUF, attributes=rw ); // define labels for bounds begin and end as used in C library #ifndef BOUNDS_GROUP_REDEFINED group BOUNDS_GROUP_NAME (ordered, contiguous) { select BOUNDS_GROUP_SELECT; } #endif "_lc_ub_bounds" := addressof(group:BOUNDS_GROUP_NAME); "_lc_ue_bounds" := addressof(group:BOUNDS_GROUP_NAME) + sizeof(group:BOUNDS_GROUP_NAME); #ifdef __HEAPADDR group ( ordered, run_addr=__HEAPADDR ) { select "heap"; } #endif #ifdef __STACKADDR group ( ordered, run_addr=__STACKADDR ) { select "stack"; } #endif #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) // symbol to set mode bits and interrupt disable bits // in cstart module before calling the application (main) "_APPLICATION_MODE_" = __APPLICATION_MODE; #endif } } bus local_bus { mau = 8; width = 32; } }
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210C-EVAL/Settings/arm_arch.lsl
LSL
asf20
10,931
;; NOTE: To allow the use of this file for both ARMv6M and ARMv7M, ;; we will only use 16-bit Thumb intructions. .extern _lc_ub_stack ; usr/sys mode stack pointer .extern _lc_ue_stack ; symbol required by debugger .extern _lc_ub_table ; ROM to RAM copy table .extern main .extern _Exit .extern exit .weak exit .global __get_argcv .weak __get_argcv .extern __argcvbuf .weak __argcvbuf .extern __init_hardware .extern __init_vector_table .extern SystemInit .if @defined('__PROF_ENABLE__') .extern __prof_init .endif .if @defined('__POSIX__') .extern posix_main .extern _posix_boot_stack_top .endif .global _START .section .text.cstart .thumb _START: ;; anticipate possible ROM/RAM remapping ;; by loading the 'real' program address ldr r1,=_Next bx r1 _Next: ;; initialize the stack pointer ldr r1,=_lc_ub_stack ; TODO: make this part of the vector table mov sp,r1 ;; call a user function which initializes hardware ;; such as ROM/RAM re-mapping or MMU configuration bl __init_hardware ;ldr r0, =SystemInit ;bx r0 bl SystemInit ;; copy initialized sections from ROM to RAM ;; and clear uninitialized data sections in RAM ldr r3,=_lc_ub_table movs r0,#0 cploop: ldr r4,[r3,#0] ; load type ldr r5,[r3,#4] ; dst address ldr r6,[r3,#8] ; src address ldr r7,[r3,#12] ; size cmp r4,#1 beq copy cmp r4,#2 beq clear b done copy: subs r7,r7,#1 ldrb r1,[r6,r7] strb r1,[r5,r7] bne copy adds r3,r3,#16 b cploop clear: subs r7,r7,#1 strb r0,[r5,r7] bne clear adds r3,r3,#16 b cploop done: ;; initialize or copy the vector table bl __init_vector_table .if @defined('__POSIX__') ;; posix stack buffer for system upbringing ldr r0,=_posix_boot_stack_top ldr r0, [r0] mov sp,r0 .else ;; load r10 with end of USR/SYS stack, which is ;; needed in case stack overflow checking is on ;; NOTE: use 16-bit instructions only, for ARMv6M ldr r0,=_lc_ue_stack mov r10,r0 .endif .if @defined('__PROF_ENABLE__') bl __prof_init .endif .if @defined('__POSIX__') ;; call posix_main with no arguments bl posix_main .else ;; retrieve argc and argv (default argv[0]==NULL & argc==0) bl __get_argcv ldr r1,=__argcvbuf ;; call main bl main .endif ;; call exit using the return value from main() ;; Note. Calling exit will also run all functions ;; that were supplied through atexit(). bl exit __get_argcv: ; weak definition movs r0,#0 bx lr .ltorg .endsec .calls '_START','__init_hardware' .calls '_START','__init_vector_table' .if @defined('__PROF_ENABLE__') .calls '_START','__prof_init' .endif .if @defined('__POSIX__') .calls '_START','posix_main' .else .calls '_START','__get_argcv' .calls '_START','main' .endif .calls '_START','exit' .calls '_START','',0 .end
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210E-EVAL/cstart_thumb2.asm
Assembly
asf20
3,949
//////////////////////////////////////////////////////////////////////////// // // File : stm32f103_cmsis.lsl // // Version : @(#)stm32f103_cmsis.lsl 1.2 09/06/04 // // Description : LSL file for the STMicroelectronics STM32F103, CMSIS version // // Copyright 2009 Altium BV // // NOTE: // This file is derived from cm3.lsl and stm32f103.lsl. // It is assumed that the user works with the ARMv7M architecture. // Other architectures will not work with this lsl file. // //////////////////////////////////////////////////////////////////////////// // // We do not want the vectors as defined in arm_arch.lsl // #define __NO_DEFAULT_AUTO_VECTORS 1 #define __NR_OF_VECTORS 76 #ifndef __STACK # define __STACK 8k #endif #ifndef __HEAP # define __HEAP 2k #endif #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x08000000 #endif #ifndef __XVWBUF #define __XVWBUF 256 /* buffer used by CrossView */ #endif #include <arm_arch.lsl> //////////////////////////////////////////////////////////////////////////// // // In the STM32F10x, 3 different boot modes can be selected // - User Flash memory is selected as boot space // - SystemMemory is selected as boot space // - Embedded SRAM is selected as boot space // // This aliases the physical memory associated with each boot mode to Block // 000 (0x00000000 boot memory). Even when aliased in the boot memory space, // the related memory (Flash memory or SRAM) is still accessible at its // original memory space. // // If no memory is defined yet use the following memory settings // #ifndef __MEMORY memory stm32f103flash { mau = 8; type = rom; size = 512k; map ( size = 512k, dest_offset=0x08000000, dest=bus:ARM:local_bus); } memory stm32f103ram { mau = 8; type = ram; size = 64k; map ( size = 64k, dest_offset=0x20000000, dest=bus:ARM:local_bus); } #endif /* __MEMORY */ // // Custom vector table defines interrupts according to CMSIS standard // # if defined(__CPU_ARMV7M__) section_setup ::linear { // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); vector ( id = 2, optional, fill = "NMI_Handler" ); vector ( id = 3, optional, fill = "HardFault_Handler" ); vector ( id = 4, optional, fill = "MemManage_Handler" ); vector ( id = 5, optional, fill = "BusFault_Handler" ); vector ( id = 6, optional, fill = "UsageFault_Handler" ); vector ( id = 11, optional, fill = "SVC_Handler" ); vector ( id = 12, optional, fill = "DebugMon_Handler" ); vector ( id = 14, optional, fill = "PendSV_Handler" ); vector ( id = 15, optional, fill = "SysTick_Handler" ); // External Interrupts : vector ( id = 16, optional, fill = "WWDG_IRQHandler" ); // Window Watchdog vector ( id = 17, optional, fill = "PVD_IRQHandler" ); // PVD through EXTI Line detect vector ( id = 18, optional, fill = "TAMPER_IRQHandler" ); // Tamper vector ( id = 19, optional, fill = "RTC_IRQHandler" ); // RTC vector ( id = 20, optional, fill = "FLASH_IRQHandler" ); // Flash vector ( id = 21, optional, fill = "RCC_IRQHandler" ); // RCC vector ( id = 22, optional, fill = "EXTI0_IRQHandler" ); // EXTI Line 0 vector ( id = 23, optional, fill = "EXTI1_IRQHandler" ); // EXTI Line 1 vector ( id = 24, optional, fill = "EXTI2_IRQHandler" ); // EXTI Line 2 vector ( id = 25, optional, fill = "EXTI3_IRQHandler" ); // EXTI Line 3 vector ( id = 26, optional, fill = "EXTI4_IRQHandler" ); // EXTI Line 4 vector ( id = 27, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 7 vector ( id = 34, optional, fill = "ADC1_2_IRQHandler" ); // ADC1 and ADC2 vector ( id = 35, optional, fill = "USB_HP_CAN1_TX_IRQHandler" ); // USB High Priority or CAN1 TX vector ( id = 36, optional, fill = "USB_LP_CAN1_RX0_IRQHandler" ); // USB LowPriority or CAN1 RX0 vector ( id = 37, optional, fill = "CAN_RX1_IRQHandler" ); // CAN RX1 vector ( id = 38, optional, fill = "CAN_SCE_IRQHandler" ); // CAN SCE vector ( id = 39, optional, fill = "EXTI9_5_IRQHandler" ); // EXTI Line 9..5 vector ( id = 40, optional, fill = "TIM1_BRK_IRQHandler" ); // TIM1 Break vector ( id = 41, optional, fill = "TIM1_UP_IRQHandler" ); // TIM1 Update vector ( id = 42, optional, fill = "TIM1_TRG_COM_IRQHandler" ); // TIM1 Trigger and Commutation vector ( id = 43, optional, fill = "TIM1_CC_IRQHandler" ); // TIM1 Capture Compare vector ( id = 44, optional, fill = "TIM2_IRQHandler" ); // TIM2 vector ( id = 45, optional, fill = "TIM3_IRQHandler" ); // TIM3 vector ( id = 46, optional, fill = "TIM4_IRQHandler" ); // TIM4 vector ( id = 47, optional, fill = "I2C1_EV_IRQHandler" ); // I2C1 Event vector ( id = 48, optional, fill = "I2C1_ER_IRQHandler" ); // I2C1 Error vector ( id = 49, optional, fill = "I2C2_EV_IRQHandler" ); // I2C2 Event vector ( id = 50, optional, fill = "I2C2_ER_IRQHandler" ); // I2C2 Error vector ( id = 51, optional, fill = "SPI1_IRQHandler" ); // SPI1 vector ( id = 52, optional, fill = "SPI2_IRQHandler" ); // SPI2 vector ( id = 53, optional, fill = "USART1_IRQHandler" ); // USART1 vector ( id = 54, optional, fill = "USART2_IRQHandler" ); // USART2 vector ( id = 55, optional, fill = "USART3_IRQHandler" ); // USART3 vector ( id = 56, optional, fill = "EXTI15_10_IRQHandler" ); // EXTI Line 15..10 vector ( id = 57, optional, fill = "RTCAlarm_IRQHandler" ); // RTC Alarm through EXTI Line vector ( id = 58, optional, fill = "USBWakeUp_IRQHandler" ); // USB Wakeup from suspend vector ( id = 59, optional, fill = "TIM8_BRK_IRQHandler" ); // TIM8 Break vector ( id = 60, optional, fill = "TIM8_UP_IRQHandler" ); // TIM8 Update vector ( id = 61, optional, fill = "TIM8_TRG_COM_IRQHandler" ); // TIM8 Trigger and Commutation vector ( id = 62, optional, fill = "TIM8_CC_IRQHandler" ); // TIM8 Capture Compare vector ( id = 63, optional, fill = "ADC3_IRQHandler" ); // ADC3 vector ( id = 64, optional, fill = "FSMC_IRQHandler" ); // FSMC vector ( id = 65, optional, fill = "SDIO_IRQHandler" ); // SDIO vector ( id = 66, optional, fill = "TIM5_IRQHandler" ); // TIM5 vector ( id = 67, optional, fill = "SPI3_IRQHandler" ); // SPI3 vector ( id = 68, optional, fill = "UART4_IRQHandler" ); // UART4 vector ( id = 69, optional, fill = "UART5_IRQHandler" ); // UART5 vector ( id = 70, optional, fill = "TIM6_IRQHandler" ); // TIM6 vector ( id = 71, optional, fill = "TIM7_IRQHandler" ); // TIM7 vector ( id = 72, optional, fill = "DMA2_Channel1_IRQHandler" ); // DMA2 Channel1 vector ( id = 73, optional, fill = "DMA2_Channel2_IRQHandler" ); // DMA2 Channel2 vector ( id = 74, optional, fill = "DMA2_Channel3_IRQHandler" ); // DMA2 Channel3 vector ( id = 75, optional, fill = "DMA2_Channel4_5_IRQHandler" ); // DMA2 Channel4 and DMA2 Channel5 } } # endif
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210E-EVAL/Settings/STM32F10x_hd.lsl
LSL
asf20
10,586
//////////////////////////////////////////////////////////////////////////// // // File : arm_arch.lsl // // Version : @(#)arm_arch.lsl 1.4 09/04/17 // // Description : Generic LSL file for ARM architectures // // Copyright 2008-2009 Altium BV // //////////////////////////////////////////////////////////////////////////// #ifndef __STACK # define __STACK 32k #endif #ifndef __HEAP # define __HEAP 32k #endif #ifndef __STACK_FIQ # define __STACK_FIQ 8 #endif #ifndef __STACK_IRQ # define __STACK_IRQ 8 #endif #ifndef __STACK_SVC # define __STACK_SVC 8 #endif #ifndef __STACK_ABT # define __STACK_ABT 8 #endif #ifndef __STACK_UND # define __STACK_UND 8 #endif #ifndef __PROCESSOR_MODE # define __PROCESSOR_MODE 0x1F /* SYS mode */ #endif #ifndef __IRQ_BIT # define __IRQ_BIT 0x80 /* IRQ interrupts disabled */ #endif #ifndef __FIQ_BIT # define __FIQ_BIT 0x40 /* FIQ interrupts disabled */ #endif #define __APPLICATION_MODE (__PROCESSOR_MODE | __IRQ_BIT | __FIQ_BIT) #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x00000000 #endif #ifndef __VECTOR_TABLE_RAM_ADDR # define __VECTOR_TABLE_RAM_ADDR 0x00000000 #endif #if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) # ifndef __NR_OF_VECTORS # define __NR_OF_VECTORS 16 # endif # define __VECTOR_TABLE_SIZE (__NR_OF_VECTORS * 4) #else # ifdef __PIC_VECTORS # define __VECTOR_TABLE_SIZE 64 # else # ifdef __FIQ_HANDLER_INLINE # define __VECTOR_TABLE_SIZE 28 # define __NR_OF_VECTORS 7 # else # define __VECTOR_TABLE_SIZE 32 # define __NR_OF_VECTORS 8 # endif # endif #endif #ifndef __VECTOR_TABLE_RAM_SPACE # undef __VECTOR_TABLE_RAM_COPY #endif #ifndef __XVWBUF # define __XVWBUF 0 /* buffer used by CrossView Pro */ #endif #define BOUNDS_GROUP_NAME grp_bounds #define BOUNDS_GROUP_SELECT "bounds" architecture ARM { endianness { little; big; } space linear { id = 1; mau = 8; map (size = 4G, dest = bus:local_bus); copytable ( align = 4, copy_unit = 1, dest = linear ); start_address ( // It is not strictly necessary to define a run_addr for _START // because hardware starts execution at address 0x0 which should // be the vector table with a jump to the relocatable _START, but // an absolute address can prevent the branch to be out-of-range. // Or _START may be the entry point at reset and the reset handler // copies the vector table to address 0x0 after some ROM/RAM memory // re-mapping. In that case _START should be at a fixed address // in ROM, specifically the alias of address 0x0 before memory // re-mapping. #ifdef __START run_addr = __START, #endif symbol = "_START" ); stack "stack" ( #ifdef __STACK_FIXED fixed, #endif align = 4, min_size = __STACK, grows = high_to_low ); heap "heap" ( #ifdef __HEAP_FIXED fixed, #endif align = 4, min_size=__HEAP ); #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) stack "stack_fiq" ( fixed, align = 4, min_size = __STACK_FIQ, grows = high_to_low ); stack "stack_irq" ( fixed, align = 4, min_size = __STACK_IRQ, grows = high_to_low ); stack "stack_svc" ( fixed, align = 4, min_size = __STACK_SVC, grows = high_to_low ); stack "stack_abt" ( fixed, align = 4, min_size = __STACK_ABT, grows = high_to_low ); stack "stack_und" ( fixed, align = 4, min_size = __STACK_UND, grows = high_to_low ); #endif #if !defined(__NO_AUTO_VECTORS) && !defined(__NO_DEFAULT_AUTO_VECTORS) # if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); } # else # ifdef __PIC_VECTORS // vector table with ldrpc instructions from handler table vector_table "vector_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_ldrpc", template_symbol = "_lc_vector_ldrpc", vector_prefix = "_vector_ldrpc_", fill = loop ) { } // subsequent vector table (data pool) with addresses of handlers vector_table "handler_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR + 32, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop[-32], no_inline ) { vector ( id = 0, fill = "_START" ); } # else // vector table with branch instructions to handlers vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_branch", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop ) { vector ( id = 0, fill = "_START" ); } # endif # endif #endif section_layout { #if defined(__NO_AUTO_VECTORS) "_lc_ub_vector_table" = __VECTOR_TABLE_ROM_ADDR; "_lc_ue_vector_table" = __VECTOR_TABLE_ROM_ADDR + __VECTOR_TABLE_SIZE; #endif #ifdef __VECTOR_TABLE_RAM_SPACE // reserve space to copy vector table from ROM to RAM group ( ordered, run_addr = __VECTOR_TABLE_RAM_ADDR ) reserved "vector_table_space" ( size = __VECTOR_TABLE_SIZE, attributes = rwx ); #endif #ifdef __VECTOR_TABLE_RAM_COPY // provide copy address symbols for copy routine "_lc_ub_vector_table_copy" := "_lc_ub_vector_table_space"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table_space"; #else // prevent copy: copy address equals orig address "_lc_ub_vector_table_copy" := "_lc_ub_vector_table"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table"; #endif // define buffer for string input via Crossview Pro debugger group ( align = 4 ) reserved "xvwbuffer" (size=__XVWBUF, attributes=rw ); // define labels for bounds begin and end as used in C library #ifndef BOUNDS_GROUP_REDEFINED group BOUNDS_GROUP_NAME (ordered, contiguous) { select BOUNDS_GROUP_SELECT; } #endif "_lc_ub_bounds" := addressof(group:BOUNDS_GROUP_NAME); "_lc_ue_bounds" := addressof(group:BOUNDS_GROUP_NAME) + sizeof(group:BOUNDS_GROUP_NAME); #ifdef __HEAPADDR group ( ordered, run_addr=__HEAPADDR ) { select "heap"; } #endif #ifdef __STACKADDR group ( ordered, run_addr=__STACKADDR ) { select "stack"; } #endif #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) // symbol to set mode bits and interrupt disable bits // in cstart module before calling the application (main) "_APPLICATION_MODE_" = __APPLICATION_MODE; #endif } } bus local_bus { mau = 8; width = 32; } }
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210E-EVAL/Settings/arm_arch.lsl
LSL
asf20
10,931
;; NOTE: To allow the use of this file for both ARMv6M and ARMv7M, ;; we will only use 16-bit Thumb intructions. .extern _lc_ub_stack ; usr/sys mode stack pointer .extern _lc_ue_stack ; symbol required by debugger .extern _lc_ub_table ; ROM to RAM copy table .extern main .extern _Exit .extern exit .weak exit .global __get_argcv .weak __get_argcv .extern __argcvbuf .weak __argcvbuf .extern __init_hardware .extern __init_vector_table .extern SystemInit .if @defined('__PROF_ENABLE__') .extern __prof_init .endif .if @defined('__POSIX__') .extern posix_main .extern _posix_boot_stack_top .endif .global _START .section .text.cstart .thumb _START: ;; anticipate possible ROM/RAM remapping ;; by loading the 'real' program address ldr r1,=_Next bx r1 _Next: ;; initialize the stack pointer ldr r1,=_lc_ub_stack ; TODO: make this part of the vector table mov sp,r1 ;; call a user function which initializes hardware ;; such as ROM/RAM re-mapping or MMU configuration bl __init_hardware ;ldr r0, =SystemInit ;bx r0 bl SystemInit ;; copy initialized sections from ROM to RAM ;; and clear uninitialized data sections in RAM ldr r3,=_lc_ub_table movs r0,#0 cploop: ldr r4,[r3,#0] ; load type ldr r5,[r3,#4] ; dst address ldr r6,[r3,#8] ; src address ldr r7,[r3,#12] ; size cmp r4,#1 beq copy cmp r4,#2 beq clear b done copy: subs r7,r7,#1 ldrb r1,[r6,r7] strb r1,[r5,r7] bne copy adds r3,r3,#16 b cploop clear: subs r7,r7,#1 strb r0,[r5,r7] bne clear adds r3,r3,#16 b cploop done: ;; initialize or copy the vector table bl __init_vector_table .if @defined('__POSIX__') ;; posix stack buffer for system upbringing ldr r0,=_posix_boot_stack_top ldr r0, [r0] mov sp,r0 .else ;; load r10 with end of USR/SYS stack, which is ;; needed in case stack overflow checking is on ;; NOTE: use 16-bit instructions only, for ARMv6M ldr r0,=_lc_ue_stack mov r10,r0 .endif .if @defined('__PROF_ENABLE__') bl __prof_init .endif .if @defined('__POSIX__') ;; call posix_main with no arguments bl posix_main .else ;; retrieve argc and argv (default argv[0]==NULL & argc==0) bl __get_argcv ldr r1,=__argcvbuf ;; call main bl main .endif ;; call exit using the return value from main() ;; Note. Calling exit will also run all functions ;; that were supplied through atexit(). bl exit __get_argcv: ; weak definition movs r0,#0 bx lr .ltorg .endsec .calls '_START','__init_hardware' .calls '_START','__init_vector_table' .if @defined('__PROF_ENABLE__') .calls '_START','__prof_init' .endif .if @defined('__POSIX__') .calls '_START','posix_main' .else .calls '_START','__get_argcv' .calls '_START','main' .endif .calls '_START','exit' .calls '_START','',0 .end
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210B-EVAL/cstart_thumb2.asm
Assembly
asf20
3,949
//////////////////////////////////////////////////////////////////////////// // // File : arm_arch.lsl // // Version : @(#)arm_arch.lsl 1.4 09/04/17 // // Description : Generic LSL file for ARM architectures // // Copyright 2008-2009 Altium BV // //////////////////////////////////////////////////////////////////////////// #ifndef __STACK # define __STACK 32k #endif #ifndef __HEAP # define __HEAP 32k #endif #ifndef __STACK_FIQ # define __STACK_FIQ 8 #endif #ifndef __STACK_IRQ # define __STACK_IRQ 8 #endif #ifndef __STACK_SVC # define __STACK_SVC 8 #endif #ifndef __STACK_ABT # define __STACK_ABT 8 #endif #ifndef __STACK_UND # define __STACK_UND 8 #endif #ifndef __PROCESSOR_MODE # define __PROCESSOR_MODE 0x1F /* SYS mode */ #endif #ifndef __IRQ_BIT # define __IRQ_BIT 0x80 /* IRQ interrupts disabled */ #endif #ifndef __FIQ_BIT # define __FIQ_BIT 0x40 /* FIQ interrupts disabled */ #endif #define __APPLICATION_MODE (__PROCESSOR_MODE | __IRQ_BIT | __FIQ_BIT) #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x00000000 #endif #ifndef __VECTOR_TABLE_RAM_ADDR # define __VECTOR_TABLE_RAM_ADDR 0x00000000 #endif #if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) # ifndef __NR_OF_VECTORS # define __NR_OF_VECTORS 16 # endif # define __VECTOR_TABLE_SIZE (__NR_OF_VECTORS * 4) #else # ifdef __PIC_VECTORS # define __VECTOR_TABLE_SIZE 64 # else # ifdef __FIQ_HANDLER_INLINE # define __VECTOR_TABLE_SIZE 28 # define __NR_OF_VECTORS 7 # else # define __VECTOR_TABLE_SIZE 32 # define __NR_OF_VECTORS 8 # endif # endif #endif #ifndef __VECTOR_TABLE_RAM_SPACE # undef __VECTOR_TABLE_RAM_COPY #endif #ifndef __XVWBUF # define __XVWBUF 0 /* buffer used by CrossView Pro */ #endif #define BOUNDS_GROUP_NAME grp_bounds #define BOUNDS_GROUP_SELECT "bounds" architecture ARM { endianness { little; big; } space linear { id = 1; mau = 8; map (size = 4G, dest = bus:local_bus); copytable ( align = 4, copy_unit = 1, dest = linear ); start_address ( // It is not strictly necessary to define a run_addr for _START // because hardware starts execution at address 0x0 which should // be the vector table with a jump to the relocatable _START, but // an absolute address can prevent the branch to be out-of-range. // Or _START may be the entry point at reset and the reset handler // copies the vector table to address 0x0 after some ROM/RAM memory // re-mapping. In that case _START should be at a fixed address // in ROM, specifically the alias of address 0x0 before memory // re-mapping. #ifdef __START run_addr = __START, #endif symbol = "_START" ); stack "stack" ( #ifdef __STACK_FIXED fixed, #endif align = 4, min_size = __STACK, grows = high_to_low ); heap "heap" ( #ifdef __HEAP_FIXED fixed, #endif align = 4, min_size=__HEAP ); #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) stack "stack_fiq" ( fixed, align = 4, min_size = __STACK_FIQ, grows = high_to_low ); stack "stack_irq" ( fixed, align = 4, min_size = __STACK_IRQ, grows = high_to_low ); stack "stack_svc" ( fixed, align = 4, min_size = __STACK_SVC, grows = high_to_low ); stack "stack_abt" ( fixed, align = 4, min_size = __STACK_ABT, grows = high_to_low ); stack "stack_und" ( fixed, align = 4, min_size = __STACK_UND, grows = high_to_low ); #endif #if !defined(__NO_AUTO_VECTORS) && !defined(__NO_DEFAULT_AUTO_VECTORS) # if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); } # else # ifdef __PIC_VECTORS // vector table with ldrpc instructions from handler table vector_table "vector_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_ldrpc", template_symbol = "_lc_vector_ldrpc", vector_prefix = "_vector_ldrpc_", fill = loop ) { } // subsequent vector table (data pool) with addresses of handlers vector_table "handler_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR + 32, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop[-32], no_inline ) { vector ( id = 0, fill = "_START" ); } # else // vector table with branch instructions to handlers vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_branch", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop ) { vector ( id = 0, fill = "_START" ); } # endif # endif #endif section_layout { #if defined(__NO_AUTO_VECTORS) "_lc_ub_vector_table" = __VECTOR_TABLE_ROM_ADDR; "_lc_ue_vector_table" = __VECTOR_TABLE_ROM_ADDR + __VECTOR_TABLE_SIZE; #endif #ifdef __VECTOR_TABLE_RAM_SPACE // reserve space to copy vector table from ROM to RAM group ( ordered, run_addr = __VECTOR_TABLE_RAM_ADDR ) reserved "vector_table_space" ( size = __VECTOR_TABLE_SIZE, attributes = rwx ); #endif #ifdef __VECTOR_TABLE_RAM_COPY // provide copy address symbols for copy routine "_lc_ub_vector_table_copy" := "_lc_ub_vector_table_space"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table_space"; #else // prevent copy: copy address equals orig address "_lc_ub_vector_table_copy" := "_lc_ub_vector_table"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table"; #endif // define buffer for string input via Crossview Pro debugger group ( align = 4 ) reserved "xvwbuffer" (size=__XVWBUF, attributes=rw ); // define labels for bounds begin and end as used in C library #ifndef BOUNDS_GROUP_REDEFINED group BOUNDS_GROUP_NAME (ordered, contiguous) { select BOUNDS_GROUP_SELECT; } #endif "_lc_ub_bounds" := addressof(group:BOUNDS_GROUP_NAME); "_lc_ue_bounds" := addressof(group:BOUNDS_GROUP_NAME) + sizeof(group:BOUNDS_GROUP_NAME); #ifdef __HEAPADDR group ( ordered, run_addr=__HEAPADDR ) { select "heap"; } #endif #ifdef __STACKADDR group ( ordered, run_addr=__STACKADDR ) { select "stack"; } #endif #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) // symbol to set mode bits and interrupt disable bits // in cstart module before calling the application (main) "_APPLICATION_MODE_" = __APPLICATION_MODE; #endif } } bus local_bus { mau = 8; width = 32; } }
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210B-EVAL/Settings/arm_arch.lsl
LSL
asf20
10,931
//////////////////////////////////////////////////////////////////////////// // // File : stm32f103_cmsis.lsl // // Version : @(#)stm32f103_cmsis.lsl 1.2 09/06/04 // // Description : LSL file for the STMicroelectronics STM32F103, CMSIS version // // Copyright 2009 Altium BV // // NOTE: // This file is derived from cm3.lsl and stm32f103.lsl. // It is assumed that the user works with the ARMv7M architecture. // Other architectures will not work with this lsl file. // //////////////////////////////////////////////////////////////////////////// // // We do not want the vectors as defined in arm_arch.lsl // #define __NO_DEFAULT_AUTO_VECTORS 1 #define __NR_OF_VECTORS 76 #ifndef __STACK # define __STACK 8k #endif #ifndef __HEAP # define __HEAP 2k #endif #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x08000000 #endif #ifndef __XVWBUF #define __XVWBUF 256 /* buffer used by CrossView */ #endif #include <arm_arch.lsl> //////////////////////////////////////////////////////////////////////////// // // In the STM32F10x, 3 different boot modes can be selected // - User Flash memory is selected as boot space // - SystemMemory is selected as boot space // - Embedded SRAM is selected as boot space // // This aliases the physical memory associated with each boot mode to Block // 000 (0x00000000 boot memory). Even when aliased in the boot memory space, // the related memory (Flash memory or SRAM) is still accessible at its // original memory space. // // If no memory is defined yet use the following memory settings // #ifndef __MEMORY memory stm32f103flash { mau = 8; type = rom; size = 128k; map ( size = 128k, dest_offset=0x08000000, dest=bus:ARM:local_bus); } memory stm32f103ram { mau = 8; type = ram; size = 20k; map ( size = 20k, dest_offset=0x20000000, dest=bus:ARM:local_bus); } #endif /* __MEMORY */ // // Custom vector table defines interrupts according to CMSIS standard // # if defined(__CPU_ARMV7M__) section_setup ::linear { // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); vector ( id = 2, optional, fill = "NMI_Handler" ); vector ( id = 3, optional, fill = "HardFault_Handler" ); vector ( id = 4, optional, fill = "MemManage_Handler" ); vector ( id = 5, optional, fill = "BusFault_Handler" ); vector ( id = 6, optional, fill = "UsageFault_Handler" ); vector ( id = 11, optional, fill = "SVC_Handler" ); vector ( id = 12, optional, fill = "DebugMon_Handler" ); vector ( id = 14, optional, fill = "PendSV_Handler" ); vector ( id = 15, optional, fill = "SysTick_Handler" ); // External Interrupts : vector ( id = 16, optional, fill = "WWDG_IRQHandler" ); // Window Watchdog vector ( id = 17, optional, fill = "PVD_IRQHandler" ); // PVD through EXTI Line detect vector ( id = 18, optional, fill = "TAMPER_IRQHandler" ); // Tamper vector ( id = 19, optional, fill = "RTC_IRQHandler" ); // RTC vector ( id = 20, optional, fill = "FLASH_IRQHandler" ); // Flash vector ( id = 21, optional, fill = "RCC_IRQHandler" ); // RCC vector ( id = 22, optional, fill = "EXTI0_IRQHandler" ); // EXTI Line 0 vector ( id = 23, optional, fill = "EXTI1_IRQHandler" ); // EXTI Line 1 vector ( id = 24, optional, fill = "EXTI2_IRQHandler" ); // EXTI Line 2 vector ( id = 25, optional, fill = "EXTI3_IRQHandler" ); // EXTI Line 3 vector ( id = 26, optional, fill = "EXTI4_IRQHandler" ); // EXTI Line 4 vector ( id = 27, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMA1_Channel2_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMA1_Channel3_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMA1_Channel4_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMA1_Channel5_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMA1_Channel6_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMA1_Channel7_IRQHandler" ); // DMA Channel 7 vector ( id = 34, optional, fill = "ADC1_2_IRQHandler" ); // ADC1 and ADC2 vector ( id = 35, optional, fill = "USB_HP_CAN1_TX_IRQHandler" ); // USB High Priority or CAN1 TX vector ( id = 36, optional, fill = "USB_LP_CAN1_RX0_IRQHandler" ); // USB LowPriority or CAN RX0 vector ( id = 37, optional, fill = "CAN_RX1_IRQHandler" ); // CAN RX1 vector ( id = 38, optional, fill = "CAN_SCE_IRQHandler" ); // CAN SCE vector ( id = 39, optional, fill = "EXTI9_5_IRQHandler" ); // EXTI Line 9..5 vector ( id = 40, optional, fill = "TIM1_BRK_IRQHandler" ); // TIM1 Break vector ( id = 41, optional, fill = "TIM1_UP_IRQHandler" ); // TIM1 Update vector ( id = 42, optional, fill = "TIM1_TRG_COM_IRQHandler" ); // TIM1 Trigger and Commutation vector ( id = 43, optional, fill = "TIM1_CC_IRQHandler" ); // TIM1 Capture Compare vector ( id = 44, optional, fill = "TIM2_IRQHandler" ); // TIM2 vector ( id = 45, optional, fill = "TIM3_IRQHandler" ); // TIM3 vector ( id = 46, optional, fill = "TIM4_IRQHandler" ); // TIM4 vector ( id = 47, optional, fill = "I2C1_EV_IRQHandler" ); // I2C1 Event vector ( id = 48, optional, fill = "I2C1_ER_IRQHandler" ); // I2C1 Error vector ( id = 49, optional, fill = "I2C2_EV_IRQHandler" ); // I2C2 Event vector ( id = 50, optional, fill = "I2C2_ER_IRQHandler" ); // I2C2 Error vector ( id = 51, optional, fill = "SPI1_IRQHandler" ); // SPI1 vector ( id = 52, optional, fill = "SPI2_IRQHandler" ); // SPI2 vector ( id = 53, optional, fill = "USART1_IRQHandler" ); // USART1 vector ( id = 54, optional, fill = "USART2_IRQHandler" ); // USART2 vector ( id = 55, optional, fill = "USART3_IRQHandler" ); // USART3 vector ( id = 56, optional, fill = "EXTI15_10_IRQHandler" ); // EXTI Line 15..10 vector ( id = 57, optional, fill = "RTCAlarm_IRQHandler" ); // RTC Alarm through EXTI Line vector ( id = 58, optional, fill = "USBWakeUp_IRQHandler" ); // USB Wakeup from suspend } } # endif
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Custom_HID/HiTOP/STM3210B-EVAL/Settings/STM32F10x_md.lsl
LSL
asf20
8,716
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_pwr.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Connection/disconnection & power management header ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_PWR_H #define __USB_PWR_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ typedef enum _RESUME_STATE { RESUME_EXTERNAL, RESUME_INTERNAL, RESUME_LATER, RESUME_WAIT, RESUME_START, RESUME_ON, RESUME_OFF, RESUME_ESOF } RESUME_STATE; typedef enum _DEVICE_STATE { UNCONNECTED, ATTACHED, POWERED, SUSPENDED, ADDRESSED, CONFIGURED } DEVICE_STATE; /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void Suspend(void); void Resume_Init(void); void Resume(RESUME_STATE eResumeSetVal); RESULT PowerOn(void); RESULT PowerOff(void); /* External variables --------------------------------------------------------*/ extern __IO uint32_t bDeviceState; /* USB device status */ extern __IO bool fSuspendEnabled; /* true when suspend is possible */ #endif /*__USB_PWR_H*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/inc/usb_pwr.h
C
asf20
2,245
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : hw_config.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Hardware Configuration & Setup ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __HW_CONFIG_H #define __HW_CONFIG_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported define -----------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ /* External variables --------------------------------------------------------*/ void Set_System(void); void Set_USBClock(void); void Enter_LowPowerMode(void); void Leave_LowPowerMode(void); void USB_Config(void); void Audio_Interrupts_Config(void); void USB_Cable_Config (FunctionalState NewState); void Speaker_Config(void); void NVIC_Config(void); void GPIO_Config(void); void Get_SerialNum(void); #endif /*__HW_CONFIG_H*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/inc/hw_config.h
C
asf20
2,060
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_desc.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Descriptor Header for Mass Storage Device ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_DESC_H #define __USB_DESC_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported define -----------------------------------------------------------*/ #define SPEAKER_SIZ_DEVICE_DESC 18 #define SPEAKER_SIZ_CONFIG_DESC 109 #define SPEAKER_SIZ_INTERFACE_DESC_SIZE 9 #define SPEAKER_SIZ_STRING_LANGID 0x04 #define SPEAKER_SIZ_STRING_VENDOR 0x26 #define SPEAKER_SIZ_STRING_PRODUCT 0x1C #define SPEAKER_SIZ_STRING_SERIAL 0x1A #define AUDIO_STANDARD_ENDPOINT_DESC_SIZE 0x09 #define AUDIO_STREAMING_ENDPOINT_DESC_SIZE 0x07 /* USB Descriptor Types */ #define USB_DEVICE_DESCRIPTOR_TYPE 0x01 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 #define USB_STRING_DESCRIPTOR_TYPE 0x03 #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 #define USB_DEVICE_CLASS_AUDIO 0x01 #define AUDIO_SUBCLASS_AUDIOCONTROL 0x01 #define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02 #define AUDIO_PROTOCOL_UNDEFINED 0x00 #define AUDIO_STREAMING_GENERAL 0x01 #define AUDIO_STREAMING_FORMAT_TYPE 0x02 /* Audio Descriptor Types */ #define AUDIO_INTERFACE_DESCRIPTOR_TYPE 0x24 #define AUDIO_ENDPOINT_DESCRIPTOR_TYPE 0x25 /* Audio Control Interface Descriptor Subtypes */ #define AUDIO_CONTROL_HEADER 0x01 #define AUDIO_CONTROL_INPUT_TERMINAL 0x02 #define AUDIO_CONTROL_OUTPUT_TERMINAL 0x03 #define AUDIO_CONTROL_FEATURE_UNIT 0x06 #define AUDIO_INPUT_TERMINAL_DESC_SIZE 0x0C #define AUDIO_OUTPUT_TERMINAL_DESC_SIZE 0x09 #define AUDIO_STREAMING_INTERFACE_DESC_SIZE 0x07 #define AUDIO_CONTROL_MUTE 0x0001 #define AUDIO_FORMAT_TYPE_I 0x01 #define AUDIO_FORMAT_TYPE_III 0x03 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 #define AUDIO_ENDPOINT_GENERAL 0x01 /* Exported functions ------------------------------------------------------- */ extern const uint8_t Speaker_DeviceDescriptor[SPEAKER_SIZ_DEVICE_DESC]; extern const uint8_t Speaker_ConfigDescriptor[SPEAKER_SIZ_CONFIG_DESC]; extern const uint8_t Speaker_StringLangID[SPEAKER_SIZ_STRING_LANGID]; extern const uint8_t Speaker_StringVendor[SPEAKER_SIZ_STRING_VENDOR]; extern const uint8_t Speaker_StringProduct[SPEAKER_SIZ_STRING_PRODUCT]; extern uint8_t Speaker_StringSerial[SPEAKER_SIZ_STRING_SERIAL]; #endif /* __USB_DESC_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/inc/usb_desc.h
C
asf20
4,252
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_prop.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : All processing related to Mass Storage Demo (Endpoint 0) ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __usb_prop_H #define __usb_prop_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void Speaker_init(void); void Speaker_Reset(void); void Speaker_SetConfiguration(void); void Speaker_SetDeviceAddress (void); void Speaker_Status_In (void); void Speaker_Status_Out (void); RESULT Speaker_Data_Setup(uint8_t); RESULT Speaker_NoData_Setup(uint8_t); RESULT Speaker_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting); uint8_t *Speaker_GetDeviceDescriptor(uint16_t ); uint8_t *Speaker_GetConfigDescriptor(uint16_t); uint8_t *Speaker_GetStringDescriptor(uint16_t); uint8_t *Mute_Command(uint16_t Length); /* Exported define -----------------------------------------------------------*/ #define Speaker_GetConfiguration NOP_Process //#define Speaker_SetConfiguration NOP_Process #define Speaker_GetInterface NOP_Process #define Speaker_SetInterface NOP_Process #define Speaker_GetStatus NOP_Process #define Speaker_ClearFeature NOP_Process #define Speaker_SetEndPointFeature NOP_Process #define Speaker_SetDeviceFeature NOP_Process //#define Speaker_SetDeviceAddress NOP_Process #define GET_CUR 0x81 #define SET_CUR 0x01 #endif /* __usb_prop_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/inc/usb_prop.h
C
asf20
2,811
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : stm32f10x_conf.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Library configuration file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F10x_CONF_H #define __STM32F10x_CONF_H /* Includes ------------------------------------------------------------------*/ /* Uncomment the line below to enable peripheral header file inclusion */ /* #include "stm32f10x_adc.h" */ /* #include "stm32f10x_bkp.h" */ /* #include "stm32f10x_can.h" */ /* #include "stm32f10x_crc.h" */ /* #include "stm32f10x_dac.h" */ /* #include "stm32f10x_dbgmcu.h" */ #include "stm32f10x_dma.h" #include "stm32f10x_exti.h" #include "stm32f10x_flash.h" /* #include "stm32f10x_fsmc.h" */ #include "stm32f10x_gpio.h" #include "stm32f10x_i2c.h" /* #include "stm32f10x_iwdg.h" */ /* #include "stm32f10x_pwr.h" */ #include "stm32f10x_rcc.h" /* #include "stm32f10x_rtc.h" */ /* #include "stm32f10x_sdio.h" */ #include "stm32f10x_spi.h" /* #include "stm32f10x_tim.h" */ #include "stm32f10x_usart.h" /* #include "stm32f10x_wwdg.h" */ #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Uncomment the line below to expanse the "assert_param" macro in the Standard Peripheral Library drivers code */ /* #define USE_FULL_ASSERT 1 */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /******************************************************************************* * Macro Name : assert_param * Description : The assert_param macro is used for function's parameters check. * Input : - expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * Return : None *******************************************************************************/ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0) #endif /* USE_FULL_ASSERT */ #endif /* __STM32F10x_CONF_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/inc/stm32f10x_conf.h
C
asf20
3,432
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : stm32f10x_it.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : This file contains the headers of the interrupt handlers. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F10x_IT_H #define __STM32F10x_IT_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); void SPI2_IRQHandler(void); #ifdef STM32F10X_CL void OTG_FS_IRQHandler(void); #endif /* STM32F10X_CL */ #endif /* __STM32F10x_IT_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/inc/stm32f10x_it.h
C
asf20
2,008
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : platform_config.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Evaluation board specific configuration file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __PLATFORM_CONFIG_H #define __PLATFORM_CONFIG_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Uncomment the line corresponding to the STMicroelectronics evaluation board used to run the example */ #if !defined (USE_STM3210B_EVAL) && !defined (USE_STM3210E_EVAL) && !defined (USE_STM3210C_EVAL) //#define USE_STM3210B_EVAL //#define USE_STM3210E_EVAL #define USE_STM3210C_EVAL #endif /* Define the STM32F10x hardware depending on the used evaluation board */ #ifdef USE_STM3210B_EVAL #define USB_DISCONNECT GPIOD #define USB_DISCONNECT_PIN GPIO_Pin_9 #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOD #elif defined (USE_STM3210E_EVAL) #define USB_DISCONNECT GPIOB #define USB_DISCONNECT_PIN GPIO_Pin_14 #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB #elif defined (USE_STM3210C_EVAL) #define USB_DISCONNECT 0 #define USB_DISCONNECT_PIN 0 #define RCC_APB2Periph_GPIO_DISCONNECT 0 #endif /* USE_STM3210B_EVAL */ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #endif /* __PLATFORM_CONFIG_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/inc/platform_config.h
C
asf20
2,645
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : audiocodec_cs43l22.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : This file contains all the functions prototypes for the * CS43L22 codec firmware driver. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __AUDIOCODEC_CS43L22_H #define __AUDIOCODEC_CS43L22_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Codec output DEVICE */ #define OutputDevice_SPEAKER 1 #define OutputDevice_HEADPHONE 2 #define OutputDevice_BOTH 3 #define OutputDevice_AUTO 4 /* Volume Levels values */ #define DEFAULT_VOLMIN 0x00 #define DEFAULT_VOLMAX 0xFF #define DEFAULT_VOLSTEP 0x04 /* Codec POWER DOWN modes */ #define CodecPowerDown_HW 1 #define CodecPowerDown_SW 2 /* MUTE commands */ #define MUTE_ON 1 #define MUTE_OFF 0 /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ uint32_t CODEC_Config(uint16_t AudioOutput, uint16_t I2S_Standard, uint16_t I2S_MCLKOutput, uint8_t Volume); uint32_t CODEC_ControlVolume(uint8_t Volume); void CODEC_Mute(uint32_t Command); void CODEC_Reset(void); void CODEC_PowerDown(uint32_t CodecPowerDown_Mode); /* Low Layer Codec Fuctions --------------------------------------------------*/ uint32_t CODEC_WriteRegister(uint32_t RegisterAddr, uint32_t RegisterValue); uint32_t CODEC_ReadRegister(uint32_t RegisterAddr); void CODEC_Delay(__IO uint32_t nCount); #endif /* __AUDIOCODEC_CS43L22_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/inc/audio_codec_cs43l22.h
C
asf20
2,813
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_istr.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : This file includes the peripherals header files in the * user application. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_ISTR_H #define __USB_ISTR_H /* Includes ------------------------------------------------------------------*/ #include "usb_conf.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #ifndef STM32F10X_CL void USB_Istr(void); #else /* STM32F10X_CL */ uint32_t STM32_PCD_OTG_ISR_Handler(void); #endif /* STM32F10X_CL */ /* function prototypes Automatically built defining related macros */ void EP1_IN_Callback(void); void EP2_IN_Callback(void); void EP3_IN_Callback(void); void EP4_IN_Callback(void); void EP5_IN_Callback(void); void EP6_IN_Callback(void); void EP7_IN_Callback(void); void EP1_OUT_Callback(void); void EP2_OUT_Callback(void); void EP3_OUT_Callback(void); void EP4_OUT_Callback(void); void EP5_OUT_Callback(void); void EP6_OUT_Callback(void); void EP7_OUT_Callback(void); #ifndef STM32F10X_CL #ifdef CTR_CALLBACK void CTR_Callback(void); #endif #ifdef DOVR_CALLBACK void DOVR_Callback(void); #endif #ifdef ERR_CALLBACK void ERR_Callback(void); #endif #ifdef WKUP_CALLBACK void WKUP_Callback(void); #endif #ifdef SUSP_CALLBACK void SUSP_Callback(void); #endif #ifdef RESET_CALLBACK void RESET_Callback(void); #endif #ifdef SOF_CALLBACK void SOF_Callback(void); #endif #ifdef ESOF_CALLBACK void ESOF_Callback(void); #endif #else /* STM32F10X_CL */ /* Interrupt subroutines user callbacks prototypes. These callbacks are called into the respective interrupt sunroutine functinos and can be tailored for various user application purposes. Note: Make sure that the correspondant interrupt is enabled through the definition in usb_conf.h file */ void INTR_MODEMISMATCH_Callback(void); void INTR_SOFINTR_Callback(void); void INTR_RXSTSQLVL_Callback(void); void INTR_NPTXFEMPTY_Callback(void); void INTR_GINNAKEFF_Callback(void); void INTR_GOUTNAKEFF_Callback(void); void INTR_ERLYSUSPEND_Callback(void); void INTR_USBSUSPEND_Callback(void); void INTR_USBRESET_Callback(void); void INTR_ENUMDONE_Callback(void); void INTR_ISOOUTDROP_Callback(void); void INTR_EOPFRAME_Callback(void); void INTR_EPMISMATCH_Callback(void); void INTR_INEPINTR_Callback(void); void INTR_OUTEPINTR_Callback(void); void INTR_INCOMPLISOIN_Callback(void); void INTR_INCOMPLISOOUT_Callback(void); void INTR_WKUPINTR_Callback(void); /* Isochronous data update */ void INTR_RXSTSQLVL_ISODU_Callback(void); #endif /* STM32F10X_CL */ #endif /*__USB_ISTR_H*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/inc/usb_istr.h
C
asf20
3,908
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_conf.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Mass Storage Demo configuration header ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_CONF_H #define __USB_CONF_H /*------------------------------------------------------------------------------ Select the audio frequency WARNING: Before selecting the audio frequency, make sure the configuration of the PLLs allows acceptable accuracy for both the I2S clock and the USB clock ! PLLs are configured to have optimum accuracy on the following audio frequencies. ------------------------------------------------------------------------------*/ /* PLLs in this demo are well configured for all these frequencies */ #ifdef EXTERNAL_CRYSTAL_14_7456MHz #define AUDIO_FREQ_96K //#define AUDIO_FREQ_48K //#define AUDIO_FREQ_32K //#define AUDIO_FREQ_16K //#define AUDIO_FREQ_8K #endif /* EXTERNAL_CRYSTAL_14_7456MHz */ /* PLLs in this demo are well configured for all these frequencies */ #ifdef EXTERNAL_CRYSTAL_25MHz #define AUDIO_FREQ_16K //#define AUDIO_FREQ_8K #endif /* EXTERNAL_CRYSTAL_25MHz */ /* These frequencies lead to non integer number of data per frame --> low quality */ //#define AUDIO_FREQ_44K //#define AUDIO_FREQ_22K //#define AUDIO_FREQ_11K /*----------------------------------------------------------------------------*/ /* Size of the receive Buffer = NumberOfSamplesPerSecond x 2 x 2 (Stereo, 16bits) Do not modify these lines ! */ #ifdef AUDIO_FREQ_96K #define ISOC_BUFFER_SZE (uint32_t)(2*2*96) #elif defined AUDIO_FREQ_48K #define ISOC_BUFFER_SZE (uint32_t)(2*2*48) #elif defined AUDIO_FREQ_44K #define ISOC_BUFFER_SZE (uint32_t)(2*2*44) #elif defined AUDIO_FREQ_32K #define ISOC_BUFFER_SZE (uint32_t)(2*2*32) #elif defined AUDIO_FREQ_22K #define ISOC_BUFFER_SZE (uint32_t)(2*2*22) #elif defined AUDIO_FREQ_16K #define ISOC_BUFFER_SZE (uint32_t)(2*2*16) #elif defined AUDIO_FREQ_11K #define ISOC_BUFFER_SZE (uint32_t)(2*2*11) #elif defined AUDIO_FREQ_8K #define ISOC_BUFFER_SZE (uint32_t)(2*2*8) #endif /*------------------------------------------------------------------------------ Select the number of sub-buffers (even number) The choice of this value depends on the accuracy of the I2S clock and the availabitlity of the RAM space. ------------------------------------------------------------------------------*/ //#define NUM_SUB_BUFFERS 4 /* Min value */ //#define NUM_SUB_BUFFERS 8 //#define NUM_SUB_BUFFERS 16 //#define NUM_SUB_BUFFERS 32 //#define NUM_SUB_BUFFERS 64 #define NUM_SUB_BUFFERS 100 //#define NUM_SUB_BUFFERS 128 //#define NUM_SUB_BUFFERS 200 //#define NUM_SUB_BUFFERS 192 //#define NUM_SUB_BUFFERS 256 //#define NUM_SUB_BUFFERS 300 /*----------------------------------------------------------------------------*/ /* Define for the audio volume output */ #define AUDIO_STREAMING_VOLUME 0xB8 /*-------------------------------------------------------------*/ /* EP_NUM */ /* defines how many endpoints are used by the device */ /*-------------------------------------------------------------*/ #define EP_NUM (2) #ifndef STM32F10X_CL /*-------------------------------------------------------------*/ /* -------------- Buffer Description Table -----------------*/ /*-------------------------------------------------------------*/ /* buffer table base address */ /* buffer table base address */ #define BTABLE_ADDRESS (0x00) /* EP0 */ /* rx/tx buffer base address */ #define ENDP0_RXADDR (0x10) #define ENDP0_TXADDR (0x50) /* EP1 */ /* buffer base address */ #define ENDP1_BUF0Addr (0x90) #define ENDP1_BUF1Addr (0xC0) /*-------------------------------------------------------------*/ /* ------------------- ISTR events -------------------------*/ /*-------------------------------------------------------------*/ /* IMR_MSK */ /* mask defining which events has to be handled */ /* by the device application software */ #define IMR_MSK (CNTR_CTRM | CNTR_SOFM | CNTR_RESETM ) /*#define CTR_CALLBACK*/ /*#define DOVR_CALLBACK*/ /*#define ERR_CALLBACK*/ /*#define WKUP_CALLBACK*/ /*#define SUSP_CALLBACK*/ /*#define RESET_CALLBACK*/ #define SOF_CALLBACK /*#define ESOF_CALLBACK*/ #endif /* STM32F10X_CL */ #ifdef STM32F10X_CL /******************************************************************************* * FIFO Size Configuration * * (i) Dedicated data FIFO SPRAM of 1.25 Kbytes = 1280 bytes = 320 32-bits words * available for the endpoints IN and OUT. * Device mode features: * -1 bidirectional CTRL EP 0 * -3 IN EPs to support any kind of Bulk, Interrupt or Isochronous transfer * -3 OUT EPs to support any kind of Bulk, Interrupt or Isochronous transfer * * ii) Receive data FIFO size = RAM for setup packets + * OUT endpoint control information + * data OUT packets + miscellaneous * Space = ONE 32-bits words * --> RAM for setup packets = 4 * n + 6 space * (n is the nbr of CTRL EPs the device core supports) * --> OUT EP CTRL info = 1 space * (one space for status information written to the FIFO along with each * received packet) * --> data OUT packets = (Largest Packet Size / 4) + 1 spaces * (MINIMUM to receive packets) * --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces * (if high-bandwidth EP is enabled or multiple isochronous EPs) * --> miscellaneous = 1 space per OUT EP * (one space for transfer complete status information also pushed to the * FIFO with each endpoint's last packet) * * (iii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for * that particular IN EP. More space allocated in the IN EP Tx FIFO results * in a better performance on the USB and can hide latencies on the AHB. * * (iv) TXn min size = 16 words. (n : Transmit FIFO index) * (v) When a TxFIFO is not used, the Configuration should be as follows: * case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) * --> Txm can use the space allocated for Txn. * case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) * --> Txn should be configured with the minimum space of 16 words * (vi) The FIFO is used optimally when used TxFIFOs are allocated in the top * of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. *******************************************************************************/ #define RX_FIFO_SIZE 128 #define TX0_FIFO_SIZE 64 #define TX1_FIFO_SIZE 64 #define TX2_FIFO_SIZE 16 #define TX3_FIFO_SIZE 16 /* OTGD-FS-DEVICE IP interrupts Enable definitions */ /* Uncomment the define to enable the selected interrupt */ //#define INTR_MODEMISMATCH #define INTR_SOFINTR #define INTR_RXSTSQLVL /* Mandatory */ //#define INTR_NPTXFEMPTY //#define INTR_GINNAKEFF //#define INTR_GOUTNAKEFF //#define INTR_ERLYSUSPEND #define INTR_USBSUSPEND /* Mandatory */ #define INTR_USBRESET /* Mandatory */ #define INTR_ENUMDONE /* Mandatory */ //#define INTR_ISOOUTDROP //#define INTR_EOPFRAME //#define INTR_EPMISMATCH #define INTR_INEPINTR /* Mandatory */ #define INTR_OUTEPINTR /* Mandatory */ //#define INTR_INCOMPLISOIN //#define INTR_INCOMPLISOOUT #define INTR_WKUPINTR /* Mandatory */ /* OTGD-FS-DEVICE IP interrupts subroutines */ /* Comment the define to enable the selected interrupt subroutine and replace it by user code */ #define INTR_MODEMISMATCH_Callback NOP_Process /* #define INTR_SOFINTR_Callback NOP_Process */ #define INTR_RXSTSQLVL_Callback NOP_Process #define INTR_NPTXFEMPTY_Callback NOP_Process #define INTR_NPTXFEMPTY_Callback NOP_Process #define INTR_GINNAKEFF_Callback NOP_Process #define INTR_GOUTNAKEFF_Callback NOP_Process #define INTR_ERLYSUSPEND_Callback NOP_Process #define INTR_USBSUSPEND_Callback NOP_Process #define INTR_USBRESET_Callback NOP_Process #define INTR_ENUMDONE_Callback NOP_Process #define INTR_ISOOUTDROP_Callback NOP_Process #define INTR_EOPFRAME_Callback NOP_Process #define INTR_EPMISMATCH_Callback NOP_Process #define INTR_INEPINTR_Callback NOP_Process #define INTR_OUTEPINTR_Callback NOP_Process #define INTR_INCOMPLISOIN_Callback NOP_Process #define INTR_INCOMPLISOOUT_Callback NOP_Process #define INTR_WKUPINTR_Callback NOP_Process /* Isochronous data update */ /* #define INTR_RXSTSQLVL_ISODU_Callback NOP_Process */ #endif /* STM32F10X_CL */ /* CTR service routines */ /* associated to defined endpoints */ #define EP1_IN_Callback NOP_Process #define EP2_IN_Callback NOP_Process #define EP3_IN_Callback NOP_Process #define EP4_IN_Callback NOP_Process #define EP5_IN_Callback NOP_Process #define EP6_IN_Callback NOP_Process #define EP7_IN_Callback NOP_Process /*#define EP1_OUT_Callback NOP_Process*/ #define EP2_OUT_Callback NOP_Process #define EP3_OUT_Callback NOP_Process #define EP4_OUT_Callback NOP_Process #define EP5_OUT_Callback NOP_Process #define EP6_OUT_Callback NOP_Process #define EP7_OUT_Callback NOP_Process #endif /* __USB_CONF_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/inc/usb_conf.h
C
asf20
10,874
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_endp.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Endpoint routines ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_lib.h" #include "usb_istr.h" #include "audio_codec_cs43l22.h" #include "hw_config.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define SPI2_DR_Address 0x4000380C #ifdef AUDIO_FREQ_96K #define EDP1_BUFFER_SZE 384 #elif defined (AUDIO_FREQ_48K) #define EDP1_BUFFER_SZE 192 #elif defined (AUDIO_FREQ_44K) #define EDP1_BUFFER_SZE 176 #elif defined (AUDIO_FREQ_32K) #define EDP1_BUFFER_SZE 128 #elif defined (AUDIO_FREQ_22K) #define EDP1_BUFFER_SZE 88 #elif defined (AUDIO_FREQ_16K) #define EDP1_BUFFER_SZE 64 #elif defined (AUDIO_FREQ_11K) #define EDP1_BUFFER_SZE 44 #elif defined (AUDIO_FREQ_8K) #define EDP1_BUFFER_SZE 32 #endif /* AUDIO_FREQ_96K */ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ #ifdef USE_STM3210C_EVAL static USB_OTG_EP *ep; #endif /* USE_STM3210C_EVAL */ /* Extern variables ----------------------------------------------------------*/ extern uint8_t IsocBuff []; extern __IO uint32_t IsocBufferIdx; /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : EP1_OUT_Callback * Description : Endpoint 1 out callback routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void EP1_OUT_Callback(void) { DMA_InitTypeDef DMA_InitStructure; #ifdef USE_STM3210C_EVAL /* Get the Endpoint descriptor pointer */ ep = PCD_GetOutEP(ENDP1 & 0x7F); /* Enable the Endppoint transfer (since the the Read Endpoint function is not called) */ OTGD_FS_EPStartXfer(ep); /* Toggle the data PID */ if (ep->even_odd_frame != 0) { ep->even_odd_frame = 0; } else { ep->even_odd_frame = 1; } /* If Half of global buffer has been filled and DMA is still not enabled, Re-configure the DMA and unMute the codec */ #if (NUM_SUB_BUFFERS == 2) if (((DMA1_Channel5->CCR & 0x1) == 0) && (IsocBufferIdx == 1)) #else if (((DMA1_Channel5->CCR & 0x1) == 0) && (IsocBufferIdx == ((NUM_SUB_BUFFERS / 2) - 1))) #endif /* NUM_SUB_BUFFERS */ { /* Disable the mute mode */ CODEC_Mute(MUTE_OFF); /* Disable the I2S before starting configuration to avoid sporious transfer */ SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, DISABLE); I2S_Cmd(SPI2, DISABLE); /* Initialize the DMA1 Channel5 to its default values */ DMA_DeInit(DMA1_Channel5); /* Configure the DMA parameters */ DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)((uint16_t*)IsocBuff); DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)SPI2_DR_Address; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_BufferSize = (ISOC_BUFFER_SZE * NUM_SUB_BUFFERS) / 2; /* Divided by 2 because USB data are 8 bit and I2S buffer is 16 bit */ DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel5, &DMA_InitStructure); } #endif /* USE_STM3210C_EVAL */ } /******************************************************************************* * Function Name : INTR_RXSTSQLVL_ISODU_Callback * Description : Rx FIFO Status Queue Level, Data Update interrupt callback routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void INTR_RXSTSQLVL_ISODU_Callback(void) { /* Check if the USB transfe has reached the half of the global buffer */ if(IsocBufferIdx == (NUM_SUB_BUFFERS / 2)) { /* Check if the DMA is already enabled or not */ if ((DMA1_Channel5->CCR & 0x1) == 0x0) { /* Re-Initialize the number of data to be transferred */ DMA1_Channel5->CNDTR = (uint16_t)((ISOC_BUFFER_SZE * NUM_SUB_BUFFERS) / 2); /* Enable DMA1 Channel5 */ DMA_Cmd(DMA1_Channel5, ENABLE); /* Enable I2S DMA request for TX */ SPI_I2S_DMACmd(SPI2, SPI_I2S_DMAReq_Tx, ENABLE); /* Enable the I2S cell */ I2S_Cmd(SPI2, ENABLE); } /* Wait till the TC flag is ON (direct register access to optimize time) */ while (((DMA1->ISR & (uint32_t)0x00020000) == 0)) {} /* Clear All DMA1 channel 5 flags */ DMA_ClearFlag(DMA1_FLAG_GL5); } } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/src/usb_endp.c
C
asf20
6,320
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_istr.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : ISTR events interrupt service routines ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_lib.h" #include "usb_prop.h" #include "usb_pwr.h" #include "usb_istr.h" #include "audio_codec_cs43l22.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ __IO uint16_t wIstr; /* ISTR register last read value */ __IO uint8_t bIntPackSOF = 0; /* SOFs received between 2 consecutive packets */ uint32_t PrevFrame; /* Extern variables ----------------------------------------------------------*/ extern __IO uint32_t IsocBufferIdx; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /* function pointers to non-control endpoints service routines */ void (*pEpInt_IN[7])(void) = { EP1_IN_Callback, EP2_IN_Callback, EP3_IN_Callback, EP4_IN_Callback, EP5_IN_Callback, EP6_IN_Callback, EP7_IN_Callback, }; void (*pEpInt_OUT[7])(void) = { EP1_OUT_Callback, EP2_OUT_Callback, EP3_OUT_Callback, EP4_OUT_Callback, EP5_OUT_Callback, EP6_OUT_Callback, EP7_OUT_Callback, }; #ifndef STM32F10X_CL /******************************************************************************* * Function Name : USB_Istr * Description : STR events interrupt service routine * Input : * Output : * Return : *******************************************************************************/ void USB_Istr(void) { wIstr = _GetISTR(); #if (IMR_MSK & ISTR_CTR) if (wIstr & ISTR_CTR & wInterrupt_Mask) { /* servicing of the endpoint correct transfer interrupt */ /* clear of the CTR flag into the sub */ CTR_LP(); #ifdef CTR_CALLBACK CTR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_RESET) if (wIstr & ISTR_RESET & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_RESET); Device_Property.Reset(); #ifdef RESET_CALLBACK RESET_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_DOVR) if (wIstr & ISTR_DOVR & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_DOVR); #ifdef DOVR_CALLBACK DOVR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_ERR) if (wIstr & ISTR_ERR & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_ERR); #ifdef ERR_CALLBACK ERR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_WKUP) if (wIstr & ISTR_WKUP & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_WKUP); Resume(RESUME_EXTERNAL); #ifdef WKUP_CALLBACK WKUP_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_SUSP) if (wIstr & ISTR_SUSP & wInterrupt_Mask) { /* check if SUSPEND is possible */ if (fSuspendEnabled) { Suspend(); } else { /* if not possible then resume after xx ms */ Resume(RESUME_LATER); } /* clear of the ISTR bit must be done after setting of CNTR_FSUSP */ _SetISTR((uint16_t)CLR_SUSP); #ifdef SUSP_CALLBACK SUSP_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_SOF) if (wIstr & ISTR_SOF & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_SOF); bIntPackSOF++; #ifdef SOF_CALLBACK SOF_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_ESOF) if (wIstr & ISTR_ESOF & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_ESOF); /* resume handling timing is made with ESOFs */ Resume(RESUME_ESOF); /* request without change of the machine state */ #ifdef ESOF_CALLBACK ESOF_Callback(); #endif } #endif } /* USB_Istr */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #else /* STM32F10X_CL */ /******************************************************************************* * Function Name : STM32_PCD_OTG_ISR_Handler * Description : Handles all USB Device Interrupts * Input : None * Output : None * Return : status *******************************************************************************/ uint32_t STM32_PCD_OTG_ISR_Handler (void) { USB_OTG_GINTSTS_TypeDef gintr_status; u32 retval = 0; if (USBD_FS_IsDeviceMode()) /* ensure that we are in device mode */ { gintr_status.d32 = OTGD_FS_ReadCoreItr(); /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* If there is no interrupt pending exit the interrupt routine */ if (!gintr_status.d32) { return 0; } /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Early Suspend interrupt */ #ifdef INTR_ERLYSUSPEND if (gintr_status.b.erlysuspend) { retval |= OTGD_FS_Handle_EarlySuspend_ISR(); } #endif /* INTR_ERLYSUSPEND */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* End of Periodic Frame interrupt */ #ifdef INTR_EOPFRAME if (gintr_status.b.eopframe) { retval |= OTGD_FS_Handle_EOPF_ISR(); } #endif /* INTR_EOPFRAME */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Non Periodic Tx FIFO Emty interrupt */ #ifdef INTR_NPTXFEMPTY if (gintr_status.b.nptxfempty) { retval |= OTGD_FS_Handle_NPTxFE_ISR(); } #endif /* INTR_NPTXFEMPTY */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Wakeup or RemoteWakeup interrupt */ #ifdef INTR_WKUPINTR if (gintr_status.b.wkupintr) { retval |= OTGD_FS_Handle_Wakeup_ISR(); } #endif /* INTR_WKUPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Suspend interrupt */ #ifdef INTR_USBSUSPEND if (gintr_status.b.usbsuspend) { /* check if SUSPEND is possible */ if (fSuspendEnabled) { Suspend(); } else { /* if not possible then resume after xx ms */ Resume(RESUME_LATER); /* This case shouldn't happen in OTG Device mode because there's no ESOF interrupt to increment the ResumeS.bESOFcnt in the Resume state machine */ } retval |= OTGD_FS_Handle_USBSuspend_ISR(); } #endif /* INTR_USBSUSPEND */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Start of Frame interrupt */ #ifdef INTR_SOFINTR if (gintr_status.b.sofintr) { /* Update the frame number variable */ bIntPackSOF++; retval |= OTGD_FS_Handle_Sof_ISR(); } #endif /* INTR_SOFINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Receive FIFO Queue Status Level interrupt */ #ifdef INTR_RXSTSQLVL if (gintr_status.b.rxstsqlvl) { retval |= OTGD_FS_Handle_RxStatusQueueLevel_ISR(); } #endif /* INTR_RXSTSQLVL */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Enumeration Done interrupt */ #ifdef INTR_ENUMDONE if (gintr_status.b.enumdone) { retval |= OTGD_FS_Handle_EnumDone_ISR(); } #endif /* INTR_ENUMDONE */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Reset interrutp */ #ifdef INTR_USBRESET if (gintr_status.b.usbreset) { retval |= OTGD_FS_Handle_UsbReset_ISR(); } #endif /* INTR_USBRESET */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* IN Endpoint interrupt */ #ifdef INTR_INEPINTR if (gintr_status.b.inepint) { retval |= OTGD_FS_Handle_InEP_ISR(); } #endif /* INTR_INEPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* OUT Endpoint interrupt */ #ifdef INTR_OUTEPINTR if (gintr_status.b.outepintr) { retval |= OTGD_FS_Handle_OutEP_ISR(); } #endif /* INTR_OUTEPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Mode Mismatch interrupt */ #ifdef INTR_MODEMISMATCH if (gintr_status.b.modemismatch) { retval |= OTGD_FS_Handle_ModeMismatch_ISR(); } #endif /* INTR_MODEMISMATCH */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Global IN Endpoints NAK Effective interrupt */ #ifdef INTR_GINNAKEFF if (gintr_status.b.ginnakeff) { retval |= OTGD_FS_Handle_GInNakEff_ISR(); } #endif /* INTR_GINNAKEFF */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Global OUT Endpoints NAK effective interrupt */ #ifdef INTR_GOUTNAKEFF if (gintr_status.b.goutnakeff) { retval |= OTGD_FS_Handle_GOutNakEff_ISR(); } #endif /* INTR_GOUTNAKEFF */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Isochrounous Out packet Dropped interrupt */ #ifdef INTR_ISOOUTDROP if (gintr_status.b.isooutdrop) { retval |= OTGD_FS_Handle_IsoOutDrop_ISR(); } #endif /* INTR_ISOOUTDROP */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Endpoint Mismatch error interrupt */ #ifdef INTR_EPMISMATCH if (gintr_status.b.epmismatch) { retval |= OTGD_FS_Handle_EPMismatch_ISR(); } #endif /* INTR_EPMISMATCH */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Incomplete Isochrous IN tranfer error interrupt */ #ifdef INTR_INCOMPLISOIN if (gintr_status.b.incomplisoin) { retval |= OTGD_FS_Handle_IncomplIsoIn_ISR(); } #endif /* INTR_INCOMPLISOIN */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Incomplete Isochrous OUT tranfer error interrupt */ #ifdef INTR_INCOMPLISOOUT if (gintr_status.b.outepintr) { retval |= OTGD_FS_Handle_IncomplIsoOut_ISR(); } #endif /* INTR_INCOMPLISOOUT */ } return retval; } #endif /* STM32F10X_CL */ /******************************************************************************* * Function Name : INTR_SOFINTR_Callback * Description : Start of frame callback function. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void INTR_SOFINTR_Callback(void) { static __IO uint32_t EmptyFrameCounter = 0; /* If frame hasn't changed and the DMA is enabled */ if (IsocBufferIdx == PrevFrame) { /* Empty packet state */ EmptyFrameCounter++; } else { /* Update status */ PrevFrame = IsocBufferIdx; /* Streaming Active state */ EmptyFrameCounter = 0; } /* Stream Inactive state */ if (EmptyFrameCounter == 5) { /* Mute the audio codec to avoid sporious noise */ CODEC_Mute(MUTE_ON); /* Disable the I2S and the DMA request */ SPI_I2S_DMACmd(SPI2, SPI_I2S_DMAReq_Tx, DISABLE); I2S_Cmd(SPI2, DISABLE); /* Disable the DMA channel and clear all its flags*/ DMA1_Channel5->CCR &= 0xFFFFFFFE; DMA_ClearFlag(DMA1_FLAG_GL5); /* Enable the I2S interrupt to continue generating the clocks for the audio codec otherwise there will be a noise on the line when no file is played */ SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, ENABLE); I2S_Cmd(SPI2, ENABLE); /* Reset counters */ IsocBufferIdx = 0; PrevFrame = 0; /* Idle state */ EmptyFrameCounter ++; } } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/src/usb_istr.c
C
asf20
13,389
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : main.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Audio Speaker Demo main file ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "usb_lib.h" #include "usb_desc.h" #include "hw_config.h" #include "usb_prop.h" #include "stm32_eval.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : main. * Description : Main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { Set_System(); Speaker_Config(); Set_USBClock(); USB_Config(); USB_Init(); /* Configure Leds for toggling: If Leds are not toggling, try to power off then on the avaluation board */ STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); while (1) { uint32_t Counter = 0; STM_EVAL_LEDToggle(LED2); while (Counter++ < 0x100000); Counter = 0; STM_EVAL_LEDToggle(LED3); while (Counter++ < 0x100000); Counter = 0; } } #ifdef USE_FULL_ASSERT /******************************************************************************* * Function Name : assert_failed * Description : Reports the name of the source file and the source line number * where the assert_param error has occurred. * Input : - file: pointer to the source file name * - line: assert_param error line source number * Output : None * Return : None *******************************************************************************/ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) {} } #endif /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/src/main.c
C
asf20
3,426
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : hw_config.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Hardware Configuration & Setup ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x_it.h" #include "usb_lib.h" #include "usb_prop.h" #include "usb_desc.h" #include "hw_config.h" #include "platform_config.h" #include "usb_pwr.h" #include "audio_codec_cs43l22.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static void I2S_Config(void); static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len); /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : Set_System * Description : Configures Main system clocks & power * Input : None. * Return : None. *******************************************************************************/ void Set_System(void) { /* At this level the function SytemInit() is already called at deivce startup and all clocks have been correctly configured */ } /******************************************************************************* * Function Name : Set_USBClock * Description : Configures USB Clock input (48MHz) * Input : None. * Return : None. *******************************************************************************/ void Set_USBClock(void) { #ifdef STM32F10X_CL /* Select USBCLK source */ RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3); /* Enable the USB clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE) ; #else /* Select USBCLK source */ RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5); /* Enable the USB clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE); #endif /* STM32F10X_CL */ } /******************************************************************************* * Function Name : Enter_LowPowerMode * Description : Power-off system clocks and power while entering suspend mode * Input : None. * Return : None. *******************************************************************************/ void Enter_LowPowerMode(void) { /* Set the device state to suspend */ bDeviceState = SUSPENDED; } /******************************************************************************* * Function Name : Leave_LowPowerMode * Description : Restores system clocks and power while exiting suspend mode * Input : None. * Return : None. *******************************************************************************/ void Leave_LowPowerMode(void) { DEVICE_INFO *pInfo = &Device_Info; /* Set the device state to the correct state */ if (pInfo->Current_Configuration != 0) { /* Device configured */ bDeviceState = CONFIGURED; } else { bDeviceState = ATTACHED; } } /******************************************************************************* * Function Name : USB_Interrupts_Config * Description : Configures the USB interrupts * Input : None. * Return : None. *******************************************************************************/ void USB_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; /* 2 bit for pre-emption priority, 2 bits for subpriority */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); #ifdef STM32F10X_CL /* Enable the USB Interrupts */ NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); #endif /* STM32F10X_CL */ /* Configure the audio application interrupts */ Audio_Interrupts_Config(); } /******************************************************************************* * Function Name : Audio_Interrupts_Config * Description : Configures the Audio related interrupts * Input : None. * Return : None. *******************************************************************************/ void Audio_Interrupts_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; #ifdef USE_STM3210C_EVAL /* SPI2 IRQ Channel configuration */ NVIC_InitStructure.NVIC_IRQChannel = SPI2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); #endif /* USE_STM3210C_EVAL */ } /******************************************************************************* * Function Name : USB_Cable_Config * Description : Software Connection/Disconnection of USB Cable * Input : None. * Return : Status *******************************************************************************/ void USB_Cable_Config (FunctionalState NewState) { #ifdef USE_STM3210C_EVAL if (NewState != DISABLE) { USB_DevConnect(); } else { USB_DevDisconnect(); } #else /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ if (NewState != DISABLE) { GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN); } else { GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN); } #endif /* USE_STM3210C_EVAL */ } /******************************************************************************* * Function Name : Speaker_Config * Description : Configure and enable the I2S and the codec * Input : None. * Return : None. *******************************************************************************/ void Speaker_Config(void) { /* Configure the I2S peripheral */ I2S_Config(); /* Configure the initializatin parameters */ CODEC_Config(OutputDevice_AUTO, I2S_Standard_Phillips, I2S_MCLKOutput_Enable, AUDIO_STREAMING_VOLUME); /* Enable the DMA Clock for I2S transfers */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); } /******************************************************************************* * Function Name : I2S_Config * Description : Initializes the I2S peripheral. * Input : None * Output : None * Return : None *******************************************************************************/ static void I2S_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; I2S_InitTypeDef I2S_InitStructure; /* Enable GPIOB, GPIOC and AFIO clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE); /* I2S2 SD, CK and WS pins configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_15; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOB, &GPIO_InitStructure); /* I2S2 MCK pin configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_Init(GPIOC, &GPIO_InitStructure); /* Enable I2S2 APB1 clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); /* Deinitialize SPI2 peripheral */ SPI_I2S_DeInit(SPI2); /* I2S2 peripheral configuration */ I2S_InitStructure.I2S_Mode = I2S_Mode_MasterTx; I2S_InitStructure.I2S_Standard = I2S_Standard_Phillips; I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_16b; I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Enable; #ifdef AUDIO_FREQ_96K I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_96k; #elif defined (AUDIO_FREQ_48K) I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_48k; #elif defined (AUDIO_FREQ_44K) I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_44k; #elif defined (AUDIO_FREQ_32K) I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_32k; #elif defined (AUDIO_FREQ_22K) I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_22k; #elif defined (AUDIO_FREQ_16K) I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_16k; #elif defined (AUDIO_FREQ_11K) I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_11k; #elif defined (AUDIO_FREQ_8K) I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_8k; #endif /* AUDIO_FREQ_96K */ I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low; I2S_Init(SPI2, &I2S_InitStructure); /* Enable the SPI2/I2S2 peripheral */ I2S_Cmd(SPI2, ENABLE); } /******************************************************************************* * Function Name : Get_SerialNum. * Description : Create the serial number string descriptor. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Get_SerialNum(void) { uint32_t Device_Serial0, Device_Serial1, Device_Serial2; Device_Serial0 = *(__IO uint32_t*)(0x1FFFF7E8); Device_Serial1 = *(__IO uint32_t*)(0x1FFFF7EC); Device_Serial2 = *(__IO uint32_t*)(0x1FFFF7F0); Device_Serial0 += Device_Serial2; if (Device_Serial0 != 0) { IntToUnicode (Device_Serial0, &Speaker_StringSerial[2] , 8); IntToUnicode (Device_Serial1, &Speaker_StringSerial[18], 4); } } /******************************************************************************* * Function Name : HexToChar. * Description : Convert Hex 32Bits value into char. * Input : None. * Output : None. * Return : None. *******************************************************************************/ static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len) { uint8_t idx = 0; for( idx = 0 ; idx < len ; idx ++) { if( ((value >> 28)) < 0xA ) { pbuf[ 2* idx] = (value >> 28) + '0'; } else { pbuf[2* idx] = (value >> 28) + 'A' - 10; } value = value << 4; pbuf[ 2* idx + 1] = 0; } } #ifdef STM32F10X_CL /******************************************************************************* * Function Name : USB_OTG_BSP_uDelay. * Description : provide delay (usec). * Input : None. * Output : None. * Return : None. *******************************************************************************/ void USB_OTG_BSP_uDelay (const uint32_t usec) { RCC_ClocksTypeDef RCC_Clocks; /* Configure HCLK clock as SysTick clock source */ SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(usec * (RCC_Clocks.HCLK_Frequency / 1000000)); SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk ; while (!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)); } #endif /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/src/hw_config.c
C
asf20
11,979
/** ****************************************************************************** * @file system_stm32f10x.c * @author MCD Application Team * @version V3.3.0 * @date 04/16/2010 * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. * This file has been modified for the Audio Streaming demo. ****************************************************************************** * * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. * * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2> ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f10x_system * @{ */ /** @addtogroup STM32F10x_System_Private_Includes * @{ */ #include "stm32f10x.h" /** * @} */ /** @addtogroup STM32F10x_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F10x_System_Private_Defines * @{ */ /*!< Uncomment the line corresponding to the desired System clock (SYSCLK) frequency (after reset the HSI is used as SYSCLK source) IMPORTANT NOTE: ============== 1. After each device reset the HSI is used as System clock source. 2. Please make sure that the selected System clock doesn't exceed your device's maximum frequency. 3. If none of the define below is enabled, the HSI is used as System clock source. 4. The System clock configuration functions provided within this file assume that: - For Low and Medium density Value line devices an external 8MHz crystal is used to drive the System clock. - For Low, Medium and High density devices an external 8MHz crystal is used to drive the System clock. - For Connectivity line devices an external 25MHz crystal is used to drive the System clock. If you are using different crystal you have to adapt those functions accordingly. */ #if defined (STM32F10X_LD_VL) || (defined STM32F10X_MD_VL) /* #define SYSCLK_FREQ_HSE HSE_Value */ #define SYSCLK_FREQ_24MHz 24000000 #else /* #define SYSCLK_FREQ_HSE HSE_Value */ /* #define SYSCLK_FREQ_24MHz 24000000 */ /* #define SYSCLK_FREQ_36MHz 36000000 */ /* #define SYSCLK_FREQ_48MHz 48000000 */ /* #define SYSCLK_FREQ_56MHz 56000000 */ /* #define SYSCLK_FREQ_72MHz 72000000 */ #endif /*!< Uncomment the following line if you need to use external SRAM mounted on STM3210E-EVAL board (STM32 High density and XL-density devices) as data memory */ #if defined (STM32F10X_HD) || (defined STM32F10X_XL) /* #define DATA_IN_ExtSRAM */ #endif /** * @} */ /** @addtogroup STM32F10x_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F10x_System_Private_Variables * @{ */ /******************************************************************************* * Clock Definitions *******************************************************************************/ #ifdef SYSCLK_FREQ_HSE uint32_t SystemCoreClock = SYSCLK_FREQ_HSE; /*!< System Clock Frequency (Core Clock) */ #elif defined SYSCLK_FREQ_24MHz uint32_t SystemCoreClock = SYSCLK_FREQ_24MHz; /*!< System Clock Frequency (Core Clock) */ #elif defined SYSCLK_FREQ_36MHz uint32_t SystemCoreClock = SYSCLK_FREQ_36MHz; /*!< System Clock Frequency (Core Clock) */ #elif defined SYSCLK_FREQ_48MHz uint32_t SystemCoreClock = SYSCLK_FREQ_48MHz; /*!< System Clock Frequency (Core Clock) */ #elif defined SYSCLK_FREQ_56MHz uint32_t SystemCoreClock = SYSCLK_FREQ_56MHz; /*!< System Clock Frequency (Core Clock) */ #elif defined SYSCLK_FREQ_72MHz uint32_t SystemCoreClock = SYSCLK_FREQ_72MHz; /*!< System Clock Frequency (Core Clock) */ #else /*!< HSI Selected as System Clock source */ uint32_t SystemCoreClock = HSI_Value; /*!< System Clock Frequency (Core Clock) */ #endif __I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; ErrorStatus HSEStartUpStatus; /** * @} */ /** @addtogroup STM32F10x_System_Private_FunctionPrototypes * @{ */ /** * @} */ /** @addtogroup STM32F10x_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/ /* RCC system reset */ RCC_DeInit(); /* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON); /* Wait till HSE is ready */ HSEStartUpStatus = RCC_WaitForHSEStartUp(); if (HSEStartUpStatus == SUCCESS) { /* Enable Prefetch Buffer */ FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); /* Flash 2 wait state */ FLASH_SetLatency(FLASH_Latency_2); /* HCLK = SYSCLK */ RCC_HCLKConfig(RCC_SYSCLK_Div1); /* PCLK2 = HCLK */ RCC_PCLK2Config(RCC_HCLK_Div1); /* PCLK1 = HCLK/2 */ RCC_PCLK1Config(RCC_HCLK_Div2); #ifdef STM32F10X_CL /* Configure PLLs *********************************************************/ #ifdef EXTERNAL_CRYSTAL_25MHz /* PLL2 configuration: PLL2CLK = (HSE / 9) * 13 = 36.111 MHz */ RCC_PREDIV2Config(RCC_PREDIV2_Div9); RCC_PLL2Config(RCC_PLL2Mul_13); /* Enable PLL2 */ RCC_PLL2Cmd(ENABLE); /* Wait till PLL2 is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET) {} /* PPL3 configuration: PLL3CLK = (HSE / 9) * 14 = PLL3_VCO = 77.777 MHz */ RCC_PLL3Config(RCC_PLL3Mul_14); /* Enable PLL3 */ RCC_PLL3Cmd(ENABLE); /* Wait till PLL3 is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLL3RDY) == RESET) {} /* PLL configuration: PLLCLK = (PLL2 / 4) * 8 = 72.222 MHz */ RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div4); RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_8); #elif defined (EXTERNAL_CRYSTAL_14_7456MHz) /* PLL2 configuration: PLL2CLK = (HSE / 4) * 13 = 47.932 MHz */ RCC_PREDIV2Config(RCC_PREDIV2_Div4); RCC_PLL2Config(RCC_PLL2Mul_13); /* Enable PLL2 */ RCC_PLL2Cmd(ENABLE); /* Wait till PLL2 is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET) {} /* PPL3 configuration: PLL3CLK = (HSE / 4) * 20 = PLL3_VCO = 147.456 MHz */ RCC_PLL3Config(RCC_PLL3Mul_20); /* Enable PLL3 */ RCC_PLL3Cmd(ENABLE); /* Wait till PLL3 is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLL3RDY) == RESET) {} /* PPL1 configuration: PLL1CLK = (PLL2 / 4) * 6 = 71.8848 MHz */ RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div4); RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_6); #endif /* EXTERNAL_CRYSTAL_25MHz */ /* Configure I2S clock source: PLL3 VCO clock */ RCC_I2S2CLKConfig(RCC_I2S2CLKSource_PLL3_VCO); #else /* PLLCLK = 8MHz * 9 = 72 MHz */ RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); #endif /* STM32F10X_CL */ /* Enable PLL */ RCC_PLLCmd(ENABLE); /* Wait till PLL is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) { } /* Select PLL as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); /* Wait till PLL is used as system clock source */ while(RCC_GetSYSCLKSource() != 0x08) { } } else { /* If HSE fails to start-up, the application will have wrong clock configuration. User can add here some code to deal with this error */ /* Go to infinite loop */ while (1) { } } } /** * @brief Update SystemCoreClock according to Clock Register Values * @note None * @param None * @retval None */ void SystemCoreClockUpdate (void) { uint32_t tmp = 0, pllmull = 0, pllsource = 0; #ifdef STM32F10X_CL uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; #endif /* STM32F10X_CL */ #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) uint32_t prediv1factor = 0; #endif /* STM32F10X_LD_VL or STM32F10X_MD_VL */ /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock */ SystemCoreClock = HSI_Value; break; case 0x04: /* HSE used as system clock */ SystemCoreClock = HSE_Value; break; case 0x08: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; #ifndef STM32F10X_CL pllmull = ( pllmull >> 18) + 2; if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_Value >> 1) * pllmull; } else { #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_Value / prediv1factor) * pllmull; #else /* HSE selected as PLL clock entry */ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) {/* HSE oscillator clock divided by 2 */ SystemCoreClock = (HSE_Value >> 1) * pllmull; } else { SystemCoreClock = HSE_Value * pllmull; } #endif } #else pllmull = pllmull >> 18; if (pllmull != 0x0D) { pllmull += 2; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13 / 2; } if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_Value >> 1) * pllmull; } else {/* PREDIV1 selected as PLL clock entry */ /* Get PREDIV1 clock source and division factor */ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; if (prediv1source == 0) { /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_Value / prediv1factor) * pllmull; } else {/* PLL2 clock selected as PREDIV1 clock entry */ /* Get PREDIV2 division factor and PLL2 multiplication factor */ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; SystemCoreClock = (((HSE_Value / prediv2factor) * pll2mull) / prediv1factor) * pllmull; } } #endif /* STM32F10X_CL */ break; default: SystemCoreClock = HSI_Value; break; } /* Compute HCLK clock frequency ----------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK clock frequency */ SystemCoreClock >>= tmp; } /** * @} */ /** * @} */ /** * @} */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/src/system_stm32f10x.c
C
asf20
12,220
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : stm32f10x_it.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Main Interrupt Service Routines. * This file provides template for all exceptions handler * and peripherals interrupt service routine. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x_it.h" #include "usb_lib.h" #include "usb_istr.h" #include "hw_config.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define DUMMYDATA 0x1111 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /******************************************************************************* * Function Name : NMI_Handler * Description : This function handles NMI exception. * Input : None * Output : None * Return : None *******************************************************************************/ void NMI_Handler(void) { } /******************************************************************************* * Function Name : HardFault_Handler * Description : This function handles Hard Fault exception. * Input : None * Output : None * Return : None *******************************************************************************/ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /******************************************************************************* * Function Name : MemManage_Handler * Description : This function handles Memory Manage exception. * Input : None * Output : None * Return : None *******************************************************************************/ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /******************************************************************************* * Function Name : BusFault_Handler * Description : This function handles Bus Fault exception. * Input : None * Output : None * Return : None *******************************************************************************/ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /******************************************************************************* * Function Name : UsageFault_Handler * Description : This function handles Usage Fault exception. * Input : None * Output : None * Return : None *******************************************************************************/ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /******************************************************************************* * Function Name : SVC_Handler * Description : This function handles SVCall exception. * Input : None * Output : None * Return : None *******************************************************************************/ void SVC_Handler(void) { } /******************************************************************************* * Function Name : DebugMon_Handler * Description : This function handles Debug Monitor exception. * Input : None * Output : None * Return : None *******************************************************************************/ void DebugMon_Handler(void) { } /******************************************************************************* * Function Name : PendSV_Handler * Description : This function handles PendSVC exception. * Input : None * Output : None * Return : None *******************************************************************************/ void PendSV_Handler(void) { } /******************************************************************************* * Function Name : SysTick_Handler * Description : This function handles SysTick Handler. * Input : None * Output : None * Return : None *******************************************************************************/ void SysTick_Handler(void) { } /******************************************************************************/ /* STM32F10x Peripherals Interrupt Handlers */ /******************************************************************************/ /******************************************************************************* * Function Name : SPI2_IRQHandler * Description : This function handles SPI2 global interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ void SPI2_IRQHandler(void) { /* Proceed for the I2S TXE interrupt */ if ((SPI_I2S_GetITStatus(SPI2, SPI_I2S_IT_TXE) == SET)) { SPI_I2S_SendData(SPI2, DUMMYDATA); } } #ifdef STM32F10X_CL /******************************************************************************* * Function Name : OTG_FS_IRQHandler * Description : This function handles USB-On-The-Go FS global interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ void OTG_FS_IRQHandler(void) { STM32_PCD_OTG_ISR_Handler(); } #endif /* STM32F10X_CL */ /******************************************************************************/ /* STM32F10x Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f10x_xx.s). */ /******************************************************************************/ /******************************************************************************* * Function Name : PPP_IRQHandler * Description : This function handles PPP interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ /*void PPP_IRQHandler(void) { }*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/src/stm32f10x_it.c
C
asf20
7,938
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_pwr.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Connection/disconnection & power management ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "usb_lib.h" #include "usb_conf.h" #include "usb_pwr.h" #include "hw_config.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ __IO uint32_t bDeviceState = UNCONNECTED; /* USB device status */ __IO bool fSuspendEnabled = TRUE; /* true when suspend is possible */ struct { __IO RESUME_STATE eState; __IO uint8_t bESOFcnt; }ResumeS; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : PowerOn * Description : * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ RESULT PowerOn(void) { #ifndef STM32F10X_CL uint16_t wRegVal; /*** cable plugged-in ? ***/ USB_Cable_Config(ENABLE); /*** CNTR_PWDN = 0 ***/ wRegVal = CNTR_FRES; _SetCNTR(wRegVal); /*** CNTR_FRES = 0 ***/ wInterrupt_Mask = 0; _SetCNTR(wInterrupt_Mask); /*** Clear pending interrupts ***/ _SetISTR(0); /*** Set interrupt mask ***/ wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM; _SetCNTR(wInterrupt_Mask); #endif /* STM32F10X_CL */ return USB_SUCCESS; } /******************************************************************************* * Function Name : PowerOff * Description : handles switch-off conditions * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ RESULT PowerOff() { #ifndef STM32F10X_CL /* disable all ints and force USB reset */ _SetCNTR(CNTR_FRES); /* clear interrupt status register */ _SetISTR(0); /* Disable the Pull-Up*/ USB_Cable_Config(DISABLE); /* switch-off device */ _SetCNTR(CNTR_FRES + CNTR_PDWN); #endif /* STM32F10X_CL */ /* sw variables reset */ /* ... */ return USB_SUCCESS; } /******************************************************************************* * Function Name : Suspend * Description : sets suspend mode operating conditions * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ void Suspend(void) { #ifndef STM32F10X_CL uint16_t wCNTR; /* suspend preparation */ /* ... */ /* macrocell enters suspend mode */ wCNTR = _GetCNTR(); wCNTR |= CNTR_FSUSP; _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */ /* power reduction */ /* ... on connected devices */ #ifndef STM32F10X_CL /* force low-power mode in the macrocell */ wCNTR = _GetCNTR(); wCNTR |= CNTR_LPMODE; _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ /* switch-off the clocks */ /* ... */ Enter_LowPowerMode(); } /******************************************************************************* * Function Name : Resume_Init * Description : Handles wake-up restoring normal operations * Input : None. * Output : None. * Return : USB_SUCCESS. *******************************************************************************/ void Resume_Init(void) { #ifndef STM32F10X_CL uint16_t wCNTR; #endif /* STM32F10X_CL */ /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */ /* restart the clocks */ /* ... */ #ifndef STM32F10X_CL /* CNTR_LPMODE = 0 */ wCNTR = _GetCNTR(); wCNTR &= (~CNTR_LPMODE); _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ /* restore full power */ /* ... on connected devices */ Leave_LowPowerMode(); #ifndef STM32F10X_CL /* reset FSUSP bit */ _SetCNTR(IMR_MSK); #endif /* STM32F10X_CL */ /* reverse suspend preparation */ /* ... */ } /******************************************************************************* * Function Name : Resume * Description : This is the state machine handling resume operations and * timing sequence. The control is based on the Resume structure * variables and on the ESOF interrupt calling this subroutine * without changing machine state. * Input : a state machine value (RESUME_STATE) * RESUME_ESOF doesn't change ResumeS.eState allowing * decrementing of the ESOF counter in different states. * Output : None. * Return : None. *******************************************************************************/ void Resume(RESUME_STATE eResumeSetVal) { #ifndef STM32F10X_CL uint16_t wCNTR; #endif /* STM32F10X_CL */ if (eResumeSetVal != RESUME_ESOF) ResumeS.eState = eResumeSetVal; switch (ResumeS.eState) { case RESUME_EXTERNAL: Resume_Init(); ResumeS.eState = RESUME_OFF; break; case RESUME_INTERNAL: Resume_Init(); ResumeS.eState = RESUME_START; break; case RESUME_LATER: ResumeS.bESOFcnt = 2; ResumeS.eState = RESUME_WAIT; break; case RESUME_WAIT: ResumeS.bESOFcnt--; if (ResumeS.bESOFcnt == 0) ResumeS.eState = RESUME_START; break; case RESUME_START: #ifdef STM32F10X_CL OTGD_FS_SetRemoteWakeup(); #else wCNTR = _GetCNTR(); wCNTR |= CNTR_RESUME; _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ ResumeS.eState = RESUME_ON; ResumeS.bESOFcnt = 10; break; case RESUME_ON: #ifndef STM32F10X_CL ResumeS.bESOFcnt--; if (ResumeS.bESOFcnt == 0) { #endif /* STM32F10X_CL */ #ifdef STM32F10X_CL OTGD_FS_ResetRemoteWakeup(); #else wCNTR = _GetCNTR(); wCNTR &= (~CNTR_RESUME); _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ ResumeS.eState = RESUME_OFF; #ifndef STM32F10X_CL } #endif /* STM32F10X_CL */ break; case RESUME_OFF: case RESUME_ESOF: default: ResumeS.eState = RESUME_OFF; break; } } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/src/usb_pwr.c
C
asf20
7,830
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_prop.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : All processing related to Audio Speaker Demo ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_lib.h" #include "usb_conf.h" #include "usb_prop.h" #include "usb_desc.h" #include "usb_pwr.h" #include "hw_config.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint32_t MUTE_DATA = 0; DEVICE Device_Table = { EP_NUM, 1 }; DEVICE_PROP Device_Property = { Speaker_init, Speaker_Reset, Speaker_Status_In, Speaker_Status_Out, Speaker_Data_Setup, Speaker_NoData_Setup, Speaker_Get_Interface_Setting, Speaker_GetDeviceDescriptor, Speaker_GetConfigDescriptor, Speaker_GetStringDescriptor, 0, 0x40 /*MAX PACKET SIZE*/ }; USER_STANDARD_REQUESTS User_Standard_Requests = { Speaker_GetConfiguration, Speaker_SetConfiguration, Speaker_GetInterface, Speaker_SetInterface, Speaker_GetStatus, Speaker_ClearFeature, Speaker_SetEndPointFeature, Speaker_SetDeviceFeature, Speaker_SetDeviceAddress }; ONE_DESCRIPTOR Device_Descriptor = { (uint8_t*)Speaker_DeviceDescriptor, SPEAKER_SIZ_DEVICE_DESC }; ONE_DESCRIPTOR Config_Descriptor = { (uint8_t*)Speaker_ConfigDescriptor, SPEAKER_SIZ_CONFIG_DESC }; ONE_DESCRIPTOR String_Descriptor[4] = { {(uint8_t*)Speaker_StringLangID, SPEAKER_SIZ_STRING_LANGID}, {(uint8_t*)Speaker_StringVendor, SPEAKER_SIZ_STRING_VENDOR}, {(uint8_t*)Speaker_StringProduct, SPEAKER_SIZ_STRING_PRODUCT}, {(uint8_t*)Speaker_StringSerial, SPEAKER_SIZ_STRING_SERIAL}, }; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : Speaker_init. * Description : Speaker init routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Speaker_init() { /* Update the serial number string descriptor with the data from the unique ID*/ Get_SerialNum(); /* Initialize the current configuration */ pInformation->Current_Configuration = 0; /* Connect the device */ PowerOn(); /* Perform basic device initialization operations */ USB_SIL_Init(); bDeviceState = UNCONNECTED; } /******************************************************************************* * Function Name : Speaker_Reset. * Description : Speaker reset routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Speaker_Reset() { /* Set Speaker device as not configured state */ pInformation->Current_Configuration = 0; /* Current Feature initialization */ pInformation->Current_Feature = Speaker_ConfigDescriptor[7]; #ifdef STM32F10X_CL /* EP0 is already configured in DFU_Init() by USB_SIL_Init() function */ /* Init EP1 OUT as Isochronous endpoint */ OTG_DEV_EP_Init(EP1_OUT, OTG_DEV_EP_TYPE_ISOC, ISOC_BUFFER_SZE); #endif /* STM32F10X_CL */ bDeviceState = ATTACHED; } /******************************************************************************* * Function Name : Speaker_SetConfiguration. * Description : Udpade the device state to configured. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Speaker_SetConfiguration(void) { DEVICE_INFO *pInfo = &Device_Info; if (pInfo->Current_Configuration != 0) { /* Device configured */ bDeviceState = CONFIGURED; } } /******************************************************************************* * Function Name : Speaker_SetConfiguration. * Description : Udpade the device state to addressed. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Speaker_SetDeviceAddress (void) { bDeviceState = ADDRESSED; } /******************************************************************************* * Function Name : Speaker_Status_In. * Description : Speaker Status In routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Speaker_Status_In(void) {} /******************************************************************************* * Function Name : Speaker_Status_Out. * Description : Speaker Status Out routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Speaker_Status_Out (void) {} /******************************************************************************* * Function Name : Speaker_Data_Setup * Description : Handle the data class specific requests. * Input : None. * Output : None. * Return : USB_UNSUPPORT or USB_SUCCESS. *******************************************************************************/ RESULT Speaker_Data_Setup(uint8_t RequestNo) { uint8_t *(*CopyRoutine)(uint16_t); CopyRoutine = NULL; if ((RequestNo == GET_CUR) || (RequestNo == SET_CUR)) { CopyRoutine = Mute_Command; } else { return USB_UNSUPPORT; } pInformation->Ctrl_Info.CopyData = CopyRoutine; pInformation->Ctrl_Info.Usb_wOffset = 0; (*CopyRoutine)(0); return USB_SUCCESS; } /******************************************************************************* * Function Name : Speaker_NoData_Setup * Description : Handle the no data class specific requests. * Input : None. * Output : None. * Return : USB_UNSUPPORT or USB_SUCCESS. *******************************************************************************/ RESULT Speaker_NoData_Setup(uint8_t RequestNo) { return USB_UNSUPPORT; } /******************************************************************************* * Function Name : Speaker_GetDeviceDescriptor. * Description : Get the device descriptor. * Input : Length : uint16_t. * Output : None. * Return : The address of the device descriptor. *******************************************************************************/ uint8_t *Speaker_GetDeviceDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Device_Descriptor); } /******************************************************************************* * Function Name : Speaker_GetConfigDescriptor. * Description : Get the configuration descriptor. * Input : Length : uint16_t. * Output : None. * Return : The address of the configuration descriptor. *******************************************************************************/ uint8_t *Speaker_GetConfigDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Config_Descriptor); } /******************************************************************************* * Function Name : Speaker_GetStringDescriptor. * Description : Get the string descriptors according to the needed index. * Input : Length : uint16_t. * Output : None. * Return : The address of the string descriptors. *******************************************************************************/ uint8_t *Speaker_GetStringDescriptor(uint16_t Length) { uint8_t wValue0 = pInformation->USBwValue0; if (wValue0 > 4) { return NULL; } else { return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]); } } /******************************************************************************* * Function Name : Speaker_Get_Interface_Setting. * Description : test the interface and the alternate setting according to the * supported one. * Input1 : uint8_t: Interface : interface number. * Input2 : uint8_t: AlternateSetting : Alternate Setting number. * Output : None. * Return : The address of the string descriptors. *******************************************************************************/ RESULT Speaker_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting) { if (AlternateSetting > 1) { return USB_UNSUPPORT; } else if (Interface > 1) { return USB_UNSUPPORT; } return USB_SUCCESS; } /******************************************************************************* * Function Name : Mute_Command * Description : Handle the GET MUTE and SET MUTE command. * Input : Length : uint16_t. * Output : None. * Return : The address of the string descriptors. *******************************************************************************/ uint8_t *Mute_Command(uint16_t Length) { if (Length == 0) { pInformation->Ctrl_Info.Usb_wLength = pInformation->USBwLengths.w; return NULL; } else { return((uint8_t*)(&MUTE_DATA)); } } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/src/usb_prop.c
C
asf20
10,767
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_desc.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Descriptors for Audio Speaker Demo ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_lib.h" #include "usb_desc.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants----------------------------------------------------------*/ /* USB Standard Device Descriptor */ const uint8_t Speaker_DeviceDescriptor[] = { SPEAKER_SIZ_DEVICE_DESC, /* bLength */ USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x00, /* 1.10 */ /* bcdUSB */ 0x02, 0x00, /* bDeviceClass */ 0x00, /* bDeviceSubClass */ 0x00, /* bDeviceProtocol */ 0x40, /* bMaxPacketSize 40 */ 0x83, /* idVendor */ 0x04, 0x30, /* idProduct = 0x5730*/ 0x57, 0x00, /* 2.00 */ /* bcdDevice */ 0x02, 1, /* iManufacturer */ 2, /* iProduct */ 3, /* iSerialNumber */ 0x01 /* bNumConfigurations */ }; /* USB Configuration Descriptor */ /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */ const uint8_t Speaker_ConfigDescriptor[] = { /* Configuration 1 */ 0x09, /* bLength */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x6D, /* wTotalLength 110 bytes*/ 0x00, 0x02, /* bNumInterfaces */ 0x01, /* bConfigurationValue */ 0x00, /* iConfiguration */ 0xC0, /* bmAttributes BUS Powred*/ 0x32, /* bMaxPower = 100 mA*/ /* 09 byte*/ /* USB Speaker Standard interface descriptor */ SPEAKER_SIZ_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x00, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x00, /* bNumEndpoints */ USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */ AUDIO_SUBCLASS_AUDIOCONTROL, /* bInterfaceSubClass */ AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */ 0x00, /* iInterface */ /* 09 byte*/ /* USB Speaker Class-specific AC Interface Descriptor */ SPEAKER_SIZ_INTERFACE_DESC_SIZE, /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_CONTROL_HEADER, /* bDescriptorSubtype */ 0x00, /* 1.00 */ /* bcdADC */ 0x01, 0x27, /* wTotalLength = 39*/ 0x00, 0x01, /* bInCollection */ 0x01, /* baInterfaceNr */ /* 09 byte*/ /* USB Speaker Input Terminal Descriptor */ AUDIO_INPUT_TERMINAL_DESC_SIZE, /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_CONTROL_INPUT_TERMINAL, /* bDescriptorSubtype */ 0x01, /* bTerminalID */ 0x01, /* wTerminalType AUDIO_TERMINAL_USB_STREAMING 0x0101 */ 0x01, 0x00, /* bAssocTerminal */ 0x01, /* bNrChannels */ 0x00, /* wChannelConfig 0x0000 Mono */ 0x00, 0x00, /* iChannelNames */ 0x00, /* iTerminal */ /* 12 byte*/ /* USB Speaker Audio Feature Unit Descriptor */ 0x09, /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_CONTROL_FEATURE_UNIT, /* bDescriptorSubtype */ 0x02, /* bUnitID */ 0x01, /* bSourceID */ 0x01, /* bControlSize */ AUDIO_CONTROL_MUTE, /* bmaControls(0) */ 0x00, /* bmaControls(1) */ 0x00, /* iTerminal */ /* 09 byte*/ /*USB Speaker Output Terminal Descriptor */ 0x09, /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_CONTROL_OUTPUT_TERMINAL, /* bDescriptorSubtype */ 0x03, /* bTerminalID */ 0x01, /* wTerminalType 0x0301*/ 0x03, 0x00, /* bAssocTerminal */ 0x02, /* bSourceID */ 0x00, /* iTerminal */ /* 09 byte*/ /* USB Speaker Standard AS Interface Descriptor - Audio Streaming Zero Bandwith */ /* Interface 1, Alternate Setting 0 */ SPEAKER_SIZ_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x01, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x00, /* bNumEndpoints */ USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */ AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubClass */ AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */ 0x00, /* iInterface */ /* 09 byte*/ /* USB Speaker Standard AS Interface Descriptor - Audio Streaming Operational */ /* Interface 1, Alternate Setting 1 */ SPEAKER_SIZ_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x01, /* bInterfaceNumber */ 0x01, /* bAlternateSetting */ 0x01, /* bNumEndpoints */ USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */ AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubClass */ AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */ 0x00, /* iInterface */ /* 09 byte*/ /* USB Speaker Audio Streaming Interface Descriptor */ AUDIO_STREAMING_INTERFACE_DESC_SIZE, /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_STREAMING_GENERAL, /* bDescriptorSubtype */ 0x01, /* bTerminalLink */ 0x01, /* bDelay */ 0x01, /* wFormatTag AUDIO_FORMAT_PCM 0x0001*/ 0x00, /* 07 byte*/ /* USB Speaker Audio Type I Format Interface Descriptor */ 0x0B, /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype */ AUDIO_FORMAT_TYPE_III, /* bFormatType/// */ 0x02, /* bNrChannels */ 0x02, /* bSubFrameSize : 2 Bytes per frame (16bits) */ 16, /* bBitResolution (16-bits per sample) */ 0x01, /* bSamFreqType only one frequency supported */ #ifdef AUDIO_FREQ_96K 0x00, /* tSamFreq 96000 = 0x017700 */ 0x77, 0x01, #elif defined (AUDIO_FREQ_48K) 0x80, /* tSamFreq 48000 = 0xBB80 */ 0xBB, 0x00, #elif defined (AUDIO_FREQ_44K) 0xE0, /* tSamFreq 44000 = 0xABE0 */ 0xAB, 0x00, #elif defined (AUDIO_FREQ_32K) 0x00, /* tSamFreq 32000 = 0x7D00 */ 0x7D, 0x00, #elif defined (AUDIO_FREQ_22K) 0xF0, /* tSamFreq 22000 = 0x55F0 */ 0x55, 0x00, #elif defined (AUDIO_FREQ_16K) 0x80, /* tSamFreq 16000 = 0x3E80 */ 0x3E, 0x00, #elif defined (AUDIO_FREQ_11K) 0xF8, /* tSamFreq 11000 = 0x2AF8 */ 0x2A, 0x00, #elif defined (AUDIO_FREQ_8K) 0x40, /* tSamFreq 8000 = 0x1F40 */ 0x1F, 0x00, #endif /* AUDIO_FREQ_96K */ /* 11 byte*/ /* Endpoint 1 - Standard Descriptor */ AUDIO_STANDARD_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x01, /* bEndpointAddress 1 out endpoint*/ USB_ENDPOINT_TYPE_ISOCHRONOUS, /* bmAttributes */ #ifdef AUDIO_FREQ_96K 0x80, /* wMaxPacketSize 384 bytes (96(Samples)*2(Stereo)*2(HalfWord)) */ 0x01, #elif defined (AUDIO_FREQ_48K) 0xC0, /* wMaxPacketSize 192 bytes (48(Samples)*2(Stereo)*2(HalfWord)) */ 0x00, #elif defined (AUDIO_FREQ_44K) 0xB0, /* wMaxPacketSize 176 bytes (44(Samples)*2(Stereo)*2(HalfWord)) */ 0x00, #elif defined (AUDIO_FREQ_32K) 0x80, /* wMaxPacketSize 128 bytes (32(Samples)*2(Stereo)*2(HalfWord))*/ 0x00, #elif defined (AUDIO_FREQ_22K) 0x58, /* wMaxPacketSize 88 bytes (22(Samples)*2(Stereo)*2(HalfWord))*/ 0x00, #elif defined (AUDIO_FREQ_16K) 0x40, /* wMaxPacketSize 64 bytes (16(Samples)*2(Stereo)*2(HalfWord)) */ 0x00, #elif defined (AUDIO_FREQ_11K) 0x2C, /* wMaxPacketSize 44 bytes (11(Samples)*2(Stereo)*2(HalfWord)) */ 0x00, #elif defined (AUDIO_FREQ_8K) 0x20, /* wMaxPacketSize 32 bytes (8(Samples)*2(Stereo)*2(HalfWord)) */ 0x00, #endif /* AUDIO_FREQ_96K */ 0x01, /* bInterval */ 0x00, /* bRefresh */ 0x00, /* bSynchAddress */ /* 09 byte*/ /* Endpoint - Audio Streaming Descriptor*/ AUDIO_STREAMING_ENDPOINT_DESC_SIZE, /* bLength */ AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_ENDPOINT_GENERAL, /* bDescriptor */ 0x00, /* bmAttributes */ 0x00, /* bLockDelayUnits */ 0x00, /* wLockDelay */ 0x00, /* 07 byte*/ }; /* USB String Descriptor (optional) */ const uint8_t Speaker_StringLangID[SPEAKER_SIZ_STRING_LANGID] = { 0x04, 0x03, 0x09, 0x04 } ; /* LangID = 0x0409: U.S. English */ const uint8_t Speaker_StringVendor[SPEAKER_SIZ_STRING_VENDOR] = { SPEAKER_SIZ_STRING_VENDOR, /* Size of manufaturer string */ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType*/ /* Manufacturer: "STMicroelectronics" */ 'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0, 'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0, 'c', 0, 's', 0 }; const uint8_t Speaker_StringProduct[SPEAKER_SIZ_STRING_PRODUCT] = { SPEAKER_SIZ_STRING_PRODUCT, /* bLength */ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'S', 0, 'p', 0, 'e', 0, 'a', 0, 'k', 0, 'e', 0, 'r', 0 }; uint8_t Speaker_StringSerial[SPEAKER_SIZ_STRING_SERIAL] = { SPEAKER_SIZ_STRING_SERIAL, /* bLength */ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, '1', 0, '0', 0 }; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/src/usb_desc.c
C
asf20
13,862
;; NOTE: To allow the use of this file for both ARMv6M and ARMv7M, ;; we will only use 16-bit Thumb intructions. .extern _lc_ub_stack ; usr/sys mode stack pointer .extern _lc_ue_stack ; symbol required by debugger .extern _lc_ub_table ; ROM to RAM copy table .extern main .extern _Exit .extern exit .weak exit .global __get_argcv .weak __get_argcv .extern __argcvbuf .weak __argcvbuf .extern __init_hardware .extern __init_vector_table .extern SystemInit .if @defined('__PROF_ENABLE__') .extern __prof_init .endif .if @defined('__POSIX__') .extern posix_main .extern _posix_boot_stack_top .endif .global _START .section .text.cstart .thumb _START: ;; anticipate possible ROM/RAM remapping ;; by loading the 'real' program address ldr r1,=_Next bx r1 _Next: ;; initialize the stack pointer ldr r1,=_lc_ub_stack ; TODO: make this part of the vector table mov sp,r1 ;; call a user function which initializes hardware ;; such as ROM/RAM re-mapping or MMU configuration bl __init_hardware ;ldr r0, =SystemInit ;bx r0 bl SystemInit ;; copy initialized sections from ROM to RAM ;; and clear uninitialized data sections in RAM ldr r3,=_lc_ub_table movs r0,#0 cploop: ldr r4,[r3,#0] ; load type ldr r5,[r3,#4] ; dst address ldr r6,[r3,#8] ; src address ldr r7,[r3,#12] ; size cmp r4,#1 beq copy cmp r4,#2 beq clear b done copy: subs r7,r7,#1 ldrb r1,[r6,r7] strb r1,[r5,r7] bne copy adds r3,r3,#16 b cploop clear: subs r7,r7,#1 strb r0,[r5,r7] bne clear adds r3,r3,#16 b cploop done: ;; initialize or copy the vector table bl __init_vector_table .if @defined('__POSIX__') ;; posix stack buffer for system upbringing ldr r0,=_posix_boot_stack_top ldr r0, [r0] mov sp,r0 .else ;; load r10 with end of USR/SYS stack, which is ;; needed in case stack overflow checking is on ;; NOTE: use 16-bit instructions only, for ARMv6M ldr r0,=_lc_ue_stack mov r10,r0 .endif .if @defined('__PROF_ENABLE__') bl __prof_init .endif .if @defined('__POSIX__') ;; call posix_main with no arguments bl posix_main .else ;; retrieve argc and argv (default argv[0]==NULL & argc==0) bl __get_argcv ldr r1,=__argcvbuf ;; call main bl main .endif ;; call exit using the return value from main() ;; Note. Calling exit will also run all functions ;; that were supplied through atexit(). bl exit __get_argcv: ; weak definition movs r0,#0 bx lr .ltorg .endsec .calls '_START','__init_hardware' .calls '_START','__init_vector_table' .if @defined('__PROF_ENABLE__') .calls '_START','__prof_init' .endif .if @defined('__POSIX__') .calls '_START','posix_main' .else .calls '_START','__get_argcv' .calls '_START','main' .endif .calls '_START','exit' .calls '_START','',0 .end
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/HiTOP/AudioStreaming_14MHz/cstart_thumb2.asm
Assembly
asf20
3,949
//////////////////////////////////////////////////////////////////////////// // // File : stm32f103_cmsis.lsl // // Version : @(#)stm32f103_cmsis.lsl 1.2 09/06/04 // // Description : LSL file for the STMicroelectronics STM32F103, CMSIS version // // Copyright 2009 Altium BV // // NOTE: // This file is derived from cm3.lsl and stm32f103.lsl. // It is assumed that the user works with the ARMv7M architecture. // Other architectures will not work with this lsl file. // //////////////////////////////////////////////////////////////////////////// // // We do not want the vectors as defined in arm_arch.lsl // #define __NO_DEFAULT_AUTO_VECTORS 1 #define __NR_OF_VECTORS 84 #ifndef __STACK # define __STACK 2k #endif #ifndef __HEAP # define __HEAP 1k #endif #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x08000000 #endif #ifndef __XVWBUF #define __XVWBUF 256 /* buffer used by CrossView */ #endif #include <arm_arch.lsl> //////////////////////////////////////////////////////////////////////////// // // In the STM32F10x, 3 different boot modes can be selected // - User Flash memory is selected as boot space // - SystemMemory is selected as boot space // - Embedded SRAM is selected as boot space // // This aliases the physical memory associated with each boot mode to Block // 000 (0x00000000 boot memory). Even when aliased in the boot memory space, // the related memory (Flash memory or SRAM) is still accessible at its // original memory space. // // If no memory is defined yet use the following memory settings // #ifndef __MEMORY memory stm32f103flash { mau = 8; type = rom; size = 256k; map ( size = 256k, dest_offset=0x08000000, dest=bus:ARM:local_bus); } memory stm32f103ram { mau = 8; type = ram; size = 64k; map ( size = 64k, dest_offset=0x20000000, dest=bus:ARM:local_bus); } #endif /* __MEMORY */ // // Custom vector table defines interrupts according to CMSIS standard // # if defined(__CPU_ARMV7M__) section_setup ::linear { // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); vector ( id = 2, optional, fill = "NMI_Handler" ); vector ( id = 3, optional, fill = "HardFault_Handler" ); vector ( id = 4, optional, fill = "MemManage_Handler" ); vector ( id = 5, optional, fill = "BusFault_Handler" ); vector ( id = 6, optional, fill = "UsageFault_Handler" ); vector ( id = 11, optional, fill = "SVC_Handler" ); vector ( id = 12, optional, fill = "DebugMon_Handler" ); vector ( id = 14, optional, fill = "PendSV_Handler" ); vector ( id = 15, optional, fill = "SysTick_Handler" ); // External Interrupts : vector ( id = 16, optional, fill = "WWDG_IRQHandler" ); // Window Watchdog vector ( id = 17, optional, fill = "PVD_IRQHandler" ); // PVD through EXTI Line detect vector ( id = 18, optional, fill = "TAMPER_IRQHandler" ); // Tamper vector ( id = 19, optional, fill = "RTC_IRQHandler" ); // RTC vector ( id = 20, optional, fill = "FLASH_IRQHandler" ); // Flash vector ( id = 21, optional, fill = "RCC_IRQHandler" ); // RCC vector ( id = 22, optional, fill = "EXTI0_IRQHandler" ); // EXTI Line 0 vector ( id = 23, optional, fill = "EXTI1_IRQHandler" ); // EXTI Line 1 vector ( id = 24, optional, fill = "EXTI2_IRQHandler" ); // EXTI Line 2 vector ( id = 25, optional, fill = "EXTI3_IRQHandler" ); // EXTI Line 3 vector ( id = 26, optional, fill = "EXTI4_IRQHandler" ); // EXTI Line 4 vector ( id = 27, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMA1_Channel2_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMA1_Channel3_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMA1_Channel4_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMA1_Channel5_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMA1_Channel6_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMA1_Channel7_IRQHandler" ); // DMA Channel 7 vector ( id = 34, optional, fill = "ADC1_2_IRQHandler" ); // ADC1 and ADC2 vector ( id = 35, optional, fill = "CAN1_TX_IRQHandler" ); // CAN1 TX vector ( id = 36, optional, fill = "CAN1_RX0_IRQHandler" ); // CAN1 RX0 vector ( id = 37, optional, fill = "CAN1_RX1_IRQHandler" ); // CAN1 RX1 vector ( id = 38, optional, fill = "CAN1_SCE_IRQHandler" ); // CAN1 SCE vector ( id = 39, optional, fill = "EXTI9_5_IRQHandler" ); // EXTI Line 9..5 vector ( id = 40, optional, fill = "TIM1_BRK_IRQHandler" ); // TIM1 Break vector ( id = 41, optional, fill = "TIM1_UP_IRQHandler" ); // TIM1 Update vector ( id = 42, optional, fill = "TIM1_TRG_COM_IRQHandler" ); // TIM1 Trigger and Commutation vector ( id = 43, optional, fill = "TIM1_CC_IRQHandler" ); // TIM1 Capture Compare vector ( id = 44, optional, fill = "TIM2_IRQHandler" ); // TIM2 vector ( id = 45, optional, fill = "TIM3_IRQHandler" ); // TIM3 vector ( id = 46, optional, fill = "TIM4_IRQHandler" ); // TIM4 vector ( id = 47, optional, fill = "I2C1_EV_IRQHandler" ); // I2C1 Event vector ( id = 48, optional, fill = "I2C1_ER_IRQHandler" ); // I2C1 Error vector ( id = 49, optional, fill = "I2C2_EV_IRQHandler" ); // I2C2 Event vector ( id = 50, optional, fill = "I2C2_ER_IRQHandler" ); // I2C2 Error vector ( id = 51, optional, fill = "SPI1_IRQHandler" ); // SPI1 vector ( id = 52, optional, fill = "SPI2_IRQHandler" ); // SPI2 vector ( id = 53, optional, fill = "USART1_IRQHandler" ); // USART1 vector ( id = 54, optional, fill = "USART2_IRQHandler" ); // USART2 vector ( id = 55, optional, fill = "USART3_IRQHandler" ); // USART3 vector ( id = 56, optional, fill = "EXTI15_10_IRQHandler" ); // EXTI Line 15..10 vector ( id = 57, optional, fill = "RTCAlarm_IRQHandler" ); // RTC Alarm through EXTI Line vector ( id = 58, optional, fill = "OTG_FS_WKUP_IRQHandler" ); // USB OTG FS Wakeup through EXTI line vector ( id = 66, optional, fill = "TIM5_IRQHandler" ); // TIM5 vector ( id = 67, optional, fill = "SPI3_IRQHandler" ); // SPI3 vector ( id = 68, optional, fill = "UART4_IRQHandler" ); // UART4 vector ( id = 69, optional, fill = "UART5_IRQHandler" ); // UART5 vector ( id = 70, optional, fill = "TIM6_IRQHandler" ); // TIM6 vector ( id = 71, optional, fill = "TIM7_IRQHandler" ); // TIM7 vector ( id = 72, optional, fill = "DMA2_Channel1_IRQHandler" ); // DMA2 Channel1 vector ( id = 73, optional, fill = "DMA2_Channel2_IRQHandler" ); // DMA2 Channel2 vector ( id = 74, optional, fill = "DMA2_Channel3_IRQHandler" ); // DMA2 Channel3 vector ( id = 75, optional, fill = "DMA2_Channel4_IRQHandler" ); // DMA2 Channel4 vector ( id = 76, optional, fill = "DMA2_Channel5_IRQHandler" ); // DMA2 Channel5 vector ( id = 77, optional, fill = "ETH_IRQHandler" ); // Ethernet vector ( id = 78, optional, fill = "ETH_WKUP_IRQHandler" ); // ETH_WKUP_IRQHandler vector ( id = 79, optional, fill = "CAN2_TX_IRQHandler " ); // CAN2 TX vector ( id = 80, optional, fill = "CAN2_RX0_IRQHandler" ); // CAN2 RX0 vector ( id = 81, optional, fill = "CAN2_RX1_IRQHandler" ); // CAN2 RX1 vector ( id = 82, optional, fill = "CAN2_SCE_IRQHandler" ); // CAN2 SCE vector ( id = 83, optional, fill = "OTG_FS_IRQHandler" ); // USB OTG FS } } # endif
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/HiTOP/AudioStreaming_14MHz/Settings/STM32F10x_cl.lsl
LSL
asf20
10,566
//////////////////////////////////////////////////////////////////////////// // // File : arm_arch.lsl // // Version : @(#)arm_arch.lsl 1.4 09/04/17 // // Description : Generic LSL file for ARM architectures // // Copyright 2008-2009 Altium BV // //////////////////////////////////////////////////////////////////////////// #ifndef __STACK # define __STACK 32k #endif #ifndef __HEAP # define __HEAP 32k #endif #ifndef __STACK_FIQ # define __STACK_FIQ 8 #endif #ifndef __STACK_IRQ # define __STACK_IRQ 8 #endif #ifndef __STACK_SVC # define __STACK_SVC 8 #endif #ifndef __STACK_ABT # define __STACK_ABT 8 #endif #ifndef __STACK_UND # define __STACK_UND 8 #endif #ifndef __PROCESSOR_MODE # define __PROCESSOR_MODE 0x1F /* SYS mode */ #endif #ifndef __IRQ_BIT # define __IRQ_BIT 0x80 /* IRQ interrupts disabled */ #endif #ifndef __FIQ_BIT # define __FIQ_BIT 0x40 /* FIQ interrupts disabled */ #endif #define __APPLICATION_MODE (__PROCESSOR_MODE | __IRQ_BIT | __FIQ_BIT) #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x00000000 #endif #ifndef __VECTOR_TABLE_RAM_ADDR # define __VECTOR_TABLE_RAM_ADDR 0x00000000 #endif #if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) # ifndef __NR_OF_VECTORS # define __NR_OF_VECTORS 16 # endif # define __VECTOR_TABLE_SIZE (__NR_OF_VECTORS * 4) #else # ifdef __PIC_VECTORS # define __VECTOR_TABLE_SIZE 64 # else # ifdef __FIQ_HANDLER_INLINE # define __VECTOR_TABLE_SIZE 28 # define __NR_OF_VECTORS 7 # else # define __VECTOR_TABLE_SIZE 32 # define __NR_OF_VECTORS 8 # endif # endif #endif #ifndef __VECTOR_TABLE_RAM_SPACE # undef __VECTOR_TABLE_RAM_COPY #endif #ifndef __XVWBUF # define __XVWBUF 0 /* buffer used by CrossView Pro */ #endif #define BOUNDS_GROUP_NAME grp_bounds #define BOUNDS_GROUP_SELECT "bounds" architecture ARM { endianness { little; big; } space linear { id = 1; mau = 8; map (size = 4G, dest = bus:local_bus); copytable ( align = 4, copy_unit = 1, dest = linear ); start_address ( // It is not strictly necessary to define a run_addr for _START // because hardware starts execution at address 0x0 which should // be the vector table with a jump to the relocatable _START, but // an absolute address can prevent the branch to be out-of-range. // Or _START may be the entry point at reset and the reset handler // copies the vector table to address 0x0 after some ROM/RAM memory // re-mapping. In that case _START should be at a fixed address // in ROM, specifically the alias of address 0x0 before memory // re-mapping. #ifdef __START run_addr = __START, #endif symbol = "_START" ); stack "stack" ( #ifdef __STACK_FIXED fixed, #endif align = 4, min_size = __STACK, grows = high_to_low ); heap "heap" ( #ifdef __HEAP_FIXED fixed, #endif align = 4, min_size=__HEAP ); #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) stack "stack_fiq" ( fixed, align = 4, min_size = __STACK_FIQ, grows = high_to_low ); stack "stack_irq" ( fixed, align = 4, min_size = __STACK_IRQ, grows = high_to_low ); stack "stack_svc" ( fixed, align = 4, min_size = __STACK_SVC, grows = high_to_low ); stack "stack_abt" ( fixed, align = 4, min_size = __STACK_ABT, grows = high_to_low ); stack "stack_und" ( fixed, align = 4, min_size = __STACK_UND, grows = high_to_low ); #endif #if !defined(__NO_AUTO_VECTORS) && !defined(__NO_DEFAULT_AUTO_VECTORS) # if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); } # else # ifdef __PIC_VECTORS // vector table with ldrpc instructions from handler table vector_table "vector_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_ldrpc", template_symbol = "_lc_vector_ldrpc", vector_prefix = "_vector_ldrpc_", fill = loop ) { } // subsequent vector table (data pool) with addresses of handlers vector_table "handler_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR + 32, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop[-32], no_inline ) { vector ( id = 0, fill = "_START" ); } # else // vector table with branch instructions to handlers vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_branch", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop ) { vector ( id = 0, fill = "_START" ); } # endif # endif #endif section_layout { #if defined(__NO_AUTO_VECTORS) "_lc_ub_vector_table" = __VECTOR_TABLE_ROM_ADDR; "_lc_ue_vector_table" = __VECTOR_TABLE_ROM_ADDR + __VECTOR_TABLE_SIZE; #endif #ifdef __VECTOR_TABLE_RAM_SPACE // reserve space to copy vector table from ROM to RAM group ( ordered, run_addr = __VECTOR_TABLE_RAM_ADDR ) reserved "vector_table_space" ( size = __VECTOR_TABLE_SIZE, attributes = rwx ); #endif #ifdef __VECTOR_TABLE_RAM_COPY // provide copy address symbols for copy routine "_lc_ub_vector_table_copy" := "_lc_ub_vector_table_space"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table_space"; #else // prevent copy: copy address equals orig address "_lc_ub_vector_table_copy" := "_lc_ub_vector_table"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table"; #endif // define buffer for string input via Crossview Pro debugger group ( align = 4 ) reserved "xvwbuffer" (size=__XVWBUF, attributes=rw ); // define labels for bounds begin and end as used in C library #ifndef BOUNDS_GROUP_REDEFINED group BOUNDS_GROUP_NAME (ordered, contiguous) { select BOUNDS_GROUP_SELECT; } #endif "_lc_ub_bounds" := addressof(group:BOUNDS_GROUP_NAME); "_lc_ue_bounds" := addressof(group:BOUNDS_GROUP_NAME) + sizeof(group:BOUNDS_GROUP_NAME); #ifdef __HEAPADDR group ( ordered, run_addr=__HEAPADDR ) { select "heap"; } #endif #ifdef __STACKADDR group ( ordered, run_addr=__STACKADDR ) { select "stack"; } #endif #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) // symbol to set mode bits and interrupt disable bits // in cstart module before calling the application (main) "_APPLICATION_MODE_" = __APPLICATION_MODE; #endif } } bus local_bus { mau = 8; width = 32; } }
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/HiTOP/AudioStreaming_14MHz/Settings/arm_arch.lsl
LSL
asf20
10,931
;; NOTE: To allow the use of this file for both ARMv6M and ARMv7M, ;; we will only use 16-bit Thumb intructions. .extern _lc_ub_stack ; usr/sys mode stack pointer .extern _lc_ue_stack ; symbol required by debugger .extern _lc_ub_table ; ROM to RAM copy table .extern main .extern _Exit .extern exit .weak exit .global __get_argcv .weak __get_argcv .extern __argcvbuf .weak __argcvbuf .extern __init_hardware .extern __init_vector_table .extern SystemInit .if @defined('__PROF_ENABLE__') .extern __prof_init .endif .if @defined('__POSIX__') .extern posix_main .extern _posix_boot_stack_top .endif .global _START .section .text.cstart .thumb _START: ;; anticipate possible ROM/RAM remapping ;; by loading the 'real' program address ldr r1,=_Next bx r1 _Next: ;; initialize the stack pointer ldr r1,=_lc_ub_stack ; TODO: make this part of the vector table mov sp,r1 ;; call a user function which initializes hardware ;; such as ROM/RAM re-mapping or MMU configuration bl __init_hardware ;ldr r0, =SystemInit ;bx r0 bl SystemInit ;; copy initialized sections from ROM to RAM ;; and clear uninitialized data sections in RAM ldr r3,=_lc_ub_table movs r0,#0 cploop: ldr r4,[r3,#0] ; load type ldr r5,[r3,#4] ; dst address ldr r6,[r3,#8] ; src address ldr r7,[r3,#12] ; size cmp r4,#1 beq copy cmp r4,#2 beq clear b done copy: subs r7,r7,#1 ldrb r1,[r6,r7] strb r1,[r5,r7] bne copy adds r3,r3,#16 b cploop clear: subs r7,r7,#1 strb r0,[r5,r7] bne clear adds r3,r3,#16 b cploop done: ;; initialize or copy the vector table bl __init_vector_table .if @defined('__POSIX__') ;; posix stack buffer for system upbringing ldr r0,=_posix_boot_stack_top ldr r0, [r0] mov sp,r0 .else ;; load r10 with end of USR/SYS stack, which is ;; needed in case stack overflow checking is on ;; NOTE: use 16-bit instructions only, for ARMv6M ldr r0,=_lc_ue_stack mov r10,r0 .endif .if @defined('__PROF_ENABLE__') bl __prof_init .endif .if @defined('__POSIX__') ;; call posix_main with no arguments bl posix_main .else ;; retrieve argc and argv (default argv[0]==NULL & argc==0) bl __get_argcv ldr r1,=__argcvbuf ;; call main bl main .endif ;; call exit using the return value from main() ;; Note. Calling exit will also run all functions ;; that were supplied through atexit(). bl exit __get_argcv: ; weak definition movs r0,#0 bx lr .ltorg .endsec .calls '_START','__init_hardware' .calls '_START','__init_vector_table' .if @defined('__PROF_ENABLE__') .calls '_START','__prof_init' .endif .if @defined('__POSIX__') .calls '_START','posix_main' .else .calls '_START','__get_argcv' .calls '_START','main' .endif .calls '_START','exit' .calls '_START','',0 .end
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/HiTOP/AudioStreaming_25MHz/cstart_thumb2.asm
Assembly
asf20
3,949
//////////////////////////////////////////////////////////////////////////// // // File : stm32f103_cmsis.lsl // // Version : @(#)stm32f103_cmsis.lsl 1.2 09/06/04 // // Description : LSL file for the STMicroelectronics STM32F103, CMSIS version // // Copyright 2009 Altium BV // // NOTE: // This file is derived from cm3.lsl and stm32f103.lsl. // It is assumed that the user works with the ARMv7M architecture. // Other architectures will not work with this lsl file. // //////////////////////////////////////////////////////////////////////////// // // We do not want the vectors as defined in arm_arch.lsl // #define __NO_DEFAULT_AUTO_VECTORS 1 #define __NR_OF_VECTORS 84 #ifndef __STACK # define __STACK 2k #endif #ifndef __HEAP # define __HEAP 1k #endif #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x08000000 #endif #ifndef __XVWBUF #define __XVWBUF 256 /* buffer used by CrossView */ #endif #include <arm_arch.lsl> //////////////////////////////////////////////////////////////////////////// // // In the STM32F10x, 3 different boot modes can be selected // - User Flash memory is selected as boot space // - SystemMemory is selected as boot space // - Embedded SRAM is selected as boot space // // This aliases the physical memory associated with each boot mode to Block // 000 (0x00000000 boot memory). Even when aliased in the boot memory space, // the related memory (Flash memory or SRAM) is still accessible at its // original memory space. // // If no memory is defined yet use the following memory settings // #ifndef __MEMORY memory stm32f103flash { mau = 8; type = rom; size = 256k; map ( size = 256k, dest_offset=0x08000000, dest=bus:ARM:local_bus); } memory stm32f103ram { mau = 8; type = ram; size = 64k; map ( size = 64k, dest_offset=0x20000000, dest=bus:ARM:local_bus); } #endif /* __MEMORY */ // // Custom vector table defines interrupts according to CMSIS standard // # if defined(__CPU_ARMV7M__) section_setup ::linear { // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); vector ( id = 2, optional, fill = "NMI_Handler" ); vector ( id = 3, optional, fill = "HardFault_Handler" ); vector ( id = 4, optional, fill = "MemManage_Handler" ); vector ( id = 5, optional, fill = "BusFault_Handler" ); vector ( id = 6, optional, fill = "UsageFault_Handler" ); vector ( id = 11, optional, fill = "SVC_Handler" ); vector ( id = 12, optional, fill = "DebugMon_Handler" ); vector ( id = 14, optional, fill = "PendSV_Handler" ); vector ( id = 15, optional, fill = "SysTick_Handler" ); // External Interrupts : vector ( id = 16, optional, fill = "WWDG_IRQHandler" ); // Window Watchdog vector ( id = 17, optional, fill = "PVD_IRQHandler" ); // PVD through EXTI Line detect vector ( id = 18, optional, fill = "TAMPER_IRQHandler" ); // Tamper vector ( id = 19, optional, fill = "RTC_IRQHandler" ); // RTC vector ( id = 20, optional, fill = "FLASH_IRQHandler" ); // Flash vector ( id = 21, optional, fill = "RCC_IRQHandler" ); // RCC vector ( id = 22, optional, fill = "EXTI0_IRQHandler" ); // EXTI Line 0 vector ( id = 23, optional, fill = "EXTI1_IRQHandler" ); // EXTI Line 1 vector ( id = 24, optional, fill = "EXTI2_IRQHandler" ); // EXTI Line 2 vector ( id = 25, optional, fill = "EXTI3_IRQHandler" ); // EXTI Line 3 vector ( id = 26, optional, fill = "EXTI4_IRQHandler" ); // EXTI Line 4 vector ( id = 27, optional, fill = "DMA1_Channel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMA1_Channel2_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMA1_Channel3_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMA1_Channel4_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMA1_Channel5_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMA1_Channel6_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMA1_Channel7_IRQHandler" ); // DMA Channel 7 vector ( id = 34, optional, fill = "ADC1_2_IRQHandler" ); // ADC1 and ADC2 vector ( id = 35, optional, fill = "CAN1_TX_IRQHandler" ); // CAN1 TX vector ( id = 36, optional, fill = "CAN1_RX0_IRQHandler" ); // CAN1 RX0 vector ( id = 37, optional, fill = "CAN1_RX1_IRQHandler" ); // CAN1 RX1 vector ( id = 38, optional, fill = "CAN1_SCE_IRQHandler" ); // CAN1 SCE vector ( id = 39, optional, fill = "EXTI9_5_IRQHandler" ); // EXTI Line 9..5 vector ( id = 40, optional, fill = "TIM1_BRK_IRQHandler" ); // TIM1 Break vector ( id = 41, optional, fill = "TIM1_UP_IRQHandler" ); // TIM1 Update vector ( id = 42, optional, fill = "TIM1_TRG_COM_IRQHandler" ); // TIM1 Trigger and Commutation vector ( id = 43, optional, fill = "TIM1_CC_IRQHandler" ); // TIM1 Capture Compare vector ( id = 44, optional, fill = "TIM2_IRQHandler" ); // TIM2 vector ( id = 45, optional, fill = "TIM3_IRQHandler" ); // TIM3 vector ( id = 46, optional, fill = "TIM4_IRQHandler" ); // TIM4 vector ( id = 47, optional, fill = "I2C1_EV_IRQHandler" ); // I2C1 Event vector ( id = 48, optional, fill = "I2C1_ER_IRQHandler" ); // I2C1 Error vector ( id = 49, optional, fill = "I2C2_EV_IRQHandler" ); // I2C2 Event vector ( id = 50, optional, fill = "I2C2_ER_IRQHandler" ); // I2C2 Error vector ( id = 51, optional, fill = "SPI1_IRQHandler" ); // SPI1 vector ( id = 52, optional, fill = "SPI2_IRQHandler" ); // SPI2 vector ( id = 53, optional, fill = "USART1_IRQHandler" ); // USART1 vector ( id = 54, optional, fill = "USART2_IRQHandler" ); // USART2 vector ( id = 55, optional, fill = "USART3_IRQHandler" ); // USART3 vector ( id = 56, optional, fill = "EXTI15_10_IRQHandler" ); // EXTI Line 15..10 vector ( id = 57, optional, fill = "RTCAlarm_IRQHandler" ); // RTC Alarm through EXTI Line vector ( id = 58, optional, fill = "OTG_FS_WKUP_IRQHandler" ); // USB OTG FS Wakeup through EXTI line vector ( id = 66, optional, fill = "TIM5_IRQHandler" ); // TIM5 vector ( id = 67, optional, fill = "SPI3_IRQHandler" ); // SPI3 vector ( id = 68, optional, fill = "UART4_IRQHandler" ); // UART4 vector ( id = 69, optional, fill = "UART5_IRQHandler" ); // UART5 vector ( id = 70, optional, fill = "TIM6_IRQHandler" ); // TIM6 vector ( id = 71, optional, fill = "TIM7_IRQHandler" ); // TIM7 vector ( id = 72, optional, fill = "DMA2_Channel1_IRQHandler" ); // DMA2 Channel1 vector ( id = 73, optional, fill = "DMA2_Channel2_IRQHandler" ); // DMA2 Channel2 vector ( id = 74, optional, fill = "DMA2_Channel3_IRQHandler" ); // DMA2 Channel3 vector ( id = 75, optional, fill = "DMA2_Channel4_IRQHandler" ); // DMA2 Channel4 vector ( id = 76, optional, fill = "DMA2_Channel5_IRQHandler" ); // DMA2 Channel5 vector ( id = 77, optional, fill = "ETH_IRQHandler" ); // Ethernet vector ( id = 78, optional, fill = "ETH_WKUP_IRQHandler" ); // ETH_WKUP_IRQHandler vector ( id = 79, optional, fill = "CAN2_TX_IRQHandler " ); // CAN2 TX vector ( id = 80, optional, fill = "CAN2_RX0_IRQHandler" ); // CAN2 RX0 vector ( id = 81, optional, fill = "CAN2_RX1_IRQHandler" ); // CAN2 RX1 vector ( id = 82, optional, fill = "CAN2_SCE_IRQHandler" ); // CAN2 SCE vector ( id = 83, optional, fill = "OTG_FS_IRQHandler" ); // USB OTG FS } } # endif
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/HiTOP/AudioStreaming_25MHz/Settings/STM32F10x_cl.lsl
LSL
asf20
10,566
//////////////////////////////////////////////////////////////////////////// // // File : arm_arch.lsl // // Version : @(#)arm_arch.lsl 1.4 09/04/17 // // Description : Generic LSL file for ARM architectures // // Copyright 2008-2009 Altium BV // //////////////////////////////////////////////////////////////////////////// #ifndef __STACK # define __STACK 32k #endif #ifndef __HEAP # define __HEAP 32k #endif #ifndef __STACK_FIQ # define __STACK_FIQ 8 #endif #ifndef __STACK_IRQ # define __STACK_IRQ 8 #endif #ifndef __STACK_SVC # define __STACK_SVC 8 #endif #ifndef __STACK_ABT # define __STACK_ABT 8 #endif #ifndef __STACK_UND # define __STACK_UND 8 #endif #ifndef __PROCESSOR_MODE # define __PROCESSOR_MODE 0x1F /* SYS mode */ #endif #ifndef __IRQ_BIT # define __IRQ_BIT 0x80 /* IRQ interrupts disabled */ #endif #ifndef __FIQ_BIT # define __FIQ_BIT 0x40 /* FIQ interrupts disabled */ #endif #define __APPLICATION_MODE (__PROCESSOR_MODE | __IRQ_BIT | __FIQ_BIT) #ifndef __VECTOR_TABLE_ROM_ADDR # define __VECTOR_TABLE_ROM_ADDR 0x00000000 #endif #ifndef __VECTOR_TABLE_RAM_ADDR # define __VECTOR_TABLE_RAM_ADDR 0x00000000 #endif #if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) # ifndef __NR_OF_VECTORS # define __NR_OF_VECTORS 16 # endif # define __VECTOR_TABLE_SIZE (__NR_OF_VECTORS * 4) #else # ifdef __PIC_VECTORS # define __VECTOR_TABLE_SIZE 64 # else # ifdef __FIQ_HANDLER_INLINE # define __VECTOR_TABLE_SIZE 28 # define __NR_OF_VECTORS 7 # else # define __VECTOR_TABLE_SIZE 32 # define __NR_OF_VECTORS 8 # endif # endif #endif #ifndef __VECTOR_TABLE_RAM_SPACE # undef __VECTOR_TABLE_RAM_COPY #endif #ifndef __XVWBUF # define __XVWBUF 0 /* buffer used by CrossView Pro */ #endif #define BOUNDS_GROUP_NAME grp_bounds #define BOUNDS_GROUP_SELECT "bounds" architecture ARM { endianness { little; big; } space linear { id = 1; mau = 8; map (size = 4G, dest = bus:local_bus); copytable ( align = 4, copy_unit = 1, dest = linear ); start_address ( // It is not strictly necessary to define a run_addr for _START // because hardware starts execution at address 0x0 which should // be the vector table with a jump to the relocatable _START, but // an absolute address can prevent the branch to be out-of-range. // Or _START may be the entry point at reset and the reset handler // copies the vector table to address 0x0 after some ROM/RAM memory // re-mapping. In that case _START should be at a fixed address // in ROM, specifically the alias of address 0x0 before memory // re-mapping. #ifdef __START run_addr = __START, #endif symbol = "_START" ); stack "stack" ( #ifdef __STACK_FIXED fixed, #endif align = 4, min_size = __STACK, grows = high_to_low ); heap "heap" ( #ifdef __HEAP_FIXED fixed, #endif align = 4, min_size=__HEAP ); #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) stack "stack_fiq" ( fixed, align = 4, min_size = __STACK_FIQ, grows = high_to_low ); stack "stack_irq" ( fixed, align = 4, min_size = __STACK_IRQ, grows = high_to_low ); stack "stack_svc" ( fixed, align = 4, min_size = __STACK_SVC, grows = high_to_low ); stack "stack_abt" ( fixed, align = 4, min_size = __STACK_ABT, grows = high_to_low ); stack "stack_und" ( fixed, align = 4, min_size = __STACK_UND, grows = high_to_low ); #endif #if !defined(__NO_AUTO_VECTORS) && !defined(__NO_DEFAULT_AUTO_VECTORS) # if defined(__CPU_ARMV7M__) || defined(__CPU_ARMV6M__) // vector table with handler addresses vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop, no_inline ) { vector ( id = 0, fill = "_START" ); // FIXME: "_lc_ub_stack" does not work vector ( id = 1, fill = "_START" ); } # else # ifdef __PIC_VECTORS // vector table with ldrpc instructions from handler table vector_table "vector_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_ldrpc", template_symbol = "_lc_vector_ldrpc", vector_prefix = "_vector_ldrpc_", fill = loop ) { } // subsequent vector table (data pool) with addresses of handlers vector_table "handler_table" ( vector_size = 4, size = 8, run_addr = __VECTOR_TABLE_ROM_ADDR + 32, template = ".text.handler_address", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop[-32], no_inline ) { vector ( id = 0, fill = "_START" ); } # else // vector table with branch instructions to handlers vector_table "vector_table" ( vector_size = 4, size = __NR_OF_VECTORS, run_addr = __VECTOR_TABLE_ROM_ADDR, template = ".text.vector_branch", template_symbol = "_lc_vector_handler", vector_prefix = "_vector_", fill = loop ) { vector ( id = 0, fill = "_START" ); } # endif # endif #endif section_layout { #if defined(__NO_AUTO_VECTORS) "_lc_ub_vector_table" = __VECTOR_TABLE_ROM_ADDR; "_lc_ue_vector_table" = __VECTOR_TABLE_ROM_ADDR + __VECTOR_TABLE_SIZE; #endif #ifdef __VECTOR_TABLE_RAM_SPACE // reserve space to copy vector table from ROM to RAM group ( ordered, run_addr = __VECTOR_TABLE_RAM_ADDR ) reserved "vector_table_space" ( size = __VECTOR_TABLE_SIZE, attributes = rwx ); #endif #ifdef __VECTOR_TABLE_RAM_COPY // provide copy address symbols for copy routine "_lc_ub_vector_table_copy" := "_lc_ub_vector_table_space"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table_space"; #else // prevent copy: copy address equals orig address "_lc_ub_vector_table_copy" := "_lc_ub_vector_table"; "_lc_ue_vector_table_copy" := "_lc_ue_vector_table"; #endif // define buffer for string input via Crossview Pro debugger group ( align = 4 ) reserved "xvwbuffer" (size=__XVWBUF, attributes=rw ); // define labels for bounds begin and end as used in C library #ifndef BOUNDS_GROUP_REDEFINED group BOUNDS_GROUP_NAME (ordered, contiguous) { select BOUNDS_GROUP_SELECT; } #endif "_lc_ub_bounds" := addressof(group:BOUNDS_GROUP_NAME); "_lc_ue_bounds" := addressof(group:BOUNDS_GROUP_NAME) + sizeof(group:BOUNDS_GROUP_NAME); #ifdef __HEAPADDR group ( ordered, run_addr=__HEAPADDR ) { select "heap"; } #endif #ifdef __STACKADDR group ( ordered, run_addr=__STACKADDR ) { select "stack"; } #endif #if !defined(__CPU_ARMV7M__) && !defined(__CPU_ARMV6M__) // symbol to set mode bits and interrupt disable bits // in cstart module before calling the application (main) "_APPLICATION_MODE_" = __APPLICATION_MODE; #endif } } bus local_bus { mau = 8; width = 32; } }
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Audio_Streaming/HiTOP/AudioStreaming_25MHz/Settings/arm_arch.lsl
LSL
asf20
10,931
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_pwr.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Connection/disconnection & power management header ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_PWR_H #define __USB_PWR_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ typedef enum _RESUME_STATE { RESUME_EXTERNAL, RESUME_INTERNAL, RESUME_LATER, RESUME_WAIT, RESUME_START, RESUME_ON, RESUME_OFF, RESUME_ESOF } RESUME_STATE; typedef enum _DEVICE_STATE { UNCONNECTED, ATTACHED, POWERED, SUSPENDED, ADDRESSED, CONFIGURED } DEVICE_STATE; /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void Suspend(void); void Resume_Init(void); void Resume(RESUME_STATE eResumeSetVal); RESULT PowerOn(void); RESULT PowerOff(void); /* External variables --------------------------------------------------------*/ extern __IO uint32_t bDeviceState; /* USB device status */ extern __IO bool fSuspendEnabled; /* true when suspend is possible */ #endif /*__USB_PWR_H*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/usb_pwr.h
C
asf20
2,250
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : dfu_mal.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Header for dfu_mal.c file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __DFU_MAL_H #define __DFU_MAL_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "dfu_mal.h" #include "usb_desc.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ #define MAL_OK 0 #define MAL_FAIL 1 #define MAX_USED_MEDIA 3 #define MAL_MASK 0xFC000000 #define INTERNAL_FLASH_BASE 0x08000000 #define SPI_FLASH_BASE 0x00000000 #define NOR_FLASH_BASE 0x64000000 #define NOR_M29W128F 0x2212 #define NOR_M29W128G 0x2221 #define NOR_S29GL128 0x2221 /* utils macro ---------------------------------------------------------------*/ #define _1st_BYTE(x) (uint8_t)((x)&0xFF) /* 1st addressing cycle */ #define _2nd_BYTE(x) (uint8_t)(((x)&0xFF00)>>8) /* 2nd addressing cycle */ #define _3rd_BYTE(x) (uint8_t)(((x)&0xFF0000)>>16) /* 3rd addressing cycle */ #define _4th_BYTE(x) (uint8_t)(((x)&0xFF000000)>>24) /* 4th addressing cycle */ /* Exported macro ------------------------------------------------------------*/ #define SET_POLLING_TIMING(x) buffer[1] = _1st_BYTE(x);\ buffer[2] = _2nd_BYTE(x);\ buffer[3] = _3rd_BYTE(x); /* Exported functions ------------------------------------------------------- */ uint16_t MAL_Init (void); uint16_t MAL_Erase (uint32_t SectorAddress); uint16_t MAL_Write (uint32_t SectorAddress, uint32_t DataLength); uint8_t *MAL_Read (uint32_t SectorAddress, uint32_t DataLength); uint16_t MAL_GetStatus(uint32_t SectorAddress ,uint8_t Cmd, uint8_t *buffer); extern uint8_t MAL_Buffer[wTransferSize]; /* RAM Buffer for Downloaded Data */ #endif /* __DFU_MAL_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/dfu_mal.h
C
asf20
2,916
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : hw_config.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Hardware Configuration & Setup ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __HW_CONFIG_H #define __HW_CONFIG_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Flash memory address from where user application will be loaded */ #define ApplicationAddress 0x08003000 /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void Set_System(void); void Set_USBClock(void); void Enter_LowPowerMode(void); void Leave_LowPowerMode(void); void USB_Cable_Config (FunctionalState NewState); void USB_Interrupts_Config(void); void DFU_Button_Config(void); uint8_t DFU_Button_Read(void); void Reset_Device(void); void SMI_FLASH_Init(void); void SMI_FLASH_SectorErase(uint32_t Address); void SMI_FLASH_WordWrite(uint32_t Address, uint32_t Data); void SMI_FLASH_PageWrite(uint32_t Address, uint32_t* wBuffer); void Get_SerialNum(void); /* External variables --------------------------------------------------------*/ #endif /*__HW_CONFIG_H*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/hw_config.h
C
asf20
2,277
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_desc.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Descriptor Header for Device Firmware Upgrade (DFU) ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_DESC_H #define __USB_DESC_H #include "platform_config.h" /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ #define DFU_SIZ_DEVICE_DESC 18 #ifdef USE_STM3210B_EVAL #define DFU_SIZ_CONFIG_DESC 36 #elif defined(USE_STM3210C_EVAL) #define DFU_SIZ_CONFIG_DESC 27 #elif defined(USE_STM3210E_EVAL) #define DFU_SIZ_CONFIG_DESC 45 #endif /* USE_STM3210B_EVAL */ #define DFU_SIZ_STRING_LANGID 4 #define DFU_SIZ_STRING_VENDOR 38 #define DFU_SIZ_STRING_PRODUCT 20 #define DFU_SIZ_STRING_SERIAL 26 #define DFU_SIZ_STRING_INTERFACE0 96 /* Flash Bank 0 */ #define DFU_SIZ_STRING_INTERFACE1 98 /* SPI Flash : M25P64*/ #define DFU_SIZ_STRING_INTERFACE2 106 /* NOR Flash : M26M128*/ extern uint8_t DFU_DeviceDescriptor[DFU_SIZ_DEVICE_DESC]; extern uint8_t DFU_ConfigDescriptor[DFU_SIZ_CONFIG_DESC]; extern uint8_t DFU_StringLangId [DFU_SIZ_STRING_LANGID]; extern uint8_t DFU_StringVendor [DFU_SIZ_STRING_VENDOR]; extern uint8_t DFU_StringProduct [DFU_SIZ_STRING_PRODUCT]; extern uint8_t DFU_StringSerial [DFU_SIZ_STRING_SERIAL]; extern uint8_t DFU_StringInterface0 [DFU_SIZ_STRING_INTERFACE0]; extern uint8_t DFU_StringInterface1 [DFU_SIZ_STRING_INTERFACE1]; extern uint8_t DFU_StringInterface2_1 [DFU_SIZ_STRING_INTERFACE2]; extern uint8_t DFU_StringInterface2_2 [DFU_SIZ_STRING_INTERFACE2]; extern uint8_t DFU_StringInterface2_3 [DFU_SIZ_STRING_INTERFACE2]; #define bMaxPacketSize0 0x40 /* bMaxPacketSize0 = 64 bytes */ #define wTransferSize 0x0400 /* wTransferSize = 1024 bytes */ /* bMaxPacketSize0 <= wTransferSize <= 32kbytes */ #define wTransferSizeB0 0x00 #define wTransferSizeB1 0x04 /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ /* External variables --------------------------------------------------------*/ #endif /* __USB_DESC_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/usb_desc.h
C
asf20
3,409
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_prop.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : All processings related to DFU demo ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_PROP_H #define __USB_PROP_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void DFU_init(void); void DFU_Reset(void); void DFU_SetConfiguration(void); void DFU_SetDeviceAddress (void); void DFU_Status_In (void); void DFU_Status_Out (void); RESULT DFU_Data_Setup(uint8_t); RESULT DFU_NoData_Setup(uint8_t); RESULT DFU_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting); uint8_t *DFU_GetDeviceDescriptor(uint16_t ); uint8_t *DFU_GetConfigDescriptor(uint16_t); uint8_t *DFU_GetStringDescriptor(uint16_t); uint8_t *UPLOAD(uint16_t Length); uint8_t *DNLOAD(uint16_t Length); uint8_t *GETSTATE(uint16_t Length); uint8_t *GETSTATUS(uint16_t Length); void DFU_write_crc (void); /* External variables --------------------------------------------------------*/ #define DFU_GetConfiguration NOP_Process //#define DFU_SetConfiguration NOP_Process #define DFU_GetInterface NOP_Process #define DFU_SetInterface NOP_Process #define DFU_GetStatus NOP_Process #define DFU_ClearFeature NOP_Process #define DFU_SetEndPointFeature NOP_Process #define DFU_SetDeviceFeature NOP_Process //#define DFU_SetDeviceAddress NOP_Process /*---------------------------------------------------------------------*/ /* DFU definitions */ /*---------------------------------------------------------------------*/ /**************************************************/ /* DFU Requests */ /**************************************************/ typedef enum _DFU_REQUESTS { DFU_DNLOAD = 1, DFU_UPLOAD, DFU_GETSTATUS, DFU_CLRSTATUS, DFU_GETSTATE, DFU_ABORT } DFU_REQUESTS; /**************************************************/ /* DFU Requests DFU states */ /**************************************************/ #define STATE_appIDLE 0 #define STATE_appDETACH 1 #define STATE_dfuIDLE 2 #define STATE_dfuDNLOAD_SYNC 3 #define STATE_dfuDNBUSY 4 #define STATE_dfuDNLOAD_IDLE 5 #define STATE_dfuMANIFEST_SYNC 6 #define STATE_dfuMANIFEST 7 #define STATE_dfuMANIFEST_WAIT_RESET 8 #define STATE_dfuUPLOAD_IDLE 9 #define STATE_dfuERROR 10 /**************************************************/ /* DFU Requests DFU status */ /**************************************************/ #define STATUS_OK 0x00 #define STATUS_ERRTARGET 0x01 #define STATUS_ERRFILE 0x02 #define STATUS_ERRWRITE 0x03 #define STATUS_ERRERASE 0x04 #define STATUS_ERRCHECK_ERASED 0x05 #define STATUS_ERRPROG 0x06 #define STATUS_ERRVERIFY 0x07 #define STATUS_ERRADDRESS 0x08 #define STATUS_ERRNOTDONE 0x09 #define STATUS_ERRFIRMWARE 0x0A #define STATUS_ERRVENDOR 0x0B #define STATUS_ERRUSBR 0x0C #define STATUS_ERRPOR 0x0D #define STATUS_ERRUNKNOWN 0x0E #define STATUS_ERRSTALLEDPKT 0x0F /**************************************************/ /* DFU Requests DFU states Manifestation State */ /**************************************************/ #define Manifest_complete 0x00 #define Manifest_In_Progress 0x01 /**************************************************/ /* Special Commands with Download Request */ /**************************************************/ #define CMD_GETCOMMANDS 0x00 #define CMD_SETADDRESSPOINTER 0x21 #define CMD_ERASE 0x41 #endif /* __USB_PROP_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/usb_prop.h
C
asf20
5,289
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : stm32f10x_conf.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Library configuration file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F10x_CONF_H #define __STM32F10x_CONF_H /* Includes ------------------------------------------------------------------*/ /* Uncomment the line below to enable peripheral header file inclusion */ /* #include "stm32f10x_adc.h" */ /* #include "stm32f10x_bkp.h" */ /* #include "stm32f10x_can.h" */ /* #include "stm32f10x_crc.h" */ /* #include "stm32f10x_dac.h" */ /* #include "stm32f10x_dbgmcu.h" */ /* #include "stm32f10x_dma.h" */ #include "stm32f10x_exti.h" #include "stm32f10x_flash.h" #include "stm32f10x_fsmc.h" #include "stm32f10x_gpio.h" /* #include "stm32f10x_i2c.h" */ /* #include "stm32f10x_iwdg.h" */ /* #include "stm32f10x_pwr.h" */ #include "stm32f10x_rcc.h" /* #include "stm32f10x_rtc.h" */ /* #include "stm32f10x_sdio.h" */ #include "stm32f10x_spi.h" /* #include "stm32f10x_tim.h" */ #include "stm32f10x_usart.h" /* #include "stm32f10x_wwdg.h" */ #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Uncomment the line below to expanse the "assert_param" macro in the Standard Peripheral Library drivers code */ /* #define USE_FULL_ASSERT 1 */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /******************************************************************************* * Macro Name : assert_param * Description : The assert_param macro is used for function's parameters check. * Input : - expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * Return : None *******************************************************************************/ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0) #endif /* USE_FULL_ASSERT */ #endif /* __STM32F10x_CONF_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/stm32f10x_conf.h
C
asf20
3,440
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : fsmc_nor.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Header for fsmc_nor.c file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __FSMC_NOR_H #define __FSMC_NOR_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /* Exported types ------------------------------------------------------------*/ typedef struct { uint16_t Manufacturer_Code; uint16_t Device_Code1; uint16_t Device_Code2; uint16_t Device_Code3; }NOR_IDTypeDef; /* NOR Status */ typedef enum { NOR_SUCCESS = 0, NOR_ONGOING, NOR_ERROR, NOR_TIMEOUT }NOR_Status; /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void FSMC_NOR_Init(void); void FSMC_NOR_ReadID(NOR_IDTypeDef* NOR_ID); NOR_Status FSMC_NOR_EraseBlock(uint32_t BlockAddr); NOR_Status FSMC_NOR_EraseChip(void); NOR_Status FSMC_NOR_WriteHalfWord(uint32_t WriteAddr, uint16_t Data); NOR_Status FSMC_NOR_WriteBuffer(uint16_t* pBuffer, uint32_t WriteAddr, uint32_t NumHalfwordToWrite); NOR_Status FSMC_NOR_ProgramBuffer(uint16_t* pBuffer, uint32_t WriteAddr, uint32_t NumHalfwordToWrite); uint16_t FSMC_NOR_ReadHalfWord(uint32_t ReadAddr); void FSMC_NOR_ReadBuffer(uint16_t* pBuffer, uint32_t ReadAddr, uint32_t NumHalfwordToRead); NOR_Status FSMC_NOR_ReturnToReadMode(void); NOR_Status FSMC_NOR_Reset(void); NOR_Status FSMC_NOR_GetStatus(uint32_t Timeout); #endif /* __FSMC_NOR_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/fsmc_nor.h
C
asf20
2,561
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : dfu_mal.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Header for dfu_mal.c file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __SPI_IF_MAL_H #define __SPI_IF_MAL_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ uint16_t SPI_If_Init(void); uint16_t SPI_If_Erase (uint32_t SectorAddress); uint16_t SPI_If_Write (uint32_t SectorAddress, uint32_t DataLength); uint8_t *SPI_If_Read (uint32_t SectorAddress, uint32_t DataLength); #endif /* __SPI_IF_MAL_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/spi_if.h
C
asf20
1,806
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : stm32f10x_it.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : This file contains the headers of the interrupt handlers. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F10x_IT_H #define __STM32F10x_IT_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); #ifndef STM32F10X_CL void USB_LP_CAN1_RX0_IRQHandler(void); #endif /* STM32F10X_CL */ #ifdef STM32F10X_CL void OTG_FS_IRQHandler(void); #endif /* STM32F10X_CL */ #endif /* __STM32F10x_IT_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/stm32f10x_it.h
C
asf20
2,068
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : platform_config.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Evaluation board specific configuration file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __PLATFORM_CONFIG_H #define __PLATFORM_CONFIG_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Uncomment the line corresponding to the STMicroelectronics evaluation board used to run the example */ #if !defined (USE_STM3210B_EVAL) && !defined (USE_STM3210E_EVAL) && !defined (USE_STM3210C_EVAL) //#define USE_STM3210B_EVAL //#define USE_STM3210E_EVAL #define USE_STM3210C_EVAL #endif /* Define the STM32F10x hardware depending on the used evaluation board */ #ifdef USE_STM3210B_EVAL #define USB_DISCONNECT GPIOD #define USB_DISCONNECT_PIN GPIO_Pin_9 #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOD #elif defined (USE_STM3210E_EVAL) #define USB_DISCONNECT GPIOB #define USB_DISCONNECT_PIN GPIO_Pin_14 #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB #elif defined (USE_STM3210C_EVAL) #define USB_DISCONNECT 0 #define USB_DISCONNECT_PIN 0 #define RCC_APB2Periph_GPIO_DISCONNECT 0 #endif /* USE_STM3210B_EVAL */ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #endif /* __PLATFORM_CONFIG_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/platform_config.h
C
asf20
2,667
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : nor_if.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Header for nor_if.c file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __NOR_IF_MAL_H #define __NOR_IF_MAL_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ uint16_t NOR_If_Init(void); uint16_t NOR_If_Erase(uint32_t Address); uint16_t NOR_If_Write(uint32_t Address, uint32_t DataLength); uint8_t *NOR_If_Read(uint32_t Address, uint32_t DataLength); #endif /* __NOR_IF_MAL_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/nor_if.h
C
asf20
1,783
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : flash_if.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Header for flash_if.c file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __FLASH_IF_MAL_H #define __FLASH_IF_MAL_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ uint16_t FLASH_If_Init(void); uint16_t FLASH_If_Erase (uint32_t SectorAddress); uint16_t FLASH_If_Write (uint32_t SectorAddress, uint32_t DataLength); uint8_t *FLASH_If_Read (uint32_t SectorAddress, uint32_t DataLength); #endif /* __FLASH_IF_MAL_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/flash_if.h
C
asf20
1,822
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : spi_flash.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Header for spi_flash.c file. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __SPI_FLASH_H #define __SPI_FLASH_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Uncomment the line corresponding to the STMicroelectronics evaluation board used to run the example */ #if !defined (USE_STM3210B_EVAL) && !defined (USE_STM3210E_EVAL) && !defined (USE_STM3210C_EVAL) //#define USE_STM3210B_EVAL #define USE_STM3210E_EVAL #endif #ifdef USE_STM3210B_EVAL #define GPIO_CS GPIOA #define RCC_APB2Periph_GPIO_CS RCC_APB2Periph_GPIOA #define GPIO_Pin_CS GPIO_Pin_4 #else /* USE_STM3210E_EVAL */ #define GPIO_CS GPIOB #define RCC_APB2Periph_GPIO_CS RCC_APB2Periph_GPIOB #define GPIO_Pin_CS GPIO_Pin_2 #endif /* Exported macro ------------------------------------------------------------*/ /* Select SPI FLASH: Chip Select pin low */ #define SPI_FLASH_CS_LOW() GPIO_ResetBits(GPIO_CS, GPIO_Pin_CS) /* Deselect SPI FLASH: Chip Select pin high */ #define SPI_FLASH_CS_HIGH() GPIO_SetBits(GPIO_CS, GPIO_Pin_CS) /* Exported functions ------------------------------------------------------- */ /*----- High layer function -----*/ void SPI_FLASH_Init(void); void SPI_FLASH_SectorErase(uint32_t SectorAddr); void SPI_FLASH_BulkErase(void); void SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); void SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); void SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead); uint32_t SPI_FLASH_ReadID(void); void SPI_FLASH_StartReadSequence(uint32_t ReadAddr); /*----- Low layer function -----*/ uint8_t SPI_FLASH_ReadByte(void); uint8_t SPI_FLASH_SendByte(uint8_t byte); uint16_t SPI_FLASH_SendHalfWord(uint16_t HalfWord); void SPI_FLASH_WriteEnable(void); void SPI_FLASH_WaitForWriteEnd(void); #endif /* __SPI_FLASH_H */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/spi_flash.h
C
asf20
3,210
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_istr.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : This file includes the peripherals header files in the * user application. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_ISTR_H #define __USB_ISTR_H /* Includes ------------------------------------------------------------------*/ #include "usb_conf.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #ifndef STM32F10X_CL void USB_Istr(void); #else /* STM32F10X_CL */ u32 STM32_PCD_OTG_ISR_Handler(void); #endif /* STM32F10X_CL */ /* function prototypes Automatically built defining related macros */ void EP1_IN_Callback(void); void EP2_IN_Callback(void); void EP3_IN_Callback(void); void EP4_IN_Callback(void); void EP5_IN_Callback(void); void EP6_IN_Callback(void); void EP7_IN_Callback(void); void EP1_OUT_Callback(void); void EP2_OUT_Callback(void); void EP3_OUT_Callback(void); void EP4_OUT_Callback(void); void EP5_OUT_Callback(void); void EP6_OUT_Callback(void); void EP7_OUT_Callback(void); #ifndef STM32F10X_CL #ifdef CTR_CALLBACK void CTR_Callback(void); #endif #ifdef DOVR_CALLBACK void DOVR_Callback(void); #endif #ifdef ERR_CALLBACK void ERR_Callback(void); #endif #ifdef WKUP_CALLBACK void WKUP_Callback(void); #endif #ifdef SUSP_CALLBACK void SUSP_Callback(void); #endif #ifdef RESET_CALLBACK void RESET_Callback(void); #endif #ifdef SOF_CALLBACK void SOF_Callback(void); #endif #ifdef ESOF_CALLBACK void ESOF_Callback(void); #endif #else /* STM32F10X_CL */ /* Interrupt subroutines user callbacks prototypes. These callbacks are called into the respective interrupt sunroutine functinos and can be tailored for various user application purposes. Note: Make sure that the correspondant interrupt is enabled through the definition in usb_conf.h file */ void INTR_MODEMISMATCH_Callback(void); void INTR_SOFINTR_Callback(void); void INTR_RXSTSQLVL_Callback(void); void INTR_NPTXFEMPTY_Callback(void); void INTR_GINNAKEFF_Callback(void); void INTR_GOUTNAKEFF_Callback(void); void INTR_ERLYSUSPEND_Callback(void); void INTR_USBSUSPEND_Callback(void); void INTR_USBRESET_Callback(void); void INTR_ENUMDONE_Callback(void); void INTR_ISOOUTDROP_Callback(void); void INTR_EOPFRAME_Callback(void); void INTR_EPMISMATCH_Callback(void); void INTR_INEPINTR_Callback(void); void INTR_OUTEPINTR_Callback(void); void INTR_INCOMPLISOIN_Callback(void); void INTR_INCOMPLISOOUT_Callback(void); void INTR_WKUPINTR_Callback(void); /* Isochronous data update */ void INTR_RXSTSQLVL_ISODU_Callback(void); #endif /* STM32F10X_CL */ #endif /*__USB_ISTR_H*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/usb_istr.h
C
asf20
3,903
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_conf.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Device Firmware Upgrade (DFU) configuration file ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USB_CONF_H #define __USB_CONF_H /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ /* External variables --------------------------------------------------------*/ /*-------------------------------------------------------------*/ /* EP_NUM */ /* defines how many endpoints are used by the device */ /*-------------------------------------------------------------*/ #define EP_NUM (1) #ifndef STM32F10X_CL /*-------------------------------------------------------------*/ /* -------------- Buffer Description Table -----------------*/ /*-------------------------------------------------------------*/ /* buffer table base address */ /* buffer table base address */ #define BTABLE_ADDRESS (0x00) /* EP0 */ /* rx/tx buffer base address */ #define ENDP0_RXADDR (0x10) #define ENDP0_TXADDR (0x50) /*-------------------------------------------------------------*/ /* ------------------- ISTR events -------------------------*/ /*-------------------------------------------------------------*/ /* IMR_MSK */ /* mask defining which events has to be handled */ /* by the device application software */ #define IMR_MSK (CNTR_CTRM | \ CNTR_WKUPM | \ CNTR_SUSPM | \ CNTR_ERRM | \ CNTR_SOFM | \ CNTR_ESOFM | \ CNTR_RESETM \ ) #endif /* STM32F10X_CL */ #ifdef STM32F10X_CL /******************************************************************************* * FIFO Size Configuration * * (i) Dedicated data FIFO SPRAM of 1.25 Kbytes = 1280 bytes = 320 32-bits words * available for the endpoints IN and OUT. * Device mode features: * -1 bidirectional CTRL EP 0 * -3 IN EPs to support any kind of Bulk, Interrupt or Isochronous transfer * -3 OUT EPs to support any kind of Bulk, Interrupt or Isochronous transfer * * ii) Receive data FIFO size = RAM for setup packets + * OUT endpoint control information + * data OUT packets + miscellaneous * Space = ONE 32-bits words * --> RAM for setup packets = 4 * n + 6 space * (n is the nbr of CTRL EPs the device core supports) * --> OUT EP CTRL info = 1 space * (one space for status information written to the FIFO along with each * received packet) * --> data OUT packets = (Largest Packet Size / 4) + 1 spaces * (MINIMUM to receive packets) * --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces * (if high-bandwidth EP is enabled or multiple isochronous EPs) * --> miscellaneous = 1 space per OUT EP * (one space for transfer complete status information also pushed to the * FIFO with each endpoint's last packet) * * (iii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for * that particular IN EP. More space allocated in the IN EP Tx FIFO results * in a better performance on the USB and can hide latencies on the AHB. * * (iv) TXn min size = 16 words. (n : Transmit FIFO index) * (v) When a TxFIFO is not used, the Configuration should be as follows: * case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) * --> Txm can use the space allocated for Txn. * case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) * --> Txn should be configured with the minimum space of 16 words * (vi) The FIFO is used optimally when used TxFIFOs are allocated in the top * of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. *******************************************************************************/ #define RX_FIFO_SIZE 128 #define TX0_FIFO_SIZE 64 #define TX1_FIFO_SIZE 64 #define TX2_FIFO_SIZE 16 #define TX3_FIFO_SIZE 16 /* OTGD-FS-DEVICE IP interrupts Enable definitions */ /* Uncomment the define to enable the selected interrupt */ //#define INTR_MODEMISMATCH #define INTR_SOFINTR #define INTR_RXSTSQLVL /* Mandatory */ //#define INTR_NPTXFEMPTY //#define INTR_GINNAKEFF //#define INTR_GOUTNAKEFF //#define INTR_ERLYSUSPEND #define INTR_USBSUSPEND /* Mandatory */ #define INTR_USBRESET /* Mandatory */ #define INTR_ENUMDONE /* Mandatory */ //#define INTR_ISOOUTDROP //#define INTR_EOPFRAME //#define INTR_EPMISMATCH #define INTR_INEPINTR /* Mandatory */ #define INTR_OUTEPINTR /* Mandatory */ //#define INTR_INCOMPLISOIN //#define INTR_INCOMPLISOOUT #define INTR_WKUPINTR /* Mandatory */ /* OTGD-FS-DEVICE IP interrupts subroutines */ /* Comment the define to enable the selected interrupt subroutine and replace it by user code */ #define INTR_MODEMISMATCH_Callback NOP_Process #define INTR_SOFINTR_Callback NOP_Process #define INTR_RXSTSQLVL_Callback NOP_Process #define INTR_NPTXFEMPTY_Callback NOP_Process #define INTR_NPTXFEMPTY_Callback NOP_Process #define INTR_GINNAKEFF_Callback NOP_Process #define INTR_GOUTNAKEFF_Callback NOP_Process #define INTR_ERLYSUSPEND_Callback NOP_Process #define INTR_USBSUSPEND_Callback NOP_Process #define INTR_USBRESET_Callback NOP_Process #define INTR_ENUMDONE_Callback NOP_Process #define INTR_ISOOUTDROP_Callback NOP_Process #define INTR_EOPFRAME_Callback NOP_Process #define INTR_EPMISMATCH_Callback NOP_Process #define INTR_INEPINTR_Callback NOP_Process #define INTR_OUTEPINTR_Callback NOP_Process #define INTR_INCOMPLISOIN_Callback NOP_Process #define INTR_INCOMPLISOOUT_Callback NOP_Process #define INTR_WKUPINTR_Callback NOP_Process /* Isochronous data update */ #define INTR_RXSTSQLVL_ISODU_Callback NOP_Process /* Isochronous transfer parameters */ /* Size of a single Isochronous buffer (size of a single transfer) */ #define ISOC_BUFFER_SZE 1 /* Number of sub-buffers (number of single buffers/transfers), should be even */ #define NUM_SUB_BUFFERS 2 #endif /* STM32F10X_CL */ /* CTR service routines */ /* associated to defined endpoints */ #define EP1_IN_Callback NOP_Process #define EP2_IN_Callback NOP_Process #define EP3_IN_Callback NOP_Process #define EP4_IN_Callback NOP_Process #define EP5_IN_Callback NOP_Process #define EP6_IN_Callback NOP_Process #define EP7_IN_Callback NOP_Process #define EP1_OUT_Callback NOP_Process #define EP2_OUT_Callback NOP_Process #define EP3_OUT_Callback NOP_Process #define EP4_OUT_Callback NOP_Process #define EP5_OUT_Callback NOP_Process #define EP6_OUT_Callback NOP_Process #define EP7_OUT_Callback NOP_Process #endif /*__USB_CONF_H*/ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/inc/usb_conf.h
C
asf20
8,558
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : fsmc_nor.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : This file provides a set of functions needed to drive the * M29W128FL, M29W128GL and S29GL128P NOR memories mounted * on STM3210E-EVAL board. ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "fsmc_nor.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define Bank1_NOR2_ADDR ((uint32_t)0x64000000) /* Delay definition */ #define BlockErase_Timeout ((uint32_t)0x00A00000) #define ChipErase_Timeout ((uint32_t)0x30000000) #define Program_Timeout ((uint32_t)0x00001400) /* Private macro -------------------------------------------------------------*/ #define ADDR_SHIFT(A) (Bank1_NOR2_ADDR + (2 * (A))) #define NOR_WRITE(Address, Data) (*(__IO uint16_t *)(Address) = (Data)) /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : FSMC_NOR_Init * Description : Configures the FSMC and GPIOs to interface with the NOR memory. * This function must be called before any write/read operation * on the NOR. * Input : None * Output : None * Return : None *******************************************************************************/ void FSMC_NOR_Init(void) { FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; FSMC_NORSRAMTimingInitTypeDef p; GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG, ENABLE); /*-- GPIO Configuration ------------------------------------------------------*/ /* NOR Data lines configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; GPIO_Init(GPIOE, &GPIO_InitStructure); /* NOR Address lines configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; GPIO_Init(GPIOF, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5; GPIO_Init(GPIOG, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6; GPIO_Init(GPIOE, &GPIO_InitStructure); /* NOE and NWE configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; GPIO_Init(GPIOD, &GPIO_InitStructure); /* NE2 configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_Init(GPIOG, &GPIO_InitStructure); /*-- FSMC Configuration ----------------------------------------------------*/ p.FSMC_AddressSetupTime = 0x02; p.FSMC_AddressHoldTime = 0x00; p.FSMC_DataSetupTime = 0x05; p.FSMC_BusTurnAroundDuration = 0x00; p.FSMC_CLKDivision = 0x00; p.FSMC_DataLatency = 0x00; p.FSMC_AccessMode = FSMC_AccessMode_B; FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2; FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR; FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); /* Enable FSMC Bank1_NOR Bank */ FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM2, ENABLE); } /****************************************************************************** * Function Name : FSMC_NOR_ReadID * Description : Reads NOR memory's Manufacturer and Device Code. * Input : - NOR_ID: pointer to a NOR_IDTypeDef structure which will hold * the Manufacturer and Device Code. * Output : None * Return : None *******************************************************************************/ void FSMC_NOR_ReadID(NOR_IDTypeDef* NOR_ID) { NOR_WRITE(ADDR_SHIFT(0x0555), 0x00AA); NOR_WRITE(ADDR_SHIFT(0x02AA), 0x0055); NOR_WRITE(ADDR_SHIFT(0x0555), 0x0090); NOR_ID->Manufacturer_Code = *(__IO uint16_t *) ADDR_SHIFT(0x0000); NOR_ID->Device_Code1 = *(__IO uint16_t *) ADDR_SHIFT(0x0001); NOR_ID->Device_Code2 = *(__IO uint16_t *) ADDR_SHIFT(0x000E); NOR_ID->Device_Code3 = *(__IO uint16_t *) ADDR_SHIFT(0x000F); } /******************************************************************************* * Function Name : FSMC_NOR_EraseBlock * Description : Erases the specified Nor memory block. * Input : - BlockAddr: address of the block to erase. * Output : None * Return : NOR_Status:The returned value can be: NOR_SUCCESS, NOR_ERROR * or NOR_TIMEOUT *******************************************************************************/ NOR_Status FSMC_NOR_EraseBlock(uint32_t BlockAddr) { NOR_WRITE(ADDR_SHIFT(0x0555), 0x00AA); NOR_WRITE(ADDR_SHIFT(0x02AA), 0x0055); NOR_WRITE(ADDR_SHIFT(0x0555), 0x0080); NOR_WRITE(ADDR_SHIFT(0x0555), 0x00AA); NOR_WRITE(ADDR_SHIFT(0x02AA), 0x0055); NOR_WRITE((Bank1_NOR2_ADDR + BlockAddr), 0x30); return (FSMC_NOR_GetStatus(BlockErase_Timeout)); } /******************************************************************************* * Function Name : FSMC_NOR_EraseChip * Description : Erases the entire chip. * Input : None * Output : None * Return : NOR_Status:The returned value can be: NOR_SUCCESS, NOR_ERROR * or NOR_TIMEOUT *******************************************************************************/ NOR_Status FSMC_NOR_EraseChip(void) { NOR_WRITE(ADDR_SHIFT(0x0555), 0x00AA); NOR_WRITE(ADDR_SHIFT(0x02AA), 0x0055); NOR_WRITE(ADDR_SHIFT(0x0555), 0x0080); NOR_WRITE(ADDR_SHIFT(0x0555), 0x00AA); NOR_WRITE(ADDR_SHIFT(0x02AA), 0x0055); NOR_WRITE(ADDR_SHIFT(0x0555), 0x0010); return (FSMC_NOR_GetStatus(ChipErase_Timeout)); } /****************************************************************************** * Function Name : FSMC_NOR_WriteHalfWord * Description : Writes a half-word to the NOR memory. * Input : - WriteAddr : NOR memory internal address to write to. * - Data : Data to write. * Output : None * Return : NOR_Status:The returned value can be: NOR_SUCCESS, NOR_ERROR * or NOR_TIMEOUT *******************************************************************************/ NOR_Status FSMC_NOR_WriteHalfWord(uint32_t WriteAddr, uint16_t Data) { NOR_WRITE(ADDR_SHIFT(0x0555), 0x00AA); NOR_WRITE(ADDR_SHIFT(0x02AA), 0x0055); NOR_WRITE(ADDR_SHIFT(0x0555), 0x00A0); NOR_WRITE((Bank1_NOR2_ADDR + WriteAddr), Data); return (FSMC_NOR_GetStatus(Program_Timeout)); } /******************************************************************************* * Function Name : FSMC_NOR_WriteBuffer * Description : Writes a half-word buffer to the FSMC NOR memory. * Input : - pBuffer : pointer to buffer. * - WriteAddr : NOR memory internal address from which the data * will be written. * - NumHalfwordToWrite : number of Half words to write. * Output : None * Return : NOR_Status:The returned value can be: NOR_SUCCESS, NOR_ERROR * or NOR_TIMEOUT *******************************************************************************/ NOR_Status FSMC_NOR_WriteBuffer(uint16_t* pBuffer, uint32_t WriteAddr, uint32_t NumHalfwordToWrite) { NOR_Status status = NOR_ONGOING; do { /* Transfer data to the memory */ status = FSMC_NOR_WriteHalfWord(WriteAddr, *pBuffer++); WriteAddr = WriteAddr + 2; NumHalfwordToWrite--; } while((status == NOR_SUCCESS) && (NumHalfwordToWrite != 0)); return (status); } /******************************************************************************* * Function Name : FSMC_NOR_ProgramBuffer * Description : Writes a half-word buffer to the FSMC NOR memory. This function * must be used only with S29GL128P NOR memory. * Input : - pBuffer : pointer to buffer. * - WriteAddr: NOR memory internal address from which the data * will be written. * - NumHalfwordToWrite: number of Half words to write. * The maximum allowed value is 32 Half words (64 bytes). * Output : None * Return : NOR_Status:The returned value can be: NOR_SUCCESS, NOR_ERROR * or NOR_TIMEOUT *******************************************************************************/ NOR_Status FSMC_NOR_ProgramBuffer(uint16_t* pBuffer, uint32_t WriteAddr, uint32_t NumHalfwordToWrite) { uint32_t lastloadedaddress = 0x00; uint32_t currentaddress = 0x00; uint32_t endaddress = 0x00; /* Initialize variables */ currentaddress = WriteAddr; endaddress = WriteAddr + NumHalfwordToWrite - 1; lastloadedaddress = WriteAddr; /* Issue unlock command sequence */ NOR_WRITE(ADDR_SHIFT(0x00555), 0x00AA); NOR_WRITE(ADDR_SHIFT(0x02AA), 0x0055); /* Write Write Buffer Load Command */ NOR_WRITE(ADDR_SHIFT(WriteAddr), 0x0025); NOR_WRITE(ADDR_SHIFT(WriteAddr), (NumHalfwordToWrite - 1)); /* Load Data into NOR Buffer */ while(currentaddress <= endaddress) { /* Store last loaded address & data value (for polling) */ lastloadedaddress = currentaddress; NOR_WRITE(ADDR_SHIFT(currentaddress), *pBuffer++); currentaddress += 1; } NOR_WRITE(ADDR_SHIFT(lastloadedaddress), 0x29); return(FSMC_NOR_GetStatus(Program_Timeout)); } /****************************************************************************** * Function Name : FSMC_NOR_ReadHalfWord * Description : Reads a half-word from the NOR memory. * Input : - ReadAddr : NOR memory internal address to read from. * Output : None * Return : Half-word read from the NOR memory *******************************************************************************/ uint16_t FSMC_NOR_ReadHalfWord(uint32_t ReadAddr) { NOR_WRITE(ADDR_SHIFT(0x00555), 0x00AA); NOR_WRITE(ADDR_SHIFT(0x002AA), 0x0055); NOR_WRITE((Bank1_NOR2_ADDR + ReadAddr), 0x00F0 ); return (*(__IO uint16_t *)((Bank1_NOR2_ADDR + ReadAddr))); } /******************************************************************************* * Function Name : FSMC_NOR_ReadBuffer * Description : Reads a block of data from the FSMC NOR memory. * Input : - pBuffer : pointer to the buffer that receives the data read * from the NOR memory. * - ReadAddr : NOR memory internal address to read from. * - NumHalfwordToRead : number of Half word to read. * Output : None * Return : None *******************************************************************************/ void FSMC_NOR_ReadBuffer(uint16_t* pBuffer, uint32_t ReadAddr, uint32_t NumHalfwordToRead) { NOR_WRITE(ADDR_SHIFT(0x0555), 0x00AA); NOR_WRITE(ADDR_SHIFT(0x02AA), 0x0055); NOR_WRITE((Bank1_NOR2_ADDR + ReadAddr), 0x00F0); for(; NumHalfwordToRead != 0x00; NumHalfwordToRead--) /* while there is data to read */ { /* Read a Halfword from the NOR */ *pBuffer++ = *(__IO uint16_t *)((Bank1_NOR2_ADDR + ReadAddr)); ReadAddr = ReadAddr + 2; } } /****************************************************************************** * Function Name : FSMC_NOR_ReturnToReadMode * Description : Returns the NOR memory to Read mode. * Input : None * Output : None * Return : NOR_SUCCESS *******************************************************************************/ NOR_Status FSMC_NOR_ReturnToReadMode(void) { NOR_WRITE(Bank1_NOR2_ADDR, 0x00F0); return (NOR_SUCCESS); } /****************************************************************************** * Function Name : FSMC_NOR_Reset * Description : Returns the NOR memory to Read mode and resets the errors in * the NOR memory Status Register. * Input : None * Output : None * Return : NOR_SUCCESS *******************************************************************************/ NOR_Status FSMC_NOR_Reset(void) { NOR_WRITE(ADDR_SHIFT(0x00555), 0x00AA); NOR_WRITE(ADDR_SHIFT(0x002AA), 0x0055); NOR_WRITE(Bank1_NOR2_ADDR, 0x00F0); return (NOR_SUCCESS); } /****************************************************************************** * Function Name : FSMC_NOR_GetStatus * Description : Returns the NOR operation status. * Input : - Timeout: NOR progamming Timeout * Output : None * Return : NOR_Status:The returned value can be: NOR_SUCCESS, NOR_ERROR * or NOR_TIMEOUT *******************************************************************************/ NOR_Status FSMC_NOR_GetStatus(uint32_t Timeout) { uint16_t val1 = 0x00, val2 = 0x00; NOR_Status status = NOR_ONGOING; uint32_t timeout = Timeout; /* Poll on NOR memory Ready/Busy signal ------------------------------------*/ while((GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_6) != RESET) && (timeout > 0)) { timeout--; } timeout = Timeout; while((GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_6) == RESET) && (timeout > 0)) { timeout--; } /* Get the NOR memory operation status -------------------------------------*/ while((Timeout != 0x00) && (status != NOR_SUCCESS)) { Timeout--; /* Read DQ6 and DQ5 */ val1 = *(__IO uint16_t *)(Bank1_NOR2_ADDR); val2 = *(__IO uint16_t *)(Bank1_NOR2_ADDR); /* If DQ6 did not toggle between the two reads then return NOR_Success */ if((val1 & 0x0040) == (val2 & 0x0040)) { return NOR_SUCCESS; } if((val1 & 0x0020) != 0x0020) { status = NOR_ONGOING; } val1 = *(__IO uint16_t *)(Bank1_NOR2_ADDR); val2 = *(__IO uint16_t *)(Bank1_NOR2_ADDR); if((val1 & 0x0040) == (val2 & 0x0040)) { return NOR_SUCCESS; } else if((val1 & 0x0020) == 0x0020) { return NOR_ERROR; } } if(Timeout == 0x00) { status = NOR_TIMEOUT; } /* Return the operation status */ return (status); } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/src/fsmc_nor.c
C
asf20
17,143
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_istr.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : ISTR events interrupt service routines ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_lib.h" #include "usb_prop.h" #include "usb_pwr.h" #include "usb_istr.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ __IO uint16_t wIstr; /* ISTR register last read value */ __IO uint8_t bIntPackSOF = 0; /* SOFs received between 2 consecutive packets */ /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /* function pointers to non-control endpoints service routines */ void (*pEpInt_IN[7])(void) = { EP1_IN_Callback, EP2_IN_Callback, EP3_IN_Callback, EP4_IN_Callback, EP5_IN_Callback, EP6_IN_Callback, EP7_IN_Callback, }; void (*pEpInt_OUT[7])(void) = { EP1_OUT_Callback, EP2_OUT_Callback, EP3_OUT_Callback, EP4_OUT_Callback, EP5_OUT_Callback, EP6_OUT_Callback, EP7_OUT_Callback, }; #ifndef STM32F10X_CL /******************************************************************************* * Function Name : USB_Istr * Description : STR events interrupt service routine * Input : * Output : * Return : *******************************************************************************/ void USB_Istr(void) { wIstr = _GetISTR(); #if (IMR_MSK & ISTR_CTR) if (wIstr & ISTR_CTR & wInterrupt_Mask) { /* servicing of the endpoint correct transfer interrupt */ /* clear of the CTR flag into the sub */ CTR_LP(); #ifdef CTR_CALLBACK CTR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_RESET) if (wIstr & ISTR_RESET & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_RESET); Device_Property.Reset(); #ifdef RESET_CALLBACK RESET_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_DOVR) if (wIstr & ISTR_DOVR & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_DOVR); #ifdef DOVR_CALLBACK DOVR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_ERR) if (wIstr & ISTR_ERR & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_ERR); #ifdef ERR_CALLBACK ERR_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_WKUP) if (wIstr & ISTR_WKUP & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_WKUP); Resume(RESUME_EXTERNAL); #ifdef WKUP_CALLBACK WKUP_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_SUSP) if (wIstr & ISTR_SUSP & wInterrupt_Mask) { /* check if SUSPEND is possible */ if (fSuspendEnabled) { Suspend(); } else { /* if not possible then resume after xx ms */ Resume(RESUME_LATER); } /* clear of the ISTR bit must be done after setting of CNTR_FSUSP */ _SetISTR((uint16_t)CLR_SUSP); #ifdef SUSP_CALLBACK SUSP_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_SOF) if (wIstr & ISTR_SOF & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_SOF); bIntPackSOF++; #ifdef SOF_CALLBACK SOF_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #if (IMR_MSK & ISTR_ESOF) if (wIstr & ISTR_ESOF & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_ESOF); /* resume handling timing is made with ESOFs */ Resume(RESUME_ESOF); /* request without change of the machine state */ #ifdef ESOF_CALLBACK ESOF_Callback(); #endif } #endif } /* USB_Istr */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #else /* STM32F10X_CL */ /******************************************************************************* * Function Name : STM32_PCD_OTG_ISR_Handler * Description : Handles all USB Device Interrupts * Input : None * Output : None * Return : status *******************************************************************************/ u32 STM32_PCD_OTG_ISR_Handler (void) { USB_OTG_GINTSTS_TypeDef gintr_status; u32 retval = 0; if (USBD_FS_IsDeviceMode()) /* ensure that we are in device mode */ { gintr_status.d32 = OTGD_FS_ReadCoreItr(); /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* If there is no interrupt pending exit the interrupt routine */ if (!gintr_status.d32) { return 0; } /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Early Suspend interrupt */ #ifdef INTR_ERLYSUSPEND if (gintr_status.b.erlysuspend) { retval |= OTGD_FS_Handle_EarlySuspend_ISR(); } #endif /* INTR_ERLYSUSPEND */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* End of Periodic Frame interrupt */ #ifdef INTR_EOPFRAME if (gintr_status.b.eopframe) { retval |= OTGD_FS_Handle_EOPF_ISR(); } #endif /* INTR_EOPFRAME */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Non Periodic Tx FIFO Emty interrupt */ #ifdef INTR_NPTXFEMPTY if (gintr_status.b.nptxfempty) { retval |= OTGD_FS_Handle_NPTxFE_ISR(); } #endif /* INTR_NPTXFEMPTY */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Wakeup or RemoteWakeup interrupt */ #ifdef INTR_WKUPINTR if (gintr_status.b.wkupintr) { retval |= OTGD_FS_Handle_Wakeup_ISR(); } #endif /* INTR_WKUPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Suspend interrupt */ #ifdef INTR_USBSUSPEND if (gintr_status.b.usbsuspend) { /* check if SUSPEND is possible */ if (fSuspendEnabled) { Suspend(); } else { /* if not possible then resume after xx ms */ Resume(RESUME_LATER); /* This case shouldn't happen in OTG Device mode because there's no ESOF interrupt to increment the ResumeS.bESOFcnt in the Resume state machine */ } retval |= OTGD_FS_Handle_USBSuspend_ISR(); } #endif /* INTR_USBSUSPEND */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Start of Frame interrupt */ #ifdef INTR_SOFINTR if (gintr_status.b.sofintr) { /* Update the frame number variable */ bIntPackSOF++; retval |= OTGD_FS_Handle_Sof_ISR(); } #endif /* INTR_SOFINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Receive FIFO Queue Status Level interrupt */ #ifdef INTR_RXSTSQLVL if (gintr_status.b.rxstsqlvl) { retval |= OTGD_FS_Handle_RxStatusQueueLevel_ISR(); } #endif /* INTR_RXSTSQLVL */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Enumeration Done interrupt */ #ifdef INTR_ENUMDONE if (gintr_status.b.enumdone) { retval |= OTGD_FS_Handle_EnumDone_ISR(); } #endif /* INTR_ENUMDONE */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Reset interrutp */ #ifdef INTR_USBRESET if (gintr_status.b.usbreset) { retval |= OTGD_FS_Handle_UsbReset_ISR(); } #endif /* INTR_USBRESET */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* IN Endpoint interrupt */ #ifdef INTR_INEPINTR if (gintr_status.b.inepint) { retval |= OTGD_FS_Handle_InEP_ISR(); } #endif /* INTR_INEPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* OUT Endpoint interrupt */ #ifdef INTR_OUTEPINTR if (gintr_status.b.outepintr) { retval |= OTGD_FS_Handle_OutEP_ISR(); } #endif /* INTR_OUTEPINTR */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Mode Mismatch interrupt */ #ifdef INTR_MODEMISMATCH if (gintr_status.b.modemismatch) { retval |= OTGD_FS_Handle_ModeMismatch_ISR(); } #endif /* INTR_MODEMISMATCH */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Global IN Endpoints NAK Effective interrupt */ #ifdef INTR_GINNAKEFF if (gintr_status.b.ginnakeff) { retval |= OTGD_FS_Handle_GInNakEff_ISR(); } #endif /* INTR_GINNAKEFF */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Global OUT Endpoints NAK effective interrupt */ #ifdef INTR_GOUTNAKEFF if (gintr_status.b.goutnakeff) { retval |= OTGD_FS_Handle_GOutNakEff_ISR(); } #endif /* INTR_GOUTNAKEFF */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Isochrounous Out packet Dropped interrupt */ #ifdef INTR_ISOOUTDROP if (gintr_status.b.isooutdrop) { retval |= OTGD_FS_Handle_IsoOutDrop_ISR(); } #endif /* INTR_ISOOUTDROP */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Endpoint Mismatch error interrupt */ #ifdef INTR_EPMISMATCH if (gintr_status.b.epmismatch) { retval |= OTGD_FS_Handle_EPMismatch_ISR(); } #endif /* INTR_EPMISMATCH */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Incomplete Isochrous IN tranfer error interrupt */ #ifdef INTR_INCOMPLISOIN if (gintr_status.b.incomplisoin) { retval |= OTGD_FS_Handle_IncomplIsoIn_ISR(); } #endif /* INTR_INCOMPLISOIN */ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /* Incomplete Isochrous OUT tranfer error interrupt */ #ifdef INTR_INCOMPLISOOUT if (gintr_status.b.outepintr) { retval |= OTGD_FS_Handle_IncomplIsoOut_ISR(); } #endif /* INTR_INCOMPLISOOUT */ } return retval; } #endif /* STM32F10X_CL */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/src/usb_istr.c
C
asf20
11,736
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : main.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Device Firmware Upgrade(DFU) demo main file ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "usb_lib.h" #include "usb_conf.h" #include "usb_prop.h" #include "usb_pwr.h" #include "dfu_mal.h" #include "hw_config.h" #include "platform_config.h" /* Private typedef -----------------------------------------------------------*/ typedef void (*pFunction)(void); /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Extern variables ----------------------------------------------------------*/ uint8_t DeviceState; uint8_t DeviceStatus[6]; pFunction Jump_To_Application; uint32_t JumpAddress; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : main. * Description : main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { DFU_Button_Config(); /* Check if the Key push-button on STM3210x-EVAL Board is pressed */ if (DFU_Button_Read() != 0x00) { /* Test if user code is programmed starting from address 0x8003000 */ if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000) { /* Jump to user application */ JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ __set_MSP(*(__IO uint32_t*) ApplicationAddress); Jump_To_Application(); } } /* Otherwise enters DFU mode to allow user to program his application */ /* Enter DFU mode */ DeviceState = STATE_dfuERROR; DeviceStatus[0] = STATUS_ERRFIRMWARE; DeviceStatus[4] = DeviceState; Set_System(); Set_USBClock(); USB_Init(); /* Main loop */ while (1) {} } #ifdef USE_FULL_ASSERT /******************************************************************************* * Function Name : assert_failed * Description : Reports the name of the source file and the source line number * where the assert_param error has occurred. * Input : - file: pointer to the source file name * - line: assert_param error line source number * Output : None * Return : None *******************************************************************************/ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) {} } #endif /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/src/main.c
C
asf20
4,038
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : nor_if.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : specific media access Layer for NOR flash ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ #include "platform_config.h" #ifdef USE_STM3210E_EVAL /* Includes ------------------------------------------------------------------*/ #include "fsmc_nor.h" #include "nor_if.h" #include "dfu_mal.h" #include "stm32f10x_fsmc.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ extern NOR_IDTypeDef NOR_ID; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : NOR_If_Init * Description : Initializes the Media on the STM32 * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t NOR_If_Init(void) { /* Configure FSMC Bank1 NOR/SRAM2 */ FSMC_NOR_Init(); /* Enable FSMC Bank1 NOR/SRAM2 */ FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM2, ENABLE); return MAL_OK; } /******************************************************************************* * Function Name : NOR_If_Erase * Description : Erase sector * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t NOR_If_Erase(uint32_t Address) { /* Erase the destination memory */ FSMC_NOR_EraseBlock(Address & 0x00FFFFFF); return MAL_OK; } /******************************************************************************* * Function Name : NOR_If_Write * Description : Write sectors * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t NOR_If_Write(uint32_t Address, uint32_t DataLength) { if ((DataLength & 1) == 1) /* Not an aligned data */ { DataLength += 1; MAL_Buffer[DataLength-1] = 0xFF; } FSMC_NOR_WriteBuffer((uint16_t *)MAL_Buffer, (Address&0x00FFFFFF), DataLength >> 1); return MAL_OK; } /******************************************************************************* * Function Name : NOR_If_Read * Description : Read sectors * Input : None * Output : None * Return : buffer address pointer *******************************************************************************/ uint8_t *NOR_If_Read(uint32_t Address, uint32_t DataLength) { return (uint8_t*)(Address); } #endif /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/src/nor_if.c
C
asf20
3,808
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : hw_config.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Hardware Configuration & Setup ******************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "spi_flash.h" #include "hw_config.h" #include "dfu_mal.h" #include "usb_lib.h" #include "usb_desc.h" #include "platform_config.h" #include "usb_pwr.h" #include "stm32_eval.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ ErrorStatus HSEStartUpStatus; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len); /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : Set_System. * Description : Configures Main system clocks & power. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Set_System(void) { #ifndef USE_STM3210C_EVAL GPIO_InitTypeDef GPIO_InitStructure; #endif /* USE_STM3210C_EVAL */ /* Unlock the internal flash */ FLASH_Unlock(); #ifdef STM32F10X_HD /* Enable the FSMC Clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); #endif /* STM32F10X_HD */ #ifndef USE_STM3210C_EVAL /* Enable "DISCONNECT" GPIO clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_DISCONNECT, ENABLE); /* Configure USB pull-up */ GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure); USB_Cable_Config(DISABLE); #endif /* USE_STM3210C_EVAL */ /* Init the media interface */ MAL_Init(); #ifndef USE_STM3210C_EVAL USB_Cable_Config(ENABLE); #endif /* USE_STM3210C_EVAL */ } /******************************************************************************* * Function Name : Set_USBClock. * Description : Configures USB Clock input (48MHz). * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Set_USBClock(void) { #ifdef STM32F10X_CL /* Select USBCLK source */ RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3); /* Enable the USB clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE) ; #else /* Select USBCLK source */ RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5); /* Enable the USB clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE); #endif /* STM32F10X_CL */ } /******************************************************************************* * Function Name : Enter_LowPowerMode. * Description : Power-off system clocks and power while entering suspend mode. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Enter_LowPowerMode(void) { /* Set the device state to suspend */ bDeviceState = SUSPENDED; } /******************************************************************************* * Function Name : Leave_LowPowerMode. * Description : Restores system clocks and power while exiting suspend mode. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Leave_LowPowerMode(void) { DEVICE_INFO *pInfo = &Device_Info; /* Set the device state to the correct state */ if (pInfo->Current_Configuration != 0) { /* Device configured */ bDeviceState = CONFIGURED; } else { bDeviceState = ATTACHED; } } /******************************************************************************* * Function Name : USB_Cable_Config. * Description : Software Connection/Disconnection of USB Cable. * Input : NewState: new state. * Output : None. * Return : None. *******************************************************************************/ void USB_Cable_Config (FunctionalState NewState) { #ifdef USE_STM3210C_EVAL if (NewState != DISABLE) { USB_DevConnect(); } else { USB_DevDisconnect(); } #else /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ if (NewState != DISABLE) { GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN); } else { GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN); } #endif /* USE_STM3210C_EVAL */ } /******************************************************************************* * Function Name : DFU_Button_Config. * Description : Configures the DFU selector Button to enter DFU Mode. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void DFU_Button_Config(void) { /* Configure "DFU enter" button */ STM_EVAL_PBInit(Button_KEY, Mode_GPIO); } /******************************************************************************* * Function Name : DFU_Button_Read. * Description : Reads the DFU selector Button to enter DFU Mode. * Input : None. * Output : None. * Return : Status *******************************************************************************/ uint8_t DFU_Button_Read (void) { return STM_EVAL_PBGetState(Button_KEY); } /******************************************************************************* * Function Name : USB_Interrupts_Config. * Description : Configures the USB interrupts. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void USB_Interrupts_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; #ifdef STM32F10X_CL /* Enable the USB Interrupts */ NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); #else NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); #endif /* STM32F10X_CL */ } /******************************************************************************* * Function Name : Reset_Device. * Description : Reset the device. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Reset_Device(void) { USB_Cable_Config(DISABLE); NVIC_SystemReset(); } /******************************************************************************* * Function Name : Get_SerialNum. * Description : Create the serial number string descriptor. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Get_SerialNum(void) { uint32_t Device_Serial0, Device_Serial1, Device_Serial2; Device_Serial0 = *(__IO uint32_t*)(0x1FFFF7E8); Device_Serial1 = *(__IO uint32_t*)(0x1FFFF7EC); Device_Serial2 = *(__IO uint32_t*)(0x1FFFF7F0); Device_Serial0 += Device_Serial2; if (Device_Serial0 != 0) { IntToUnicode (Device_Serial0, &DFU_StringSerial[2] , 8); IntToUnicode (Device_Serial1, &DFU_StringSerial[18], 4); } } /******************************************************************************* * Function Name : HexToChar. * Description : Convert Hex 32Bits value into char. * Input : None. * Output : None. * Return : None. *******************************************************************************/ static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len) { uint8_t idx = 0; for( idx = 0 ; idx < len ; idx ++) { if( ((value >> 28)) < 0xA ) { pbuf[ 2* idx] = (value >> 28) + '0'; } else { pbuf[2* idx] = (value >> 28) + 'A' - 10; } value = value << 4; pbuf[ 2* idx + 1] = 0; } } #ifdef STM32F10X_CL /******************************************************************************* * Function Name : USB_OTG_BSP_uDelay. * Description : provide delay (usec). * Input : None. * Output : None. * Return : None. *******************************************************************************/ void USB_OTG_BSP_uDelay (const uint32_t usec) { RCC_ClocksTypeDef RCC_Clocks; /* Configure HCLK clock as SysTick clock source */ SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(usec * (RCC_Clocks.HCLK_Frequency / 1000000)); SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk ; while (!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)); } #endif /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/src/hw_config.c
C
asf20
10,525