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 : spi_flash.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : This file provides a set of functions needed to manage the * communication between SPI peripheral and SPI M25P64 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. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "spi_flash.h" /* Private typedef -----------------------------------------------------------*/ #define SPI_FLASH_PageSize 0x100 /* Private define ------------------------------------------------------------*/ #define WRITE 0x02 /* Write to Memory instruction */ #define WRSR 0x01 /* Write Status Register instruction */ #define WREN 0x06 /* Write enable instruction */ #define READ 0x03 /* Read from Memory instruction */ #define RDSR 0x05 /* Read Status Register instruction */ #define RDID 0x9F /* Read identification */ #define SE 0xD8 /* Sector Erase instruction */ #define BE 0xC7 /* Bulk Erase instruction */ #define WIP_Flag 0x01 /* Write In Progress (WIP) flag */ #define Dummy_Byte 0xA5 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : SPI_FLASH_Init * Description : Initializes the peripherals used by the SPI FLASH driver. * Input : None * Output : None * Return : None *******************************************************************************/ void SPI_FLASH_Init(void) { SPI_InitTypeDef SPI_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; /* Enable SPI1 and GPIO clocks */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIO_CS, ENABLE); /* Configure SPI1 pins: SCK, MISO and MOSI */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Configure I/O for Flash Chip select */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_CS; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIO_CS, &GPIO_InitStructure); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); /* SPI1 configuration */ SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_Mode = SPI_Mode_Master; SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI1, &SPI_InitStructure); /* Enable SPI1 */ SPI_Cmd(SPI1, ENABLE); } /******************************************************************************* * Function Name : SPI_FLASH_SectorErase * Description : Erases the specified FLASH sector. * Input : SectorAddr: address of the sector to erase. * Output : None * Return : None *******************************************************************************/ void SPI_FLASH_SectorErase(uint32_t SectorAddr) { /* Send write enable instruction */ SPI_FLASH_WriteEnable(); /* Sector Erase */ /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send Sector Erase instruction */ SPI_FLASH_SendByte(SE); /* Send SectorAddr high nibble address byte */ SPI_FLASH_SendByte((SectorAddr & 0xFF0000) >> 16); /* Send SectorAddr medium nibble address byte */ SPI_FLASH_SendByte((SectorAddr & 0xFF00) >> 8); /* Send SectorAddr low nibble address byte */ SPI_FLASH_SendByte(SectorAddr & 0xFF); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); /* Wait the end of Flash writing */ SPI_FLASH_WaitForWriteEnd(); } /******************************************************************************* * Function Name : SPI_FLASH_BulkErase * Description : Erases the entire FLASH. * Input : None * Output : None * Return : None *******************************************************************************/ void SPI_FLASH_BulkErase(void) { /* Send write enable instruction */ SPI_FLASH_WriteEnable(); /* Bulk Erase */ /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send Bulk Erase instruction */ SPI_FLASH_SendByte(BE); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); /* Wait the end of Flash writing */ SPI_FLASH_WaitForWriteEnd(); } /******************************************************************************* * Function Name : SPI_FLASH_PageWrite * Description : Writes more than one byte to the FLASH with a single WRITE * cycle(Page WRITE sequence). The number of byte can't exceed * the FLASH page size. * Input : - pBuffer : pointer to the buffer containing the data to be * written to the FLASH. * - WriteAddr : FLASH's internal address to write to. * - NumByteToWrite : number of bytes to write to the FLASH, * must be equal or less than "SPI_FLASH_PageSize" value. * Output : None * Return : None *******************************************************************************/ void SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) { /* Enable the write access to the FLASH */ SPI_FLASH_WriteEnable(); /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Write to Memory " instruction */ SPI_FLASH_SendByte(WRITE); /* Send WriteAddr high nibble address byte to write to */ SPI_FLASH_SendByte((WriteAddr & 0xFF0000) >> 16); /* Send WriteAddr medium nibble address byte to write to */ SPI_FLASH_SendByte((WriteAddr & 0xFF00) >> 8); /* Send WriteAddr low nibble address byte to write to */ SPI_FLASH_SendByte(WriteAddr & 0xFF); /* while there is data to be written on the FLASH */ while (NumByteToWrite--) { /* Send the current byte */ SPI_FLASH_SendByte(*pBuffer); /* Point on the next byte to be written */ pBuffer++; } /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); /* Wait the end of Flash writing */ SPI_FLASH_WaitForWriteEnd(); } /******************************************************************************* * Function Name : SPI_FLASH_BufferWrite * Description : Writes block of data to the FLASH. In this function, the * number of WRITE cycles are reduced, using Page WRITE sequence. * Input : - pBuffer : pointer to the buffer containing the data to be * written to the FLASH. * - WriteAddr : FLASH's internal address to write to. * - NumByteToWrite : number of bytes to write to the FLASH. * Output : None * Return : None *******************************************************************************/ void SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) { uint8_t NumOfPage = 0, NumOfSingle = 0, Addr = 0, count = 0, temp = 0; Addr = WriteAddr % SPI_FLASH_PageSize; count = SPI_FLASH_PageSize - Addr; NumOfPage = NumByteToWrite / SPI_FLASH_PageSize; NumOfSingle = NumByteToWrite % SPI_FLASH_PageSize; if (Addr == 0) /* WriteAddr is SPI_FLASH_PageSize aligned */ { if (NumOfPage == 0) /* NumByteToWrite < SPI_FLASH_PageSize */ { SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumByteToWrite); } else /* NumByteToWrite > SPI_FLASH_PageSize */ { while (NumOfPage--) { SPI_FLASH_PageWrite(pBuffer, WriteAddr, SPI_FLASH_PageSize); WriteAddr += SPI_FLASH_PageSize; pBuffer += SPI_FLASH_PageSize; } SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumOfSingle); } } else /* WriteAddr is not SPI_FLASH_PageSize aligned */ { if (NumOfPage == 0) /* NumByteToWrite < SPI_FLASH_PageSize */ { if (NumOfSingle > count) /* (NumByteToWrite + WriteAddr) > SPI_FLASH_PageSize */ { temp = NumOfSingle - count; SPI_FLASH_PageWrite(pBuffer, WriteAddr, count); WriteAddr += count; pBuffer += count; SPI_FLASH_PageWrite(pBuffer, WriteAddr, temp); } else { SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumByteToWrite); } } else /* NumByteToWrite > SPI_FLASH_PageSize */ { NumByteToWrite -= count; NumOfPage = NumByteToWrite / SPI_FLASH_PageSize; NumOfSingle = NumByteToWrite % SPI_FLASH_PageSize; SPI_FLASH_PageWrite(pBuffer, WriteAddr, count); WriteAddr += count; pBuffer += count; while (NumOfPage--) { SPI_FLASH_PageWrite(pBuffer, WriteAddr, SPI_FLASH_PageSize); WriteAddr += SPI_FLASH_PageSize; pBuffer += SPI_FLASH_PageSize; } if (NumOfSingle != 0) { SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumOfSingle); } } } } /******************************************************************************* * Function Name : SPI_FLASH_BufferRead * Description : Reads a block of data from the FLASH. * Input : - pBuffer : pointer to the buffer that receives the data read * from the FLASH. * - ReadAddr : FLASH's internal address to read from. * - NumByteToRead : number of bytes to read from the FLASH. * Output : None * Return : None *******************************************************************************/ void SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) { /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Read from Memory " instruction */ SPI_FLASH_SendByte(READ); /* Send ReadAddr high nibble address byte to read from */ SPI_FLASH_SendByte((ReadAddr & 0xFF0000) >> 16); /* Send ReadAddr medium nibble address byte to read from */ SPI_FLASH_SendByte((ReadAddr& 0xFF00) >> 8); /* Send ReadAddr low nibble address byte to read from */ SPI_FLASH_SendByte(ReadAddr & 0xFF); while (NumByteToRead--) /* while there is data to be read */ { /* Read a byte from the FLASH */ *pBuffer = SPI_FLASH_SendByte(Dummy_Byte); /* Point to the next location where the byte read will be saved */ pBuffer++; } /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); } /******************************************************************************* * Function Name : SPI_FLASH_ReadID * Description : Reads FLASH identification. * Input : None * Output : None * Return : FLASH identification *******************************************************************************/ uint32_t SPI_FLASH_ReadID(void) { uint32_t Temp = 0, Temp0 = 0, Temp1 = 0, Temp2 = 0; /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "RDID " instruction */ SPI_FLASH_SendByte(0x9F); /* Read a byte from the FLASH */ Temp0 = SPI_FLASH_SendByte(Dummy_Byte); /* Read a byte from the FLASH */ Temp1 = SPI_FLASH_SendByte(Dummy_Byte); /* Read a byte from the FLASH */ Temp2 = SPI_FLASH_SendByte(Dummy_Byte); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); Temp = (Temp0 << 16) | (Temp1 << 8) | Temp2; return Temp; } /******************************************************************************* * Function Name : SPI_FLASH_StartReadSequence * Description : Initiates a read data byte (READ) sequence from the Flash. * This is done by driving the /CS line low to select the device, * then the READ instruction is transmitted followed by 3 bytes * address. This function exit and keep the /CS line low, so the * Flash still being selected. With this technique the whole * content of the Flash is read with a single READ instruction. * Input : - ReadAddr : FLASH's internal address to read from. * Output : None * Return : None *******************************************************************************/ void SPI_FLASH_StartReadSequence(uint32_t ReadAddr) { /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Read from Memory " instruction */ SPI_FLASH_SendByte(READ); /* Send the 24-bit address of the address to read from -----------------------*/ /* Send ReadAddr high nibble address byte */ SPI_FLASH_SendByte((ReadAddr & 0xFF0000) >> 16); /* Send ReadAddr medium nibble address byte */ SPI_FLASH_SendByte((ReadAddr& 0xFF00) >> 8); /* Send ReadAddr low nibble address byte */ SPI_FLASH_SendByte(ReadAddr & 0xFF); } /******************************************************************************* * Function Name : SPI_FLASH_ReadByte * Description : Reads a byte from the SPI Flash. * This function must be used only if the Start_Read_Sequence * function has been previously called. * Input : None * Output : None * Return : Byte Read from the SPI Flash. *******************************************************************************/ uint8_t SPI_FLASH_ReadByte(void) { return (SPI_FLASH_SendByte(Dummy_Byte)); } /******************************************************************************* * Function Name : SPI_FLASH_SendByte * Description : Sends a byte through the SPI interface and return the byte * received from the SPI bus. * Input : byte : byte to send. * Output : None * Return : The value of the received byte. *******************************************************************************/ uint8_t SPI_FLASH_SendByte(uint8_t byte) { /* Loop while DR register in not emplty */ while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); /* Send byte through the SPI1 peripheral */ SPI_I2S_SendData(SPI1, byte); /* Wait to receive a byte */ while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET); /* Return the byte read from the SPI bus */ return SPI_I2S_ReceiveData(SPI1); } /******************************************************************************* * Function Name : SPI_FLASH_SendHalfWord * Description : Sends a Half Word through the SPI interface and return the * Half Word received from the SPI bus. * Input : Half Word : Half Word to send. * Output : None * Return : The value of the received Half Word. *******************************************************************************/ uint16_t SPI_FLASH_SendHalfWord(uint16_t HalfWord) { /* Loop while DR register in not emplty */ while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); /* Send Half Word through the SPI1 peripheral */ SPI_I2S_SendData(SPI1, HalfWord); /* Wait to receive a Half Word */ while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET); /* Return the Half Word read from the SPI bus */ return SPI_I2S_ReceiveData(SPI1); } /******************************************************************************* * Function Name : SPI_FLASH_WriteEnable * Description : Enables the write access to the FLASH. * Input : None * Output : None * Return : None *******************************************************************************/ void SPI_FLASH_WriteEnable(void) { /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Write Enable" instruction */ SPI_FLASH_SendByte(WREN); /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); } /******************************************************************************* * Function Name : SPI_FLASH_WaitForWriteEnd * Description : Polls the status of the Write In Progress (WIP) flag in the * FLASH's status register and loop until write opertaion * has completed. * Input : None * Output : None * Return : None *******************************************************************************/ void SPI_FLASH_WaitForWriteEnd(void) { uint8_t FLASH_Status = 0; /* Select the FLASH: Chip Select low */ SPI_FLASH_CS_LOW(); /* Send "Read Status Register" instruction */ SPI_FLASH_SendByte(RDSR); /* Loop as long as the memory is busy with a write cycle */ do { /* Send a dummy byte to generate the clock needed by the FLASH and put the value of the status register in FLASH_Status variable */ FLASH_Status = SPI_FLASH_SendByte(Dummy_Byte); } while ((FLASH_Status & WIP_Flag) == SET); /* Write in progress */ /* Deselect the FLASH: Chip Select high */ SPI_FLASH_CS_HIGH(); } /******************* (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/spi_flash.c
C
asf20
18,445
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : spi_if.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : specific media access Layer for SPI 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. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "spi_flash.h" #include "spi_if.h" #include "dfu_mal.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : SPI_If_Init * Description : Initializes the Media on the STM32 * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t SPI_If_Init(void) { SPI_FLASH_Init(); return MAL_OK; } /******************************************************************************* * Function Name : SPI_If_Erase * Description : Erase sector * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t SPI_If_Erase(uint32_t SectorAddress) { SPI_FLASH_SectorErase(SectorAddress); return MAL_OK; } /******************************************************************************* * Function Name : SPI_If_Write * Description : Write sectors * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t SPI_If_Write(uint32_t SectorAddress, uint32_t DataLength) { uint32_t idx, pages; pages = (((DataLength & 0xFF00)) >> 8); if (DataLength & 0xFF) /* Not a 256 aligned data */ { for ( idx = DataLength; idx < ((DataLength & 0xFF00) + 0x100) ; idx++) { MAL_Buffer[idx] = 0xFF; } pages = (((DataLength & 0xFF00)) >> 8 ) + 1; } for (idx = 0; idx < pages; idx++) { SPI_FLASH_PageWrite(&MAL_Buffer[idx*256], SectorAddress, 256); SectorAddress += 0x100; } return MAL_OK; } /******************************************************************************* * Function Name : SPI_If_Read * Description : Read sectors * Input : None * Output : None * Return : buffer address pointer *******************************************************************************/ uint8_t *SPI_If_Read(uint32_t SectorAddress, uint32_t DataLength) { SPI_FLASH_BufferRead(MAL_Buffer, SectorAddress, (uint16_t)DataLength); return MAL_Buffer; } /******************* (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/spi_if.c
C
asf20
3,814
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : dfu_mal.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Generic media access 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 "dfu_mal.h" #include "spi_if.h" #include "flash_if.h" #include "nor_if.h" #include "fsmc_nor.h" #include "usb_lib.h" #include "usb_type.h" #include "usb_desc.h" #include "platform_config.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint16_t (*pMAL_Init) (void); uint16_t (*pMAL_Erase) (uint32_t SectorAddress); uint16_t (*pMAL_Write) (uint32_t SectorAddress, uint32_t DataLength); uint8_t *(*pMAL_Read) (uint32_t SectorAddress, uint32_t DataLength); uint8_t MAL_Buffer[wTransferSize]; /* RAM Buffer for Downloaded Data */ NOR_IDTypeDef NOR_ID; extern ONE_DESCRIPTOR DFU_String_Descriptor[7]; static const uint16_t TimingTable[5][2] = { { 3000 , 20 }, /* SPI Flash */ { 1000 , 25 }, /* NOR Flash M29W128F */ { 100 , 104 }, /* Internal Flash */ { 1000 , 25 }, /* NOR Flash M29W128G */ { 1000 , 45 } /* NOR Flash S29GL128 */ }; /* 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(void) { FLASH_If_Init(); /* Internal Flash */ #if defined(USE_STM3210B_EVAL) || defined(USE_STM3210E_EVAL) SPI_If_Init(); /* SPI Flash */ #endif /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ #ifdef USE_STM3210E_EVAL NOR_If_Init(); /* NOR Flash */ FSMC_NOR_ReadID(&NOR_ID); FSMC_NOR_ReturnToReadMode(); /* select the alternate descriptor following NOR ID */ if ((NOR_ID.Manufacturer_Code == 0x01)&&(NOR_ID.Device_Code2 == NOR_S29GL128)) { DFU_String_Descriptor[6].Descriptor = DFU_StringInterface2_3; } /* select the alternate descriptor following NOR ID */ if ((NOR_ID.Manufacturer_Code == 0x20)&&(NOR_ID.Device_Code2 == NOR_M29W128G)) { DFU_String_Descriptor[6].Descriptor = DFU_StringInterface2_2; } #endif /* USE_STM3210E_EVAL */ return MAL_OK; } /******************************************************************************* * Function Name : MAL_Erase * Description : Erase sector * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t MAL_Erase(uint32_t SectorAddress) { switch (SectorAddress & MAL_MASK) { case INTERNAL_FLASH_BASE: pMAL_Erase = FLASH_If_Erase; break; #if defined(USE_STM3210B_EVAL) || defined(USE_STM3210E_EVAL) case SPI_FLASH_BASE: pMAL_Erase = SPI_If_Erase; break; #endif /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ #ifdef USE_STM3210E_EVAL case NOR_FLASH_BASE: pMAL_Erase = NOR_If_Erase; break; #endif /* USE_STM3210E_EVAL */ default: return MAL_FAIL; } return pMAL_Erase(SectorAddress); } /******************************************************************************* * Function Name : MAL_Write * Description : Write sectors * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t MAL_Write (uint32_t SectorAddress, uint32_t DataLength) { switch (SectorAddress & MAL_MASK) { case INTERNAL_FLASH_BASE: pMAL_Write = FLASH_If_Write; break; #if defined(USE_STM3210B_EVAL) || defined(USE_STM3210E_EVAL) case SPI_FLASH_BASE: pMAL_Write = SPI_If_Write; break; #endif /* USE_STM3210B_EVAL || USE_STM3210E_EVAL */ #ifdef USE_STM3210E_EVAL case NOR_FLASH_BASE: pMAL_Write = NOR_If_Write; break; #endif /* USE_STM3210E_EVAL */ default: return MAL_FAIL; } return pMAL_Write(SectorAddress, DataLength); } /******************************************************************************* * Function Name : MAL_Read * Description : Read sectors * Input : None * Output : None * Return : Buffer pointer *******************************************************************************/ uint8_t *MAL_Read (uint32_t SectorAddress, uint32_t DataLength) { switch (SectorAddress & MAL_MASK) { case INTERNAL_FLASH_BASE: pMAL_Read = FLASH_If_Read; break; #if defined(USE_STM3210B_EVAL) || defined(USE_STM3210E_EVAL) case SPI_FLASH_BASE: pMAL_Read = SPI_If_Read; break; #endif /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ #ifdef USE_STM3210E_EVAL case NOR_FLASH_BASE: pMAL_Read = NOR_If_Read; break; #endif /* USE_STM3210E_EVAL */ default: return 0; } return pMAL_Read (SectorAddress, DataLength); } /******************************************************************************* * Function Name : MAL_GetStatus * Description : Get status * Input : None * Output : None * Return : Buffer pointer *******************************************************************************/ uint16_t MAL_GetStatus(uint32_t SectorAddress , uint8_t Cmd, uint8_t *buffer) { uint8_t x = (SectorAddress >> 26) & 0x03 ; /* 0x000000000 --> 0 */ /* 0x640000000 --> 1 */ /* 0x080000000 --> 2 */ uint8_t y = Cmd & 0x01; if ((x == 1) && (NOR_ID.Device_Code2 == NOR_M29W128G)&& (NOR_ID.Manufacturer_Code == 0x20)) { x = 3 ; } else if((x == 1) && (NOR_ID.Device_Code2 == NOR_S29GL128) && (NOR_ID.Manufacturer_Code == 0x01)) { x = 4 ; } SET_POLLING_TIMING(TimingTable[x][y]); /* x: Erase/Write Timing */ /* y: Media */ return MAL_OK; } /******************* (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/dfu_mal.c
C
asf20
7,292
/******************** (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_prop.h" #include "usb_pwr.h" /* 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_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 */ #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/Device_Firmware_Upgrade/src/stm32f10x_it.c
C
asf20
7,902
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : flash_if.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : specific media access Layer for internal 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. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "flash_if.h" #include "dfu_mal.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : FLASH_If_Init * Description : Initializes the Media on the STM32 * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t FLASH_If_Init(void) { return MAL_OK; } /******************************************************************************* * Function Name : FLASH_If_Erase * Description : Erase sector * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t FLASH_If_Erase(uint32_t SectorAddress) { FLASH_ErasePage(SectorAddress); return MAL_OK; } /******************************************************************************* * Function Name : FLASH_If_Write * Description : Write sectors * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t FLASH_If_Write(uint32_t SectorAddress, uint32_t DataLength) { uint32_t idx = 0; if (DataLength & 0x3) /* Not an aligned data */ { for (idx = DataLength; idx < ((DataLength & 0xFFFC) + 4); idx++) { MAL_Buffer[idx] = 0xFF; } } /* Data received are Word multiple */ for (idx = 0; idx < DataLength; idx = idx + 4) { FLASH_ProgramWord(SectorAddress, *(uint32_t *)(MAL_Buffer + idx)); SectorAddress += 4; } return MAL_OK; } /******************************************************************************* * Function Name : FLASH_If_Read * Description : Read sectors * Input : None * Output : None * Return : buffer address pointer *******************************************************************************/ uint8_t *FLASH_If_Read (uint32_t SectorAddress, uint32_t DataLength) { return (uint8_t*)(SectorAddress); } /******************* (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/flash_if.c
C
asf20
3,680
/******************** (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/Device_Firmware_Upgrade/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 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. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "spi_flash.h" #include "usb_lib.h" #include "hw_config.h" #include "usb_conf.h" #include "usb_prop.h" #include "usb_desc.h" #include "usb_pwr.h" #include "dfu_mal.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint32_t wBlockNum = 0, wlength = 0; uint32_t Manifest_State = Manifest_complete; uint32_t Pointer = ApplicationAddress; /* Base Address to Erase, Program or Read */ DEVICE Device_Table = { EP_NUM, 1 }; DEVICE_PROP Device_Property = { DFU_init, DFU_Reset, DFU_Status_In, DFU_Status_Out, DFU_Data_Setup, DFU_NoData_Setup, DFU_Get_Interface_Setting, DFU_GetDeviceDescriptor, DFU_GetConfigDescriptor, DFU_GetStringDescriptor, 0, /*DFU_EP0Buffer*/ bMaxPacketSize0 /*Max Packet size*/ }; USER_STANDARD_REQUESTS User_Standard_Requests = { DFU_GetConfiguration, DFU_SetConfiguration, DFU_GetInterface, DFU_SetInterface, DFU_GetStatus, DFU_ClearFeature, DFU_SetEndPointFeature, DFU_SetDeviceFeature, DFU_SetDeviceAddress }; ONE_DESCRIPTOR Device_Descriptor = { (uint8_t*)DFU_DeviceDescriptor, DFU_SIZ_DEVICE_DESC }; ONE_DESCRIPTOR Config_Descriptor = { (uint8_t*)DFU_ConfigDescriptor, DFU_SIZ_CONFIG_DESC }; #ifdef USE_STM3210E_EVAL ONE_DESCRIPTOR DFU_String_Descriptor[7] = #elif defined(USE_STM3210B_EVAL) ONE_DESCRIPTOR DFU_String_Descriptor[6] = #elif defined(USE_STM3210C_EVAL) ONE_DESCRIPTOR DFU_String_Descriptor[5] = #endif /* USE_STM3210E_EVAL */ { { (u8*)DFU_StringLangId, DFU_SIZ_STRING_LANGID }, { (u8*)DFU_StringVendor, DFU_SIZ_STRING_VENDOR }, { (u8*)DFU_StringProduct, DFU_SIZ_STRING_PRODUCT }, { (u8*)DFU_StringSerial, DFU_SIZ_STRING_SERIAL }, { (u8*)DFU_StringInterface0, DFU_SIZ_STRING_INTERFACE0 } #ifdef USE_STM3210B_EVAL , { (u8*)DFU_StringInterface1, DFU_SIZ_STRING_INTERFACE1 } #endif /* USE_STM3210B_EVAL */ #ifdef USE_STM3210E_EVAL , { (u8*)DFU_StringInterface1, DFU_SIZ_STRING_INTERFACE1 }, { (u8*)DFU_StringInterface2_1, DFU_SIZ_STRING_INTERFACE2 } #endif /* USE_STM3210E_EVAL */ }; /* Extern variables ----------------------------------------------------------*/ extern uint8_t DeviceState ; extern uint8_t DeviceStatus[6]; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : DFU_init. * Description : DFU init routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void DFU_init(void) { DEVICE_INFO *pInfo = &Device_Info; /* Update the serial number string descriptor with the data from the unique ID*/ Get_SerialNum(); pInfo->Current_Configuration = 0; /* Connect the device */ PowerOn(); /* Perform basic device initialization operations */ USB_SIL_Init(); /* Enable USB interrupts */ USB_Interrupts_Config(); bDeviceState = UNCONNECTED; } /******************************************************************************* * Function Name : DFU_Reset. * Description : DFU reset routine * Input : None. * Output : None. * Return : None. *******************************************************************************/ void DFU_Reset(void) { /* Set DFU_DEVICE as not configured */ Device_Info.Current_Configuration = 0; /* Current Feature initialization */ pInformation->Current_Feature = DFU_ConfigDescriptor[7]; #ifdef STM32F10X_CL /* EP0 is already configured in DFU_Init by OTG_DEV_Init() function No Other endpoints needed for this firmware */ #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); SetEPTxCount(ENDP0, Device_Property.MaxPacketSize); Clear_Status_Out(ENDP0); SetEPRxValid(ENDP0); /* Set this device to response on default address */ SetDeviceAddress(0); #endif /* STM32F10X_CL */ /* Set the new control state of the device to Attached */ bDeviceState = ATTACHED; } /******************************************************************************* * Function Name : DFU_SetConfiguration. * Description : Udpade the device state to configured. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void DFU_SetConfiguration(void) { DEVICE_INFO *pInfo = &Device_Info; if (pInfo->Current_Configuration != 0) { /* Device configured */ bDeviceState = CONFIGURED; } } /******************************************************************************* * Function Name : DFU_SetConfiguration. * Description : Udpade the device state to addressed. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void DFU_SetDeviceAddress (void) { bDeviceState = ADDRESSED; } /******************************************************************************* * Function Name : DFU_Status_In. * Description : DFU status IN routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void DFU_Status_In(void) {} /******************************************************************************* * Function Name : DFU_Status_Out. * Description : DFU status OUT routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void DFU_Status_Out (void) { DEVICE_INFO *pInfo = &Device_Info; uint32_t Addr; if (pInfo->USBbRequest == DFU_GETSTATUS) { if (DeviceState == STATE_dfuDNBUSY) { if (wBlockNum == 0) /* Decode the Special Command*/ { if ((MAL_Buffer[0] == CMD_GETCOMMANDS) && (wlength == 1)) {} else if (( MAL_Buffer[0] == CMD_SETADDRESSPOINTER ) && (wlength == 5)) { Pointer = MAL_Buffer[1]; Pointer += MAL_Buffer[2] << 8; Pointer += MAL_Buffer[3] << 16; Pointer += MAL_Buffer[4] << 24; } else if (( MAL_Buffer[0] == CMD_ERASE ) && (wlength == 5)) { Pointer = MAL_Buffer[1]; Pointer += MAL_Buffer[2] << 8; Pointer += MAL_Buffer[3] << 16; Pointer += MAL_Buffer[4] << 24; MAL_Erase(Pointer); } } else if (wBlockNum > 1) // Download Command { Addr = ((wBlockNum - 2) * wTransferSize) + Pointer; MAL_Write(Addr, wlength); } wlength = 0; wBlockNum = 0; DeviceState = STATE_dfuDNLOAD_SYNC; DeviceStatus[4] = DeviceState; DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; return; } else if (DeviceState == STATE_dfuMANIFEST)/* Manifestation in progress*/ { DFU_write_crc(); return; } } return; } /******************************************************************************* * Function Name : DFU_Data_Setup. * Description : Handle the data class specific requests. * Input : RequestNb. * Output : None. * Return : USB_SUCCESS or USB_UNSUPPORT. *******************************************************************************/ RESULT DFU_Data_Setup(uint8_t RequestNo) { uint8_t *(*CopyRoutine)(uint16_t); CopyRoutine = NULL; if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) { if (RequestNo == DFU_UPLOAD && (DeviceState == STATE_dfuIDLE || DeviceState == STATE_dfuUPLOAD_IDLE )) { CopyRoutine = UPLOAD; } else if (RequestNo == DFU_DNLOAD && (DeviceState == STATE_dfuIDLE || DeviceState == STATE_dfuDNLOAD_IDLE)) { DeviceState = STATE_dfuDNLOAD_SYNC; CopyRoutine = DNLOAD; } else if (RequestNo == DFU_GETSTATE) { CopyRoutine = GETSTATE; } else if (RequestNo == DFU_GETSTATUS) { CopyRoutine = GETSTATUS; } else { return USB_UNSUPPORT; } } 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 : DFU_NoData_Setup. * Description : Handle the No data class specific requests. * Input : Request Nb. * Output : None. * Return : USB_SUCCESS or USB_UNSUPPORT. *******************************************************************************/ RESULT DFU_NoData_Setup(uint8_t RequestNo) { if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) { /*DFU_NDLOAD*/ if (RequestNo == DFU_DNLOAD) { /* End of DNLOAD operation*/ if (DeviceState == STATE_dfuDNLOAD_IDLE || DeviceState == STATE_dfuIDLE ) { Manifest_State = Manifest_In_Progress; DeviceState = STATE_dfuMANIFEST_SYNC; DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; DeviceStatus[4] = DeviceState; return USB_SUCCESS; } } /*DFU_UPLOAD*/ else if (RequestNo == DFU_UPLOAD) { DeviceState = STATE_dfuIDLE; DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; DeviceStatus[4] = DeviceState; return USB_SUCCESS; } /*DFU_CLRSTATUS*/ else if (RequestNo == DFU_CLRSTATUS) { if (DeviceState == STATE_dfuERROR) { DeviceState = STATE_dfuIDLE; DeviceStatus[0] = STATUS_OK;/*bStatus*/ DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; /*bwPollTimeout=0ms*/ DeviceStatus[4] = DeviceState;/*bState*/ DeviceStatus[5] = 0;/*iString*/ } else { /*State Error*/ DeviceState = STATE_dfuERROR; DeviceStatus[0] = STATUS_ERRUNKNOWN;/*bStatus*/ DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; /*bwPollTimeout=0ms*/ DeviceStatus[4] = DeviceState;/*bState*/ DeviceStatus[5] = 0;/*iString*/ } return USB_SUCCESS; } /*DFU_ABORT*/ else if (RequestNo == DFU_ABORT) { if (DeviceState == STATE_dfuIDLE || DeviceState == STATE_dfuDNLOAD_SYNC || DeviceState == STATE_dfuDNLOAD_IDLE || DeviceState == STATE_dfuMANIFEST_SYNC || DeviceState == STATE_dfuUPLOAD_IDLE ) { DeviceState = STATE_dfuIDLE; DeviceStatus[0] = STATUS_OK; DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; /*bwPollTimeout=0ms*/ DeviceStatus[4] = DeviceState; DeviceStatus[5] = 0; /*iString*/ wBlockNum = 0; wlength = 0; } return USB_SUCCESS; } } return USB_UNSUPPORT; } /* End of DFU_NoData_Setup */ /******************************************************************************* * Function Name : DFU_GetDeviceDescriptor. * Description : Gets the device descriptor. * Input : Length. * Output : None. * Return : The address of the device descriptor. *******************************************************************************/ uint8_t *DFU_GetDeviceDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Device_Descriptor); } /******************************************************************************* * Function Name : DFU_GetConfigDescriptor. * Description : Gets the configuration descriptor. * Input : Length. * Output : None. * Return : The address of the configuration discriptor. *******************************************************************************/ uint8_t *DFU_GetConfigDescriptor(uint16_t Length) { return Standard_GetDescriptorData (Length, &Config_Descriptor); } /******************************************************************************* * Function Name : DFU_GetStringDescriptor. * Description : Gets the string descriptors according to the needed index. * Input : Length. * Output : None. * Return : The address of the string descriptors. *******************************************************************************/ uint8_t *DFU_GetStringDescriptor(uint16_t Length) { uint8_t wValue0 = pInformation->USBwValue0; if (wValue0 > 8) { return NULL; } else { return Standard_GetDescriptorData(Length, &DFU_String_Descriptor[wValue0]); } } /******************************************************************************* * Function Name : DFU_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 DFU_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting) { if (AlternateSetting > 3) { return USB_UNSUPPORT; /* In this application we don't have more than 3 AlternateSettings */ } else if (Interface > 2) { return USB_UNSUPPORT; /* In this application we have only 1 interfaces */ } return USB_SUCCESS; } /******************************************************************************* * Function Name : UPLOAD * Description : Upload routine. * Input : Length. * Output : None. * Return : Pointer to data. *******************************************************************************/ uint8_t *UPLOAD(uint16_t Length) { DEVICE_INFO *pInfo = &Device_Info; uint8_t B1, B0; uint16_t offset, returned; uint8_t *Phy_Addr = NULL; uint32_t Addr = 0; B0 = pInfo->USBwValues.bw.bb0; B1 = pInfo->USBwValues.bw.bb1; wBlockNum = (uint16_t)B1; wBlockNum = wBlockNum * 0x100; wBlockNum += (uint16_t)B0; /* wBlockNum value updated*/ B0 = pInfo->USBwLengths.bw.bb0; B1 = pInfo->USBwLengths.bw.bb1; wlength = (uint16_t)B0; wlength = wlength * 0x100; wlength += (uint16_t)B1; /* wlength value updated*/ offset = pInformation->Ctrl_Info.Usb_wOffset; if (wBlockNum == 0) /* Get Command */ { if (wlength > 3) { DeviceState = STATE_dfuIDLE ; } else { DeviceState = STATE_dfuUPLOAD_IDLE; } DeviceStatus[4] = DeviceState; DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; MAL_Buffer[0] = CMD_GETCOMMANDS; MAL_Buffer[1] = CMD_SETADDRESSPOINTER; MAL_Buffer[2] = CMD_ERASE; if (Length == 0) { pInformation->Ctrl_Info.Usb_wLength = 3 ; return NULL; } return(&MAL_Buffer[0]); } else if (wBlockNum > 1) { DeviceState = STATE_dfuUPLOAD_IDLE ; DeviceStatus[4] = DeviceState; DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; Addr = ((wBlockNum - 2) * wTransferSize) + Pointer; /* Change is Accelerated*/ Phy_Addr = MAL_Read(Addr, wlength); returned = wlength - offset; if (Length == 0) { pInformation->Ctrl_Info.Usb_wLength = returned ; return NULL; } return(Phy_Addr + offset); } else /* unsupported wBlockNum */ { DeviceState = STATUS_ERRSTALLEDPKT; DeviceStatus[4] = DeviceState; DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; return NULL; } } /******************************************************************************* * Function Name : DNLOAD * Description : Download routine. * Input : Length. * Output : None. * Return : Pointer to data. *******************************************************************************/ uint8_t *DNLOAD (uint16_t Length) { DEVICE_INFO *pInfo = &Device_Info; uint8_t B1, B0; uint16_t offset, returned; B0 = pInfo->USBwValues.bw.bb0; B1 = pInfo->USBwValues.bw.bb1; wBlockNum = (uint16_t)B1; wBlockNum = wBlockNum * 0x100; wBlockNum += (uint16_t)B0; B0 = pInfo->USBwLengths.bw.bb0; B1 = pInfo->USBwLengths.bw.bb1; wlength = (uint16_t)B0; wlength = wlength * 0x100; wlength += (uint16_t)B1; offset = pInfo->Ctrl_Info.Usb_wOffset; DeviceState = STATE_dfuDNLOAD_SYNC; DeviceStatus[4] = DeviceState; returned = wlength - offset; if (Length == 0) { pInformation->Ctrl_Info.Usb_wLength = returned ; return NULL; } return((uint8_t*)MAL_Buffer + offset); } /******************************************************************************* * Function Name : GETSTATE. * Description : Get State request routine. * Input : Length. * Output : None. * Return : Pointer to data. *******************************************************************************/ uint8_t *GETSTATE(uint16_t Length) { if (Length == 0) { pInformation->Ctrl_Info.Usb_wLength = 1 ; return NULL; } else return(&DeviceState); } /******************************************************************************* * Function Name : GETSTATUS. * Description : Get Status request routine. * Input : Length. * Output : None. * Return : Pointer to data. *******************************************************************************/ uint8_t *GETSTATUS(uint16_t Length) { switch (DeviceState) { case STATE_dfuDNLOAD_SYNC: if (wlength != 0) { DeviceState = STATE_dfuDNBUSY; DeviceStatus[4] = DeviceState; if ((wBlockNum == 0) && (MAL_Buffer[0] == CMD_ERASE)) { MAL_GetStatus(Pointer, 0, DeviceStatus); } else { MAL_GetStatus(Pointer, 1, DeviceStatus); } } else /* (wlength==0)*/ { DeviceState = STATE_dfuDNLOAD_IDLE; DeviceStatus[4] = DeviceState; DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; } break; case STATE_dfuMANIFEST_SYNC : if (Manifest_State == Manifest_In_Progress) { DeviceState = STATE_dfuMANIFEST; DeviceStatus[4] = DeviceState; DeviceStatus[1] = 1; /*bwPollTimeout = 1ms*/ DeviceStatus[2] = 0; DeviceStatus[3] = 0; //break; } else if (Manifest_State == Manifest_complete && Config_Descriptor.Descriptor[20] & 0x04) { DeviceState = STATE_dfuIDLE; DeviceStatus[4] = DeviceState; DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; //break; } break; default : break; } if (Length == 0) { pInformation->Ctrl_Info.Usb_wLength = 6 ; return NULL; } else return(&(DeviceStatus[0])); } /******************************************************************************* * Function Name : DFU_write_crc. * Description : DFU Write CRC routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void DFU_write_crc(void) { Manifest_State = Manifest_complete; if (Config_Descriptor.Descriptor[20] & 0x04) { DeviceState = STATE_dfuMANIFEST_SYNC; DeviceStatus[4] = DeviceState; DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; return; } else { DeviceState = STATE_dfuMANIFEST_WAIT_RESET; DeviceStatus[4] = DeviceState; DeviceStatus[1] = 0; DeviceStatus[2] = 0; DeviceStatus[3] = 0; Reset_Device(); return; } } /******************* (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_prop.c
C
asf20
22,371
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_desc.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Descriptors 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. *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "usb_desc.h" #include "platform_config.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ uint8_t DFU_DeviceDescriptor[DFU_SIZ_DEVICE_DESC] = { 0x12, /* bLength */ 0x01, /* bDescriptorType */ 0x00, /* bcdUSB, version 1.00 */ 0x01, 0x00, /* bDeviceClass : See interface */ 0x00, /* bDeviceSubClass : See interface*/ 0x00, /* bDeviceProtocol : See interface */ bMaxPacketSize0, /* bMaxPacketSize0 0x40 = 64 */ 0x83, /* idVendor (0483) */ 0x04, 0x11, /* idProduct (0xDF11) DFU PiD*/ 0xDF, 0x00, /* bcdDevice*/ 0x02, 0x01, /* iManufacturer : index of string Manufacturer */ 0x02, /* iProduct : index of string descriptor of product*/ 0x03, /* iSerialNumber : index of string serial number*/ 0x01 /*bNumConfigurations */ }; #ifdef USE_STM3210B_EVAL uint8_t DFU_ConfigDescriptor[DFU_SIZ_CONFIG_DESC] = { 0x09, /* bLength: Configuation Descriptor size */ 0x02, /* bDescriptorType: Configuration */ DFU_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 */ /* 09 */ /************ Descriptor of DFU interface 0 Alternate setting 0 *********/ 0x09, /* bLength: Interface Descriptor size */ 0x04, /* bDescriptorType: */ /* Interface descriptor type */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bNumEndpoints*/ 0xFE, /* bInterfaceClass: Application Specific Class Code */ 0x01, /* bInterfaceSubClass : Device Firmware Upgrade Code */ 0x02, /* nInterfaceProtocol: DFU mode protocol */ 0x04, /* iInterface: */ /* Index of string descriptor */ /* 18 */ /************ Descriptor of DFU interface 0 Alternate setting 1 **********/ 0x09, /* bLength: Interface Descriptor size */ 0x04, /* bDescriptorType: */ /* Interface descriptor type */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x01, /* bAlternateSetting: Alternate setting */ 0x00, /* bNumEndpoints*/ 0xFE, /* bInterfaceClass: Application Specific Class Code */ 0x01, /* bInterfaceSubClass : Device Firmware Upgrade Code */ 0x02, /* nInterfaceProtocol: DFU mode protocol */ 0x05, /* iInterface: */ /* Index of string descriptor */ /* 27 */ /******************** DFU Functional Descriptor********************/ 0x09, /*blength = 9 Bytes*/ 0x21, /* DFU Functional Descriptor*/ 0x0B, /*bmAttribute bitCanDnload = 1 (bit 0) bitCanUpload = 1 (bit 1) bitManifestationTolerant = 0 (bit 2) bitWillDetach = 1 (bit 3) Reserved (bit4-6) bitAcceleratedST = 0 (bit 7)*/ 0xFF, /*DetachTimeOut= 255 ms*/ 0x00, wTransferSizeB0, wTransferSizeB1, /* TransferSize = 1024 Byte*/ 0x1A, /* bcdDFUVersion*/ 0x01 /***********************************************************/ /*36*/ }; #elif defined (USE_STM3210C_EVAL) uint8_t DFU_ConfigDescriptor[DFU_SIZ_CONFIG_DESC] = { 0x09, /* bLength: Configuation Descriptor size */ 0x02, /* bDescriptorType: Configuration */ DFU_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 */ /* 09 */ /************ Descriptor of DFU interface 0 Alternate setting 0 *********/ 0x09, /* bLength: Interface Descriptor size */ 0x04, /* bDescriptorType: */ /* Interface descriptor type */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bNumEndpoints*/ 0xFE, /* bInterfaceClass: Application Specific Class Code */ 0x01, /* bInterfaceSubClass : Device Firmware Upgrade Code */ 0x02, /* nInterfaceProtocol: DFU mode protocol */ 0x04, /* iInterface: */ /* Index of string descriptor */ /* 18 */ /******************** DFU Functional Descriptor********************/ 0x09, /*blength = 9 Bytes*/ 0x21, /* DFU Functional Descriptor*/ 0x0B, /*bmAttribute bitCanDnload = 1 (bit 0) bitCanUpload = 1 (bit 1) bitManifestationTolerant = 0 (bit 2) bitWillDetach = 1 (bit 3) Reserved (bit4-6) bitAcceleratedST = 0 (bit 7)*/ 0xFF, /*DetachTimeOut= 255 ms*/ 0x00, wTransferSizeB0, wTransferSizeB1, /* TransferSize = 1024 Byte*/ 0x1A, /* bcdDFUVersion*/ 0x01 /***********************************************************/ /*27*/ }; #elif defined (USE_STM3210E_EVAL) uint8_t DFU_ConfigDescriptor[DFU_SIZ_CONFIG_DESC] = { 0x09, /* bLength: Configuation Descriptor size */ 0x02, /* bDescriptorType: Configuration */ DFU_SIZ_CONFIG_DESC, /* wTotalLength: Bytes returned */ 0x00, 0x01, /* bNumInterfaces: 1 interface */ 0x01, /* bConfigurationValue: */ /* Configuration value */ 0x00, /* iConfiguration: */ /* Index of string descriptor */ /* describing the configuration */ 0x80, /* bmAttributes: */ /* bus powered */ 0x20, /* MaxPower 100 mA: this current is used for detecting Vbus */ /* 09 */ /************ Descriptor of DFU interface 0 Alternate setting 0 *********/ 0x09, /* bLength: Interface Descriptor size */ 0x04, /* bDescriptorType: */ /* Interface descriptor type */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x00, /* bNumEndpoints*/ 0xFE, /* bInterfaceClass: Application Specific Class Code */ 0x01, /* bInterfaceSubClass : Device Firmware Upgrade Code */ 0x02, /* nInterfaceProtocol: DFU mode protocol */ 0x04, /* iInterface: */ /* Index of string descriptor */ /* 18 */ /************ Descriptor of DFU interface 0 Alternate setting 1 **********/ 0x09, /* bLength: Interface Descriptor size */ 0x04, /* bDescriptorType: */ /* Interface descriptor type */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x01, /* bAlternateSetting: Alternate setting */ 0x00, /* bNumEndpoints*/ 0xFE, /* bInterfaceClass: Application Specific Class Code */ 0x01, /* bInterfaceSubClass : Device Firmware Upgrade Code */ 0x02, /* nInterfaceProtocol: DFU mode protocol */ 0x05, /* iInterface: */ /* Index of string descriptor */ /* 27 */ /************ Descriptor of DFU interface 0 Alternate setting 2 **********/ 0x09, /* bLength: Interface Descriptor size */ 0x04, /* bDescriptorType: */ /* Interface descriptor type */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x02, /* bAlternateSetting: Alternate setting */ 0x00, /* bNumEndpoints*/ 0xFE, /* bInterfaceClass: Application Specific Class Code */ 0x01, /* bInterfaceSubClass : Device Firmware Upgrade Code */ 0x02, /* nInterfaceProtocol: DFU mode protocol */ 0x06, /* iInterface: */ /* Index of string descriptor */ /* 36 */ /******************** DFU Functional Descriptor********************/ 0x09, /*blength = 9 Bytes*/ 0x21, /* DFU Functional Descriptor*/ 0x0B, /*bmAttribute bitCanDnload = 1 (bit 0) bitCanUpload = 1 (bit 1) bitManifestationTolerant = 0 (bit 2) bitWillDetach = 1 (bit 3) Reserved (bit4-6) bitAcceleratedST = 0 (bit 7)*/ 0xFF, /*DetachTimeOut= 255 ms*/ 0x00, wTransferSizeB0, wTransferSizeB1, /* TransferSize = 1024 Byte*/ 0x1A, /* bcdDFUVersion*/ 0x01 /***********************************************************/ /*45*/ }; #endif /* USE_STM3210B_EVAL */ uint8_t DFU_StringLangId[DFU_SIZ_STRING_LANGID] = { DFU_SIZ_STRING_LANGID, 0x03, 0x09, 0x04 /* LangID = 0x0409: U.S. English */ }; uint8_t DFU_StringVendor[DFU_SIZ_STRING_VENDOR] = { DFU_SIZ_STRING_VENDOR, 0x03, /* 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 }; uint8_t DFU_StringProduct[DFU_SIZ_STRING_PRODUCT] = { DFU_SIZ_STRING_PRODUCT, 0x03, /* Product name: "STM32 DFU" */ 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'D', 0, 'F', 0, 'U', 0 }; uint8_t DFU_StringSerial[DFU_SIZ_STRING_SERIAL] = { DFU_SIZ_STRING_SERIAL, 0x03, /* Serial number */ 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, '1', 0, '0', 0 }; #ifdef USE_STM3210B_EVAL uint8_t DFU_StringInterface0[DFU_SIZ_STRING_INTERFACE0] = { DFU_SIZ_STRING_INTERFACE0, 0x03, // Interface 0: "@Internal Flash /0x08000000/12*001Ka,116*001Kg" '@', 0, 'I', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'n', 0, 'a', 0, 'l', 0, /* 18 */ ' ', 0, 'F', 0, 'l', 0, 'a', 0, 's', 0, 'h', 0, ' ', 0, ' ', 0, /* 16 */ '/', 0, '0', 0, 'x', 0, '0', 0, '8', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, /* 22 */ '/', 0, '1', 0, '2', 0, '*', 0, '0', 0, '0', 0, '1', 0, 'K', 0, 'a', 0, /* 18 */ ',', 0, '1', 0, '1', 0, '6', 0, '*', 0, '0', 0, '0', 0, '1', 0, 'K', 0, 'g', 0, /* 20 */ }; #elif defined (USE_STM3210C_EVAL) uint8_t DFU_StringInterface0[DFU_SIZ_STRING_INTERFACE0] = { DFU_SIZ_STRING_INTERFACE0, 0x03, // Interface 0: "@Internal Flash /0x08000000/06*002Ka,122*002Kg" '@', 0, 'I', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'n', 0, 'a', 0, 'l', 0, /* 18 */ ' ', 0, 'F', 0, 'l', 0, 'a', 0, 's', 0, 'h', 0, ' ', 0, ' ', 0, /* 16 */ '/', 0, '0', 0, 'x', 0, '0', 0, '8', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, /* 22 */ '/', 0, '0', 0, '6', 0, '*', 0, '0', 0, '0', 0, '2', 0, 'K', 0, 'a', 0, /* 18 */ ',', 0, '1', 0, '2', 0, '2', 0, '*', 0, '0', 0, '0', 0, '2', 0, 'K', 0, 'g', 0, /* 20 */ }; #elif defined (USE_STM3210E_EVAL) #ifdef STM32F10X_XL uint8_t DFU_StringInterface0[DFU_SIZ_STRING_INTERFACE0] = { DFU_SIZ_STRING_INTERFACE0, 0x03, // Interface 0: "@Internal Flash /0x08000000/06*002Ka,506*002Kg" '@', 0, 'I', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'n', 0, 'a', 0, 'l', 0, /* 18 */ ' ', 0, 'F', 0, 'l', 0, 'a', 0, 's', 0, 'h', 0, ' ', 0, ' ', 0, /* 16 */ '/', 0, '0', 0, 'x', 0, '0', 0, '8', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, /* 22 */ '/', 0, '0', 0, '6', 0, '*', 0, '0', 0, '0', 0, '2', 0, 'K', 0, 'a', 0, /* 18 */ ',', 0, '5', 0, '0', 0, '6', 0, '*', 0, '0', 0, '0', 0, '2', 0, 'K', 0, 'g', 0, /* 20 */ }; #else uint8_t DFU_StringInterface0[DFU_SIZ_STRING_INTERFACE0] = { DFU_SIZ_STRING_INTERFACE0, 0x03, // Interface 0: "@Internal Flash /0x08000000/06*002Ka,250*002Kg" '@', 0, 'I', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'n', 0, 'a', 0, 'l', 0, /* 18 */ ' ', 0, 'F', 0, 'l', 0, 'a', 0, 's', 0, 'h', 0, ' ', 0, ' ', 0, /* 16 */ '/', 0, '0', 0, 'x', 0, '0', 0, '8', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, /* 22 */ '/', 0, '0', 0, '6', 0, '*', 0, '0', 0, '0', 0, '2', 0, 'K', 0, 'a', 0, /* 18 */ ',', 0, '2', 0, '5', 0, '0', 0, '*', 0, '0', 0, '0', 0, '2', 0, 'K', 0, 'g', 0, /* 20 */ }; #endif /* STM32F10X_XL */ #endif /* USE_STM3210B_EVAL */ #if defined(USE_STM3210B_EVAL) || defined(USE_STM3210E_EVAL) uint8_t DFU_StringInterface1[DFU_SIZ_STRING_INTERFACE1] = { DFU_SIZ_STRING_INTERFACE1, 0x03, // Interface 1: "@ SPI Flash: M25P64 /0x00000000/128*064Kg" '@', 0, 'S', 0, 'P', 0, 'I', 0, ' ', 0, 'F', 0, 'l', 0, 'a', 0, 's', 0, 'h', 0, ' ', 0, ':', 0, ' ', 0, 'M', 0, '2', 0, '5', 0, 'P', 0, '6', 0, '4', 0, '/', 0, '0', 0, 'x', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '/', 0, '1', 0, '2', 0, '8', 0, '*', 0, '6', 0, '4', 0, 'K', 0, 'g', 0 }; #endif /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ #ifdef USE_STM3210E_EVAL uint8_t DFU_StringInterface2_1[DFU_SIZ_STRING_INTERFACE2] = { DFU_SIZ_STRING_INTERFACE2, 0x03, // Interface 1: "@ NOR Flash: M29W128 /0x64000000/256*064Kg" '@', 0, 'N', 0, 'O', 0, 'R', 0, ' ', 0, 'F', 0, 'l', 0, 'a', 0, 's', 0, 'h', 0, ' ', 0, ':', 0, ' ', 0, 'M', 0, '2', 0, '9', 0, 'W', 0, '1', 0, '2', 0, '8', 0, 'F', 0, '/', 0, '0', 0, 'x', 0, '6', 0, '4', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '/', 0, '0', 0, '2', 0, '5', 0, '6', 0, '*', 0, '6', 0, '4', 0, 'K', 0, 'g', 0 }; uint8_t DFU_StringInterface2_2[DFU_SIZ_STRING_INTERFACE2] = { DFU_SIZ_STRING_INTERFACE2, 0x03, // Interface 1: "@ NOR Flash: M29W128 /0x64000000/128*128Kg" '@', 0, 'N', 0, 'O', 0, 'R', 0, ' ', 0, 'F', 0, 'l', 0, 'a', 0, 's', 0, 'h', 0, ' ', 0, ':', 0, ' ', 0, 'M', 0, '2', 0, '9', 0, 'W', 0, '1', 0, '2', 0, '8', 0, 'G', 0, '/', 0, '0', 0, 'x', 0, '6', 0, '4', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '/', 0, '1', 0, '2', 0, '8', 0, '*', 0, '1', 0, '2', 0, '8', 0, 'K', 0, 'g', 0 }; uint8_t DFU_StringInterface2_3[DFU_SIZ_STRING_INTERFACE2] = { DFU_SIZ_STRING_INTERFACE2, 0x03, // Interface 1: "@ NOR Flash:S29GL128 /0x64000000/128*128Kg" '@', 0, 'N', 0, 'O', 0, 'R', 0, ' ', 0, 'F', 0, 'l', 0, 'a', 0, 's', 0, 'h', 0, ' ', 0, ':', 0, ' ', 0, 'S', 0, '2', 0, '9', 0, 'G', 0, 'L', 0 , '1', 0, '2', 0, '8', 0, '/', 0, '0', 0, 'x', 0, '6', 0, '4', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0, '/', 0, '1', 0, '2', 0, '8', 0, '*', 0, '1', 0, '2', 0, '8', 0, 'K', 0, 'g', 0 }; #endif /* USE_STM3210E_EVAL */ /******************* (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_desc.c
C
asf20
16,922
;; 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/Device_Firmware_Upgrade/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/Device_Firmware_Upgrade/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/Device_Firmware_Upgrade/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/Device_Firmware_Upgrade/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/Device_Firmware_Upgrade/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/Device_Firmware_Upgrade/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/Device_Firmware_Upgrade/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/Device_Firmware_Upgrade/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/Device_Firmware_Upgrade/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/Device_Firmware_Upgrade/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/Device_Firmware_Upgrade/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/Device_Firmware_Upgrade/HiTOP/STM3210B-EVAL/Settings/STM32F10x_md.lsl
LSL
asf20
8,716
/******************** (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/binary_template/inc/stm32f10x_conf.h
C
asf20
3,456
/******************** (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); #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/binary_template/inc/stm32f10x_it.h
C
asf20
1,900
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : main.h * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Header for main.c module ******************************************************************************** * 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 __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "stm32_eval.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void TimingDelay_Decrement(void); #endif /* __MAIN_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/binary_template/inc/main.h
C
asf20
1,626
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : main.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Main program body. ******************************************************************************** * 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 "main.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ static __IO uint32_t TimingDelay; /* Private function prototypes -----------------------------------------------*/ void NVIC_Configuration(void); void Delay(__IO uint32_t nTime); /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : main * Description : Main program. * Input : None * Output : None * Return : None *******************************************************************************/ int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f10x_xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f10x.c file */ /* Configure the LEDs */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); /* NVIC configuration */ NVIC_Configuration(); /* Setup SysTick Timer for 1 msec interrupts */ if (SysTick_Config(SystemCoreClock / 1000)) { /* Capture error */ while (1); } while (1) { /* Toggle all leds */ STM_EVAL_LEDToggle(LED1); STM_EVAL_LEDToggle(LED2); STM_EVAL_LEDToggle(LED3); STM_EVAL_LEDToggle(LED4); /* Insert 500 ms delay */ Delay(500); /* Toggle all leds */ STM_EVAL_LEDToggle(LED1); STM_EVAL_LEDToggle(LED2); STM_EVAL_LEDToggle(LED3); STM_EVAL_LEDToggle(LED4); /* Insert 300 ms delay */ Delay(300); } } /******************************************************************************* * Function Name : NVIC_Configuration * Description : Configures Vector Table base location. * Input : None * Output : None * Return : None *******************************************************************************/ void NVIC_Configuration(void) { /* Set the Vector Table base location at 0x3000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x3000); } /******************************************************************************* * Function Name : Delay * Description : Inserts a delay time. * Input : nTime: specifies the delay time length, in milliseconds. * Output : None * Return : None *******************************************************************************/ void Delay(uint32_t nTime) { TimingDelay = nTime; while(TimingDelay != 0); } /******************************************************************************* * Function Name : TimingDelay_Decrement * Description : Decrements the TimingDelay variable. * Input : None * Output : TimingDelay * Return : None *******************************************************************************/ void TimingDelay_Decrement(void) { if (TimingDelay != 0x00) { TimingDelay--; } } #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/binary_template/src/main.c
C
asf20
5,338
/******************** (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 "main.h" /* 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) { TimingDelay_Decrement(); } /******************************************************************************/ /* 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/Device_Firmware_Upgrade/binary_template/src/stm32f10x_it.c
C
asf20
6,622
;; 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/Device_Firmware_Upgrade/binary_template/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 0x08003000 #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 = 0xFD000; map ( size = 0xFD000, dest_offset=0x08003000, 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 */ section_layout ::linear { group( contiguous ) { select ".bss.stack"; select "stack"; } } // // 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 = "_stacklabel" ); // 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/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210E-EVAL_XL/Settings/STM32F10x_xl_offset.lsl
LSL
asf20
10,738
//////////////////////////////////////////////////////////////////////////// // // 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/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210E-EVAL_XL/Settings/arm_arch.lsl
LSL
asf20
10,931
.section .bss.stack .global _stacklabel _stacklabel: .endsec
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210E-EVAL_XL/setstack.asm
Assembly
asf20
66
;; 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/Device_Firmware_Upgrade/binary_template/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/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210C-EVAL/Settings/STM32F10x_cl_offset.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/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210C-EVAL/Settings/arm_arch.lsl
LSL
asf20
10,931
.section .bss.stack .global _stacklabel _stacklabel: .endsec
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210C-EVAL/setstack.asm
Assembly
asf20
66
;; 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/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210E-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/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210E-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 0x08003000 #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=0x08003000, 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/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210E-EVAL/Settings/STM32F10x_hd_offset.lsl
LSL
asf20
10,586
.section .bss.stack .global _stacklabel _stacklabel: .endsec
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210E-EVAL/setstack.asm
Assembly
asf20
66
;; 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/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210B-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 0x08003000 #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=0x08003000, 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/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210B-EVAL/Settings/STM32F10x_md_offset.lsl
LSL
asf20
8,716
//////////////////////////////////////////////////////////////////////////// // // 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/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210B-EVAL/Settings/arm_arch.lsl
LSL
asf20
10,931
.section .bss.stack .global _stacklabel _stacklabel: .endsec
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Device_Firmware_Upgrade/binary_template/HiTOP/STM3210B-EVAL/setstack.asm
Assembly
asf20
66
/******************** (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/JoyStickMouse/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 -----------------------------------------------------------*/ #define CURSOR_STEP 20 #define DOWN 2 #define LEFT 3 #define RIGHT 4 #define UP 5 /* Exported functions ------------------------------------------------------- */ void Set_System(void); void Set_USBClock(void); void GPIO_AINConfig(void); void Enter_LowPowerMode(void); void Leave_LowPowerMode(void); void USB_Interrupts_Config(void); void USB_Cable_Config (FunctionalState NewState); void Joystick_Send(uint8_t Keys); uint8_t JoyState(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/JoyStickMouse/inc/hw_config.h
C
asf20
2,127
/******************** (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 Joystick Mouse 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 JOYSTICK_SIZ_HID_DESC 0x09 #define JOYSTICK_OFF_HID_DESC 0x12 #define JOYSTICK_SIZ_DEVICE_DESC 18 #define JOYSTICK_SIZ_CONFIG_DESC 34 #define JOYSTICK_SIZ_REPORT_DESC 74 #define JOYSTICK_SIZ_STRING_LANGID 4 #define JOYSTICK_SIZ_STRING_VENDOR 38 #define JOYSTICK_SIZ_STRING_PRODUCT 30 #define JOYSTICK_SIZ_STRING_SERIAL 26 #define STANDARD_ENDPOINT_DESC_SIZE 0x09 /* Exported functions ------------------------------------------------------- */ extern const uint8_t Joystick_DeviceDescriptor[JOYSTICK_SIZ_DEVICE_DESC]; extern const uint8_t Joystick_ConfigDescriptor[JOYSTICK_SIZ_CONFIG_DESC]; extern const uint8_t Joystick_ReportDescriptor[JOYSTICK_SIZ_REPORT_DESC]; extern const uint8_t Joystick_StringLangID[JOYSTICK_SIZ_STRING_LANGID]; extern const uint8_t Joystick_StringVendor[JOYSTICK_SIZ_STRING_VENDOR]; extern const uint8_t Joystick_StringProduct[JOYSTICK_SIZ_STRING_PRODUCT]; extern uint8_t Joystick_StringSerial[JOYSTICK_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/JoyStickMouse/inc/usb_desc.h
C
asf20
3,025
/******************** (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 Joystick Mouse 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 Joystick_init(void); void Joystick_Reset(void); void Joystick_SetConfiguration(void); void Joystick_SetDeviceAddress (void); void Joystick_Status_In (void); void Joystick_Status_Out (void); RESULT Joystick_Data_Setup(uint8_t); RESULT Joystick_NoData_Setup(uint8_t); RESULT Joystick_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting); uint8_t *Joystick_GetDeviceDescriptor(uint16_t ); uint8_t *Joystick_GetConfigDescriptor(uint16_t); uint8_t *Joystick_GetStringDescriptor(uint16_t); RESULT Joystick_SetProtocol(void); uint8_t *Joystick_GetProtocolValue(uint16_t Length); RESULT Joystick_SetProtocol(void); uint8_t *Joystick_GetReportDescriptor(uint16_t Length); uint8_t *Joystick_GetHIDDescriptor(uint16_t Length); /* Exported define -----------------------------------------------------------*/ #define Joystick_GetConfiguration NOP_Process //#define Joystick_SetConfiguration NOP_Process #define Joystick_GetInterface NOP_Process #define Joystick_SetInterface NOP_Process #define Joystick_GetStatus NOP_Process #define Joystick_ClearFeature NOP_Process #define Joystick_SetEndPointFeature NOP_Process #define Joystick_SetDeviceFeature NOP_Process //#define Joystick_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/JoyStickMouse/inc/usb_prop.h
C
asf20
3,122
/******************** (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/JoyStickMouse/inc/stm32f10x_conf.h
C
asf20
3,433
/******************** (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 EXTI9_5_IRQHandler(void); #ifdef STM32F10X_CL void OTG_FS_WKUP_IRQHandler(void); #else void USBWakeUp_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/JoyStickMouse/inc/stm32f10x_it.h
C
asf20
2,231
/******************** (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 #define RCC_APB2Periph_ALLGPIO (RCC_APB2Periph_GPIOA \ | RCC_APB2Periph_GPIOB \ | RCC_APB2Periph_GPIOC \ | RCC_APB2Periph_GPIOD \ | RCC_APB2Periph_GPIOE ) #elif defined (USE_STM3210E_EVAL) #define USB_DISCONNECT GPIOB #define USB_DISCONNECT_PIN GPIO_Pin_14 #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB #define RCC_APB2Periph_ALLGPIO (RCC_APB2Periph_GPIOA \ | RCC_APB2Periph_GPIOB \ | RCC_APB2Periph_GPIOC \ | RCC_APB2Periph_GPIOD \ | RCC_APB2Periph_GPIOE \ | RCC_APB2Periph_GPIOF \ | RCC_APB2Periph_GPIOG ) #elif defined (USE_STM3210C_EVAL) /* USB_Disconnect pin not used */ #define USB_DISCONNECT 0 #define USB_DISCONNECT_PIN 0 #define RCC_APB2Periph_GPIO_DISCONNECT 0 #define GPIO_Pin_UP GPIO_Pin_15 /* PG.15 */ #define GPIO_Pin_DOWN GPIO_Pin_3 /* PD.03 */ #define GPIO_Pin_LEFT GPIO_Pin_14 /* PG.14 */ #define GPIO_Pin_RIGHT GPIO_Pin_13 /* PG.13 */ #define RCC_APB2Periph_ALLGPIO (RCC_APB2Periph_GPIOA \ | RCC_APB2Periph_GPIOB \ | RCC_APB2Periph_GPIOC \ | RCC_APB2Periph_GPIOD \ | RCC_APB2Periph_GPIOE \ | RCC_APB2Periph_GPIOF \ | RCC_APB2Periph_GPIOG ) #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/JoyStickMouse/inc/platform_config.h
C
asf20
4,394
/******************** (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/JoyStickMouse/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 : Joystick Mouse 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) /*-------------------------------------------------------------*/ /* ------------------- 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/JoyStickMouse/inc/usb_conf.h
C
asf20
8,480
/******************** (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 : 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) { 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/JoyStickMouse/src/usb_istr.c
C
asf20
11,753
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : main.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Joystick Mouse 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" /* 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(); USB_Interrupts_Config(); Set_USBClock(); USB_Init(); while (1) { if (bDeviceState == CONFIGURED) { if (JoyState() != 0) { Joystick_Send(JoyState()); } } } } #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/JoyStickMouse/src/main.c
C
asf20
3,153
/******************** (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 "hw_config.h" #include "usb_lib.h" #include "usb_desc.h" #include "platform_config.h" #include "usb_pwr.h" #include "usb_lib.h" #include "stm32_eval.h" #ifdef USE_STM3210C_EVAL #include "stm3210c_eval_ioe.h" #endif /* USE_STM3210C_EVAL */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ ErrorStatus HSEStartUpStatus; EXTI_InitTypeDef EXTI_InitStructure; /* 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) { #ifndef USE_STM3210C_EVAL GPIO_InitTypeDef GPIO_InitStructure; #endif /* #ifdef USE_STM3210C_EVAL */ /* 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) { } } /* enable the PWR clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); /* Set all the GPIOs to AIN */ GPIO_AINConfig(); #ifndef STM32F10X_CL /* Enable the USB disconnect GPIO clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_DISCONNECT, ENABLE); /* 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 /* STM32F10X_CL */ #ifndef USE_STM3210C_EVAL /* Configure the Joystick buttons in GPIO mode */ STM_EVAL_PBInit(Button_RIGHT, Mode_GPIO); STM_EVAL_PBInit(Button_LEFT, Mode_GPIO); STM_EVAL_PBInit(Button_UP, Mode_GPIO); STM_EVAL_PBInit(Button_DOWN, Mode_GPIO); #else /* Configure the IOE on which the JoyStick is connected */ IOE_Config(); #endif /* USE_STM3210C_EVAL */ /* Configure the Key button in EXTI mode */ STM_EVAL_PBInit(Button_KEY, Mode_EXTI); /* Configure the EXTI line 18 connected internally to the USB IP */ EXTI_ClearITPendingBit(EXTI_Line18); EXTI_InitStructure.EXTI_Line = EXTI_Line18; // USB resume from suspend mode EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); EXTI_ClearITPendingBit(KEY_BUTTON_EXTI_LINE); } /******************************************************************************* * 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 : GPIO_AINConfig * Description : Configures all IOs as AIN to reduce the power consumption. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void GPIO_AINConfig(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Enable all GPIOs Clock*/ RCC_APB2PeriphClockCmd(RCC_APB2Periph_ALLGPIO, ENABLE); /* Configure all GPIO port pins in Analog Input mode (floating input trigger OFF) */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_Init(GPIOE, &GPIO_InitStructure); #if defined (USE_STM3210E_EVAL) || defined (USE_STM3210C_EVAL) GPIO_Init(GPIOF, &GPIO_InitStructure); GPIO_Init(GPIOG, &GPIO_InitStructure); #endif /* USE_STM3210E_EVAL */ /* Disable all GPIOs Clock*/ RCC_APB2PeriphClockCmd(RCC_APB2Periph_ALLGPIO, DISABLE); } /******************************************************************************* * 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; /* Clear EXTI Line18 pending bit */ EXTI_ClearITPendingBit(KEY_BUTTON_EXTI_LINE); /* Request to enter STOP mode with regulator in low power mode */ PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); } /******************************************************************************* * 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; /* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON); /* Wait till HSE is ready */ HSEStartUpStatus = RCC_WaitForHSEStartUp(); /* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON); /* Wait till HSE is ready */ while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET) {} #ifdef STM32F10X_CL /* Enable PLL2 */ RCC_PLL2Cmd(ENABLE); /* Wait till PLL2 is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET) {} #endif /* STM32F10X_CL */ /* Enable PLL1 */ RCC_PLLCmd(ENABLE); /* Wait till PLL1 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) {} /* 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 = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* Enable the USB Wake-up interrupt */ NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_WKUP_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_Init(&NVIC_InitStructure); #else /* Enable the USB interrupt */ NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* Enable the USB Wake-up interrupt */ NVIC_InitStructure.NVIC_IRQChannel = USBWakeUp_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_Init(&NVIC_InitStructure); #endif /* STM32F10X_CL */ /* Enable the Key EXTI line Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = KEY_BUTTON_EXTI_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; 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 : JoyState. * Description : Decodes the Joystick direction. * Input : None. * Output : None. * Return value : The direction value. *******************************************************************************/ uint8_t JoyState(void) { #ifdef USE_STM3210C_EVAL return IOE_JoyStickGetState(); #else /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ /* "right" key is pressed */ if (!STM_EVAL_PBGetState(Button_RIGHT)) { return JOY_RIGHT; } /* "left" key is pressed */ if (!STM_EVAL_PBGetState(Button_LEFT)) { return JOY_LEFT; } /* "up" key is pressed */ if (!STM_EVAL_PBGetState(Button_UP)) { return JOY_UP; } /* "down" key is pressed */ if (!STM_EVAL_PBGetState(Button_DOWN)) { return JOY_DOWN; } /* No key is pressed */ else { return 0; } #endif /* USE_STM3210C_EVAL */ } /******************************************************************************* * Function Name : Joystick_Send. * Description : prepares buffer to be sent containing Joystick event infos. * Input : Keys: keys received from terminal. * Output : None. * Return value : None. *******************************************************************************/ void Joystick_Send(uint8_t Keys) { uint8_t Mouse_Buffer[4] = {0, 0, 0, 0}; int8_t X = 0, Y = 0; switch (Keys) { case JOY_LEFT: X -= CURSOR_STEP; break; case JOY_RIGHT: X += CURSOR_STEP; break; case JOY_UP: Y -= CURSOR_STEP; break; case JOY_DOWN: Y += CURSOR_STEP; break; default: return; } /* prepare buffer to send */ Mouse_Buffer[1] = X; Mouse_Buffer[2] = Y; /* Copy mouse position info in ENDP1 Tx Packet Memory Area*/ USB_SIL_Write(EP1_IN, Mouse_Buffer, 4); #ifndef STM32F10X_CL /* Enable endpoint for transmission */ SetEPTxValid(ENDP1); #endif /* STM32F10X_CL */ } /******************************************************************************* * 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, &Joystick_StringSerial[2] , 8); IntToUnicode (Device_Serial1, &Joystick_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/JoyStickMouse/src/hw_config.c
C
asf20
17,050
/******************** (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_istr.h" #include "usb_lib.h" #include "usb_pwr.h" #include "platform_config.h" #include "stm32_eval.h" /* 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_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 : 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) { /* Check if the remote wakeup feature is enabled (it could be disabled by the host through ClearFeature request) */ if (pInformation->Current_Feature & 0x20) { /* Exit low power mode and re-configure clocks */ Resume(RESUME_INTERNAL); #ifdef STM32F10X_CL /* Send resume signaling to the host */ Resume(RESUME_ESOF); mDELAY(3); /* Stop resume signaling to the host */ Resume(RESUME_ESOF); #endif /* STM32F10X_CL */ } /* Clear the EXTI line pending bit */ EXTI_ClearITPendingBit(KEY_BUTTON_EXTI_LINE); } } #ifdef STM32F10X_CL /******************************************************************************* * Function Name : OTG_FS_WKUP_IRQHandler * Description : This function handles OTG WakeUp interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ void OTG_FS_WKUP_IRQHandler(void) { /* Initiate external resume sequence (1 step) */ Resume(RESUME_EXTERNAL); EXTI_ClearITPendingBit(EXTI_Line18); } #else /******************************************************************************* * Function Name : USBWakeUp_IRQHandler * Description : This function handles USB WakeUp interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ void USBWakeUp_IRQHandler(void) { EXTI_ClearITPendingBit(EXTI_Line18); } #endif /* STM32F10X_CL */ #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/JoyStickMouse/src/stm32f10x_it.c
C
asf20
10,038
/******************** (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 ? ***/ 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) { #ifndef STM32F10X_CL u16 wCNTR; /* suspend preparation */ /* ... */ /* macrocell enters suspend mode */ wCNTR = _GetCNTR(); wCNTR |= CNTR_FSUSP; _SetCNTR(wCNTR); /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */ /* power reduction */ /* ... on connected devices */ /* force low-power mode in the macrocell */ wCNTR = _GetCNTR(); wCNTR |= CNTR_LPMODE; _SetCNTR(wCNTR); #endif /* STM32F10X_CL */ #ifdef STM32F10X_CL /* Gate the PHY and AHB USB clocks */ _OTGD_FS_GATE_PHYCLK; #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 u16 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 */ #ifdef STM32F10X_CL /* Ungate the PHY and AHB USB clocks */ _OTGD_FS_UNGATE_PHYCLK; #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/JoyStickMouse/src/usb_pwr.c
C
asf20
8,008
/******************** (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 Joystick Mouse 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 ProtocolValue; /* -------------------------------------------------------------------------- */ /* Structures initializations */ /* -------------------------------------------------------------------------- */ DEVICE Device_Table = { EP_NUM, 1 }; DEVICE_PROP Device_Property = { Joystick_init, Joystick_Reset, Joystick_Status_In, Joystick_Status_Out, Joystick_Data_Setup, Joystick_NoData_Setup, Joystick_Get_Interface_Setting, Joystick_GetDeviceDescriptor, Joystick_GetConfigDescriptor, Joystick_GetStringDescriptor, 0, 0x40 /*MAX PACKET SIZE*/ }; USER_STANDARD_REQUESTS User_Standard_Requests = { Joystick_GetConfiguration, Joystick_SetConfiguration, Joystick_GetInterface, Joystick_SetInterface, Joystick_GetStatus, Joystick_ClearFeature, Joystick_SetEndPointFeature, Joystick_SetDeviceFeature, Joystick_SetDeviceAddress }; ONE_DESCRIPTOR Device_Descriptor = { (uint8_t*)Joystick_DeviceDescriptor, JOYSTICK_SIZ_DEVICE_DESC }; ONE_DESCRIPTOR Config_Descriptor = { (uint8_t*)Joystick_ConfigDescriptor, JOYSTICK_SIZ_CONFIG_DESC }; ONE_DESCRIPTOR Joystick_Report_Descriptor = { (uint8_t *)Joystick_ReportDescriptor, JOYSTICK_SIZ_REPORT_DESC }; ONE_DESCRIPTOR Mouse_Hid_Descriptor = { (uint8_t*)Joystick_ConfigDescriptor + JOYSTICK_OFF_HID_DESC, JOYSTICK_SIZ_HID_DESC }; ONE_DESCRIPTOR String_Descriptor[4] = { {(uint8_t*)Joystick_StringLangID, JOYSTICK_SIZ_STRING_LANGID}, {(uint8_t*)Joystick_StringVendor, JOYSTICK_SIZ_STRING_VENDOR}, {(uint8_t*)Joystick_StringProduct, JOYSTICK_SIZ_STRING_PRODUCT}, {(uint8_t*)Joystick_StringSerial, JOYSTICK_SIZ_STRING_SERIAL} }; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : Joystick_init. * Description : Joystick Mouse init routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Joystick_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 : Joystick_Reset. * Description : Joystick Mouse reset routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Joystick_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 = Joystick_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, 4); #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); SetEPTxCount(ENDP1, 4); SetEPRxStatus(ENDP1, EP_RX_DIS); SetEPTxStatus(ENDP1, EP_TX_NAK); /* Set this device to response on default address */ SetDeviceAddress(0); #endif /* STM32F10X_CL */ bDeviceState = ATTACHED; } /******************************************************************************* * Function Name : Joystick_SetConfiguration. * Description : Udpade the device state to configured. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Joystick_SetConfiguration(void) { DEVICE_INFO *pInfo = &Device_Info; if (pInfo->Current_Configuration != 0) { /* Device configured */ bDeviceState = CONFIGURED; } } /******************************************************************************* * Function Name : Joystick_SetConfiguration. * Description : Udpade the device state to addressed. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Joystick_SetDeviceAddress (void) { bDeviceState = ADDRESSED; } /******************************************************************************* * Function Name : Joystick_Status_In. * Description : Joystick status IN routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Joystick_Status_In(void) {} /******************************************************************************* * Function Name : Joystick_Status_Out * Description : Joystick status OUT routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Joystick_Status_Out (void) {} /******************************************************************************* * Function Name : Joystick_Data_Setup * Description : Handle the data class specific requests. * Input : Request Nb. * Output : None. * Return : USB_UNSUPPORT or USB_SUCCESS. *******************************************************************************/ RESULT Joystick_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 = Joystick_GetReportDescriptor; } else if (pInformation->USBwValue1 == HID_DESCRIPTOR_TYPE) { CopyRoutine = Joystick_GetHIDDescriptor; } } /* End of GET_DESCRIPTOR */ /*** GET_PROTOCOL ***/ else if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) && RequestNo == GET_PROTOCOL) { CopyRoutine = Joystick_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 : Joystick_NoData_Setup * Description : handle the no data class specific requests * Input : Request Nb. * Output : None. * Return : USB_UNSUPPORT or USB_SUCCESS. *******************************************************************************/ RESULT Joystick_NoData_Setup(uint8_t RequestNo) { if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) && (RequestNo == SET_PROTOCOL)) { return Joystick_SetProtocol(); } else { return USB_UNSUPPORT; } } /******************************************************************************* * Function Name : Joystick_GetDeviceDescriptor. * Description : Gets the device descriptor. * Input : Length * Output : None. * Return : The address of the device descriptor. *******************************************************************************/ uint8_t *Joystick_GetDeviceDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Device_Descriptor); } /******************************************************************************* * Function Name : Joystick_GetConfigDescriptor. * Description : Gets the configuration descriptor. * Input : Length * Output : None. * Return : The address of the configuration descriptor. *******************************************************************************/ uint8_t *Joystick_GetConfigDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Config_Descriptor); } /******************************************************************************* * Function Name : Joystick_GetStringDescriptor * Description : Gets the string descriptors according to the needed index * Input : Length * Output : None. * Return : The address of the string descriptors. *******************************************************************************/ uint8_t *Joystick_GetStringDescriptor(uint16_t Length) { uint8_t wValue0 = pInformation->USBwValue0; if (wValue0 > 4) { return NULL; } else { return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]); } } /******************************************************************************* * Function Name : Joystick_GetReportDescriptor. * Description : Gets the HID report descriptor. * Input : Length * Output : None. * Return : The address of the configuration descriptor. *******************************************************************************/ uint8_t *Joystick_GetReportDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Joystick_Report_Descriptor); } /******************************************************************************* * Function Name : Joystick_GetHIDDescriptor. * Description : Gets the HID descriptor. * Input : Length * Output : None. * Return : The address of the configuration descriptor. *******************************************************************************/ uint8_t *Joystick_GetHIDDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Mouse_Hid_Descriptor); } /******************************************************************************* * Function Name : Joystick_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 Joystick_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 : Joystick_SetProtocol * Description : Joystick Set Protocol request routine. * Input : None. * Output : None. * Return : USB SUCCESS. *******************************************************************************/ RESULT Joystick_SetProtocol(void) { uint8_t wValue0 = pInformation->USBwValue0; ProtocolValue = wValue0; return USB_SUCCESS; } /******************************************************************************* * Function Name : Joystick_GetProtocolValue * Description : get the protocol value * Input : Length. * Output : None. * Return : address of the protcol value. *******************************************************************************/ uint8_t *Joystick_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/JoyStickMouse/src/usb_prop.c
C
asf20
14,085
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_desc.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Descriptors for Joystick Mouse 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 Joystick_DeviceDescriptor[JOYSTICK_SIZ_DEVICE_DESC] = { 0x12, /*bLength */ USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ 0x00, /*bcdUSB */ 0x02, 0x00, /*bDeviceClass*/ 0x00, /*bDeviceSubClass*/ 0x00, /*bDeviceProtocol*/ 0x40, /*bMaxPacketSize 64*/ 0x83, /*idVendor (0x0483)*/ 0x04, 0x10, /*idProduct = 0x5710*/ 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*/ } ; /* Joystick_DeviceDescriptor */ /* USB Configuration Descriptor */ /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */ const uint8_t Joystick_ConfigDescriptor[JOYSTICK_SIZ_CONFIG_DESC] = { 0x09, /* bLength: Configuation Descriptor size */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */ JOYSTICK_SIZ_CONFIG_DESC, /* wTotalLength: Bytes returned */ 0x00, 0x01, /*bNumInterfaces: 1 interface*/ 0x01, /*bConfigurationValue: Configuration value*/ 0x00, /*iConfiguration: Index of string descriptor describing the configuration*/ 0xE0, /*bmAttributes: bus powered */ 0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/ /************** Descriptor of Joystick Mouse interface ****************/ /* 09 */ 0x09, /*bLength: Interface Descriptor size*/ USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType: Interface descriptor type*/ 0x00, /*bInterfaceNumber: Number of Interface*/ 0x00, /*bAlternateSetting: Alternate setting*/ 0x01, /*bNumEndpoints*/ 0x03, /*bInterfaceClass: HID*/ 0x01, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/ 0x02, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/ 0, /*iInterface: Index of string descriptor*/ /******************** Descriptor of Joystick Mouse HID ********************/ /* 18 */ 0x09, /*bLength: HID Descriptor size*/ HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/ 0x00, /*bcdHID: HID Class Spec release number*/ 0x01, 0x00, /*bCountryCode: Hardware target country*/ 0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/ 0x22, /*bDescriptorType*/ JOYSTICK_SIZ_REPORT_DESC,/*wItemLength: Total length of Report descriptor*/ 0x00, /******************** Descriptor of Joystick Mouse endpoint ********************/ /* 27 */ 0x07, /*bLength: Endpoint Descriptor size*/ USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/ 0x81, /*bEndpointAddress: Endpoint Address (IN)*/ 0x03, /*bmAttributes: Interrupt endpoint*/ 0x04, /*wMaxPacketSize: 4 Byte max */ 0x00, 0x20, /*bInterval: Polling Interval (32 ms)*/ /* 34 */ } ; /* MOUSE_ConfigDescriptor */ const uint8_t Joystick_ReportDescriptor[JOYSTICK_SIZ_REPORT_DESC] = { 0x05, /*Usage Page(Generic Desktop)*/ 0x01, 0x09, /*Usage(Mouse)*/ 0x02, 0xA1, /*Collection(Logical)*/ 0x01, 0x09, /*Usage(Pointer)*/ 0x01, /* 8 */ 0xA1, /*Collection(Linked)*/ 0x00, 0x05, /*Usage Page(Buttons)*/ 0x09, 0x19, /*Usage Minimum(1)*/ 0x01, 0x29, /*Usage Maximum(3)*/ 0x03, /* 16 */ 0x15, /*Logical Minimum(0)*/ 0x00, 0x25, /*Logical Maximum(1)*/ 0x01, 0x95, /*Report Count(3)*/ 0x03, 0x75, /*Report Size(1)*/ 0x01, /* 24 */ 0x81, /*Input(Variable)*/ 0x02, 0x95, /*Report Count(1)*/ 0x01, 0x75, /*Report Size(5)*/ 0x05, 0x81, /*Input(Constant,Array)*/ 0x01, /* 32 */ 0x05, /*Usage Page(Generic Desktop)*/ 0x01, 0x09, /*Usage(X axis)*/ 0x30, 0x09, /*Usage(Y axis)*/ 0x31, 0x09, /*Usage(Wheel)*/ 0x38, /* 40 */ 0x15, /*Logical Minimum(-127)*/ 0x81, 0x25, /*Logical Maximum(127)*/ 0x7F, 0x75, /*Report Size(8)*/ 0x08, 0x95, /*Report Count(3)*/ 0x03, /* 48 */ 0x81, /*Input(Variable, Relative)*/ 0x06, 0xC0, /*End Collection*/ 0x09, 0x3c, 0x05, 0xff, 0x09, /* 56 */ 0x01, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, /* 64 */ 0x02, 0xb1, 0x22, 0x75, 0x06, 0x95, 0x01, 0xb1, /* 72 */ 0x01, 0xc0 } ; /* Joystick_ReportDescriptor */ /* USB String Descriptors (optional) */ const uint8_t Joystick_StringLangID[JOYSTICK_SIZ_STRING_LANGID] = { JOYSTICK_SIZ_STRING_LANGID, USB_STRING_DESCRIPTOR_TYPE, 0x09, 0x04 } ; /* LangID = 0x0409: U.S. English */ const uint8_t Joystick_StringVendor[JOYSTICK_SIZ_STRING_VENDOR] = { JOYSTICK_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 Joystick_StringProduct[JOYSTICK_SIZ_STRING_PRODUCT] = { JOYSTICK_SIZ_STRING_PRODUCT, /* bLength */ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'J', 0, 'o', 0, 'y', 0, 's', 0, 't', 0, 'i', 0, 'c', 0, 'k', 0 }; uint8_t Joystick_StringSerial[JOYSTICK_SIZ_STRING_SERIAL] = { JOYSTICK_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/JoyStickMouse/src/usb_desc.c
C
asf20
8,465
;; 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/JoyStickMouse/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/JoyStickMouse/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/JoyStickMouse/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/JoyStickMouse/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/JoyStickMouse/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/JoyStickMouse/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/JoyStickMouse/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 = "DMAChannel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMAChannel2_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMAChannel3_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMAChannel4_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMAChannel5_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMAChannel6_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMAChannel7_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/JoyStickMouse/HiTOP/STM3210E-EVAL/Settings/STM32F10x_hd.lsl
LSL
asf20
10,572
//////////////////////////////////////////////////////////////////////////// // // 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/JoyStickMouse/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/JoyStickMouse/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/JoyStickMouse/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 = "DMAChannel1_IRQHandler" ); // DMA Channel 1 vector ( id = 28, optional, fill = "DMAChannel2_IRQHandler" ); // DMA Channel 2 vector ( id = 29, optional, fill = "DMAChannel3_IRQHandler" ); // DMA Channel 3 vector ( id = 30, optional, fill = "DMAChannel4_IRQHandler" ); // DMA Channel 4 vector ( id = 31, optional, fill = "DMAChannel5_IRQHandler" ); // DMA Channel 5 vector ( id = 32, optional, fill = "DMAChannel6_IRQHandler" ); // DMA Channel 6 vector ( id = 33, optional, fill = "DMAChannel7_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/JoyStickMouse/HiTOP/STM3210B-EVAL/Settings/STM32F10x_md.lsl
LSL
asf20
8,702
/******************** (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/Virtual_COM_Port/inc/usb_pwr.h
C
asf20
2,246
/******************** (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 -----------------------------------------------------------*/ #define MASS_MEMORY_START 0x04002000 #define BULK_MAX_PACKET_SIZE 0x00000040 #define LED_ON 0xF0 #define LED_OFF 0xFF #define USART_RX_DATA_SIZE 2048 /* 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 USART_Config_Default(void); bool USART_Config(void); void USB_To_USART_Send_Data(uint8_t* data_buffer, uint8_t Nb_bytes); void USART_To_USB_Send_Data(void); void Handle_USBAsynchXfer (void); 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/Virtual_COM_Port/inc/hw_config.h
C
asf20
2,375
/******************** (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 Virtual COM Port 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 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 VIRTUAL_COM_PORT_DATA_SIZE 64 #define VIRTUAL_COM_PORT_INT_SIZE 8 #define VIRTUAL_COM_PORT_SIZ_DEVICE_DESC 18 #define VIRTUAL_COM_PORT_SIZ_CONFIG_DESC 67 #define VIRTUAL_COM_PORT_SIZ_STRING_LANGID 4 #define VIRTUAL_COM_PORT_SIZ_STRING_VENDOR 38 #define VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT 50 #define VIRTUAL_COM_PORT_SIZ_STRING_SERIAL 26 #define STANDARD_ENDPOINT_DESC_SIZE 0x09 /* Exported functions ------------------------------------------------------- */ extern const uint8_t Virtual_Com_Port_DeviceDescriptor[VIRTUAL_COM_PORT_SIZ_DEVICE_DESC]; extern const uint8_t Virtual_Com_Port_ConfigDescriptor[VIRTUAL_COM_PORT_SIZ_CONFIG_DESC]; extern const uint8_t Virtual_Com_Port_StringLangID[VIRTUAL_COM_PORT_SIZ_STRING_LANGID]; extern const uint8_t Virtual_Com_Port_StringVendor[VIRTUAL_COM_PORT_SIZ_STRING_VENDOR]; extern const uint8_t Virtual_Com_Port_StringProduct[VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT]; extern uint8_t Virtual_Com_Port_StringSerial[VIRTUAL_COM_PORT_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/Virtual_COM_Port/inc/usb_desc.h
C
asf20
2,939
/******************** (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 Virtual COM Port 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 ------------------------------------------------------------*/ typedef struct { uint32_t bitrate; uint8_t format; uint8_t paritytype; uint8_t datatype; }LINE_CODING; /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported define -----------------------------------------------------------*/ #define Virtual_Com_Port_GetConfiguration NOP_Process //#define Virtual_Com_Port_SetConfiguration NOP_Process #define Virtual_Com_Port_GetInterface NOP_Process #define Virtual_Com_Port_SetInterface NOP_Process #define Virtual_Com_Port_GetStatus NOP_Process #define Virtual_Com_Port_ClearFeature NOP_Process #define Virtual_Com_Port_SetEndPointFeature NOP_Process #define Virtual_Com_Port_SetDeviceFeature NOP_Process //#define Virtual_Com_Port_SetDeviceAddress NOP_Process #define SEND_ENCAPSULATED_COMMAND 0x00 #define GET_ENCAPSULATED_RESPONSE 0x01 #define SET_COMM_FEATURE 0x02 #define GET_COMM_FEATURE 0x03 #define CLEAR_COMM_FEATURE 0x04 #define SET_LINE_CODING 0x20 #define GET_LINE_CODING 0x21 #define SET_CONTROL_LINE_STATE 0x22 #define SEND_BREAK 0x23 /* Exported functions ------------------------------------------------------- */ void Virtual_Com_Port_init(void); void Virtual_Com_Port_Reset(void); void Virtual_Com_Port_SetConfiguration(void); void Virtual_Com_Port_SetDeviceAddress (void); void Virtual_Com_Port_Status_In (void); void Virtual_Com_Port_Status_Out (void); RESULT Virtual_Com_Port_Data_Setup(uint8_t); RESULT Virtual_Com_Port_NoData_Setup(uint8_t); RESULT Virtual_Com_Port_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting); uint8_t *Virtual_Com_Port_GetDeviceDescriptor(uint16_t ); uint8_t *Virtual_Com_Port_GetConfigDescriptor(uint16_t); uint8_t *Virtual_Com_Port_GetStringDescriptor(uint16_t); uint8_t *Virtual_Com_Port_GetLineCoding(uint16_t Length); uint8_t *Virtual_Com_Port_SetLineCoding(uint16_t Length); #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/Virtual_COM_Port/inc/usb_prop.h
C
asf20
3,491
/******************** (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/Virtual_COM_Port/inc/stm32f10x_conf.h
C
asf20
3,450
/******************** (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 */ #if defined (USE_STM3210B_EVAL) || defined (USE_STM3210E_EVAL) void USART1_IRQHandler(void); #endif /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ #ifdef USE_STM3210C_EVAL void USART2_IRQHandler(void); #endif /* USE_STM3210C_EVAL */ #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/Virtual_COM_Port/inc/stm32f10x_it.h
C
asf20
2,307
/******************** (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 #define EVAL_COM1_IRQn USART1_IRQn #elif defined (USE_STM3210E_EVAL) #define USB_DISCONNECT GPIOB #define USB_DISCONNECT_PIN GPIO_Pin_14 #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB #define EVAL_COM1_IRQn USART1_IRQn #elif defined (USE_STM3210C_EVAL) #define USB_DISCONNECT 0 #define USB_DISCONNECT_PIN 0 #define RCC_APB2Periph_GPIO_DISCONNECT 0 #define EVAL_COM1_IRQn USART2_IRQn #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/Virtual_COM_Port/inc/platform_config.h
C
asf20
2,842
/******************** (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/Virtual_COM_Port/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 : Virtual COM Port 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 /* 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 (4) #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 (0x40) #define ENDP0_TXADDR (0x80) /* EP1 */ /* tx buffer base address */ #define ENDP1_TXADDR (0xC0) #define ENDP2_TXADDR (0x100) #define ENDP3_RXADDR (0x110) /*-------------------------------------------------------------*/ /* ------------------- 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 /* 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/Virtual_COM_Port/inc/usb_conf.h
C
asf20
8,738
/******************** (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_desc.h" #include "usb_mem.h" #include "hw_config.h" #include "usb_istr.h" #include "usb_pwr.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Interval between sending IN packets in frame number (1 frame = 1ms) */ #define VCOMPORT_IN_FRAME_INTERVAL 5 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint8_t USB_Rx_Buffer[VIRTUAL_COM_PORT_DATA_SIZE]; extern uint8_t USART_Rx_Buffer[]; extern uint32_t USART_Rx_ptr_out; extern uint32_t USART_Rx_length; extern uint8_t USB_Tx_State; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : EP1_IN_Callback * Description : * Input : None. * Output : None. * Return : None. *******************************************************************************/ void EP1_IN_Callback (void) { uint16_t USB_Tx_ptr; uint16_t USB_Tx_length; if (USB_Tx_State == 1) { if (USART_Rx_length == 0) { USB_Tx_State = 0; } else { if (USART_Rx_length > VIRTUAL_COM_PORT_DATA_SIZE){ USB_Tx_ptr = USART_Rx_ptr_out; USB_Tx_length = VIRTUAL_COM_PORT_DATA_SIZE; USART_Rx_ptr_out += VIRTUAL_COM_PORT_DATA_SIZE; USART_Rx_length -= VIRTUAL_COM_PORT_DATA_SIZE; } else { USB_Tx_ptr = USART_Rx_ptr_out; USB_Tx_length = USART_Rx_length; USART_Rx_ptr_out += USART_Rx_length; USART_Rx_length = 0; } #ifdef USE_STM3210C_EVAL USB_SIL_Write(EP1_IN, &USART_Rx_Buffer[USB_Tx_ptr], USB_Tx_length); #else UserToPMABufferCopy(&USART_Rx_Buffer[USB_Tx_ptr], ENDP1_TXADDR, USB_Tx_length); SetEPTxCount(ENDP1, USB_Tx_length); SetEPTxValid(ENDP1); #endif } } } /******************************************************************************* * Function Name : EP3_OUT_Callback * Description : * Input : None. * Output : None. * Return : None. *******************************************************************************/ void EP3_OUT_Callback(void) { uint16_t USB_Rx_Cnt; /* Get the received data buffer and update the counter */ USB_Rx_Cnt = USB_SIL_Read(EP3_OUT, USB_Rx_Buffer); /* USB data will be immediately processed, this allow next USB traffic beeing NAKed till the end of the USART Xfet */ USB_To_USART_Send_Data(USB_Rx_Buffer, USB_Rx_Cnt); #ifndef STM32F10X_CL /* Enable the receive of data on EP3 */ SetEPRxValid(ENDP3); #endif /* STM32F10X_CL */ } /******************************************************************************* * Function Name : SOF_Callback / INTR_SOFINTR_Callback * Description : * Input : None. * Output : None. * Return : None. *******************************************************************************/ #ifdef STM32F10X_CL void INTR_SOFINTR_Callback(void) #else void SOF_Callback(void) #endif /* STM32F10X_CL */ { static uint32_t FrameCount = 0; if(bDeviceState == CONFIGURED) { if (FrameCount++ == VCOMPORT_IN_FRAME_INTERVAL) { /* Reset the frame counter */ FrameCount = 0; /* Check the data to be sent through IN pipe */ Handle_USBAsynchXfer(); } } } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Virtual_COM_Port/src/usb_endp.c
C
asf20
4,843
/******************** (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_SOF) if (wIstr & ISTR_SOF & wInterrupt_Mask) { _SetISTR((uint16_t)CLR_SOF); bIntPackSOF++; #ifdef SOF_CALLBACK SOF_Callback(); #endif } #endif /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ #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_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/Virtual_COM_Port/src/usb_istr.c
C
asf20
11,742
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : main.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Virtual Com Port 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_pwr.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(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); 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/Virtual_COM_Port/src/main.c
C
asf20
3,014
/******************** (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 "stm32_eval.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ ErrorStatus HSEStartUpStatus; USART_InitTypeDef USART_InitStructure; uint8_t USART_Rx_Buffer [USART_RX_DATA_SIZE]; uint32_t USART_Rx_ptr_in = 0; uint32_t USART_Rx_ptr_out = 0; uint32_t USART_Rx_length = 0; uint8_t USB_Tx_State = 0; static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len); /* Extern variables ----------------------------------------------------------*/ extern LINE_CODING linecoding; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : Set_System * Description : Configures Main system clocks & power * Input : None. * Return : None. *******************************************************************************/ void Set_System(void) { #ifndef USE_STM3210C_EVAL GPIO_InitTypeDef GPIO_InitStructure; #endif /* USE_STM3210C_EVAL */ /* 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) { } } #ifndef USE_STM3210C_EVAL /* Enable USB_DISCONNECT GPIO clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_DISCONNECT, ENABLE); /* Configure USB pull-up pin */ 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 */ } /******************************************************************************* * 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_Interrupts_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); #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 USART Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = EVAL_COM1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_Init(&NVIC_InitStructure); } /******************************************************************************* * 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 : USART_Config_Default. * Description : configure the EVAL_COM1 with default values. * Input : None. * Return : None. *******************************************************************************/ void USART_Config_Default(void) { /* EVAL_COM1 default configuration */ /* EVAL_COM1 configured as follow: - BaudRate = 9600 baud - Word Length = 8 Bits - One Stop Bit - Parity Odd - Hardware flow control desabled - Receive and transmit enabled */ USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_Odd; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; /* Configure and enable the USART */ STM_EVAL_COMInit(COM1, &USART_InitStructure); /* Enable the USART Receive interrupt */ USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE); } /******************************************************************************* * Function Name : USART_Config. * Description : Configure the EVAL_COM1 according to the linecoding structure. * Input : None. * Return : Configuration status TRUE : configuration done with success FALSE : configuration aborted. *******************************************************************************/ bool USART_Config(void) { /* set the Stop bit*/ switch (linecoding.format) { case 0: USART_InitStructure.USART_StopBits = USART_StopBits_1; break; case 1: USART_InitStructure.USART_StopBits = USART_StopBits_1_5; break; case 2: USART_InitStructure.USART_StopBits = USART_StopBits_2; break; default : { USART_Config_Default(); return (FALSE); } } /* set the parity bit*/ switch (linecoding.paritytype) { case 0: USART_InitStructure.USART_Parity = USART_Parity_No; break; case 1: USART_InitStructure.USART_Parity = USART_Parity_Even; break; case 2: USART_InitStructure.USART_Parity = USART_Parity_Odd; break; default : { USART_Config_Default(); return (FALSE); } } /*set the data type : only 8bits and 9bits is supported */ switch (linecoding.datatype) { case 0x07: /* With this configuration a parity (Even or Odd) should be set */ USART_InitStructure.USART_WordLength = USART_WordLength_8b; break; case 0x08: if (USART_InitStructure.USART_Parity == USART_Parity_No) { USART_InitStructure.USART_WordLength = USART_WordLength_8b; } else { USART_InitStructure.USART_WordLength = USART_WordLength_9b; } break; default : { USART_Config_Default(); return (FALSE); } } USART_InitStructure.USART_BaudRate = linecoding.bitrate; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; /* Configure and enable the USART */ STM_EVAL_COMInit(COM1, &USART_InitStructure); return (TRUE); } /******************************************************************************* * Function Name : USB_To_USART_Send_Data. * Description : send the received data from USB to the UART 0. * Input : data_buffer: data address. Nb_bytes: number of bytes to send. * Return : none. *******************************************************************************/ void USB_To_USART_Send_Data(uint8_t* data_buffer, uint8_t Nb_bytes) { uint32_t i; for (i = 0; i < Nb_bytes; i++) { USART_SendData(EVAL_COM1, *(data_buffer + i)); while(USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TXE) == RESET); } } /******************************************************************************* * Function Name : Handle_USBAsynchXfer. * Description : send data to USB. * Input : None. * Return : none. *******************************************************************************/ void Handle_USBAsynchXfer (void) { uint16_t USB_Tx_ptr; uint16_t USB_Tx_length; if(USB_Tx_State != 1) { if (USART_Rx_ptr_out == USART_RX_DATA_SIZE) { USART_Rx_ptr_out = 0; } if(USART_Rx_ptr_out == USART_Rx_ptr_in) { USB_Tx_State = 0; return; } if(USART_Rx_ptr_out > USART_Rx_ptr_in) /* rollback */ { USART_Rx_length = USART_RX_DATA_SIZE - USART_Rx_ptr_out; } else { USART_Rx_length = USART_Rx_ptr_in - USART_Rx_ptr_out; } if (USART_Rx_length > VIRTUAL_COM_PORT_DATA_SIZE) { USB_Tx_ptr = USART_Rx_ptr_out; USB_Tx_length = VIRTUAL_COM_PORT_DATA_SIZE; USART_Rx_ptr_out += VIRTUAL_COM_PORT_DATA_SIZE; USART_Rx_length -= VIRTUAL_COM_PORT_DATA_SIZE; } else { USB_Tx_ptr = USART_Rx_ptr_out; USB_Tx_length = USART_Rx_length; USART_Rx_ptr_out += USART_Rx_length; USART_Rx_length = 0; } USB_Tx_State = 1; #ifdef USE_STM3210C_EVAL USB_SIL_Write(EP1_IN, &USART_Rx_Buffer[USB_Tx_ptr], USB_Tx_length); #else UserToPMABufferCopy(&USART_Rx_Buffer[USB_Tx_ptr], ENDP1_TXADDR, USB_Tx_length); SetEPTxCount(ENDP1, USB_Tx_length); SetEPTxValid(ENDP1); #endif } } /******************************************************************************* * Function Name : UART_To_USB_Send_Data. * Description : send the received data from UART 0 to USB. * Input : None. * Return : none. *******************************************************************************/ void USART_To_USB_Send_Data(void) { if (linecoding.datatype == 7) { USART_Rx_Buffer[USART_Rx_ptr_in] = USART_ReceiveData(EVAL_COM1) & 0x7F; } else if (linecoding.datatype == 8) { USART_Rx_Buffer[USART_Rx_ptr_in] = USART_ReceiveData(EVAL_COM1); } USART_Rx_ptr_in++; /* To avoid buffer overflow */ if(USART_Rx_ptr_in == USART_RX_DATA_SIZE) { USART_Rx_ptr_in = 0; } } /******************************************************************************* * 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, &Virtual_Com_Port_StringSerial[2] , 8); IntToUnicode (Device_Serial1, &Virtual_Com_Port_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/Virtual_COM_Port/src/hw_config.c
C
asf20
17,731
/******************** (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 ------------------------------------------------------------*/ /* 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_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 (USE_STM3210B_EVAL) || defined (USE_STM3210E_EVAL) /******************************************************************************* * Function Name : USART1_IRQHandler * Description : This function handles USART1 global interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ void USART1_IRQHandler(void) { if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) { /* Send the received data to the PC Host*/ USART_To_USB_Send_Data(); } /* If overrun condition occurs, clear the ORE flag and recover communication */ if (USART_GetFlagStatus(USART1, USART_FLAG_ORE) != RESET) { (void)USART_ReceiveData(USART1); } } #endif /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ #ifdef USE_STM3210C_EVAL /******************************************************************************* * Function Name : USART2_IRQHandler * Description : This function handles USART2 global interrupt request. * Input : None * Output : None * Return : None *******************************************************************************/ void USART2_IRQHandler(void) { if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) { /* Send the received data to the PC Host*/ USART_To_USB_Send_Data(); } /* If overrun condition occurs, clear the ORE flag and recover communication */ if (USART_GetFlagStatus(USART2, USART_FLAG_ORE) != RESET) { (void)USART_ReceiveData(USART2); } } #endif /* USE_STM3210C_EVAL */ #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/Virtual_COM_Port/src/stm32f10x_it.c
C
asf20
9,520
/******************** (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/Virtual_COM_Port/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 Virtual Com Port 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 ---------------------------------------------------------*/ uint8_t Request = 0; LINE_CODING linecoding = { 115200, /* baud rate*/ 0x00, /* stop bits-1*/ 0x00, /* parity - none*/ 0x08 /* no. of bits 8*/ }; /* -------------------------------------------------------------------------- */ /* Structures initializations */ /* -------------------------------------------------------------------------- */ DEVICE Device_Table = { EP_NUM, 1 }; DEVICE_PROP Device_Property = { Virtual_Com_Port_init, Virtual_Com_Port_Reset, Virtual_Com_Port_Status_In, Virtual_Com_Port_Status_Out, Virtual_Com_Port_Data_Setup, Virtual_Com_Port_NoData_Setup, Virtual_Com_Port_Get_Interface_Setting, Virtual_Com_Port_GetDeviceDescriptor, Virtual_Com_Port_GetConfigDescriptor, Virtual_Com_Port_GetStringDescriptor, 0, 0x40 /*MAX PACKET SIZE*/ }; USER_STANDARD_REQUESTS User_Standard_Requests = { Virtual_Com_Port_GetConfiguration, Virtual_Com_Port_SetConfiguration, Virtual_Com_Port_GetInterface, Virtual_Com_Port_SetInterface, Virtual_Com_Port_GetStatus, Virtual_Com_Port_ClearFeature, Virtual_Com_Port_SetEndPointFeature, Virtual_Com_Port_SetDeviceFeature, Virtual_Com_Port_SetDeviceAddress }; ONE_DESCRIPTOR Device_Descriptor = { (uint8_t*)Virtual_Com_Port_DeviceDescriptor, VIRTUAL_COM_PORT_SIZ_DEVICE_DESC }; ONE_DESCRIPTOR Config_Descriptor = { (uint8_t*)Virtual_Com_Port_ConfigDescriptor, VIRTUAL_COM_PORT_SIZ_CONFIG_DESC }; ONE_DESCRIPTOR String_Descriptor[4] = { {(uint8_t*)Virtual_Com_Port_StringLangID, VIRTUAL_COM_PORT_SIZ_STRING_LANGID}, {(uint8_t*)Virtual_Com_Port_StringVendor, VIRTUAL_COM_PORT_SIZ_STRING_VENDOR}, {(uint8_t*)Virtual_Com_Port_StringProduct, VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT}, {(uint8_t*)Virtual_Com_Port_StringSerial, VIRTUAL_COM_PORT_SIZ_STRING_SERIAL} }; /* Extern variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Extern function prototypes ------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : Virtual_Com_Port_init. * Description : Virtual COM Port Mouse init routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Virtual_Com_Port_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(); /* configure the USART to the default settings */ USART_Config_Default(); bDeviceState = UNCONNECTED; } /******************************************************************************* * Function Name : Virtual_Com_Port_Reset * Description : Virtual_Com_Port Mouse reset routine * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Virtual_Com_Port_Reset(void) { /* Set Virtual_Com_Port DEVICE as not configured */ pInformation->Current_Configuration = 0; /* Current Feature initialization */ pInformation->Current_Feature = Virtual_Com_Port_ConfigDescriptor[7]; /* Set Virtual_Com_Port DEVICE with the default Interface*/ pInformation->Current_Interface = 0; #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, VIRTUAL_COM_PORT_DATA_SIZE); /* Init EP2 IN as Interrupt endpoint */ OTG_DEV_EP_Init(EP2_IN, OTG_DEV_EP_TYPE_INT, VIRTUAL_COM_PORT_INT_SIZE); /* Init EP3 OUT as Bulk endpoint */ OTG_DEV_EP_Init(EP3_OUT, OTG_DEV_EP_TYPE_BULK, VIRTUAL_COM_PORT_DATA_SIZE); #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_BULK); SetEPTxAddr(ENDP1, ENDP1_TXADDR); SetEPTxStatus(ENDP1, EP_TX_NAK); SetEPRxStatus(ENDP1, EP_RX_DIS); /* Initialize Endpoint 2 */ SetEPType(ENDP2, EP_INTERRUPT); SetEPTxAddr(ENDP2, ENDP2_TXADDR); SetEPRxStatus(ENDP2, EP_RX_DIS); SetEPTxStatus(ENDP2, EP_TX_NAK); /* Initialize Endpoint 3 */ SetEPType(ENDP3, EP_BULK); SetEPRxAddr(ENDP3, ENDP3_RXADDR); SetEPRxCount(ENDP3, VIRTUAL_COM_PORT_DATA_SIZE); SetEPRxStatus(ENDP3, EP_RX_VALID); SetEPTxStatus(ENDP3, EP_TX_DIS); /* Set this device to response on default address */ SetDeviceAddress(0); #endif /* STM32F10X_CL */ bDeviceState = ATTACHED; } /******************************************************************************* * Function Name : Virtual_Com_Port_SetConfiguration. * Description : Udpade the device state to configured. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Virtual_Com_Port_SetConfiguration(void) { DEVICE_INFO *pInfo = &Device_Info; if (pInfo->Current_Configuration != 0) { /* Device configured */ bDeviceState = CONFIGURED; } } /******************************************************************************* * Function Name : Virtual_Com_Port_SetConfiguration. * Description : Udpade the device state to addressed. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Virtual_Com_Port_SetDeviceAddress (void) { bDeviceState = ADDRESSED; } /******************************************************************************* * Function Name : Virtual_Com_Port_Status_In. * Description : Virtual COM Port Status In Routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Virtual_Com_Port_Status_In(void) { if (Request == SET_LINE_CODING) { USART_Config(); Request = 0; } } /******************************************************************************* * Function Name : Virtual_Com_Port_Status_Out * Description : Virtual COM Port Status OUT Routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ void Virtual_Com_Port_Status_Out(void) {} /******************************************************************************* * Function Name : Virtual_Com_Port_Data_Setup * Description : handle the data class specific requests * Input : Request Nb. * Output : None. * Return : USB_UNSUPPORT or USB_SUCCESS. *******************************************************************************/ RESULT Virtual_Com_Port_Data_Setup(uint8_t RequestNo) { uint8_t *(*CopyRoutine)(uint16_t); CopyRoutine = NULL; if (RequestNo == GET_LINE_CODING) { if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) { CopyRoutine = Virtual_Com_Port_GetLineCoding; } } else if (RequestNo == SET_LINE_CODING) { if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) { CopyRoutine = Virtual_Com_Port_SetLineCoding; } Request = SET_LINE_CODING; } if (CopyRoutine == NULL) { return USB_UNSUPPORT; } pInformation->Ctrl_Info.CopyData = CopyRoutine; pInformation->Ctrl_Info.Usb_wOffset = 0; (*CopyRoutine)(0); return USB_SUCCESS; } /******************************************************************************* * Function Name : Virtual_Com_Port_NoData_Setup. * Description : handle the no data class specific requests. * Input : Request Nb. * Output : None. * Return : USB_UNSUPPORT or USB_SUCCESS. *******************************************************************************/ RESULT Virtual_Com_Port_NoData_Setup(uint8_t RequestNo) { if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) { if (RequestNo == SET_COMM_FEATURE) { return USB_SUCCESS; } else if (RequestNo == SET_CONTROL_LINE_STATE) { return USB_SUCCESS; } } return USB_UNSUPPORT; } /******************************************************************************* * Function Name : Virtual_Com_Port_GetDeviceDescriptor. * Description : Gets the device descriptor. * Input : Length. * Output : None. * Return : The address of the device descriptor. *******************************************************************************/ uint8_t *Virtual_Com_Port_GetDeviceDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Device_Descriptor); } /******************************************************************************* * Function Name : Virtual_Com_Port_GetConfigDescriptor. * Description : get the configuration descriptor. * Input : Length. * Output : None. * Return : The address of the configuration descriptor. *******************************************************************************/ uint8_t *Virtual_Com_Port_GetConfigDescriptor(uint16_t Length) { return Standard_GetDescriptorData(Length, &Config_Descriptor); } /******************************************************************************* * Function Name : Virtual_Com_Port_GetStringDescriptor * Description : Gets the string descriptors according to the needed index * Input : Length. * Output : None. * Return : The address of the string descriptors. *******************************************************************************/ uint8_t *Virtual_Com_Port_GetStringDescriptor(uint16_t Length) { uint8_t wValue0 = pInformation->USBwValue0; if (wValue0 > 4) { return NULL; } else { return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]); } } /******************************************************************************* * Function Name : Virtual_Com_Port_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 Virtual_Com_Port_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting) { if (AlternateSetting > 0) { return USB_UNSUPPORT; } else if (Interface > 1) { return USB_UNSUPPORT; } return USB_SUCCESS; } /******************************************************************************* * Function Name : Virtual_Com_Port_GetLineCoding. * Description : send the linecoding structure to the PC host. * Input : Length. * Output : None. * Return : Inecoding structure base address. *******************************************************************************/ uint8_t *Virtual_Com_Port_GetLineCoding(uint16_t Length) { if (Length == 0) { pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding); return NULL; } return(uint8_t *)&linecoding; } /******************************************************************************* * Function Name : Virtual_Com_Port_SetLineCoding. * Description : Set the linecoding structure fields. * Input : Length. * Output : None. * Return : Linecoding structure base address. *******************************************************************************/ uint8_t *Virtual_Com_Port_SetLineCoding(uint16_t Length) { if (Length == 0) { pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding); return NULL; } return(uint8_t *)&linecoding; } /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
zzqq5414-jk-rabbit
sw/lib/STM32_USB-FS-Device_Lib_V3.2.1/Project/Virtual_COM_Port/src/usb_prop.c
C
asf20
14,269
/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** * File Name : usb_desc.c * Author : MCD Application Team * Version : V3.2.1 * Date : 07/05/2010 * Description : Descriptors for Virtual Com Port 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" /* USB Standard Device Descriptor */ const uint8_t Virtual_Com_Port_DeviceDescriptor[] = { 0x12, /* bLength */ USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x00, 0x02, /* bcdUSB = 2.00 */ 0x02, /* bDeviceClass: CDC */ 0x00, /* bDeviceSubClass */ 0x00, /* bDeviceProtocol */ 0x40, /* bMaxPacketSize0 */ 0x83, 0x04, /* idVendor = 0x0483 */ 0x40, 0x57, /* idProduct = 0x7540 */ 0x00, 0x02, /* bcdDevice = 2.00 */ 1, /* Index of string descriptor describing manufacturer */ 2, /* Index of string descriptor describing product */ 3, /* Index of string descriptor describing the device's serial number */ 0x01 /* bNumConfigurations */ }; const uint8_t Virtual_Com_Port_ConfigDescriptor[] = { /*Configuation Descriptor*/ 0x09, /* bLength: Configuation Descriptor size */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */ VIRTUAL_COM_PORT_SIZ_CONFIG_DESC, /* wTotalLength:no of returned bytes */ 0x00, 0x02, /* bNumInterfaces: 2 interface */ 0x01, /* bConfigurationValue: Configuration value */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */ 0xC0, /* bmAttributes: self powered */ 0x32, /* MaxPower 0 mA */ /*Interface Descriptor*/ 0x09, /* bLength: Interface Descriptor size */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */ /* Interface descriptor type */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x01, /* bNumEndpoints: One endpoints used */ 0x02, /* bInterfaceClass: Communication Interface Class */ 0x02, /* bInterfaceSubClass: Abstract Control Model */ 0x01, /* bInterfaceProtocol: Common AT commands */ 0x00, /* iInterface: */ /*Header Functional Descriptor*/ 0x05, /* bLength: Endpoint Descriptor size */ 0x24, /* bDescriptorType: CS_INTERFACE */ 0x00, /* bDescriptorSubtype: Header Func Desc */ 0x10, /* bcdCDC: spec release number */ 0x01, /*Call Managment Functional Descriptor*/ 0x05, /* bFunctionLength */ 0x24, /* bDescriptorType: CS_INTERFACE */ 0x01, /* bDescriptorSubtype: Call Management Func Desc */ 0x00, /* bmCapabilities: D0+D1 */ 0x01, /* bDataInterface: 1 */ /*ACM Functional Descriptor*/ 0x04, /* bFunctionLength */ 0x24, /* bDescriptorType: CS_INTERFACE */ 0x02, /* bDescriptorSubtype: Abstract Control Management desc */ 0x02, /* bmCapabilities */ /*Union Functional Descriptor*/ 0x05, /* bFunctionLength */ 0x24, /* bDescriptorType: CS_INTERFACE */ 0x06, /* bDescriptorSubtype: Union func desc */ 0x00, /* bMasterInterface: Communication class interface */ 0x01, /* bSlaveInterface0: Data Class Interface */ /*Endpoint 2 Descriptor*/ 0x07, /* bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */ 0x82, /* bEndpointAddress: (IN2) */ 0x03, /* bmAttributes: Interrupt */ VIRTUAL_COM_PORT_INT_SIZE, /* wMaxPacketSize: */ 0x00, 0xFF, /* bInterval: */ /*Data class interface descriptor*/ 0x09, /* bLength: Endpoint Descriptor size */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: */ 0x01, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x02, /* bNumEndpoints: Two endpoints used */ 0x0A, /* bInterfaceClass: CDC */ 0x00, /* bInterfaceSubClass: */ 0x00, /* bInterfaceProtocol: */ 0x00, /* iInterface: */ /*Endpoint 3 Descriptor*/ 0x07, /* bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */ 0x03, /* bEndpointAddress: (OUT3) */ 0x02, /* bmAttributes: Bulk */ VIRTUAL_COM_PORT_DATA_SIZE, /* wMaxPacketSize: */ 0x00, 0x00, /* bInterval: ignore for Bulk transfer */ /*Endpoint 1 Descriptor*/ 0x07, /* bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */ 0x81, /* bEndpointAddress: (IN1) */ 0x02, /* bmAttributes: Bulk */ VIRTUAL_COM_PORT_DATA_SIZE, /* wMaxPacketSize: */ 0x00, 0x00 /* bInterval */ }; /* USB String Descriptors */ const uint8_t Virtual_Com_Port_StringLangID[VIRTUAL_COM_PORT_SIZ_STRING_LANGID] = { VIRTUAL_COM_PORT_SIZ_STRING_LANGID, USB_STRING_DESCRIPTOR_TYPE, 0x09, 0x04 /* LangID = 0x0409: U.S. English */ }; const uint8_t Virtual_Com_Port_StringVendor[VIRTUAL_COM_PORT_SIZ_STRING_VENDOR] = { VIRTUAL_COM_PORT_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 Virtual_Com_Port_StringProduct[VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT] = { VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT, /* bLength */ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ /* Product name: "STM32 Virtual COM Port" */ 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'V', 0, 'i', 0, 'r', 0, 't', 0, 'u', 0, 'a', 0, 'l', 0, ' ', 0, 'C', 0, 'O', 0, 'M', 0, ' ', 0, 'P', 0, 'o', 0, 'r', 0, 't', 0, ' ', 0, ' ', 0 }; uint8_t Virtual_Com_Port_StringSerial[VIRTUAL_COM_PORT_SIZ_STRING_SERIAL] = { VIRTUAL_COM_PORT_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/Virtual_COM_Port/src/usb_desc.c
C
asf20
7,150
;; 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/Virtual_COM_Port/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/Virtual_COM_Port/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/Virtual_COM_Port/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/Virtual_COM_Port/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/Virtual_COM_Port/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/Virtual_COM_Port/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/Virtual_COM_Port/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/Virtual_COM_Port/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/Virtual_COM_Port/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/Virtual_COM_Port/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/Virtual_COM_Port/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/Virtual_COM_Port/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_Speaker/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 ------------------------------------------------------------*/ /* Codec Control defines */ #define PLLon 1 #define PLLoff 0 #define VerifData 1 #define NoVerifData 0 #define Codec_PDN_GPIO GPIOG #define Codec_PDN_Pin GPIO_Pin_11 #define BufferSize 100 #define CodecAddress 0x27 /* 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_Config(void); void USB_Cable_Config (FunctionalState NewState); void Speaker_Config(void); void NVIC_Config(void); void GPIO_Config(void); uint32_t Sound_release(uint16_t Standard, uint16_t MCLKOutput, uint16_t AudioFreq, uint8_t AudioRepetitions); void I2S_Config(uint16_t Standard, uint16_t MCLKOutput, uint16_t AudioFreq); void Codec_PowerDown(void); uint32_t I2SCodec_WriteRegister(uint32_t RegisterAddr, uint32_t RegisterValue, uint32_t Verify); uint32_t Codec_SpeakerConfig(uint16_t I2S_Standard, uint8_t volume, uint32_t verif, uint8_t pll); 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_Speaker/inc/hw_config.h
C
asf20
2,755