parent
2ae5e614fc
commit
d4ad8d3978
File diff suppressed because it is too large
Load Diff
|
|
@ -1,797 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>ALIENTEK_EXPLORER_STM32F407ZGT6</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F407ZGTx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.14.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000-0x2001FFFF) IRAM2(0x10000000-0x1000FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll></FlashDriverDll>
|
||||
<DeviceId></DeviceId>
|
||||
<RegisterFile></RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>$$Device:STM32F407ZGTx$CMSIS\SVD\STM32F40x.svd</SFDFile>
|
||||
<bCustSvd>0</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>ALIENTEK_EXPLORER_STM32F407ZGT6\</OutputDirectory>
|
||||
<OutputName>ALIENTEK_EXPLORER_STM32F407ZGT6</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>0</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>0</BrowseInformation>
|
||||
<ListingPath></ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>0</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments>-REMAP -MPU</SimDllArguments>
|
||||
<SimDlgDll>DCM.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM4</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments>-MPU</TargetDllArguments>
|
||||
<TargetDlgDll>TCM.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM4</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4101</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>STLink\ST-LINKIII-KEIL_SWO.dll</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>1</AdsALst>
|
||||
<AdsACrf>1</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>1</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>1</AdsLsun>
|
||||
<AdsLven>1</AdsLven>
|
||||
<AdsLsxf>1</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M4"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>2</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>1</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>0</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x20000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x8000000</StartAddress>
|
||||
<Size>0x100000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x8000000</StartAddress>
|
||||
<Size>0x100000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x20000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x10000000</StartAddress>
|
||||
<Size>0x10000</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>4</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>2</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>1</v6Lang>
|
||||
<v6LangP>1</v6LangP>
|
||||
<vShortEn>1</vShortEn>
|
||||
<vShortWch>1</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define>USE_HAL_DRIVER,STM32F407xx,USE_HAL_DRIVER,STM32F407xx,USE_MODBUS</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\BSP\Inc;..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Inc\Legacy;..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32F4xx\Include;..\..\..\..\platform\vendor_bsp\st\CMSIS\Include;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc;..\..\..\..\kernel\core\include;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\TOS_CONFIG;..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\ascii;..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions;..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\include;..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\rtu;..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\tcp;..\..\..\..\components\connectivity\Modbus\porting\TencentOS_Tiny</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x08000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile></ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc></Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>Application/MDK-ARM</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_stm32f407xx.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>startup_stm32f407xx.s</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Application/User</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\main.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mcu_init.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\mcu_init.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_msp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\stm32f4xx_hal_msp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_it.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\stm32f4xx_it.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\usart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\tim.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Drivers/STM32F4xx_HAL_Driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cortex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_dma.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_dma_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_exti.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_exti.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash_ramfunc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ramfunc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pwr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pwr_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rcc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rcc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_tim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_tim_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Drivers/CMSIS</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>system_stm32f4xx.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\system_stm32f4xx.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>tos/arch</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>tos_cpu.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>port_c.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_c.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>port_s.S</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_s.S</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>tos/kernel</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>tos_event.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_event.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_global.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_global.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mmblk.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mmblk.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mmheap.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mmheap.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mutex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mutex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_pend.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_pend.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_robin.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_robin.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_sched.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_sched.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_sem.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_sem.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_sys.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_sys.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_task.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_task.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_tick.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_tick.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_time.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_time.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_timer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_timer.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_binary_heap.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_binary_heap.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_char_fifo.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_char_fifo.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_completion.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_completion.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_countdownlatch.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_countdownlatch.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mail_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mail_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_message_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_message_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_priority_mail_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_priority_mail_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_priority_message_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_priority_message_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_priority_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_priority_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_ring_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_ring_queue.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>tos/cmsis</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>cmsis_os.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\osal\cmsis_os\cmsis_os.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>examples</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>modbus.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\examples\modbus\modbus.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>modbus_src</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>mbascii.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\ascii\mbascii.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfunccoils.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfunccoils.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfuncdiag.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfuncdiag.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfuncdisc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfuncdisc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfuncholding.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfuncholding.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfuncinput.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfuncinput.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfuncother.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfuncother.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbutils.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbutils.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbcrc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\rtu\mbcrc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbrtu.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\rtu\mbrtu.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mb.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\mb.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbtcp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\tcp\mbtcp.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>modbus_port</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>portevent.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\porting\TencentOS_Tiny\portevent.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>portserial.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\porting\TencentOS_Tiny\portserial.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>porttimer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\porting\TencentOS_Tiny\porttimer.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.3.0" condition="CMSIS Core">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="ALIENTEK_EXPLORER_STM32F407ZGT6"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,438 +0,0 @@
|
|||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
||||
;* File Name : startup_stm32f407xx.s
|
||||
;* Author : MCD Application Team
|
||||
;* Description : STM32F407xx devices vector table for MDK-ARM toolchain.
|
||||
;* This module performs:
|
||||
;* - Set the initial SP
|
||||
;* - Set the initial PC == Reset_Handler
|
||||
;* - Set the vector table entries with the exceptions ISR address
|
||||
;* - Branches to __main in the C library (which eventually
|
||||
;* calls main()).
|
||||
;* After Reset the CortexM4 processor is in Thread mode,
|
||||
;* priority is Privileged, and the Stack is set to Main.
|
||||
;* <<< Use Configuration Wizard in Context Menu >>>
|
||||
;*******************************************************************************
|
||||
;
|
||||
;* Redistribution and use in source and binary forms, with or without modification,
|
||||
;* are permitted provided that the following conditions are met:
|
||||
;* 1. Redistributions of source code must retain the above copyright notice,
|
||||
;* this list of conditions and the following disclaimer.
|
||||
;* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
;* this list of conditions and the following disclaimer in the documentation
|
||||
;* and/or other materials provided with the distribution.
|
||||
;* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
;* may be used to endorse or promote products derived from this software
|
||||
;* without specific prior written permission.
|
||||
;*
|
||||
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;
|
||||
;*******************************************************************************
|
||||
|
||||
; Amount of memory (in bytes) allocated for Stack
|
||||
; Tailor this value to your application needs
|
||||
; <h> Stack Configuration
|
||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Stack_Size EQU 0x400
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem SPACE Stack_Size
|
||||
__initial_sp
|
||||
|
||||
|
||||
; <h> Heap Configuration
|
||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Heap_Size EQU 0x200
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
Heap_Mem SPACE Heap_Size
|
||||
__heap_limit
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window WatchDog
|
||||
DCD PVD_IRQHandler ; PVD through EXTI Line detection
|
||||
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
|
||||
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
|
||||
DCD FLASH_IRQHandler ; FLASH
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line4
|
||||
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
|
||||
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
|
||||
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
|
||||
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
|
||||
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
|
||||
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
|
||||
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
|
||||
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
|
||||
DCD CAN1_TX_IRQHandler ; CAN1 TX
|
||||
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
|
||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
||||
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
|
||||
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
|
||||
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
|
||||
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
|
||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
|
||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
|
||||
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
|
||||
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
|
||||
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
|
||||
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
|
||||
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
|
||||
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
|
||||
DCD FMC_IRQHandler ; FMC
|
||||
DCD SDIO_IRQHandler ; SDIO
|
||||
DCD TIM5_IRQHandler ; TIM5
|
||||
DCD SPI3_IRQHandler ; SPI3
|
||||
DCD UART4_IRQHandler ; UART4
|
||||
DCD UART5_IRQHandler ; UART5
|
||||
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
|
||||
DCD TIM7_IRQHandler ; TIM7
|
||||
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
|
||||
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
|
||||
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
|
||||
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
|
||||
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
|
||||
DCD ETH_IRQHandler ; Ethernet
|
||||
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
|
||||
DCD CAN2_TX_IRQHandler ; CAN2 TX
|
||||
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
|
||||
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
|
||||
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
|
||||
DCD OTG_FS_IRQHandler ; USB OTG FS
|
||||
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
|
||||
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
|
||||
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
|
||||
DCD USART6_IRQHandler ; USART6
|
||||
DCD I2C3_EV_IRQHandler ; I2C3 event
|
||||
DCD I2C3_ER_IRQHandler ; I2C3 error
|
||||
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
|
||||
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
|
||||
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
|
||||
DCD OTG_HS_IRQHandler ; USB OTG HS
|
||||
DCD DCMI_IRQHandler ; DCMI
|
||||
DCD 0 ; Reserved
|
||||
DCD HASH_RNG_IRQHandler ; Hash and Rng
|
||||
DCD FPU_IRQHandler ; FPU
|
||||
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset handler
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
PendSV_Handler PROC
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SysTick_Handler PROC
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
|
||||
EXPORT WWDG_IRQHandler [WEAK]
|
||||
EXPORT PVD_IRQHandler [WEAK]
|
||||
EXPORT TAMP_STAMP_IRQHandler [WEAK]
|
||||
EXPORT RTC_WKUP_IRQHandler [WEAK]
|
||||
EXPORT FLASH_IRQHandler [WEAK]
|
||||
EXPORT RCC_IRQHandler [WEAK]
|
||||
EXPORT EXTI0_IRQHandler [WEAK]
|
||||
EXPORT EXTI1_IRQHandler [WEAK]
|
||||
EXPORT EXTI2_IRQHandler [WEAK]
|
||||
EXPORT EXTI3_IRQHandler [WEAK]
|
||||
EXPORT EXTI4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream0_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream1_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream2_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream3_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream5_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream6_IRQHandler [WEAK]
|
||||
EXPORT ADC_IRQHandler [WEAK]
|
||||
EXPORT CAN1_TX_IRQHandler [WEAK]
|
||||
EXPORT CAN1_RX0_IRQHandler [WEAK]
|
||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
||||
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
|
||||
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
|
||||
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
|
||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
||||
EXPORT TIM2_IRQHandler [WEAK]
|
||||
EXPORT TIM3_IRQHandler [WEAK]
|
||||
EXPORT TIM4_IRQHandler [WEAK]
|
||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
||||
EXPORT SPI1_IRQHandler [WEAK]
|
||||
EXPORT SPI2_IRQHandler [WEAK]
|
||||
EXPORT USART1_IRQHandler [WEAK]
|
||||
EXPORT USART2_IRQHandler [WEAK]
|
||||
EXPORT USART3_IRQHandler [WEAK]
|
||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
||||
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
|
||||
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
|
||||
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
|
||||
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
|
||||
EXPORT TIM8_CC_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream7_IRQHandler [WEAK]
|
||||
EXPORT FMC_IRQHandler [WEAK]
|
||||
EXPORT SDIO_IRQHandler [WEAK]
|
||||
EXPORT TIM5_IRQHandler [WEAK]
|
||||
EXPORT SPI3_IRQHandler [WEAK]
|
||||
EXPORT UART4_IRQHandler [WEAK]
|
||||
EXPORT UART5_IRQHandler [WEAK]
|
||||
EXPORT TIM6_DAC_IRQHandler [WEAK]
|
||||
EXPORT TIM7_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream0_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream1_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream2_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream3_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream4_IRQHandler [WEAK]
|
||||
EXPORT ETH_IRQHandler [WEAK]
|
||||
EXPORT ETH_WKUP_IRQHandler [WEAK]
|
||||
EXPORT CAN2_TX_IRQHandler [WEAK]
|
||||
EXPORT CAN2_RX0_IRQHandler [WEAK]
|
||||
EXPORT CAN2_RX1_IRQHandler [WEAK]
|
||||
EXPORT CAN2_SCE_IRQHandler [WEAK]
|
||||
EXPORT OTG_FS_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream5_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream6_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream7_IRQHandler [WEAK]
|
||||
EXPORT USART6_IRQHandler [WEAK]
|
||||
EXPORT I2C3_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C3_ER_IRQHandler [WEAK]
|
||||
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
|
||||
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
|
||||
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
|
||||
EXPORT OTG_HS_IRQHandler [WEAK]
|
||||
EXPORT DCMI_IRQHandler [WEAK]
|
||||
EXPORT HASH_RNG_IRQHandler [WEAK]
|
||||
EXPORT FPU_IRQHandler [WEAK]
|
||||
|
||||
WWDG_IRQHandler
|
||||
PVD_IRQHandler
|
||||
TAMP_STAMP_IRQHandler
|
||||
RTC_WKUP_IRQHandler
|
||||
FLASH_IRQHandler
|
||||
RCC_IRQHandler
|
||||
EXTI0_IRQHandler
|
||||
EXTI1_IRQHandler
|
||||
EXTI2_IRQHandler
|
||||
EXTI3_IRQHandler
|
||||
EXTI4_IRQHandler
|
||||
DMA1_Stream0_IRQHandler
|
||||
DMA1_Stream1_IRQHandler
|
||||
DMA1_Stream2_IRQHandler
|
||||
DMA1_Stream3_IRQHandler
|
||||
DMA1_Stream4_IRQHandler
|
||||
DMA1_Stream5_IRQHandler
|
||||
DMA1_Stream6_IRQHandler
|
||||
ADC_IRQHandler
|
||||
CAN1_TX_IRQHandler
|
||||
CAN1_RX0_IRQHandler
|
||||
CAN1_RX1_IRQHandler
|
||||
CAN1_SCE_IRQHandler
|
||||
EXTI9_5_IRQHandler
|
||||
TIM1_BRK_TIM9_IRQHandler
|
||||
TIM1_UP_TIM10_IRQHandler
|
||||
TIM1_TRG_COM_TIM11_IRQHandler
|
||||
TIM1_CC_IRQHandler
|
||||
TIM2_IRQHandler
|
||||
TIM3_IRQHandler
|
||||
TIM4_IRQHandler
|
||||
I2C1_EV_IRQHandler
|
||||
I2C1_ER_IRQHandler
|
||||
I2C2_EV_IRQHandler
|
||||
I2C2_ER_IRQHandler
|
||||
SPI1_IRQHandler
|
||||
SPI2_IRQHandler
|
||||
USART1_IRQHandler
|
||||
USART2_IRQHandler
|
||||
USART3_IRQHandler
|
||||
EXTI15_10_IRQHandler
|
||||
RTC_Alarm_IRQHandler
|
||||
OTG_FS_WKUP_IRQHandler
|
||||
TIM8_BRK_TIM12_IRQHandler
|
||||
TIM8_UP_TIM13_IRQHandler
|
||||
TIM8_TRG_COM_TIM14_IRQHandler
|
||||
TIM8_CC_IRQHandler
|
||||
DMA1_Stream7_IRQHandler
|
||||
FMC_IRQHandler
|
||||
SDIO_IRQHandler
|
||||
TIM5_IRQHandler
|
||||
SPI3_IRQHandler
|
||||
UART4_IRQHandler
|
||||
UART5_IRQHandler
|
||||
TIM6_DAC_IRQHandler
|
||||
TIM7_IRQHandler
|
||||
DMA2_Stream0_IRQHandler
|
||||
DMA2_Stream1_IRQHandler
|
||||
DMA2_Stream2_IRQHandler
|
||||
DMA2_Stream3_IRQHandler
|
||||
DMA2_Stream4_IRQHandler
|
||||
ETH_IRQHandler
|
||||
ETH_WKUP_IRQHandler
|
||||
CAN2_TX_IRQHandler
|
||||
CAN2_RX0_IRQHandler
|
||||
CAN2_RX1_IRQHandler
|
||||
CAN2_SCE_IRQHandler
|
||||
OTG_FS_IRQHandler
|
||||
DMA2_Stream5_IRQHandler
|
||||
DMA2_Stream6_IRQHandler
|
||||
DMA2_Stream7_IRQHandler
|
||||
USART6_IRQHandler
|
||||
I2C3_EV_IRQHandler
|
||||
I2C3_ER_IRQHandler
|
||||
OTG_HS_EP1_OUT_IRQHandler
|
||||
OTG_HS_EP1_IN_IRQHandler
|
||||
OTG_HS_WKUP_IRQHandler
|
||||
OTG_HS_IRQHandler
|
||||
DCMI_IRQHandler
|
||||
HASH_RNG_IRQHandler
|
||||
FPU_IRQHandler
|
||||
|
||||
B .
|
||||
|
||||
ENDP
|
||||
|
||||
ALIGN
|
||||
|
||||
;*******************************************************************************
|
||||
; User Stack and Heap initialization
|
||||
;*******************************************************************************
|
||||
IF :DEF:__MICROLIB
|
||||
|
||||
EXPORT __initial_sp
|
||||
EXPORT __heap_base
|
||||
EXPORT __heap_limit
|
||||
|
||||
ELSE
|
||||
|
||||
IMPORT __use_two_region_memory
|
||||
EXPORT __user_initial_stackheap
|
||||
|
||||
__user_initial_stackheap
|
||||
|
||||
LDR R0, = Heap_Mem
|
||||
LDR R1, =(Stack_Mem + Stack_Size)
|
||||
LDR R2, = (Heap_Mem + Heap_Size)
|
||||
LDR R3, = Stack_Mem
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
|
||||
ENDIF
|
||||
|
||||
END
|
||||
|
||||
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,882 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>TencentOS_tiny</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>STM32L431RCTx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32L4xx_DFP.2.2.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack</PackURL>
|
||||
<Cpu>IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll></FlashDriverDll>
|
||||
<DeviceId></DeviceId>
|
||||
<RegisterFile></RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>$$Device:STM32L431RCTx$CMSIS\SVD\STM32L4x1.svd</SFDFile>
|
||||
<bCustSvd>0</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\obj\</OutputDirectory>
|
||||
<OutputName>TencentOS_tiny</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>0</BrowseInformation>
|
||||
<ListingPath>.\list\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>0</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments>-REMAP -MPU</SimDllArguments>
|
||||
<SimDlgDll>DCM.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM4</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments>-MPU</TargetDllArguments>
|
||||
<TargetDlgDll>TCM.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM4</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4107</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>STLink\ST-LINKIII-KEIL_SWO.dll</Flash2>
|
||||
<Flash3></Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>1</AdsALst>
|
||||
<AdsACrf>1</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>1</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>1</AdsLsun>
|
||||
<AdsLven>1</AdsLven>
|
||||
<AdsLsxf>1</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M4"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>2</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>0</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>1</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x10000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x8000000</StartAddress>
|
||||
<Size>0x40000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x8000000</StartAddress>
|
||||
<Size>0x40000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x10000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>1</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>2</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>1</v6Lang>
|
||||
<v6LangP>1</v6LangP>
|
||||
<vShortEn>1</vShortEn>
|
||||
<vShortWch>1</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define>USE_HAL_DRIVER,STM32L431xx,NDEBUG</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\BSP\Inc;..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Legacy;..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32L4xx\Include;..\..\..\..\platform\vendor_bsp\st\CMSIS\Include;..\..\..\..\kernel\core\include;..\..\TOS-CONFIG;..\..\..\..\platform\arch\arm\cortex-m4\keil;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc;..\..\BSP\Hardware\DHT11;..\..\BSP\Hardware\OLED;..\..\BSP\Hardware\BH1750;..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\ascii;..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions;..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\include;..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\rtu;..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\tcp;..\..\BSP\Hardware\Modbus_Port</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x08000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile></ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc></Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>Application/MDK-ARM</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_stm32l431xx.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>startup_stm32l431xx.s</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Application/User</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\main.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mcu_init.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\mcu_init.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_msp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\stm32l4xx_hal_msp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\usart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\adc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>dac.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\dac.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>i2c.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\i2c.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>spi.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\spi.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_it_modbus.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\stm32l4xx_it_modbus.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\tim.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>examples</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>modbus.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\examples\modbus\modbus.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Drivers/STM32L4xx_HAL_Driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_tim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_tim_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_uart_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_i2c.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_i2c_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_rcc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_rcc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_flash_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_flash_ramfunc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ramfunc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_dma.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_dma_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_pwr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_pwr_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_cortex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_adc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_adc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_dac.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_dac_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_spi.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_spi_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Drivers/CMSIS</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>system_stm32l4xx.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Src\system_stm32l4xx.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Hardware</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>DHT11_BUS.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Hardware\DHT11\DHT11_BUS.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>oled.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Hardware\OLED\oled.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>kernel</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>tos_binary_heap.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_binary_heap.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_char_fifo.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_char_fifo.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_completion.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_completion.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_countdownlatch.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_countdownlatch.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_event.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_event.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_global.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_global.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mail_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mail_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_message_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_message_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mmblk.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mmblk.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mmheap.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mmheap.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_mutex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_mutex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_pend.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_pend.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_priority_mail_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_priority_mail_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_priority_message_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_priority_message_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_priority_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_priority_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_ring_queue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_ring_queue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_robin.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_robin.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_sched.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_sched.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_sem.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_sem.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_sys.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_sys.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_task.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_task.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_tick.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_tick.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_time.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_time.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_timer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\kernel\core\tos_timer.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>cpu</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>port_s.S</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_s.S</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tos_cpu.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>port_c.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_c.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>cmsis</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>cmsis_os.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\osal\cmsis_os\cmsis_os.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>config</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>tos_config.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\TOS-CONFIG\tos_config.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>modbus_src</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>mbascii.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\ascii\mbascii.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfunccoils.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfunccoils.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfuncdiag.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfuncdiag.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfuncdisc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfuncdisc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfuncholding.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfuncholding.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfuncinput.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfuncinput.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbfuncother.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbfuncother.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbutils.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\functions\mbutils.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbcrc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\rtu\mbcrc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbrtu.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\rtu\mbrtu.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mbtcp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\tcp\mbtcp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mb.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\components\connectivity\Modbus\3rdparty\freemodbus-v1.6\modbus\mb.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>modbus_port</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>portevent.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Hardware\Modbus_Port\portevent.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>portserial.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Hardware\Modbus_Port\portserial.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>porttimer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\BSP\Hardware\Modbus_Port\porttimer.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.3.0" condition="CMSIS Core">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="TencentOS_tiny"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,404 +0,0 @@
|
|||
;********************** COPYRIGHT(c) 2017 STMicroelectronics ******************
|
||||
;* File Name : startup_stm32l431xx.s
|
||||
;* Author : MCD Application Team
|
||||
;* Description : STM32L431xx Ultra Low Power devices vector table for MDK-ARM toolchain.
|
||||
;* This module performs:
|
||||
;* - Set the initial SP
|
||||
;* - Set the initial PC == Reset_Handler
|
||||
;* - Set the vector table entries with the exceptions ISR address
|
||||
;* - Branches to __main in the C library (which eventually
|
||||
;* calls main()).
|
||||
;* After Reset the Cortex-M4 processor is in Thread mode,
|
||||
;* priority is Privileged, and the Stack is set to Main.
|
||||
;* <<< Use Configuration Wizard in Context Menu >>>
|
||||
;*******************************************************************************
|
||||
;*
|
||||
;* Redistribution and use in source and binary forms, with or without modification,
|
||||
;* are permitted provided that the following conditions are met:
|
||||
;* 1. Redistributions of source code must retain the above copyright notice,
|
||||
;* this list of conditions and the following disclaimer.
|
||||
;* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
;* this list of conditions and the following disclaimer in the documentation
|
||||
;* and/or other materials provided with the distribution.
|
||||
;* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
;* may be used to endorse or promote products derived from this software
|
||||
;* without specific prior written permission.
|
||||
;*
|
||||
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;*
|
||||
;*******************************************************************************
|
||||
;
|
||||
; Amount of memory (in bytes) allocated for Stack
|
||||
; Tailor this value to your application needs
|
||||
; <h> Stack Configuration
|
||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Stack_Size EQU 0x100
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem SPACE Stack_Size
|
||||
__initial_sp
|
||||
|
||||
|
||||
; <h> Heap Configuration
|
||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Heap_Size EQU 0x100
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
Heap_Mem SPACE Heap_Size
|
||||
__heap_limit
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window WatchDog
|
||||
DCD PVD_PVM_IRQHandler ; PVD/PVM1/PVM2/PVM3/PVM4 through EXTI Line detection
|
||||
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
|
||||
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
|
||||
DCD FLASH_IRQHandler ; FLASH
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line4
|
||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
||||
DCD ADC1_IRQHandler ; ADC1
|
||||
DCD CAN1_TX_IRQHandler ; CAN1 TX
|
||||
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
|
||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
||||
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
|
||||
DCD TIM1_BRK_TIM15_IRQHandler ; TIM1 Break and TIM15
|
||||
DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16
|
||||
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
|
||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; External Line[15:10]
|
||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SDMMC1_IRQHandler ; SDMMC1
|
||||
DCD 0 ; Reserved
|
||||
DCD SPI3_IRQHandler ; SPI3
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
|
||||
DCD TIM7_IRQHandler ; TIM7
|
||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel 1
|
||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel 2
|
||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel 3
|
||||
DCD DMA2_Channel4_IRQHandler ; DMA2 Channel 4
|
||||
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel 5
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD COMP_IRQHandler ; COMP Interrupt
|
||||
DCD LPTIM1_IRQHandler ; LP TIM1 interrupt
|
||||
DCD LPTIM2_IRQHandler ; LP TIM2 interrupt
|
||||
DCD 0 ; Reserved
|
||||
DCD DMA2_Channel6_IRQHandler ; DMA2 Channel 6
|
||||
DCD DMA2_Channel7_IRQHandler ; DMA2 Channel 7
|
||||
DCD LPUART1_IRQHandler ; LP UART1 interrupt
|
||||
DCD QUADSPI_IRQHandler ; Quad SPI global interrupt
|
||||
DCD I2C3_EV_IRQHandler ; I2C3 event
|
||||
DCD I2C3_ER_IRQHandler ; I2C3 error
|
||||
DCD SAI1_IRQHandler ; Serial Audio Interface 1 global interrupt
|
||||
DCD 0 ; Reserved
|
||||
DCD SWPMI1_IRQHandler ; Serial Wire Interface 1 global interrupt
|
||||
DCD TSC_IRQHandler ; Touch Sense Controller global interrupt
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD RNG_IRQHandler ; RNG global interrupt
|
||||
DCD FPU_IRQHandler ; FPU
|
||||
DCD CRS_IRQHandler ; CRS interrupt
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset handler
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
PendSV_Handler PROC
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SysTick_Handler PROC
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
|
||||
EXPORT WWDG_IRQHandler [WEAK]
|
||||
EXPORT PVD_PVM_IRQHandler [WEAK]
|
||||
EXPORT TAMP_STAMP_IRQHandler [WEAK]
|
||||
EXPORT RTC_WKUP_IRQHandler [WEAK]
|
||||
EXPORT FLASH_IRQHandler [WEAK]
|
||||
EXPORT RCC_IRQHandler [WEAK]
|
||||
EXPORT EXTI0_IRQHandler [WEAK]
|
||||
EXPORT EXTI1_IRQHandler [WEAK]
|
||||
EXPORT EXTI2_IRQHandler [WEAK]
|
||||
EXPORT EXTI3_IRQHandler [WEAK]
|
||||
EXPORT EXTI4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
||||
EXPORT ADC1_IRQHandler [WEAK]
|
||||
EXPORT CAN1_TX_IRQHandler [WEAK]
|
||||
EXPORT CAN1_RX0_IRQHandler [WEAK]
|
||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
||||
EXPORT TIM1_BRK_TIM15_IRQHandler [WEAK]
|
||||
EXPORT TIM1_UP_TIM16_IRQHandler [WEAK]
|
||||
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
|
||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
||||
EXPORT TIM2_IRQHandler [WEAK]
|
||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
||||
EXPORT SPI1_IRQHandler [WEAK]
|
||||
EXPORT SPI2_IRQHandler [WEAK]
|
||||
EXPORT USART1_IRQHandler [WEAK]
|
||||
EXPORT USART2_IRQHandler [WEAK]
|
||||
EXPORT USART3_IRQHandler [WEAK]
|
||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
||||
EXPORT SDMMC1_IRQHandler [WEAK]
|
||||
EXPORT SPI3_IRQHandler [WEAK]
|
||||
EXPORT TIM6_DAC_IRQHandler [WEAK]
|
||||
EXPORT TIM7_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel1_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel2_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel3_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel4_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel5_IRQHandler [WEAK]
|
||||
EXPORT COMP_IRQHandler [WEAK]
|
||||
EXPORT LPTIM1_IRQHandler [WEAK]
|
||||
EXPORT LPTIM2_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel6_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel7_IRQHandler [WEAK]
|
||||
EXPORT LPUART1_IRQHandler [WEAK]
|
||||
EXPORT QUADSPI_IRQHandler [WEAK]
|
||||
EXPORT I2C3_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C3_ER_IRQHandler [WEAK]
|
||||
EXPORT SAI1_IRQHandler [WEAK]
|
||||
EXPORT SWPMI1_IRQHandler [WEAK]
|
||||
EXPORT TSC_IRQHandler [WEAK]
|
||||
EXPORT RNG_IRQHandler [WEAK]
|
||||
EXPORT FPU_IRQHandler [WEAK]
|
||||
EXPORT CRS_IRQHandler [WEAK]
|
||||
|
||||
WWDG_IRQHandler
|
||||
PVD_PVM_IRQHandler
|
||||
TAMP_STAMP_IRQHandler
|
||||
RTC_WKUP_IRQHandler
|
||||
FLASH_IRQHandler
|
||||
RCC_IRQHandler
|
||||
EXTI0_IRQHandler
|
||||
EXTI1_IRQHandler
|
||||
EXTI2_IRQHandler
|
||||
EXTI3_IRQHandler
|
||||
EXTI4_IRQHandler
|
||||
DMA1_Channel1_IRQHandler
|
||||
DMA1_Channel2_IRQHandler
|
||||
DMA1_Channel3_IRQHandler
|
||||
DMA1_Channel4_IRQHandler
|
||||
DMA1_Channel5_IRQHandler
|
||||
DMA1_Channel6_IRQHandler
|
||||
DMA1_Channel7_IRQHandler
|
||||
ADC1_IRQHandler
|
||||
CAN1_TX_IRQHandler
|
||||
CAN1_RX0_IRQHandler
|
||||
CAN1_RX1_IRQHandler
|
||||
CAN1_SCE_IRQHandler
|
||||
EXTI9_5_IRQHandler
|
||||
TIM1_BRK_TIM15_IRQHandler
|
||||
TIM1_UP_TIM16_IRQHandler
|
||||
TIM1_TRG_COM_IRQHandler
|
||||
TIM1_CC_IRQHandler
|
||||
TIM2_IRQHandler
|
||||
I2C1_EV_IRQHandler
|
||||
I2C1_ER_IRQHandler
|
||||
I2C2_EV_IRQHandler
|
||||
I2C2_ER_IRQHandler
|
||||
SPI1_IRQHandler
|
||||
SPI2_IRQHandler
|
||||
USART1_IRQHandler
|
||||
USART2_IRQHandler
|
||||
USART3_IRQHandler
|
||||
EXTI15_10_IRQHandler
|
||||
RTC_Alarm_IRQHandler
|
||||
SDMMC1_IRQHandler
|
||||
SPI3_IRQHandler
|
||||
TIM6_DAC_IRQHandler
|
||||
TIM7_IRQHandler
|
||||
DMA2_Channel1_IRQHandler
|
||||
DMA2_Channel2_IRQHandler
|
||||
DMA2_Channel3_IRQHandler
|
||||
DMA2_Channel4_IRQHandler
|
||||
DMA2_Channel5_IRQHandler
|
||||
COMP_IRQHandler
|
||||
LPTIM1_IRQHandler
|
||||
LPTIM2_IRQHandler
|
||||
DMA2_Channel6_IRQHandler
|
||||
DMA2_Channel7_IRQHandler
|
||||
LPUART1_IRQHandler
|
||||
QUADSPI_IRQHandler
|
||||
I2C3_EV_IRQHandler
|
||||
I2C3_ER_IRQHandler
|
||||
SAI1_IRQHandler
|
||||
SWPMI1_IRQHandler
|
||||
TSC_IRQHandler
|
||||
RNG_IRQHandler
|
||||
FPU_IRQHandler
|
||||
CRS_IRQHandler
|
||||
|
||||
B .
|
||||
|
||||
ENDP
|
||||
|
||||
ALIGN
|
||||
|
||||
;*******************************************************************************
|
||||
; User Stack and Heap initialization
|
||||
;*******************************************************************************
|
||||
IF :DEF:__MICROLIB
|
||||
|
||||
EXPORT __initial_sp
|
||||
EXPORT __heap_base
|
||||
EXPORT __heap_limit
|
||||
|
||||
ELSE
|
||||
|
||||
IMPORT __use_two_region_memory
|
||||
EXPORT __user_initial_stackheap
|
||||
|
||||
__user_initial_stackheap
|
||||
|
||||
LDR R0, = Heap_Mem
|
||||
LDR R1, =(Stack_Mem + Stack_Size)
|
||||
LDR R2, = (Heap_Mem + Heap_Size)
|
||||
LDR R3, = Stack_Mem
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
|
||||
ENDIF
|
||||
|
||||
END
|
||||
|
||||
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
||||
|
|
@ -1,330 +0,0 @@
|
|||
2018-09-13 (REL_1_6_0) Christian Walter <cwalter@embedded-solutions.at>
|
||||
Notes: Changed licensing for mbfuncdisc.c. Updating licensing info
|
||||
and contact details in core stack.
|
||||
|
||||
2010-05-06 (REL_1_5_0) Christian Walter <cwalter@embedded-solutions.at>
|
||||
Notes: Added support for Atmel AT91SAM3S (Cortex M3) for IAR.
|
||||
|
||||
Detailed notes:
|
||||
- FEATURES (ATSAM3S) : Added new port.
|
||||
|
||||
2007-08-28 (REL_1_4_0) Christian Walter <wolti@sil.at>:
|
||||
Notes: Added support for HCS08. Fixed some small bugs in the documentation
|
||||
for the porting layer.
|
||||
|
||||
Detailed notes:
|
||||
- FEATURES (HCS08) : Added new port.
|
||||
- BUGS (ALL) : Fixed some small bugs in the porting guide.
|
||||
|
||||
2007-07-17 (REL_1_3_0) Christian Walter <wolti@sil.at>:
|
||||
Notes: Added ARM7/AT91SAM7X port. Added Linux/TCP port from Steven Guo.
|
||||
|
||||
Detailed notes:
|
||||
- FEATURES (ARM7): Added ARM7/AT91SAM7x port.
|
||||
- FEATURES (LINUX): Added Linux/TCP port from Steven Guo.
|
||||
- BUGS (ALL): Fixed bug in <eMBFuncReadInputRegister> where the high
|
||||
byte of the register count was ignored. This does not have a
|
||||
practical impact because the actual number of registers is always
|
||||
lower.
|
||||
|
||||
2007-07-17 (REL_1_3_0) Christian Walter <wolti@sil.at>:
|
||||
Notes: Added Linux/TCP port. Fixed bug in MSP430 port.
|
||||
Detailted notes:
|
||||
- FEATURE (LINUX): Added Linux/TCP port.
|
||||
- BUGS (MSP430): Fixed bug with calculating the timer value.
|
||||
|
||||
2007-04-25 (REL_1_2_0) Christian Walter <wolti@sil.at>:
|
||||
Notes: Added LPC214X ARM port with Keil compiler. Added Z8Encore port for
|
||||
Z8F6422 microcontroller.
|
||||
|
||||
Detailed notes:
|
||||
- FEATURE (ARM): Added LPC214X ARM port for Keil ARM 2.41.
|
||||
- FEATURE (Z8ENCORE): Added Z8F6422 for Z8Encore using the ZDS II - Z8
|
||||
Encore! development tools.
|
||||
|
||||
2007-02-18 (REL_1_1_2) Christian Walter <wolti@sil.at>:
|
||||
Notes: Fixed typo with the defined defining the supported Modbus
|
||||
functions. Fixed bug when illegal slave address was passed to eMBInit
|
||||
where the error was not detected. Fixed typo in the holding registers
|
||||
where the frame for write multiple registers was parsed with the wrong
|
||||
constants. The fix is not critical because the values matched. Fixed bug
|
||||
in discrete input registers implementation where the frame was not parsed
|
||||
correctly. Added new support for a CodeWarrior Coldfire port.
|
||||
|
||||
Detailed notes:
|
||||
- BUG (ALL): Modbus functions are compiled into the stack conditionally
|
||||
by changing the MB_FUNC_XXX defines to either true(1) or false(0).
|
||||
The defines for MB_FUNC_READ_HOLDING and MB_FUNC_WRITE_HOLDING
|
||||
were wrong.
|
||||
- BUG (ALL): eMBInit did not correctly check for addresses. Therefore
|
||||
is was possible to start the Modbus stack with an address of 0
|
||||
or one > 247.
|
||||
- BUG (ALL): eMBFuncWriteHoldingRegister should use
|
||||
MB_PDU_FUNC_WRITE_MUL_ADDR_OFF and not MB_PDU_FUNC_READ_ADDR_OFF.
|
||||
- BUG (ALL): eMBFuncReadDiscreteInputs calculated the number of discrete
|
||||
registers to read wrong.
|
||||
- FEATURE (ALL): Fixed some warnings in the code.
|
||||
|
||||
2006-11-19 (REL_1_1_1) Christian Walter <wolti@sil.at>:
|
||||
Notes: Fixed bug in Read/Write Multiple Registers function where
|
||||
the registers addresses where calculated wrong.
|
||||
Fixed bug in RTU and ASCII with the resource allocation in case of
|
||||
an error.
|
||||
Changed license to BSD style licsense.
|
||||
|
||||
Detailed notes:
|
||||
- OTHER (ALL): License is now BSD for protocol stack.
|
||||
- BUG (ALL): The registers address received in a Modbus frame
|
||||
must be converted to application addresses. The code for this
|
||||
conversion was missing and therefore has lead to error when
|
||||
this function was used (Registers of by one, Start at > 1).
|
||||
- BUG (ALL): If the serial initialization within the porting fails
|
||||
a timer is still allocated in eMBRTUInit and eMBASCIIInit. This
|
||||
can lead to a memory leak depending upon the implementation of the
|
||||
porting layer.
|
||||
- FEATURE (MCF5235): Added sample shell scripts for testing.
|
||||
- FEATURE (MSP430): Added sample shell script for testing and
|
||||
changed default values to match the other ports.
|
||||
|
||||
2006-10-30 (REL_1_1_0) Christian Walter <wolti@sil.at>:
|
||||
Notes: Added support for Read/Write Multiple Registers function
|
||||
(0x17). Added some tips to reduce memory requirements.
|
||||
Added MSP430 Port for GCC and Rowley Crossworks.
|
||||
|
||||
Detailed notes:
|
||||
- FEATURE (MSP430): Added new MSP430 port.
|
||||
- FEATURE (ALL): Added support for Read/Write Multiple Registers
|
||||
function (0x17). The implementation simply makes two callbacks
|
||||
to the eMBRegHoldingCB function where first the values are
|
||||
written and then the other register values are read.
|
||||
- FEATURE (ALL): Added some tips on reducing memory requirements
|
||||
with the protocol stack.
|
||||
|
||||
2006-10-30 (REL_1_0_5) Christian Walter <wolti@sil.at>:
|
||||
Notes: eMBDisable and eMBClose can now be called multiple times
|
||||
which makes shutdown of the protocol stack easier.
|
||||
Fixed bug in RTU state machine where we switched from the
|
||||
error state immediately to the idle state. Correct behaviour
|
||||
would be to wait till the end of frame.
|
||||
Added new STR71X GCC port which uses only freely available tools
|
||||
like GNU ARM, OpenOCD (Wiggler) and GDB.
|
||||
|
||||
Detailed notes:
|
||||
- FEATURE (STR71X): Added GCC standalone port which does not
|
||||
depend on the Rowley Crosswork tools.
|
||||
- FEATURE (ALL): eMBDisable can now be called multiple times
|
||||
and returns MB_ENOERR in case is was already disabled.
|
||||
eMBClose also supports beeing called multiple times in
|
||||
which pvMBFrameCloseCur( ) is called when the protocol stack
|
||||
is in state STATE_DISABLED.
|
||||
- BUG (RTU): Fixed bug in xMBRTUReceiveFSM where the error
|
||||
state is immediately left because of a missing break. Instead
|
||||
we should wait till the damaged frame is finished.
|
||||
|
||||
2006-10-11 (REL_1_0_4) Christian Walter <wolti@sil.at>:
|
||||
Notes: Fixed bug when more than 255 coils are requested. Fixed bug in
|
||||
Linux/Cygwin port when not all bytes could be written by the first
|
||||
call to write. Added support for removing previously registered
|
||||
function handlers.
|
||||
|
||||
Detailed notes:
|
||||
- BUG (ALL): mbfunccoils contained a bug which limited the amount
|
||||
of coils to read to 255.
|
||||
- BUG (LINUX): prvbMBPortSerialWrite contained a bug in the loop
|
||||
which writes the RTU/ASCII frame to the serial file descriptor.
|
||||
If not all bytes where written in the first call or write was
|
||||
interrupted the sent frame is corrupted.
|
||||
- FEATURE (ALL): eMBRegisterCB now supports NULL as handler
|
||||
argument in which case a previously registered function
|
||||
handler is deregistered from the protocol stack.
|
||||
|
||||
2006-09-27 (REL_1_0_3) Christian Walter <wolti@sil.at>:
|
||||
Notes: Added new functions to support registering of custom callback
|
||||
handlers. This makes it possible to implement new Modbus function
|
||||
codes without touching the protocol stack.
|
||||
New port for ATMega128 added. Thanks to Richard C Sandoz Jr. for
|
||||
the patches.
|
||||
|
||||
Detailed notes:
|
||||
- FEATURE (ALL): Added support for registering new functions handlers
|
||||
with eMBRegisterCB.
|
||||
- FEATURE (AVR): Added patches from Richard C Sandoz Jr. for ATMega128
|
||||
|
||||
2006-09-06 (REL_1_0_2) Christian Walter <wolti@sil.at>:
|
||||
Notes: Fixed bug in FreeRTOS porting layer for STR71X/lwIP target where
|
||||
memory is not freed in the sys_arch_thread_remove function.
|
||||
Synched MCF5235TCP port with the FreeRTOS/lwIP port for the STR71X.
|
||||
|
||||
Detailed notes:
|
||||
- BUG (STR71XTCP): Sys_arch_thread_remove did not free the memory from
|
||||
the TCB.
|
||||
- BUG (STR71XTCP): Unnecessary call to vTaskSuspendAll removed.
|
||||
- BUG (STR71XTCP): Bug with counting variable. The first to lwIP tasks
|
||||
got the same name (lwIP0).
|
||||
- FEATURE (MCF5235TCP): Enhanced functions from the STR71X/lwIP port
|
||||
merged into the Coldfire port.
|
||||
|
||||
2006-09-04 (REL_1_0_1) Christian Walter <wolti@sil.at>:
|
||||
Notes: Fixed bug in serial driver for STR71x target when the ring buffer
|
||||
overflows.
|
||||
|
||||
Detailed notes:
|
||||
- BUG (STR71XTCP): Under high load the ring buffer in the serial driver
|
||||
functions might overflow. There was an error with counting the number
|
||||
of received characters which corrupted received frames.
|
||||
Now receiver correctly recovers in case of dropped bytes.
|
||||
|
||||
2006-09-04 (REL_1_0) Christian Walter <wolti@sil.at>:
|
||||
Notes: Added support for ATmega8, ATmega16, ATmega32, ATmega169 and
|
||||
RS485 drivers in the AVR support. Special thanks to Tran Minh Hoang
|
||||
for his contribution.
|
||||
Added a new lwIP port for the STR71X target which uses one serial
|
||||
interface for a PPP connection. This can be used for remote Modbus/TCP
|
||||
devices in combination with a Modem (E.g. GPRS or Analog).
|
||||
|
||||
Detailed notes:
|
||||
- FEATURES (AVR): Integrated patches from Tran Minh Hoang to support the
|
||||
ATmega8, ATmega16, ATmega32, ATmega169 controllers.
|
||||
- FEATURES (AVR): Added support for RS485 drivers in the AVR code. The
|
||||
example supports the DS76176.
|
||||
- FEATURES (STR71XTCP): implemented function in STR71X/lwIP porting layer
|
||||
to remove running tasks.
|
||||
- FEATURES (STR71XTCP): added new thread creation function in STR71X/lwIP
|
||||
porting layer which allows specifing the stack size.
|
||||
- BUGS (STR71XTCP): pppOpen defined in ppp.c does not check the return
|
||||
value of sys_thread_new. If task creation fails the system crashes.
|
||||
- BUGS (STR71XTCP): pppMain must not return - Instead it should remove
|
||||
its task from the scheduler.
|
||||
|
||||
2006-08-30 (REL_9) Christian Walter <wolti@sil.at>:
|
||||
Notes: Added lwIP port for the MCF5235 target. The lwIP part is
|
||||
generic and therefore FreeModbus now works on any target with
|
||||
lwIP support.
|
||||
|
||||
Detailed notes:
|
||||
- FEATURES: Incoperated MCF5235 FreeRTOS/lwIP port done by the
|
||||
author in this project.
|
||||
- FEATURES: Added lwIP port for FreeModbus
|
||||
- FEATURES: Added demo application for FreeModbus and lwIP.
|
||||
|
||||
2006-08-22 (REL_0_82) Christian Walter <wolti@sil.at>
|
||||
Notes: Fixed bug with Modbus ASCII support
|
||||
|
||||
Detailed notes:
|
||||
- BUG: During the last upgrade an error was introduced in the
|
||||
initialization code of Modbus ASCII and therefore ASCII
|
||||
support was broken. The bug is fixed now and was tested with
|
||||
the Win32 port.
|
||||
|
||||
2006-08-22 (REL_0_81) Christian Walter <wolti@sil.at>
|
||||
Notes: Added porting guide
|
||||
|
||||
Detailed notes:
|
||||
- OTHER: Added a new porting guide to the documentation.
|
||||
- OTHER: Added a empty example for new ports to the project as a
|
||||
starting point.
|
||||
|
||||
2006-08-01 (REL_0_8) Christian Walter <wolti@sil.at>
|
||||
Notes: Added Linux RTU/ASCII port.
|
||||
|
||||
Detailed notes:
|
||||
- FEATURES: Added a new Linux RTU/ASCII port. The port should work
|
||||
on any Linux distribution and it should be possible to run it
|
||||
on uCLinux.
|
||||
|
||||
2006-06-26 (REL_0_7) Christian Walter <wolti@sil.at>
|
||||
Notes: Changed the WIN32 serial port to better fit into the design.
|
||||
|
||||
Detailed notes:
|
||||
- OTHER: Design of the WIN32 serial port changed. The polling function
|
||||
for the serial device are now called from the event loop.
|
||||
- OTHER: Debugging uses the same interface as the WIN32/TCP port.
|
||||
|
||||
2006-06-25 Christian Walter <wolti@sil.at>
|
||||
|
||||
Notes: Initial work on a Modbus/TCP port is available. The port includes
|
||||
an example for a Win32 port which uses the Winsock API.
|
||||
|
||||
Detailed notes:
|
||||
- FEATURES: added required functions to core protocol stack to support
|
||||
a Modbus/TCP implementation.
|
||||
- FEATURES: added a Win32 port for the Modbus/TCP core. The port is
|
||||
currently limited to one concurrent client.
|
||||
- OTHER: The implementation of eMBClose to shutdown the protocol stack
|
||||
was changed to unify it with the new Modbus/TCP code.
|
||||
-
|
||||
|
||||
2006-06-18 Christian Walter <wolti@sil.at>
|
||||
|
||||
Detailed notes:
|
||||
- OTHER: while working on the Win32 port some line feeds got
|
||||
wrong. Also some source files used tabs instead of spaces.
|
||||
- OTHER: prototypes for xMBUtilSetBits and xMBUtilGetBits fixed.
|
||||
usNBits should be ucNBits by convention.
|
||||
|
||||
2006-06-17 Christian Walter <wolti@sil.at>
|
||||
|
||||
Notes: Fixed various bugs with the Win32 port
|
||||
|
||||
Detailed notes:
|
||||
- FEATURES: implement shutdown functionality for protocol stack.
|
||||
- FEATURES: protocol stack can be enabled and disabled during runtime.
|
||||
- FEATURES: interface functions now do more error checking. For
|
||||
example if eMBPool is called in an uninitialized state.
|
||||
- FEATURES: extended Win32 demo application to use the new features.
|
||||
- BUG: fixed bug in Win32 demo for ASCII mode.
|
||||
|
||||
2006-06-16 Christian Walter <wolti@sil.at>
|
||||
Notes: The new version includes a new port for the
|
||||
Win32 platform
|
||||
|
||||
Detailed notes:
|
||||
- FEATURES: added Win32 platform
|
||||
|
||||
2006-05-14 Christian Walter <wolti@sil.at>
|
||||
Notes: The new version includes a new port for the
|
||||
Freescale MCF5235 processor.
|
||||
|
||||
Detailed notes:
|
||||
- FEATURES: added new MCF5235 port.
|
||||
- OTHER: fixed some missing code headers.
|
||||
|
||||
2006-05-01 Christian Walter <wolti@sil.at>
|
||||
Notes: This version removes the t1.5 timers from the Modbus RTU
|
||||
implementation because no one actually uses it and the CPU
|
||||
load is very high. T
|
||||
In addition some documentation cleanups has been done and the
|
||||
ARM demo has been updated.
|
||||
|
||||
Detailed notes:
|
||||
|
||||
- FEATURES: the t1.5 timeout has been removed. Therefore only
|
||||
one timer is required.
|
||||
- BUG: the ARM demo project missed some files in the project
|
||||
workspace and did not compile cleanly
|
||||
|
||||
2006-02-28 Christian Walter <wolti@sil.at>
|
||||
Notes: This version includes support for two new command
|
||||
(write multiple coils, read discrete input)
|
||||
|
||||
Detailed notes:
|
||||
- BUG: some function used the wrong data types
|
||||
- FEATURES: added support for write multiple coils function.
|
||||
- FEATURES: added support for read discrete input.
|
||||
- OTHER: some code cleanups with lint tool.
|
||||
|
||||
2006-02-28 Christian Walter <wolti@sil.at>
|
||||
|
||||
Notes: The new version 0.31 adds support for reading and writing the
|
||||
coil registers and add some bug fixes.
|
||||
|
||||
Detailed notes:
|
||||
- BUG: fixed bug with to small modbus requests being ignored.
|
||||
- FEATURES: added support for write single coil function.
|
||||
- FEATURES: added support for working with byte packed bit fields
|
||||
to support coils and discrete inputs better.
|
||||
- API: API for set slave id functions changed.
|
||||
|
||||
2006-02-26 Christian Walter <wolti@sil.at>
|
||||
|
||||
Notes: First public release which includes an ARM and AVR port.
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
Copyright (c) 2006 Christian Walter <wolti@sil.at>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
|
@ -1,345 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "croutine.h"
|
||||
|
||||
/* Lists for ready and blocked co-routines. --------------------*/
|
||||
static xList pxReadyCoRoutineLists[ configMAX_CO_ROUTINE_PRIORITIES ]; /*< Prioritised ready co-routines. */
|
||||
static xList xDelayedCoRoutineList1; /*< Delayed co-routines. */
|
||||
static xList xDelayedCoRoutineList2; /*< Delayed co-routines (two lists are used - one for delays that have overflowed the current tick count. */
|
||||
static xList * pxDelayedCoRoutineList; /*< Points to the delayed co-routine list currently being used. */
|
||||
static xList * pxOverflowDelayedCoRoutineList; /*< Points to the delayed co-routine list currently being used to hold co-routines that have overflowed the current tick count. */
|
||||
static xList xPendingReadyList; /*< Holds co-routines that have been readied by an external event. They cannot be added directly to the ready lists as the ready lists cannot be accessed by interrupts. */
|
||||
|
||||
/* Other file private variables. --------------------------------*/
|
||||
corCRCB * pxCurrentCoRoutine = NULL;
|
||||
static unsigned portBASE_TYPE uxTopCoRoutineReadyPriority = 0;
|
||||
static portTickType xCoRoutineTickCount = 0;
|
||||
|
||||
/* The initial state of the co-routine when it is created. */
|
||||
#define corINITIAL_STATE ( 0 )
|
||||
|
||||
/*
|
||||
* Place the co-routine represented by pxCRCB into the appropriate ready queue
|
||||
* for the priority. It is inserted at the end of the list.
|
||||
*
|
||||
* This macro accesses the co-routine ready lists and therefore must not be
|
||||
* used from within an ISR.
|
||||
*/
|
||||
#define prvAddCoRoutineToReadyQueue( pxCRCB ) \
|
||||
{ \
|
||||
if( pxCRCB->uxPriority > uxTopCoRoutineReadyPriority ) \
|
||||
{ \
|
||||
uxTopCoRoutineReadyPriority = pxCRCB->uxPriority; \
|
||||
} \
|
||||
vListInsertEnd( ( xList * ) &( pxReadyCoRoutineLists[ pxCRCB->uxPriority ] ), &( pxCRCB->xGenericListItem ) ); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility to ready all the lists used by the scheduler. This is called
|
||||
* automatically upon the creation of the first co-routine.
|
||||
*/
|
||||
static void prvInitialiseCoRoutineLists( void );
|
||||
|
||||
/*
|
||||
* Co-routines that are readied by an interrupt cannot be placed directly into
|
||||
* the ready lists (there is no mutual exclusion). Instead they are placed in
|
||||
* in the pending ready list in order that they can later be moved to the ready
|
||||
* list by the co-routine scheduler.
|
||||
*/
|
||||
static inline void prvCheckPendingReadyList( void );
|
||||
|
||||
/*
|
||||
* Macro that looks at the list of co-routines that are currently delayed to
|
||||
* see if any require waking.
|
||||
*
|
||||
* Co-routines are stored in the queue in the order of their wake time -
|
||||
* meaning once one co-routine has been found whose timer has not expired
|
||||
* we need not look any further down the list.
|
||||
*/
|
||||
static inline void prvCheckDelayedList( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, unsigned portBASE_TYPE uxPriority, unsigned portBASE_TYPE uxIndex )
|
||||
{
|
||||
signed portBASE_TYPE xReturn;
|
||||
corCRCB *pxCoRoutine;
|
||||
|
||||
/* Allocate the memory that will store the co-routine control block. */
|
||||
pxCoRoutine = ( corCRCB * ) pvPortMalloc( sizeof( corCRCB ) );
|
||||
if( pxCoRoutine )
|
||||
{
|
||||
/* If pxCurrentCoRoutine is NULL then this is the first co-routine to
|
||||
be created and the co-routine data structures need initialising. */
|
||||
if( pxCurrentCoRoutine == NULL )
|
||||
{
|
||||
pxCurrentCoRoutine = pxCoRoutine;
|
||||
prvInitialiseCoRoutineLists();
|
||||
}
|
||||
|
||||
/* Check the priority is within limits. */
|
||||
if( uxPriority >= configMAX_CO_ROUTINE_PRIORITIES )
|
||||
{
|
||||
uxPriority = configMAX_CO_ROUTINE_PRIORITIES - 1;
|
||||
}
|
||||
|
||||
/* Fill out the co-routine control block from the function parameters. */
|
||||
pxCoRoutine->uxState = corINITIAL_STATE;
|
||||
pxCoRoutine->uxPriority = uxPriority;
|
||||
pxCoRoutine->uxIndex = uxIndex;
|
||||
pxCoRoutine->pxCoRoutineFunction = pxCoRoutineCode;
|
||||
|
||||
/* Initialise all the other co-routine control block parameters. */
|
||||
vListInitialiseItem( &( pxCoRoutine->xGenericListItem ) );
|
||||
vListInitialiseItem( &( pxCoRoutine->xEventListItem ) );
|
||||
|
||||
/* Set the co-routine control block as a link back from the xListItem.
|
||||
This is so we can get back to the containing CRCB from a generic item
|
||||
in a list. */
|
||||
listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xGenericListItem ), pxCoRoutine );
|
||||
listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xEventListItem ), pxCoRoutine );
|
||||
|
||||
/* Event lists are always in priority order. */
|
||||
listSET_LIST_ITEM_VALUE( &( pxCoRoutine->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) uxPriority );
|
||||
|
||||
/* Now the co-routine has been initialised it can be added to the ready
|
||||
list at the correct priority. */
|
||||
prvAddCoRoutineToReadyQueue( pxCoRoutine );
|
||||
|
||||
xReturn = pdPASS;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;
|
||||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList )
|
||||
{
|
||||
portTickType xTimeToWake;
|
||||
|
||||
/* Calculate the time to wake - this may overflow but this is
|
||||
not a problem. */
|
||||
xTimeToWake = xCoRoutineTickCount + xTicksToDelay;
|
||||
|
||||
/* We must remove ourselves from the ready list before adding
|
||||
ourselves to the blocked list as the same list item is used for
|
||||
both lists. */
|
||||
vListRemove( ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) );
|
||||
|
||||
/* The list item will be inserted in wake time order. */
|
||||
listSET_LIST_ITEM_VALUE( &( pxCurrentCoRoutine->xGenericListItem ), xTimeToWake );
|
||||
|
||||
if( xTimeToWake < xCoRoutineTickCount )
|
||||
{
|
||||
/* Wake time has overflowed. Place this item in the
|
||||
overflow list. */
|
||||
vListInsert( ( xList * ) pxOverflowDelayedCoRoutineList, ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The wake time has not overflowed, so we can use the
|
||||
current block list. */
|
||||
vListInsert( ( xList * ) pxDelayedCoRoutineList, ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) );
|
||||
}
|
||||
|
||||
if( pxEventList )
|
||||
{
|
||||
/* Also add the co-routine to an event list. If this is done then the
|
||||
function must be called with interrupts disabled. */
|
||||
vListInsert( pxEventList, &( pxCurrentCoRoutine->xEventListItem ) );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static inline void prvCheckPendingReadyList( void )
|
||||
{
|
||||
/* Are there any co-routines waiting to get moved to the ready list? These
|
||||
are co-routines that have been readied by an ISR. The ISR cannot access
|
||||
the ready lists itself. */
|
||||
while( !listLIST_IS_EMPTY( &xPendingReadyList ) )
|
||||
{
|
||||
corCRCB *pxUnblockedCRCB;
|
||||
|
||||
/* The pending ready list can be accessed by an ISR. */
|
||||
portDISABLE_INTERRUPTS();
|
||||
{
|
||||
pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( (&xPendingReadyList) );
|
||||
vListRemove( &( pxUnblockedCRCB->xEventListItem ) );
|
||||
}
|
||||
portENABLE_INTERRUPTS();
|
||||
|
||||
vListRemove( &( pxUnblockedCRCB->xGenericListItem ) );
|
||||
prvAddCoRoutineToReadyQueue( pxUnblockedCRCB );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static inline void prvCheckDelayedList( void )
|
||||
{
|
||||
static portTickType xLastTickCount, xPassedTicks;
|
||||
corCRCB *pxCRCB;
|
||||
|
||||
xPassedTicks = xTaskGetTickCount() - xLastTickCount;
|
||||
while( xPassedTicks )
|
||||
{
|
||||
xCoRoutineTickCount++;
|
||||
xPassedTicks--;
|
||||
|
||||
/* If the tick count has overflowed we need to swap the ready lists. */
|
||||
if( xCoRoutineTickCount == 0 )
|
||||
{
|
||||
xList * pxTemp;
|
||||
|
||||
/* Tick count has overflowed so we need to swap the delay lists. If there are
|
||||
any items in pxDelayedCoRoutineList here then there is an error! */
|
||||
pxTemp = pxDelayedCoRoutineList;
|
||||
pxDelayedCoRoutineList = pxOverflowDelayedCoRoutineList;
|
||||
pxOverflowDelayedCoRoutineList = pxTemp;
|
||||
}
|
||||
|
||||
/* See if this tick has made a timeout expire. */
|
||||
while( ( pxCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedCoRoutineList ) ) != NULL )
|
||||
{
|
||||
if( xCoRoutineTickCount < listGET_LIST_ITEM_VALUE( &( pxCRCB->xGenericListItem ) ) )
|
||||
{
|
||||
/* Timeout not yet expired. */
|
||||
break;
|
||||
}
|
||||
|
||||
portDISABLE_INTERRUPTS();
|
||||
{
|
||||
/* The event could have occurred just before this critical
|
||||
section. If this is the case then the generic list item will
|
||||
have been moved to the pending ready list and the following
|
||||
line is still valid. Also the pvContainer parameter will have
|
||||
been set to NULL so the following lines are also valid. */
|
||||
vListRemove( &( pxCRCB->xGenericListItem ) );
|
||||
|
||||
/* Is the co-routine waiting on an event also? */
|
||||
if( pxCRCB->xEventListItem.pvContainer )
|
||||
{
|
||||
vListRemove( &( pxCRCB->xEventListItem ) );
|
||||
}
|
||||
}
|
||||
portENABLE_INTERRUPTS();
|
||||
|
||||
prvAddCoRoutineToReadyQueue( pxCRCB );
|
||||
}
|
||||
}
|
||||
|
||||
xLastTickCount = xCoRoutineTickCount;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vCoRoutineSchedule( void )
|
||||
{
|
||||
/* See if any co-routines readied by events need moving to the ready lists. */
|
||||
prvCheckPendingReadyList();
|
||||
|
||||
/* See if any delayed co-routines have timed out. */
|
||||
prvCheckDelayedList();
|
||||
|
||||
/* Find the highest priority queue that contains ready co-routines. */
|
||||
while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) )
|
||||
{
|
||||
if( uxTopCoRoutineReadyPriority == 0 )
|
||||
{
|
||||
/* No more co-routines to check. */
|
||||
return;
|
||||
}
|
||||
--uxTopCoRoutineReadyPriority;
|
||||
}
|
||||
|
||||
/* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines
|
||||
of the same priority get an equal share of the processor time. */
|
||||
listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) );
|
||||
|
||||
/* Call the co-routine. */
|
||||
( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex );
|
||||
|
||||
return;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvInitialiseCoRoutineLists( void )
|
||||
{
|
||||
unsigned portBASE_TYPE uxPriority;
|
||||
|
||||
for( uxPriority = 0; uxPriority < configMAX_CO_ROUTINE_PRIORITIES; uxPriority++ )
|
||||
{
|
||||
vListInitialise( ( xList * ) &( pxReadyCoRoutineLists[ uxPriority ] ) );
|
||||
}
|
||||
|
||||
vListInitialise( ( xList * ) &xDelayedCoRoutineList1 );
|
||||
vListInitialise( ( xList * ) &xDelayedCoRoutineList2 );
|
||||
vListInitialise( ( xList * ) &xPendingReadyList );
|
||||
|
||||
/* Start with pxDelayedCoRoutineList using list1 and the
|
||||
pxOverflowDelayedCoRoutineList using list2. */
|
||||
pxDelayedCoRoutineList = &xDelayedCoRoutineList1;
|
||||
pxOverflowDelayedCoRoutineList = &xDelayedCoRoutineList2;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xCoRoutineRemoveFromEventList( const xList *pxEventList )
|
||||
{
|
||||
corCRCB *pxUnblockedCRCB;
|
||||
signed portBASE_TYPE xReturn;
|
||||
|
||||
/* This function is called from within an interrupt. It can only access
|
||||
event lists and the pending ready list. */
|
||||
pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );
|
||||
vListRemove( &( pxUnblockedCRCB->xEventListItem ) );
|
||||
vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxUnblockedCRCB->xEventListItem ) );
|
||||
|
||||
if( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority )
|
||||
{
|
||||
xReturn = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = pdFALSE;
|
||||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef INC_FREERTOS_H
|
||||
#define INC_FREERTOS_H
|
||||
|
||||
|
||||
/*
|
||||
* Include the generic headers required for the FreeRTOS port being used.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
|
||||
/* Basic FreeRTOS definitions. */
|
||||
#include "projdefs.h"
|
||||
|
||||
/* Application specific configuration options. */
|
||||
#include "FreeRTOSConfig.h"
|
||||
|
||||
/* Definitions specific to the port being used. */
|
||||
#include "portable.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Check all the required application specific macros have been defined.
|
||||
* These macros are application specific and (as downloaded) are defined
|
||||
* within FreeRTOSConfig.h.
|
||||
*/
|
||||
|
||||
#ifndef configUSE_PREEMPTION
|
||||
#error Missing definition: configUSE_PREEMPTION should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#ifndef configUSE_IDLE_HOOK
|
||||
#error Missing definition: configUSE_IDLE_HOOK should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#ifndef configUSE_TICK_HOOK
|
||||
#error Missing definition: configUSE_TICK_HOOK should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#ifndef configUSE_CO_ROUTINES
|
||||
#error Missing definition: configUSE_CO_ROUTINES should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDE_vTaskPrioritySet
|
||||
#error Missing definition: INCLUDE_vTaskPrioritySet should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDE_uxTaskPriorityGet
|
||||
#error Missing definition: INCLUDE_uxTaskPriorityGet should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDE_vTaskDelete
|
||||
#error Missing definition: INCLUDE_vTaskDelete should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDE_vTaskCleanUpResources
|
||||
#error Missing definition: INCLUDE_vTaskCleanUpResources should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDE_vTaskSuspend
|
||||
#error Missing definition: INCLUDE_vTaskSuspend should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDE_vTaskDelayUntil
|
||||
#error Missing definition: INCLUDE_vTaskDelayUntil should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDE_vTaskDelay
|
||||
#error Missing definition: INCLUDE_vTaskDelay should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#ifndef configUSE_16_BIT_TICKS
|
||||
#error Missing definition: configUSE_16_BIT_TICKS should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,716 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
#ifndef CO_ROUTINE_H
|
||||
#define CO_ROUTINE_H
|
||||
|
||||
#include "list.h"
|
||||
|
||||
/* Used to hide the implementation of the co-routine control block. The
|
||||
control block structure however has to be included in the header due to
|
||||
the macro implementation of the co-routine functionality. */
|
||||
typedef void * xCoRoutineHandle;
|
||||
|
||||
/* Defines the prototype to which co-routine functions must conform. */
|
||||
typedef void (*crCOROUTINE_CODE)( xCoRoutineHandle, unsigned portBASE_TYPE );
|
||||
|
||||
typedef struct corCoRoutineControlBlock
|
||||
{
|
||||
crCOROUTINE_CODE pxCoRoutineFunction;
|
||||
xListItem xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */
|
||||
xListItem xEventListItem; /*< List item used to place the CRCB in event lists. */
|
||||
unsigned portBASE_TYPE uxPriority; /*< The priority of the co-routine in relation to other co-routines. */
|
||||
unsigned portBASE_TYPE uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */
|
||||
unsigned portSHORT uxState; /*< Used internally by the co-routine implementation. */
|
||||
} corCRCB; /* Co-routine control block. Note must be identical in size down to uxPriority with tskTCB. */
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
*<pre>
|
||||
portBASE_TYPE xCoRoutineCreate(
|
||||
crCOROUTINE_CODE pxCoRoutineCode,
|
||||
unsigned portBASE_TYPE uxPriority,
|
||||
unsigned portBASE_TYPE uxIndex
|
||||
);</pre>
|
||||
*
|
||||
* Create a new co-routine and add it to the list of co-routines that are
|
||||
* ready to run.
|
||||
*
|
||||
* @param pxCoRoutineCode Pointer to the co-routine function. Co-routine
|
||||
* functions require special syntax - see the co-routine section of the WEB
|
||||
* documentation for more information.
|
||||
*
|
||||
* @param uxPriority The priority with respect to other co-routines at which
|
||||
* the co-routine will run.
|
||||
*
|
||||
* @param uxIndex Used to distinguish between different co-routines that
|
||||
* execute the same function. See the example below and the co-routine section
|
||||
* of the WEB documentation for further information.
|
||||
*
|
||||
* @return pdPASS if the co-routine was successfully created and added to a ready
|
||||
* list, otherwise an error code defined with ProjDefs.h.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Co-routine to be created.
|
||||
void vFlashCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
|
||||
{
|
||||
// Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
// This may not be necessary for const variables.
|
||||
static const char cLedToFlash[ 2 ] = { 5, 6 };
|
||||
static const portTickType xTimeToDelay[ 2 ] = { 200, 400 };
|
||||
|
||||
// Must start every co-routine with a call to crSTART();
|
||||
crSTART( xHandle );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
// This co-routine just delays for a fixed period, then toggles
|
||||
// an LED. Two co-routines are created using this function, so
|
||||
// the uxIndex parameter is used to tell the co-routine which
|
||||
// LED to flash and how long to delay. This assumes xQueue has
|
||||
// already been created.
|
||||
vParTestToggleLED( cLedToFlash[ uxIndex ] );
|
||||
crDELAY( xHandle, uxFlashRates[ uxIndex ] );
|
||||
}
|
||||
|
||||
// Must end every co-routine with a call to crEND();
|
||||
crEND();
|
||||
}
|
||||
|
||||
// Function that creates two co-routines.
|
||||
void vOtherFunction( void )
|
||||
{
|
||||
unsigned char ucParameterToPass;
|
||||
xTaskHandle xHandle;
|
||||
|
||||
// Create two co-routines at priority 0. The first is given index 0
|
||||
// so (from the code above) toggles LED 5 every 200 ticks. The second
|
||||
// is given index 1 so toggles LED 6 every 400 ticks.
|
||||
for( uxIndex = 0; uxIndex < 2; uxIndex++ )
|
||||
{
|
||||
xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex );
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xCoRoutineCreate xCoRoutineCreate
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
signed portBASE_TYPE xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, unsigned portBASE_TYPE uxPriority, unsigned portBASE_TYPE uxIndex );
|
||||
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
*<pre>
|
||||
void vCoRoutineSchedule( void );</pre>
|
||||
*
|
||||
* Run a co-routine.
|
||||
*
|
||||
* vCoRoutineSchedule() executes the highest priority co-routine that is able
|
||||
* to run. The co-routine will execute until it either blocks, yields or is
|
||||
* preempted by a task. Co-routines execute cooperatively so one
|
||||
* co-routine cannot be preempted by another, but can be preempted by a task.
|
||||
*
|
||||
* If an application comprises of both tasks and co-routines then
|
||||
* vCoRoutineSchedule should be called from the idle task (in an idle task
|
||||
* hook).
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// This idle task hook will schedule a co-routine each time it is called.
|
||||
// The rest of the idle task will execute between co-routine calls.
|
||||
void vApplicationIdleHook( void )
|
||||
{
|
||||
vCoRoutineSchedule();
|
||||
}
|
||||
|
||||
// Alternatively, if you do not require any other part of the idle task to
|
||||
// execute, the idle task hook can call vCoRoutineScheduler() within an
|
||||
// infinite loop.
|
||||
void vApplicationIdleHook( void )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
vCoRoutineSchedule();
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup vCoRoutineSchedule vCoRoutineSchedule
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
void vCoRoutineSchedule( void );
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* <pre>
|
||||
crSTART( xCoRoutineHandle xHandle );</pre>
|
||||
*
|
||||
* This macro MUST always be called at the start of a co-routine function.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Co-routine to be created.
|
||||
void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
|
||||
{
|
||||
// Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
static portLONG ulAVariable;
|
||||
|
||||
// Must start every co-routine with a call to crSTART();
|
||||
crSTART( xHandle );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
// Co-routine functionality goes here.
|
||||
}
|
||||
|
||||
// Must end every co-routine with a call to crEND();
|
||||
crEND();
|
||||
}</pre>
|
||||
* \defgroup crSTART crSTART
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crSTART( pxCRCB ) switch( ( ( corCRCB * )pxCRCB )->uxState ) { case 0:
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* <pre>
|
||||
crEND();</pre>
|
||||
*
|
||||
* This macro MUST always be called at the end of a co-routine function.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Co-routine to be created.
|
||||
void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
|
||||
{
|
||||
// Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
static portLONG ulAVariable;
|
||||
|
||||
// Must start every co-routine with a call to crSTART();
|
||||
crSTART( xHandle );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
// Co-routine functionality goes here.
|
||||
}
|
||||
|
||||
// Must end every co-routine with a call to crEND();
|
||||
crEND();
|
||||
}</pre>
|
||||
* \defgroup crSTART crSTART
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crEND() }
|
||||
|
||||
/*
|
||||
* These macros are intended for internal use by the co-routine implementation
|
||||
* only. The macros should not be used directly by application writers.
|
||||
*/
|
||||
#define crSET_STATE0( xHandle ) ( ( corCRCB * )xHandle)->uxState = (__LINE__ * 2); return; case (__LINE__ * 2):
|
||||
#define crSET_STATE1( xHandle ) ( ( corCRCB * )xHandle)->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1):
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
*<pre>
|
||||
crDELAY( xCoRoutineHandle xHandle, portTickType xTicksToDelay );</pre>
|
||||
*
|
||||
* Delay a co-routine for a fixed period of time.
|
||||
*
|
||||
* crDELAY can only be called from the co-routine function itself - not
|
||||
* from within a function called by the co-routine function. This is because
|
||||
* co-routines do not maintain their own stack.
|
||||
*
|
||||
* @param xHandle The handle of the co-routine to delay. This is the xHandle
|
||||
* parameter of the co-routine function.
|
||||
*
|
||||
* @param xTickToDelay The number of ticks that the co-routine should delay
|
||||
* for. The actual amount of time this equates to is defined by
|
||||
* configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant portTICK_RATE_MS
|
||||
* can be used to convert ticks to milliseconds.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Co-routine to be created.
|
||||
void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
|
||||
{
|
||||
// Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
// This may not be necessary for const variables.
|
||||
// We are to delay for 200ms.
|
||||
static const xTickType xDelayTime = 200 / portTICK_RATE_MS;
|
||||
|
||||
// Must start every co-routine with a call to crSTART();
|
||||
crSTART( xHandle );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
// Delay for 200ms.
|
||||
crDELAY( xHandle, xDelayTime );
|
||||
|
||||
// Do something here.
|
||||
}
|
||||
|
||||
// Must end every co-routine with a call to crEND();
|
||||
crEND();
|
||||
}</pre>
|
||||
* \defgroup crDELAY crDELAY
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crDELAY( xHandle, xTicksToDelay ) \
|
||||
if( xTicksToDelay > 0 ) \
|
||||
{ \
|
||||
vCoRoutineAddToDelayedList( xTicksToDelay, NULL ); \
|
||||
} \
|
||||
crSET_STATE0( xHandle );
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
crQUEUE_SEND(
|
||||
xCoRoutineHandle xHandle,
|
||||
xQueueHandle pxQueue,
|
||||
void *pvItemToQueue,
|
||||
portTickType xTicksToWait,
|
||||
portBASE_TYPE *pxResult
|
||||
)</pre>
|
||||
*
|
||||
* The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine
|
||||
* equivalent to the xQueueSend() and xQueueReceive() functions used by tasks.
|
||||
*
|
||||
* crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas
|
||||
* xQueueSend() and xQueueReceive() can only be used from tasks.
|
||||
*
|
||||
* crQUEUE_SEND can only be called from the co-routine function itself - not
|
||||
* from within a function called by the co-routine function. This is because
|
||||
* co-routines do not maintain their own stack.
|
||||
*
|
||||
* See the co-routine section of the WEB documentation for information on
|
||||
* passing data between tasks and co-routines and between ISR's and
|
||||
* co-routines.
|
||||
*
|
||||
* @param xHandle The handle of the calling co-routine. This is the xHandle
|
||||
* parameter of the co-routine function.
|
||||
*
|
||||
* @param pxQueue The handle of the queue on which the data will be posted.
|
||||
* The handle is obtained as the return value when the queue is created using
|
||||
* the xQueueCreate() API function.
|
||||
*
|
||||
* @param pvItemToQueue A pointer to the data being posted onto the queue.
|
||||
* The number of bytes of each queued item is specified when the queue is
|
||||
* created. This number of bytes is copied from pvItemToQueue into the queue
|
||||
* itself.
|
||||
*
|
||||
* @param xTickToDelay The number of ticks that the co-routine should block
|
||||
* to wait for space to become available on the queue, should space not be
|
||||
* available immediately. The actual amount of time this equates to is defined
|
||||
* by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant
|
||||
* portTICK_RATE_MS can be used to convert ticks to milliseconds (see example
|
||||
* below).
|
||||
*
|
||||
* @param pxResult The variable pointed to by pxResult will be set to pdPASS if
|
||||
* data was successfully posted onto the queue, otherwise it will be set to an
|
||||
* error defined within ProjDefs.h.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Co-routine function that blocks for a fixed period then posts a number onto
|
||||
// a queue.
|
||||
static void prvCoRoutineFlashTask( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
|
||||
{
|
||||
// Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
static portBASE_TYPE xNumberToPost = 0;
|
||||
static portBASE_TYPE xResult;
|
||||
|
||||
// Co-routines must begin with a call to crSTART().
|
||||
crSTART( xHandle );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
// This assumes the queue has already been created.
|
||||
crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult );
|
||||
|
||||
if( xResult != pdPASS )
|
||||
{
|
||||
// The message was not posted!
|
||||
}
|
||||
|
||||
// Increment the number to be posted onto the queue.
|
||||
xNumberToPost++;
|
||||
|
||||
// Delay for 100 ticks.
|
||||
crDELAY( xHandle, 100 );
|
||||
}
|
||||
|
||||
// Co-routines must end with a call to crEND().
|
||||
crEND();
|
||||
}</pre>
|
||||
* \defgroup crQUEUE_SEND crQUEUE_SEND
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \
|
||||
{ \
|
||||
*pxResult = xQueueCRSend( pxQueue, pvItemToQueue, xTicksToWait ); \
|
||||
if( *pxResult == errQUEUE_BLOCKED ) \
|
||||
{ \
|
||||
crSET_STATE0( xHandle ); \
|
||||
*pxResult = xQueueCRSend( pxQueue, pvItemToQueue, 0 ); \
|
||||
} \
|
||||
if( *pxResult == errQUEUE_YIELD ) \
|
||||
{ \
|
||||
crSET_STATE1( xHandle ); \
|
||||
*pxResult = pdPASS; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* <pre>
|
||||
crQUEUE_RECEIVE(
|
||||
xCoRoutineHandle xHandle,
|
||||
xQueueHandle pxQueue,
|
||||
void *pvBuffer,
|
||||
portTickType xTicksToWait,
|
||||
portBASE_TYPE *pxResult
|
||||
)</pre>
|
||||
*
|
||||
* The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine
|
||||
* equivalent to the xQueueSend() and xQueueReceive() functions used by tasks.
|
||||
*
|
||||
* crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas
|
||||
* xQueueSend() and xQueueReceive() can only be used from tasks.
|
||||
*
|
||||
* crQUEUE_RECEIVE can only be called from the co-routine function itself - not
|
||||
* from within a function called by the co-routine function. This is because
|
||||
* co-routines do not maintain their own stack.
|
||||
*
|
||||
* See the co-routine section of the WEB documentation for information on
|
||||
* passing data between tasks and co-routines and between ISR's and
|
||||
* co-routines.
|
||||
*
|
||||
* @param xHandle The handle of the calling co-routine. This is the xHandle
|
||||
* parameter of the co-routine function.
|
||||
*
|
||||
* @param pxQueue The handle of the queue from which the data will be received.
|
||||
* The handle is obtained as the return value when the queue is created using
|
||||
* the xQueueCreate() API function.
|
||||
*
|
||||
* @param pvBuffer The buffer into which the received item is to be copied.
|
||||
* The number of bytes of each queued item is specified when the queue is
|
||||
* created. This number of bytes is copied into pvBuffer.
|
||||
*
|
||||
* @param xTickToDelay The number of ticks that the co-routine should block
|
||||
* to wait for data to become available from the queue, should data not be
|
||||
* available immediately. The actual amount of time this equates to is defined
|
||||
* by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant
|
||||
* portTICK_RATE_MS can be used to convert ticks to milliseconds (see the
|
||||
* crQUEUE_SEND example).
|
||||
*
|
||||
* @param pxResult The variable pointed to by pxResult will be set to pdPASS if
|
||||
* data was successfully retrieved from the queue, otherwise it will be set to
|
||||
* an error code as defined within ProjDefs.h.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// A co-routine receives the number of an LED to flash from a queue. It
|
||||
// blocks on the queue until the number is received.
|
||||
static void prvCoRoutineFlashWorkTask( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
|
||||
{
|
||||
// Variables in co-routines must be declared static if they must maintain value across a blocking call.
|
||||
static portBASE_TYPE xResult;
|
||||
static unsigned portBASE_TYPE uxLEDToFlash;
|
||||
|
||||
// All co-routines must start with a call to crSTART().
|
||||
crSTART( xHandle );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
// Wait for data to become available on the queue.
|
||||
crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
|
||||
|
||||
if( xResult == pdPASS )
|
||||
{
|
||||
// We received the LED to flash - flash it!
|
||||
vParTestToggleLED( uxLEDToFlash );
|
||||
}
|
||||
}
|
||||
|
||||
crEND();
|
||||
}</pre>
|
||||
* \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \
|
||||
{ \
|
||||
*pxResult = xQueueCRReceive( pxQueue, pvBuffer, xTicksToWait ); \
|
||||
if( *pxResult == errQUEUE_BLOCKED ) \
|
||||
{ \
|
||||
crSET_STATE0( xHandle ); \
|
||||
*pxResult = xQueueCRReceive( pxQueue, pvBuffer, 0 ); \
|
||||
} \
|
||||
if( *pxResult == errQUEUE_YIELD ) \
|
||||
{ \
|
||||
crSET_STATE1( xHandle ); \
|
||||
*pxResult = pdPASS; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* <pre>
|
||||
crQUEUE_SEND_FROM_ISR(
|
||||
xQueueHandle pxQueue,
|
||||
void *pvItemToQueue,
|
||||
portBASE_TYPE xCoRoutinePreviouslyWoken
|
||||
)</pre>
|
||||
*
|
||||
* The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the
|
||||
* co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR()
|
||||
* functions used by tasks.
|
||||
*
|
||||
* crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to
|
||||
* pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and
|
||||
* xQueueReceiveFromISR() can only be used to pass data between a task and and
|
||||
* ISR.
|
||||
*
|
||||
* crQUEUE_SEND_FROM_ISR can only be called from an ISR to send data to a queue
|
||||
* that is being used from within a co-routine.
|
||||
*
|
||||
* See the co-routine section of the WEB documentation for information on
|
||||
* passing data between tasks and co-routines and between ISR's and
|
||||
* co-routines.
|
||||
*
|
||||
* @param xQueue The handle to the queue on which the item is to be posted.
|
||||
*
|
||||
* @param pvItemToQueue A pointer to the item that is to be placed on the
|
||||
* queue. The size of the items the queue will hold was defined when the
|
||||
* queue was created, so this many bytes will be copied from pvItemToQueue
|
||||
* into the queue storage area.
|
||||
*
|
||||
* @param xCoRoutinePreviouslyWoken This is included so an ISR can post onto
|
||||
* the same queue multiple times from a single interrupt. The first call
|
||||
* should always pass in pdFALSE. Subsequent calls should pass in
|
||||
* the value returned from the previous call.
|
||||
*
|
||||
* @return pdTRUE if a co-routine was woken by posting onto the queue. This is
|
||||
* used by the ISR to determine if a context switch may be required following
|
||||
* the ISR.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// A co-routine that blocks on a queue waiting for characters to be received.
|
||||
static void vReceivingCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
|
||||
{
|
||||
portCHAR cRxedChar;
|
||||
portBASE_TYPE xResult;
|
||||
|
||||
// All co-routines must start with a call to crSTART().
|
||||
crSTART( xHandle );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
// Wait for data to become available on the queue. This assumes the
|
||||
// queue xCommsRxQueue has already been created!
|
||||
crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
|
||||
|
||||
// Was a character received?
|
||||
if( xResult == pdPASS )
|
||||
{
|
||||
// Process the character here.
|
||||
}
|
||||
}
|
||||
|
||||
// All co-routines must end with a call to crEND().
|
||||
crEND();
|
||||
}
|
||||
|
||||
// An ISR that uses a queue to send characters received on a serial port to
|
||||
// a co-routine.
|
||||
void vUART_ISR( void )
|
||||
{
|
||||
portCHAR cRxedChar;
|
||||
portBASE_TYPE xCRWokenByPost = pdFALSE;
|
||||
|
||||
// We loop around reading characters until there are none left in the UART.
|
||||
while( UART_RX_REG_NOT_EMPTY() )
|
||||
{
|
||||
// Obtain the character from the UART.
|
||||
cRxedChar = UART_RX_REG;
|
||||
|
||||
// Post the character onto a queue. xCRWokenByPost will be pdFALSE
|
||||
// the first time around the loop. If the post causes a co-routine
|
||||
// to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.
|
||||
// In this manner we can ensure that if more than one co-routine is
|
||||
// blocked on the queue only one is woken by this ISR no matter how
|
||||
// many characters are posted to the queue.
|
||||
xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost );
|
||||
}
|
||||
}</pre>
|
||||
* \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken )
|
||||
|
||||
|
||||
/**
|
||||
* croutine. h
|
||||
* <pre>
|
||||
crQUEUE_SEND_FROM_ISR(
|
||||
xQueueHandle pxQueue,
|
||||
void *pvBuffer,
|
||||
portBASE_TYPE * pxCoRoutineWoken
|
||||
)</pre>
|
||||
*
|
||||
* The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the
|
||||
* co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR()
|
||||
* functions used by tasks.
|
||||
*
|
||||
* crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to
|
||||
* pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and
|
||||
* xQueueReceiveFromISR() can only be used to pass data between a task and and
|
||||
* ISR.
|
||||
*
|
||||
* crQUEUE_RECEIVE_FROM_ISR can only be called from an ISR to receive data
|
||||
* from a queue that is being used from within a co-routine (a co-routine
|
||||
* posted to the queue).
|
||||
*
|
||||
* See the co-routine section of the WEB documentation for information on
|
||||
* passing data between tasks and co-routines and between ISR's and
|
||||
* co-routines.
|
||||
*
|
||||
* @param xQueue The handle to the queue on which the item is to be posted.
|
||||
*
|
||||
* @param pvBuffer A pointer to a buffer into which the received item will be
|
||||
* placed. The size of the items the queue will hold was defined when the
|
||||
* queue was created, so this many bytes will be copied from the queue into
|
||||
* pvBuffer.
|
||||
*
|
||||
* @param pxCoRoutineWoken A co-routine may be blocked waiting for space to become
|
||||
* available on the queue. If crQUEUE_RECEIVE_FROM_ISR causes such a
|
||||
* co-routine to unblock *pxCoRoutineWoken will get set to pdTRUE, otherwise
|
||||
* *pxCoRoutineWoken will remain unchanged.
|
||||
*
|
||||
* @return pdTRUE an item was successfully received from the queue, otherwise
|
||||
* pdFALSE.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// A co-routine that posts a character to a queue then blocks for a fixed
|
||||
// period. The character is incremented each time.
|
||||
static void vSendingCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
|
||||
{
|
||||
// cChar holds its value while this co-routine is blocked and must therefore
|
||||
// be declared static.
|
||||
static portCHAR cCharToTx = 'a';
|
||||
portBASE_TYPE xResult;
|
||||
|
||||
// All co-routines must start with a call to crSTART().
|
||||
crSTART( xHandle );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
// Send the next character to the queue.
|
||||
crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult );
|
||||
|
||||
if( xResult == pdPASS )
|
||||
{
|
||||
// The character was successfully posted to the queue.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Could not post the character to the queue.
|
||||
}
|
||||
|
||||
// Enable the UART Tx interrupt to cause an interrupt in this
|
||||
// hypothetical UART. The interrupt will obtain the character
|
||||
// from the queue and send it.
|
||||
ENABLE_RX_INTERRUPT();
|
||||
|
||||
// Increment to the next character then block for a fixed period.
|
||||
// cCharToTx will maintain its value across the delay as it is
|
||||
// declared static.
|
||||
cCharToTx++;
|
||||
if( cCharToTx > 'x' )
|
||||
{
|
||||
cCharToTx = 'a';
|
||||
}
|
||||
crDELAY( 100 );
|
||||
}
|
||||
|
||||
// All co-routines must end with a call to crEND().
|
||||
crEND();
|
||||
}
|
||||
|
||||
// An ISR that uses a queue to receive characters to send on a UART.
|
||||
void vUART_ISR( void )
|
||||
{
|
||||
portCHAR cCharToTx;
|
||||
portBASE_TYPE xCRWokenByPost = pdFALSE;
|
||||
|
||||
while( UART_TX_REG_EMPTY() )
|
||||
{
|
||||
// Are there any characters in the queue waiting to be sent?
|
||||
// xCRWokenByPost will automatically be set to pdTRUE if a co-routine
|
||||
// is woken by the post - ensuring that only a single co-routine is
|
||||
// woken no matter how many times we go around this loop.
|
||||
if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) )
|
||||
{
|
||||
SEND_CHARACTER( cCharToTx );
|
||||
}
|
||||
}
|
||||
}</pre>
|
||||
* \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( pxQueue, pvBuffer, pxCoRoutineWoken )
|
||||
|
||||
/*
|
||||
* This function is intended for internal use by the co-routine macros only.
|
||||
* The macro nature of the co-routine implementation requires that the
|
||||
* prototype appears here. The function should not be used by application
|
||||
* writers.
|
||||
*
|
||||
* Removes the current co-routine from its ready list and places it in the
|
||||
* appropriate delayed list.
|
||||
*/
|
||||
void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList );
|
||||
|
||||
/*
|
||||
* This function is intended for internal use by the queue implementation only.
|
||||
* The function should not be used by application writers.
|
||||
*
|
||||
* Removes the highest priority co-routine from the event list and places it in
|
||||
* the pending ready list.
|
||||
*/
|
||||
signed portBASE_TYPE xCoRoutineRemoveFromEventList( const xList *pxEventList );
|
||||
|
||||
|
||||
#endif /* CO_ROUTINE_H */
|
||||
|
|
@ -1,282 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is the list implementation used by the scheduler. While it is tailored
|
||||
* heavily for the schedulers needs, it is also available for use by
|
||||
* application code.
|
||||
*
|
||||
* xLists can only store pointers to xListItems. Each xListItem contains a
|
||||
* numeric value (xItemValue). Most of the time the lists are sorted in
|
||||
* descending item value order.
|
||||
*
|
||||
* Lists are created already containing one list item. The value of this
|
||||
* item is the maximum possible that can be stored, it is therefore always at
|
||||
* the end of the list and acts as a marker. The list member pxHead always
|
||||
* points to this marker - even though it is at the tail of the list. This
|
||||
* is because the tail contains a wrap back pointer to the true head of
|
||||
* the list.
|
||||
*
|
||||
* In addition to it's value, each list item contains a pointer to the next
|
||||
* item in the list (pxNext), a pointer to the list it is in (pxContainer)
|
||||
* and a pointer to back to the object that contains it. These later two
|
||||
* pointers are included for efficiency of list manipulation. There is
|
||||
* effectively a two way link between the object containing the list item and
|
||||
* the list item itself.
|
||||
*
|
||||
*
|
||||
* \page ListIntroduction List Implementation
|
||||
* \ingroup FreeRTOSIntro
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V4.3.1
|
||||
|
||||
+ Included local const within listGET_OWNER_OF_NEXT_ENTRY() to assist
|
||||
compiler with optimisation. Thanks B.R.
|
||||
*/
|
||||
|
||||
#ifndef LIST_H
|
||||
#define LIST_H
|
||||
|
||||
/*
|
||||
* Definition of the only type of object that a list can contain.
|
||||
*/
|
||||
struct xLIST_ITEM
|
||||
{
|
||||
portTickType xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */
|
||||
volatile struct xLIST_ITEM * pxNext; /*< Pointer to the next xListItem in the list. */
|
||||
volatile struct xLIST_ITEM * pxPrevious;/*< Pointer to the previous xListItem in the list. */
|
||||
void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */
|
||||
void * pvContainer; /*< Pointer to the list in which this list item is placed (if any). */
|
||||
};
|
||||
typedef struct xLIST_ITEM xListItem; /* For some reason lint wants this as two separate definitions. */
|
||||
|
||||
struct xMINI_LIST_ITEM
|
||||
{
|
||||
portTickType xItemValue;
|
||||
volatile struct xLIST_ITEM *pxNext;
|
||||
volatile struct xLIST_ITEM *pxPrevious;
|
||||
};
|
||||
typedef struct xMINI_LIST_ITEM xMiniListItem;
|
||||
|
||||
/*
|
||||
* Definition of the type of queue used by the scheduler.
|
||||
*/
|
||||
typedef struct xLIST
|
||||
{
|
||||
volatile unsigned portBASE_TYPE uxNumberOfItems;
|
||||
volatile xListItem * pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to pvListGetOwnerOfNextEntry (). */
|
||||
volatile xMiniListItem xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */
|
||||
} xList;
|
||||
|
||||
/*
|
||||
* Access macro to set the owner of a list item. The owner of a list item
|
||||
* is the object (usually a TCB) that contains the list item.
|
||||
*
|
||||
* \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( pxListItem )->pvOwner = ( void * ) pxOwner
|
||||
|
||||
/*
|
||||
* Access macro to set the value of the list item. In most cases the value is
|
||||
* used to sort the list in descending order.
|
||||
*
|
||||
* \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( pxListItem )->xItemValue = xValue
|
||||
|
||||
/*
|
||||
* Access macro the retrieve the value of the list item. The value can
|
||||
* represent anything - for example a the priority of a task, or the time at
|
||||
* which a task should be unblocked.
|
||||
*
|
||||
* \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue )
|
||||
|
||||
/*
|
||||
* Access macro to determine if a list contains any items. The macro will
|
||||
* only have the value true if the list is empty.
|
||||
*
|
||||
* \page listLIST_IS_EMPTY listLIST_IS_EMPTY
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listLIST_IS_EMPTY( pxList ) ( ( pxList )->uxNumberOfItems == ( unsigned portBASE_TYPE ) 0 )
|
||||
|
||||
/*
|
||||
* Access macro to return the number of items in the list.
|
||||
*/
|
||||
#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems )
|
||||
|
||||
/*
|
||||
* Access function to obtain the owner of the next entry in a list.
|
||||
*
|
||||
* The list member pxIndex is used to walk through a list. Calling
|
||||
* listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list
|
||||
* and returns that entries pxOwner parameter. Using multiple calls to this
|
||||
* function it is therefore possible to move through every item contained in
|
||||
* a list.
|
||||
*
|
||||
* The pxOwner parameter of a list item is a pointer to the object that owns
|
||||
* the list item. In the scheduler this is normally a task control block.
|
||||
* The pxOwner parameter effectively creates a two way link between the list
|
||||
* item and its owner.
|
||||
*
|
||||
* @param pxList The list from which the next item owner is to be returned.
|
||||
*
|
||||
* \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \
|
||||
{ \
|
||||
xList * const pxConstList = pxList; \
|
||||
/* Increment the index to the next item and return the item, ensuring */ \
|
||||
/* we don't return the marker used at the end of the list. */ \
|
||||
( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \
|
||||
if( ( pxConstList )->pxIndex == ( xListItem * ) &( ( pxConstList )->xListEnd ) ) \
|
||||
{ \
|
||||
( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \
|
||||
} \
|
||||
pxTCB = ( pxConstList )->pxIndex->pvOwner; \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Access function to obtain the owner of the first entry in a list. Lists
|
||||
* are normally sorted in ascending item value order.
|
||||
*
|
||||
* This function returns the pxOwner member of the first item in the list.
|
||||
* The pxOwner parameter of a list item is a pointer to the object that owns
|
||||
* the list item. In the scheduler this is normally a task control block.
|
||||
* The pxOwner parameter effectively creates a two way link between the list
|
||||
* item and its owner.
|
||||
*
|
||||
* @param pxList The list from which the owner of the head item is to be
|
||||
* returned.
|
||||
*
|
||||
* \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( ( pxList->uxNumberOfItems != ( unsigned portBASE_TYPE ) 0 ) ? ( (&( pxList->xListEnd ))->pxNext->pvOwner ) : ( NULL ) )
|
||||
|
||||
/*
|
||||
* Check to see if a list item is within a list. The list item maintains a
|
||||
* "container" pointer that points to the list it is in. All this macro does
|
||||
* is check to see if the container and the list match.
|
||||
*
|
||||
* @param pxList The list we want to know if the list item is within.
|
||||
* @param pxListItem The list item we want to know if is in the list.
|
||||
* @return pdTRUE is the list item is in the list, otherwise pdFALSE.
|
||||
* pointer against
|
||||
*/
|
||||
#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( pxListItem )->pvContainer == ( void * ) pxList )
|
||||
|
||||
/*
|
||||
* Must be called before a list is used! This initialises all the members
|
||||
* of the list structure and inserts the xListEnd item into the list as a
|
||||
* marker to the back of the list.
|
||||
*
|
||||
* @param pxList Pointer to the list being initialised.
|
||||
*
|
||||
* \page vListInitialise vListInitialise
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
void vListInitialise( xList *pxList );
|
||||
|
||||
/*
|
||||
* Must be called before a list item is used. This sets the list container to
|
||||
* null so the item does not think that it is already contained in a list.
|
||||
*
|
||||
* @param pxItem Pointer to the list item being initialised.
|
||||
*
|
||||
* \page vListInitialiseItem vListInitialiseItem
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
void vListInitialiseItem( xListItem *pxItem );
|
||||
|
||||
/*
|
||||
* Insert a list item into a list. The item will be inserted into the list in
|
||||
* a position determined by its item value (descending item value order).
|
||||
*
|
||||
* @param pxList The list into which the item is to be inserted.
|
||||
*
|
||||
* @param pxNewListItem The item to that is to be placed in the list.
|
||||
*
|
||||
* \page vListInsert vListInsert
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
void vListInsert( xList *pxList, xListItem *pxNewListItem );
|
||||
|
||||
/*
|
||||
* Insert a list item into a list. The item will be inserted in a position
|
||||
* such that it will be the last item within the list returned by multiple
|
||||
* calls to listGET_OWNER_OF_NEXT_ENTRY.
|
||||
*
|
||||
* The list member pvIndex is used to walk through a list. Calling
|
||||
* listGET_OWNER_OF_NEXT_ENTRY increments pvIndex to the next item in the list.
|
||||
* Placing an item in a list using vListInsertEnd effectively places the item
|
||||
* in the list position pointed to by pvIndex. This means that every other
|
||||
* item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before
|
||||
* the pvIndex parameter again points to the item being inserted.
|
||||
*
|
||||
* @param pxList The list into which the item is to be inserted.
|
||||
*
|
||||
* @param pxNewListItem The list item to be inserted into the list.
|
||||
*
|
||||
* \page vListInsertEnd vListInsertEnd
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
void vListInsertEnd( xList *pxList, xListItem *pxNewListItem );
|
||||
|
||||
/*
|
||||
* Remove an item from a list. The list item has a pointer to the list that
|
||||
* it is in, so only the list item need be passed into the function.
|
||||
*
|
||||
* @param vListRemove The item to be removed. The item will remove itself from
|
||||
* the list pointed to by it's pxContainer parameter.
|
||||
*
|
||||
* \page vListRemove vListRemove
|
||||
* \ingroup LinkedList
|
||||
*/
|
||||
void vListRemove( xListItem *pxItemToRemove );
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http:www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http:www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Portable layer API. Each function must be defined for each port.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#ifndef PORTABLE_H
|
||||
#define PORTABLE_H
|
||||
|
||||
/* Include the macro file relevant to the port being used. */
|
||||
|
||||
#ifdef SAM7_GCC
|
||||
#include "FreeRTOS/portable/GCC/ARM7_AT91SAM7S/portmacro.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Setup the stack of a new task so it is ready to be placed under the
|
||||
* scheduler control. The registers have to be placed on the stack in
|
||||
* the order that the port expects to find them.
|
||||
*/
|
||||
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters );
|
||||
|
||||
/*
|
||||
* Map to the memory management routines required for the port.
|
||||
*/
|
||||
void *pvPortMalloc( size_t xSize );
|
||||
void vPortFree( void *pv );
|
||||
void vPortInitialiseBlocks( void );
|
||||
|
||||
/*
|
||||
* Setup the hardware ready for the scheduler to take control. This generally
|
||||
* sets up a tick interrupt and sets timers for the correct tick frequency.
|
||||
*/
|
||||
portBASE_TYPE xPortStartScheduler( void );
|
||||
|
||||
/*
|
||||
* Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
|
||||
* the hardware is left in its original condition after the scheduler stops
|
||||
* executing.
|
||||
*/
|
||||
void vPortEndScheduler( void );
|
||||
|
||||
#endif /* PORTABLE_H */
|
||||
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef PROJDEFS_H
|
||||
#define PROJDEFS_H
|
||||
|
||||
/* Defines to prototype to which task functions must conform. */
|
||||
typedef void (*pdTASK_CODE)( void * );
|
||||
|
||||
#define pdTRUE ( 1 )
|
||||
#define pdFALSE ( 0 )
|
||||
|
||||
#define pdPASS ( 1 )
|
||||
#define pdFAIL ( 0 )
|
||||
#define errQUEUE_EMPTY ( 0 )
|
||||
#define errQUEUE_FULL ( 0 )
|
||||
|
||||
/* Error definitions. */
|
||||
#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 )
|
||||
#define errNO_TASK_TO_RUN ( -2 )
|
||||
#define errQUEUE_BLOCKED ( -4 )
|
||||
#define errQUEUE_YIELD ( -5 )
|
||||
|
||||
#endif /* PROJDEFS_H */
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,474 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef QUEUE_H
|
||||
#define QUEUE_H
|
||||
|
||||
typedef void * xQueueHandle;
|
||||
|
||||
/**
|
||||
* queue. h
|
||||
* <pre>
|
||||
xQueueHandle xQueueCreate(
|
||||
unsigned portBASE_TYPE uxQueueLength,
|
||||
unsigned portBASE_TYPE uxItemSize
|
||||
);
|
||||
* </pre>
|
||||
*
|
||||
* Creates a new queue instance. This allocates the storage required by the
|
||||
* new queue and returns a handle for the queue.
|
||||
*
|
||||
* @param uxQueueLength The maximum number of items that the queue can contain.
|
||||
*
|
||||
* @param uxItemSize The number of bytes each item in the queue will require.
|
||||
* Items are queued by copy, not by reference, so this is the number of bytes
|
||||
* that will be copied for each posted item. Each item on the queue must be
|
||||
* the same size.
|
||||
*
|
||||
* @return If the queue is successfully create then a handle to the newly
|
||||
* created queue is returned. If the queue cannot be created then 0 is
|
||||
* returned.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
struct AMessage
|
||||
{
|
||||
portCHAR ucMessageID;
|
||||
portCHAR ucData[ 20 ];
|
||||
};
|
||||
|
||||
void vATask( void *pvParameters )
|
||||
{
|
||||
xQueueHandle xQueue1, xQueue2;
|
||||
|
||||
// Create a queue capable of containing 10 unsigned long values.
|
||||
xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );
|
||||
if( xQueue1 == 0 )
|
||||
{
|
||||
// Queue was not created and must not be used.
|
||||
}
|
||||
|
||||
// Create a queue capable of containing 10 pointers to AMessage structures.
|
||||
// These should be passed by pointer as they contain a lot of data.
|
||||
xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
|
||||
if( xQueue2 == 0 )
|
||||
{
|
||||
// Queue was not created and must not be used.
|
||||
}
|
||||
|
||||
// ... Rest of task code.
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xQueueCreate xQueueCreate
|
||||
* \ingroup QueueManagement
|
||||
*/
|
||||
xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize );
|
||||
|
||||
/**
|
||||
* queue. h
|
||||
* <pre>
|
||||
portBASE_TYPE xQueueSend(
|
||||
xQueueHandle xQueue,
|
||||
const void * pvItemToQueue,
|
||||
portTickType xTicksToWait
|
||||
);
|
||||
* </pre>
|
||||
*
|
||||
* Post an item on a queue. The item is queued by copy, not by reference.
|
||||
* This function must not be called from an interrupt service routine.
|
||||
* See xQueueSendFromISR () for an alternative which may be used in an ISR.
|
||||
*
|
||||
* @param xQueue The handle to the queue on which the item is to be posted.
|
||||
*
|
||||
* @param pvItemToQueue A pointer to the item that is to be placed on the
|
||||
* queue. The size of the items the queue will hold was defined when the
|
||||
* queue was created, so this many bytes will be copied from pvItemToQueue
|
||||
* into the queue storage area.
|
||||
*
|
||||
* @param xTicksToWait The maximum amount of time the task should block
|
||||
* waiting for space to become available on the queue, should it already
|
||||
* be full. The call will return immediately if this is set to 0. The
|
||||
* time is defined in tick periods so the constant portTICK_RATE_MS
|
||||
* should be used to convert to real time if this is required.
|
||||
*
|
||||
* @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
struct AMessage
|
||||
{
|
||||
portCHAR ucMessageID;
|
||||
portCHAR ucData[ 20 ];
|
||||
} xMessage;
|
||||
|
||||
unsigned portLONG ulVar = 10UL;
|
||||
|
||||
void vATask( void *pvParameters )
|
||||
{
|
||||
xQueueHandle xQueue1, xQueue2;
|
||||
struct AMessage *pxMessage;
|
||||
|
||||
// Create a queue capable of containing 10 unsigned long values.
|
||||
xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );
|
||||
|
||||
// Create a queue capable of containing 10 pointers to AMessage structures.
|
||||
// These should be passed by pointer as they contain a lot of data.
|
||||
xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
|
||||
|
||||
// ...
|
||||
|
||||
if( xQueue1 != 0 )
|
||||
{
|
||||
// Send an unsigned long. Wait for 10 ticks for space to become
|
||||
// available if necessary.
|
||||
if( xQueueSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
|
||||
{
|
||||
// Failed to post the message, even after 10 ticks.
|
||||
}
|
||||
}
|
||||
|
||||
if( xQueue2 != 0 )
|
||||
{
|
||||
// Send a pointer to a struct AMessage object. Don't block if the
|
||||
// queue is already full.
|
||||
pxMessage = & xMessage;
|
||||
xQueueSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
|
||||
}
|
||||
|
||||
// ... Rest of task code.
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xQueueSend xQueueSend
|
||||
* \ingroup QueueManagement
|
||||
*/
|
||||
signed portBASE_TYPE xQueueSend( xQueueHandle xQueue, const void * pvItemToQueue, portTickType xTicksToWait );
|
||||
|
||||
/**
|
||||
* queue. h
|
||||
* <pre>
|
||||
portBASE_TYPE xQueueReceive(
|
||||
xQueueHandle xQueue,
|
||||
void *pvBuffer,
|
||||
portTickType xTicksToWait
|
||||
);</pre>
|
||||
*
|
||||
* Receive an item from a queue. The item is received by copy so a buffer of
|
||||
* adequate size must be provided. The number of bytes copied into the buffer
|
||||
* was defined when the queue was created.
|
||||
*
|
||||
* This function must not be used in an interrupt service routine. See
|
||||
* xQueueReceiveFromISR for an alternative that can.
|
||||
*
|
||||
* @param pxQueue The handle to the queue from which the item is to be
|
||||
* received.
|
||||
*
|
||||
* @param pvBuffer Pointer to the buffer into which the received item will
|
||||
* be copied.
|
||||
*
|
||||
* @param xTicksToWait The maximum amount of time the task should block
|
||||
* waiting for an item to receive should the queue be empty at the time
|
||||
* of the call. The time is defined in tick periods so the constant
|
||||
* portTICK_RATE_MS should be used to convert to real time if this is required.
|
||||
*
|
||||
* @return pdTRUE if an item was successfully received from the queue,
|
||||
* otherwise pdFALSE.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
struct AMessage
|
||||
{
|
||||
portCHAR ucMessageID;
|
||||
portCHAR ucData[ 20 ];
|
||||
} xMessage;
|
||||
|
||||
xQueueHandle xQueue;
|
||||
|
||||
// Task to create a queue and post a value.
|
||||
void vATask( void *pvParameters )
|
||||
{
|
||||
struct AMessage *pxMessage;
|
||||
|
||||
// Create a queue capable of containing 10 pointers to AMessage structures.
|
||||
// These should be passed by pointer as they contain a lot of data.
|
||||
xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
|
||||
if( xQueue == 0 )
|
||||
{
|
||||
// Failed to create the queue.
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
// Send a pointer to a struct AMessage object. Don't block if the
|
||||
// queue is already full.
|
||||
pxMessage = & xMessage;
|
||||
xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
|
||||
|
||||
// ... Rest of task code.
|
||||
}
|
||||
|
||||
// Task to receive from the queue.
|
||||
void vADifferentTask( void *pvParameters )
|
||||
{
|
||||
struct AMessage *pxRxedMessage;
|
||||
|
||||
if( xQueue != 0 )
|
||||
{
|
||||
// Receive a message on the created queue. Block for 10 ticks if a
|
||||
// message is not immediately available.
|
||||
if( xQueueReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
|
||||
{
|
||||
// pcRxedMessage now points to the struct AMessage variable posted
|
||||
// by vATask.
|
||||
}
|
||||
}
|
||||
|
||||
// ... Rest of task code.
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xQueueReceive xQueueReceive
|
||||
* \ingroup QueueManagement
|
||||
*/
|
||||
signed portBASE_TYPE xQueueReceive( xQueueHandle xQueue, void *pvBuffer, portTickType xTicksToWait );
|
||||
|
||||
/**
|
||||
* queue. h
|
||||
* <pre>unsigned portBASE_TYPE uxQueueMessagesWaiting( xQueueHandle xQueue );</pre>
|
||||
*
|
||||
* Return the number of messages stored in a queue.
|
||||
*
|
||||
* @param xQueue A handle to the queue being queried.
|
||||
*
|
||||
* @return The number of messages available in the queue.
|
||||
*
|
||||
* \page uxQueueMessagesWaiting uxQueueMessagesWaiting
|
||||
* \ingroup QueueManagement
|
||||
*/
|
||||
unsigned portBASE_TYPE uxQueueMessagesWaiting( xQueueHandle xQueue );
|
||||
|
||||
/**
|
||||
* queue. h
|
||||
* <pre>void vQueueDelete( xQueueHandle xQueue );</pre>
|
||||
*
|
||||
* Delete a queue - freeing all the memory allocated for storing of items
|
||||
* placed on the queue.
|
||||
*
|
||||
* @param xQueue A handle to the queue to be deleted.
|
||||
*
|
||||
* \page vQueueDelete vQueueDelete
|
||||
* \ingroup QueueManagement
|
||||
*/
|
||||
void vQueueDelete( xQueueHandle xQueue );
|
||||
|
||||
/**
|
||||
* queue. h
|
||||
* <pre>
|
||||
portBASE_TYPE xQueueSendFromISR(
|
||||
xQueueHandle pxQueue,
|
||||
const void *pvItemToQueue,
|
||||
portBASE_TYPE xTaskPreviouslyWoken
|
||||
);
|
||||
</pre>
|
||||
*
|
||||
* Post an item on a queue. It is safe to use this function from within an
|
||||
* interrupt service routine.
|
||||
*
|
||||
* Items are queued by copy not reference so it is preferable to only
|
||||
* queue small items, especially when called from an ISR. In most cases
|
||||
* it would be preferable to store a pointer to the item being queued.
|
||||
*
|
||||
* @param xQueue The handle to the queue on which the item is to be posted.
|
||||
*
|
||||
* @param pvItemToQueue A pointer to the item that is to be placed on the
|
||||
* queue. The size of the items the queue will hold was defined when the
|
||||
* queue was created, so this many bytes will be copied from pvItemToQueue
|
||||
* into the queue storage area.
|
||||
*
|
||||
* @param cTaskPreviouslyWoken This is included so an ISR can post onto
|
||||
* the same queue multiple times from a single interrupt. The first call
|
||||
* should always pass in pdFALSE. Subsequent calls should pass in
|
||||
* the value returned from the previous call. See the file serial .c in the
|
||||
* PC port for a good example of this mechanism.
|
||||
*
|
||||
* @return pdTRUE if a task was woken by posting onto the queue. This is
|
||||
* used by the ISR to determine if a context switch may be required following
|
||||
* the ISR.
|
||||
*
|
||||
* Example usage for buffered IO (where the ISR can obtain more than one value
|
||||
* per call):
|
||||
<pre>
|
||||
void vBufferISR( void )
|
||||
{
|
||||
portCHAR cIn;
|
||||
portBASE_TYPE xTaskWokenByPost;
|
||||
|
||||
// We have not woken a task at the start of the ISR.
|
||||
cTaskWokenByPost = pdFALSE;
|
||||
|
||||
// Loop until the buffer is empty.
|
||||
do
|
||||
{
|
||||
// Obtain a byte from the buffer.
|
||||
cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
|
||||
|
||||
// Post the byte. The first time round the loop cTaskWokenByPost
|
||||
// will be pdFALSE. If the queue send causes a task to wake we do
|
||||
// not want the task to run until we have finished the ISR, so
|
||||
// xQueueSendFromISR does not cause a context switch. Also we
|
||||
// don't want subsequent posts to wake any other tasks, so we store
|
||||
// the return value back into cTaskWokenByPost so xQueueSendFromISR
|
||||
// knows not to wake any task the next iteration of the loop.
|
||||
xTaskWokenByPost = xQueueSendFromISR( xRxQueue, &cIn, cTaskWokenByPost );
|
||||
|
||||
} while( portINPUT_BYTE( BUFFER_COUNT ) );
|
||||
|
||||
// Now the buffer is empty we can switch context if necessary.
|
||||
if( cTaskWokenByPost )
|
||||
{
|
||||
taskYIELD ();
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
*
|
||||
* \defgroup xQueueSendFromISR xQueueSendFromISR
|
||||
* \ingroup QueueManagement
|
||||
*/
|
||||
signed portBASE_TYPE xQueueSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xTaskPreviouslyWoken );
|
||||
|
||||
/**
|
||||
* queue. h
|
||||
* <pre>
|
||||
portBASE_TYPE xQueueReceiveFromISR(
|
||||
xQueueHandle pxQueue,
|
||||
void *pvBuffer,
|
||||
portBASE_TYPE *pxTaskWoken
|
||||
);
|
||||
* </pre>
|
||||
*
|
||||
* Receive an item from a queue. It is safe to use this function from within an
|
||||
* interrupt service routine.
|
||||
*
|
||||
* @param pxQueue The handle to the queue from which the item is to be
|
||||
* received.
|
||||
*
|
||||
* @param pvBuffer Pointer to the buffer into which the received item will
|
||||
* be copied.
|
||||
*
|
||||
* @param pxTaskWoken A task may be blocked waiting for space to become
|
||||
* available on the queue. If xQueueReceiveFromISR causes such a task to
|
||||
* unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will
|
||||
* remain unchanged.
|
||||
*
|
||||
* @return pdTRUE if an item was successfully received from the queue,
|
||||
* otherwise pdFALSE.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
|
||||
xQueueHandle xQueue;
|
||||
|
||||
// Function to create a queue and post some values.
|
||||
void vAFunction( void *pvParameters )
|
||||
{
|
||||
portCHAR cValueToPost;
|
||||
const portTickType xBlockTime = ( portTickType )0xff;
|
||||
|
||||
// Create a queue capable of containing 10 characters.
|
||||
xQueue = xQueueCreate( 10, sizeof( portCHAR ) );
|
||||
if( xQueue == 0 )
|
||||
{
|
||||
// Failed to create the queue.
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
// Post some characters that will be used within an ISR. If the queue
|
||||
// is full then this task will block for xBlockTime ticks.
|
||||
cValueToPost = 'a';
|
||||
xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
|
||||
cValueToPost = 'b';
|
||||
xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
|
||||
|
||||
// ... keep posting characters ... this task may block when the queue
|
||||
// becomes full.
|
||||
|
||||
cValueToPost = 'c';
|
||||
xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
|
||||
}
|
||||
|
||||
// ISR that outputs all the characters received on the queue.
|
||||
void vISR_Routine( void )
|
||||
{
|
||||
portBASE_TYPE xTaskWokenByReceive = pdFALSE;
|
||||
portCHAR cRxedChar;
|
||||
|
||||
while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
|
||||
{
|
||||
// A character was received. Output the character now.
|
||||
vOutputCharacter( cRxedChar );
|
||||
|
||||
// If removing the character from the queue woke the task that was
|
||||
// posting onto the queue cTaskWokenByReceive will have been set to
|
||||
// pdTRUE. No matter how many times this loop iterates only one
|
||||
// task will be woken.
|
||||
}
|
||||
|
||||
if( cTaskWokenByPost != ( portCHAR ) pdFALSE;
|
||||
{
|
||||
taskYIELD ();
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xQueueReceiveFromISR xQueueReceiveFromISR
|
||||
* \ingroup QueueManagement
|
||||
*/
|
||||
signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken );
|
||||
|
||||
|
||||
/*
|
||||
* The functions defined above are for passing data to and from tasks. The
|
||||
* functions below are the equivalents for passing data to and from
|
||||
* co-rtoutines.
|
||||
*
|
||||
* These functions are called from the co-routine macro implementation and
|
||||
* should not be called directly from application code. Instead use the macro
|
||||
* wrappers defined within croutine.h.
|
||||
*/
|
||||
signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken );
|
||||
signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken );
|
||||
signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait );
|
||||
signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait );
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,292 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
#include "queue.h"
|
||||
|
||||
#ifndef SEMAPHORE_H
|
||||
#define SEMAPHORE_H
|
||||
|
||||
typedef xQueueHandle xSemaphoreHandle;
|
||||
|
||||
#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( unsigned portCHAR ) 1 )
|
||||
#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned portCHAR ) 0 )
|
||||
#define semGIVE_BLOCK_TIME ( ( portTickType ) 0 )
|
||||
|
||||
|
||||
/**
|
||||
* semphr. h
|
||||
* <pre>vSemaphoreCreateBinary( xSemaphoreHandle xSemaphore )</pre>
|
||||
*
|
||||
* <i>Macro</i> that implements a semaphore by using the existing queue mechanism.
|
||||
* The queue length is 1 as this is a binary semaphore. The data size is 0
|
||||
* as we don't want to actually store any data - we just want to know if the
|
||||
* queue is empty or full.
|
||||
*
|
||||
* @param xSemaphore Handle to the created semaphore. Should be of type xSemaphoreHandle.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
xSemaphoreHandle xSemaphore;
|
||||
|
||||
void vATask( void * pvParameters )
|
||||
{
|
||||
// Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
|
||||
// This is a macro so pass the variable in directly.
|
||||
vSemaphoreCreateBinary( xSemaphore );
|
||||
|
||||
if( xSemaphore != NULL )
|
||||
{
|
||||
// The semaphore was created successfully.
|
||||
// The semaphore can now be used.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary
|
||||
* \ingroup Semaphores
|
||||
*/
|
||||
#define vSemaphoreCreateBinary( xSemaphore ) { \
|
||||
xSemaphore = xQueueCreate( ( unsigned portCHAR ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH ); \
|
||||
if( xSemaphore != NULL ) \
|
||||
{ \
|
||||
xSemaphoreGive( xSemaphore ); \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* semphr. h
|
||||
* xSemaphoreTake(
|
||||
* xSemaphoreHandle xSemaphore,
|
||||
* portTickType xBlockTime
|
||||
* )</pre>
|
||||
*
|
||||
* <i>Macro</i> to obtain a semaphore. The semaphore must of been created using
|
||||
* vSemaphoreCreateBinary ().
|
||||
*
|
||||
* @param xSemaphore A handle to the semaphore being obtained. This is the
|
||||
* handle returned by vSemaphoreCreateBinary ();
|
||||
*
|
||||
* @param xBlockTime The time in ticks to wait for the semaphore to become
|
||||
* available. The macro portTICK_RATE_MS can be used to convert this to a
|
||||
* real time. A block time of zero can be used to poll the semaphore.
|
||||
*
|
||||
* @return pdTRUE if the semaphore was obtained. pdFALSE if xBlockTime
|
||||
* expired without the semaphore becoming available.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
xSemaphoreHandle xSemaphore = NULL;
|
||||
|
||||
// A task that creates a semaphore.
|
||||
void vATask( void * pvParameters )
|
||||
{
|
||||
// Create the semaphore to guard a shared resource.
|
||||
vSemaphoreCreateBinary( xSemaphore );
|
||||
}
|
||||
|
||||
// A task that uses the semaphore.
|
||||
void vAnotherTask( void * pvParameters )
|
||||
{
|
||||
// ... Do other things.
|
||||
|
||||
if( xSemaphore != NULL )
|
||||
{
|
||||
// See if we can obtain the semaphore. If the semaphore is not available
|
||||
// wait 10 ticks to see if it becomes free.
|
||||
if( xSemaphoreTake( xSemaphore, ( portTickType ) 10 ) == pdTRUE )
|
||||
{
|
||||
// We were able to obtain the semaphore and can now access the
|
||||
// shared resource.
|
||||
|
||||
// ...
|
||||
|
||||
// We have finished accessing the shared resource. Release the
|
||||
// semaphore.
|
||||
xSemaphoreGive( xSemaphore );
|
||||
}
|
||||
else
|
||||
{
|
||||
// We could not obtain the semaphore and can therefore not access
|
||||
// the shared resource safely.
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xSemaphoreTake xSemaphoreTake
|
||||
* \ingroup Semaphores
|
||||
*/
|
||||
#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueReceive( ( xQueueHandle ) xSemaphore, NULL, xBlockTime )
|
||||
|
||||
/**
|
||||
* semphr. h
|
||||
* <pre>xSemaphoreGive( xSemaphoreHandle xSemaphore )</pre>
|
||||
*
|
||||
* <i>Macro</i> to release a semaphore. The semaphore must of been created using
|
||||
* vSemaphoreCreateBinary (), and obtained using sSemaphoreTake ().
|
||||
*
|
||||
* This must not be used from an ISR. See xSemaphoreGiveFromISR () for
|
||||
* an alternative which can be used from an ISR.
|
||||
*
|
||||
* @param xSemaphore A handle to the semaphore being released. This is the
|
||||
* handle returned by vSemaphoreCreateBinary ();
|
||||
*
|
||||
* @return pdTRUE if the semaphore was released. pdFALSE if an error occurred.
|
||||
* Semaphores are implemented using queues. An error can occur if there is
|
||||
* no space on the queue to post a message - indicating that the
|
||||
* semaphore was not first obtained correctly.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
xSemaphoreHandle xSemaphore = NULL;
|
||||
|
||||
void vATask( void * pvParameters )
|
||||
{
|
||||
// Create the semaphore to guard a shared resource.
|
||||
vSemaphoreCreateBinary( xSemaphore );
|
||||
|
||||
if( xSemaphore != NULL )
|
||||
{
|
||||
if( xSemaphoreGive( xSemaphore ) != pdTRUE )
|
||||
{
|
||||
// We would expect this call to fail because we cannot give
|
||||
// a semaphore without first "taking" it!
|
||||
}
|
||||
|
||||
// Obtain the semaphore - don't block if the semaphore is not
|
||||
// immediately available.
|
||||
if( xSemaphoreTake( xSemaphore, ( portTickType ) 0 ) )
|
||||
{
|
||||
// We now have the semaphore and can access the shared resource.
|
||||
|
||||
// ...
|
||||
|
||||
// We have finished accessing the shared resource so can free the
|
||||
// semaphore.
|
||||
if( xSemaphoreGive( xSemaphore ) != pdTRUE )
|
||||
{
|
||||
// We would not expect this call to fail because we must have
|
||||
// obtained the semaphore to get here.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xSemaphoreGive xSemaphoreGive
|
||||
* \ingroup Semaphores
|
||||
*/
|
||||
#define xSemaphoreGive( xSemaphore ) xQueueSend( ( xQueueHandle ) xSemaphore, NULL, semGIVE_BLOCK_TIME )
|
||||
|
||||
/**
|
||||
* semphr. h
|
||||
* <pre>
|
||||
xSemaphoreGiveFromISR(
|
||||
xSemaphoreHandle xSemaphore,
|
||||
portSHORT sTaskPreviouslyWoken
|
||||
)</pre>
|
||||
*
|
||||
* <i>Macro</i> to release a semaphore. The semaphore must of been created using
|
||||
* vSemaphoreCreateBinary (), and obtained using xSemaphoreTake ().
|
||||
*
|
||||
* This macro can be used from an ISR.
|
||||
*
|
||||
* @param xSemaphore A handle to the semaphore being released. This is the
|
||||
* handle returned by vSemaphoreCreateBinary ();
|
||||
*
|
||||
* @param sTaskPreviouslyWoken This is included so an ISR can make multiple calls
|
||||
* to xSemaphoreGiveFromISR () from a single interrupt. The first call
|
||||
* should always pass in pdFALSE. Subsequent calls should pass in
|
||||
* the value returned from the previous call. See the file serial .c in the
|
||||
* PC port for a good example of using xSemaphoreGiveFromISR ().
|
||||
*
|
||||
* @return pdTRUE if a task was woken by releasing the semaphore. This is
|
||||
* used by the ISR to determine if a context switch may be required following
|
||||
* the ISR.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
#define LONG_TIME 0xffff
|
||||
#define TICKS_TO_WAIT 10
|
||||
xSemaphoreHandle xSemaphore = NULL;
|
||||
|
||||
// Repetitive task.
|
||||
void vATask( void * pvParameters )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
// We want this task to run every 10 ticks or a timer. The semaphore
|
||||
// was created before this task was started
|
||||
|
||||
// Block waiting for the semaphore to become available.
|
||||
if( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE )
|
||||
{
|
||||
// It is time to execute.
|
||||
|
||||
// ...
|
||||
|
||||
// We have finished our task. Return to the top of the loop where
|
||||
// we will block on the semaphore until it is time to execute
|
||||
// again.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Timer ISR
|
||||
void vTimerISR( void * pvParameters )
|
||||
{
|
||||
static unsigned portCHAR ucLocalTickCount = 0;
|
||||
|
||||
// A timer tick has occurred.
|
||||
|
||||
// ... Do other time functions.
|
||||
|
||||
// Is it time for vATask () to run?
|
||||
ucLocalTickCount++;
|
||||
if( ucLocalTickCount >= TICKS_TO_WAIT )
|
||||
{
|
||||
// Unblock the task by releasing the semaphore.
|
||||
xSemaphoreGive( xSemaphore );
|
||||
|
||||
// Reset the count so we release the semaphore again in 10 ticks time.
|
||||
ucLocalTickCount = 0;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR
|
||||
* \ingroup Semaphores
|
||||
*/
|
||||
#define xSemaphoreGiveFromISR( xSemaphore, xTaskPreviouslyWoken ) xQueueSendFromISR( ( xQueueHandle ) xSemaphore, NULL, xTaskPreviouslyWoken )
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,970 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes since V4.3.1:
|
||||
|
||||
+ Added xTaskGetSchedulerState() function.
|
||||
*/
|
||||
|
||||
#ifndef TASK_H
|
||||
#define TASK_H
|
||||
|
||||
#include "portable.h"
|
||||
#include "list.h"
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* MACROS AND DEFINITIONS
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define tskKERNEL_VERSION_NUMBER "V4.4.0"
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*
|
||||
* Type by which tasks are referenced. For example, a call to xTaskCreate
|
||||
* returns (via a pointer parameter) an xTaskHandle variable that can then
|
||||
* be used as a parameter to vTaskDelete to delete the task.
|
||||
*
|
||||
* \page xTaskHandle xTaskHandle
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
typedef void * xTaskHandle;
|
||||
|
||||
/*
|
||||
* Used internally only.
|
||||
*/
|
||||
typedef struct xTIME_OUT
|
||||
{
|
||||
portBASE_TYPE xOverflowCount;
|
||||
portTickType xTimeOnEntering;
|
||||
} xTimeOutType;
|
||||
|
||||
/*
|
||||
* Defines the priority used by the idle task. This must not be modified.
|
||||
*
|
||||
* \ingroup TaskUtils
|
||||
*/
|
||||
#define tskIDLE_PRIORITY ( ( unsigned portBASE_TYPE ) 0 )
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*
|
||||
* Macro for forcing a context switch.
|
||||
*
|
||||
* \page taskYIELD taskYIELD
|
||||
* \ingroup SchedulerControl
|
||||
*/
|
||||
#define taskYIELD() portYIELD()
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*
|
||||
* Macro to mark the start of a critical code region. Preemptive context
|
||||
* switches cannot occur when in a critical region.
|
||||
*
|
||||
* NOTE: This may alter the stack (depending on the portable implementation)
|
||||
* so must be used with care!
|
||||
*
|
||||
* \page taskENTER_CRITICAL taskENTER_CRITICAL
|
||||
* \ingroup SchedulerControl
|
||||
*/
|
||||
#define taskENTER_CRITICAL() portENTER_CRITICAL()
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*
|
||||
* Macro to mark the end of a critical code region. Preemptive context
|
||||
* switches cannot occur when in a critical region.
|
||||
*
|
||||
* NOTE: This may alter the stack (depending on the portable implementation)
|
||||
* so must be used with care!
|
||||
*
|
||||
* \page taskEXIT_CRITICAL taskEXIT_CRITICAL
|
||||
* \ingroup SchedulerControl
|
||||
*/
|
||||
#define taskEXIT_CRITICAL() portEXIT_CRITICAL()
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*
|
||||
* Macro to disable all maskable interrupts.
|
||||
*
|
||||
* \page taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
|
||||
* \ingroup SchedulerControl
|
||||
*/
|
||||
#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*
|
||||
* Macro to enable microcontroller interrupts.
|
||||
*
|
||||
* \page taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
|
||||
* \ingroup SchedulerControl
|
||||
*/
|
||||
#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
|
||||
|
||||
/* Definitions returned by xTaskGetSchedulerState(). */
|
||||
#define taskSCHEDULER_NOT_STARTED 0
|
||||
#define taskSCHEDULER_RUNNING 1
|
||||
#define taskSCHEDULER_SUSPENDED 2
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* TASK CREATION API
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*<pre>
|
||||
portBASE_TYPE xTaskCreate(
|
||||
pdTASK_CODE pvTaskCode,
|
||||
const portCHAR * const pcName,
|
||||
unsigned portSHORT usStackDepth,
|
||||
void *pvParameters,
|
||||
unsigned portBASE_TYPE uxPriority,
|
||||
xTaskHandle *pvCreatedTask
|
||||
);</pre>
|
||||
*
|
||||
* Create a new task and add it to the list of tasks that are ready to run.
|
||||
*
|
||||
* @param pvTaskCode Pointer to the task entry function. Tasks
|
||||
* must be implemented to never return (i.e. continuous loop).
|
||||
*
|
||||
* @param pcName A descriptive name for the task. This is mainly used to
|
||||
* facilitate debugging. Max length defined by tskMAX_TASK_NAME_LEN - default
|
||||
* is 16.
|
||||
*
|
||||
* @param usStackDepth The size of the task stack specified as the number of
|
||||
* variables the stack can hold - not the number of bytes. For example, if
|
||||
* the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
|
||||
* will be allocated for stack storage.
|
||||
*
|
||||
* @param pvParameters Pointer that will be used as the parameter for the task
|
||||
* being created.
|
||||
*
|
||||
* @param uxPriority The priority at which the task should run.
|
||||
*
|
||||
* @param pvCreatedTask Used to pass back a handle by which the created task
|
||||
* can be referenced.
|
||||
*
|
||||
* @return pdPASS if the task was successfully created and added to a ready
|
||||
* list, otherwise an error code defined in the file errors. h
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Task to be created.
|
||||
void vTaskCode( void * pvParameters )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
// Task code goes here.
|
||||
}
|
||||
}
|
||||
|
||||
// Function that creates a task.
|
||||
void vOtherFunction( void )
|
||||
{
|
||||
unsigned char ucParameterToPass;
|
||||
xTaskHandle xHandle;
|
||||
|
||||
// Create the task, storing the handle.
|
||||
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
|
||||
|
||||
// Use the handle to delete the task.
|
||||
vTaskDelete( xHandle );
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xTaskCreate xTaskCreate
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
signed portBASE_TYPE xTaskCreate( pdTASK_CODE pvTaskCode, const signed portCHAR * const pcName, unsigned portSHORT usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pvCreatedTask );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>void vTaskDelete( xTaskHandle pxTask );</pre>
|
||||
*
|
||||
* INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
|
||||
* See the configuration section for more information.
|
||||
*
|
||||
* Remove a task from the RTOS real time kernels management. The task being
|
||||
* deleted will be removed from all ready, blocked, suspended and event lists.
|
||||
*
|
||||
* NOTE: The idle task is responsible for freeing the kernel allocated
|
||||
* memory from tasks that have been deleted. It is therefore important that
|
||||
* the idle task is not starved of microcontroller processing time if your
|
||||
* application makes any calls to vTaskDelete (). Memory allocated by the
|
||||
* task code is not automatically freed, and should be freed before the task
|
||||
* is deleted.
|
||||
*
|
||||
* See the demo application file death.c for sample code that utilises
|
||||
* vTaskDelete ().
|
||||
*
|
||||
* @param pxTask The handle of the task to be deleted. Passing NULL will
|
||||
* cause the calling task to be deleted.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
void vOtherFunction( void )
|
||||
{
|
||||
xTaskHandle xHandle;
|
||||
|
||||
// Create the task, storing the handle.
|
||||
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
|
||||
|
||||
// Use the handle to delete the task.
|
||||
vTaskDelete( xHandle );
|
||||
}
|
||||
</pre>
|
||||
* \defgroup vTaskDelete vTaskDelete
|
||||
* \ingroup Tasks
|
||||
*/
|
||||
void vTaskDelete( xTaskHandle pxTask );
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* TASK CONTROL API
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>void vTaskDelay( portTickType xTicksToDelay );</pre>
|
||||
*
|
||||
* Delay a task for a given number of ticks. The actual time that the
|
||||
* task remains blocked depends on the tick rate. The constant
|
||||
* portTICK_RATE_MS can be used to calculate real time from the tick
|
||||
* rate - with the resolution of one tick period.
|
||||
*
|
||||
* INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
|
||||
* See the configuration section for more information.
|
||||
*
|
||||
* @param xTicksToDelay The amount of time, in tick periods, that
|
||||
* the calling task should block.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Wait 10 ticks before performing an action.
|
||||
// NOTE:
|
||||
// This is for demonstration only and would be better achieved
|
||||
// using vTaskDelayUntil ().
|
||||
void vTaskFunction( void * pvParameters )
|
||||
{
|
||||
portTickType xDelay, xNextTime;
|
||||
|
||||
// Calc the time at which we want to perform the action
|
||||
// next.
|
||||
xNextTime = xTaskGetTickCount () + ( portTickType ) 10;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
xDelay = xNextTime - xTaskGetTickCount ();
|
||||
xNextTime += ( portTickType ) 10;
|
||||
|
||||
// Guard against overflow
|
||||
if( xDelay <= ( portTickType ) 10 )
|
||||
{
|
||||
vTaskDelay( xDelay );
|
||||
}
|
||||
|
||||
// Perform action here.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup vTaskDelay vTaskDelay
|
||||
* \ingroup TaskCtrl
|
||||
*/
|
||||
void vTaskDelay( portTickType xTicksToDelay );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>void vTaskDelayUntil( portTickType *pxPreviousWakeTime, portTickType xTimeIncrement );</pre>
|
||||
*
|
||||
* INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available.
|
||||
* See the configuration section for more information.
|
||||
*
|
||||
* Delay a task until a specified time. This function can be used by cyclical
|
||||
* tasks to ensure a constant execution frequency.
|
||||
*
|
||||
* This function differs from vTaskDelay () in one important aspect: vTaskDelay () will
|
||||
* cause a task to block for the specified number of ticks from the time vTaskDelay () is
|
||||
* called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed
|
||||
* execution frequency as the time between a task starting to execute and that task
|
||||
* calling vTaskDelay () may not be fixed [the task may take a different path though the
|
||||
* code between calls, or may get interrupted or preempted a different number of times
|
||||
* each time it executes].
|
||||
*
|
||||
* Whereas vTaskDelay () specifies a wake time relative to the time at which the function
|
||||
* is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
|
||||
* unblock.
|
||||
*
|
||||
* The constant portTICK_RATE_MS can be used to calculate real time from the tick
|
||||
* rate - with the resolution of one tick period.
|
||||
*
|
||||
* @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
|
||||
* task was last unblocked. The variable must be initialised with the current time
|
||||
* prior to its first use (see the example below). Following this the variable is
|
||||
* automatically updated within vTaskDelayUntil ().
|
||||
*
|
||||
* @param xTimeIncrement The cycle time period. The task will be unblocked at
|
||||
* time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the
|
||||
* same xTimeIncrement parameter value will cause the task to execute with
|
||||
* a fixed interface period.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
// Perform an action every 10 ticks.
|
||||
void vTaskFunction( void * pvParameters )
|
||||
{
|
||||
portTickType xLastWakeTime;
|
||||
const portTickType xFrequency = 10;
|
||||
|
||||
// Initialise the xLastWakeTime variable with the current time.
|
||||
xLastWakeTime = xTaskGetTickCount ();
|
||||
for( ;; )
|
||||
{
|
||||
// Wait for the next cycle.
|
||||
vTaskDelayUntil( &xLastWakeTime, xFrequency );
|
||||
|
||||
// Perform action here.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup vTaskDelayUntil vTaskDelayUntil
|
||||
* \ingroup TaskCtrl
|
||||
*/
|
||||
void vTaskDelayUntil( portTickType *pxPreviousWakeTime, portTickType xTimeIncrement );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask );</pre>
|
||||
*
|
||||
* INCLUDE_xTaskPriorityGet must be defined as 1 for this function to be available.
|
||||
* See the configuration section for more information.
|
||||
*
|
||||
* Obtain the priority of any task.
|
||||
*
|
||||
* @param pxTask Handle of the task to be queried. Passing a NULL
|
||||
* handle results in the priority of the calling task being returned.
|
||||
*
|
||||
* @return The priority of pxTask.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
void vAFunction( void )
|
||||
{
|
||||
xTaskHandle xHandle;
|
||||
|
||||
// Create a task, storing the handle.
|
||||
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
|
||||
|
||||
// ...
|
||||
|
||||
// Use the handle to obtain the priority of the created task.
|
||||
// It was created with tskIDLE_PRIORITY, but may have changed
|
||||
// it itself.
|
||||
if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
|
||||
{
|
||||
// The task has changed it's priority.
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
// Is our priority higher than the created task?
|
||||
if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
|
||||
{
|
||||
// Our priority (obtained using NULL handle) is higher.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup uxTaskPriorityGet uxTaskPriorityGet
|
||||
* \ingroup TaskCtrl
|
||||
*/
|
||||
unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority );</pre>
|
||||
*
|
||||
* INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
|
||||
* See the configuration section for more information.
|
||||
*
|
||||
* Set the priority of any task.
|
||||
*
|
||||
* A context switch will occur before the function returns if the priority
|
||||
* being set is higher than the currently executing task.
|
||||
*
|
||||
* @param pxTask Handle to the task for which the priority is being set.
|
||||
* Passing a NULL handle results in the priority of the calling task being set.
|
||||
*
|
||||
* @param uxNewPriority The priority to which the task will be set.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
void vAFunction( void )
|
||||
{
|
||||
xTaskHandle xHandle;
|
||||
|
||||
// Create a task, storing the handle.
|
||||
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
|
||||
|
||||
// ...
|
||||
|
||||
// Use the handle to raise the priority of the created task.
|
||||
vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
|
||||
|
||||
// ...
|
||||
|
||||
// Use a NULL handle to raise our priority to the same value.
|
||||
vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
|
||||
}
|
||||
</pre>
|
||||
* \defgroup vTaskPrioritySet vTaskPrioritySet
|
||||
* \ingroup TaskCtrl
|
||||
*/
|
||||
void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>void vTaskSuspend( xTaskHandle pxTaskToSuspend );</pre>
|
||||
*
|
||||
* INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
|
||||
* See the configuration section for more information.
|
||||
*
|
||||
* Suspend any task. When suspended a task will never get any microcontroller
|
||||
* processing time, no matter what its priority.
|
||||
*
|
||||
* Calls to vTaskSuspend are not accumulative -
|
||||
* i.e. calling vTaskSuspend () twice on the same task still only requires one
|
||||
* call to vTaskResume () to ready the suspended task.
|
||||
*
|
||||
* @param pxTaskToSuspend Handle to the task being suspended. Passing a NULL
|
||||
* handle will cause the calling task to be suspended.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
void vAFunction( void )
|
||||
{
|
||||
xTaskHandle xHandle;
|
||||
|
||||
// Create a task, storing the handle.
|
||||
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
|
||||
|
||||
// ...
|
||||
|
||||
// Use the handle to suspend the created task.
|
||||
vTaskSuspend( xHandle );
|
||||
|
||||
// ...
|
||||
|
||||
// The created task will not run during this period, unless
|
||||
// another task calls vTaskResume( xHandle ).
|
||||
|
||||
//...
|
||||
|
||||
|
||||
// Suspend ourselves.
|
||||
vTaskSuspend( NULL );
|
||||
|
||||
// We cannot get here unless another task calls vTaskResume
|
||||
// with our handle as the parameter.
|
||||
}
|
||||
</pre>
|
||||
* \defgroup vTaskSuspend vTaskSuspend
|
||||
* \ingroup TaskCtrl
|
||||
*/
|
||||
void vTaskSuspend( xTaskHandle pxTaskToSuspend );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>void vTaskResume( xTaskHandle pxTaskToResume );</pre>
|
||||
*
|
||||
* INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
|
||||
* See the configuration section for more information.
|
||||
*
|
||||
* Resumes a suspended task.
|
||||
*
|
||||
* A task that has been suspended by one of more calls to vTaskSuspend ()
|
||||
* will be made available for running again by a single call to
|
||||
* vTaskResume ().
|
||||
*
|
||||
* @param pxTaskToResume Handle to the task being readied.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
void vAFunction( void )
|
||||
{
|
||||
xTaskHandle xHandle;
|
||||
|
||||
// Create a task, storing the handle.
|
||||
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
|
||||
|
||||
// ...
|
||||
|
||||
// Use the handle to suspend the created task.
|
||||
vTaskSuspend( xHandle );
|
||||
|
||||
// ...
|
||||
|
||||
// The created task will not run during this period, unless
|
||||
// another task calls vTaskResume( xHandle ).
|
||||
|
||||
//...
|
||||
|
||||
|
||||
// Resume the suspended task ourselves.
|
||||
vTaskResume( xHandle );
|
||||
|
||||
// The created task will once again get microcontroller processing
|
||||
// time in accordance with it priority within the system.
|
||||
}
|
||||
</pre>
|
||||
* \defgroup vTaskResume vTaskResume
|
||||
* \ingroup TaskCtrl
|
||||
*/
|
||||
void vTaskResume( xTaskHandle pxTaskToResume );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>void xTaskResumeFromISR( xTaskHandle pxTaskToResume );</pre>
|
||||
*
|
||||
* INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
|
||||
* available. See the configuration section for more information.
|
||||
*
|
||||
* An implementation of vTaskResume() that can be called from within an ISR.
|
||||
*
|
||||
* A task that has been suspended by one of more calls to vTaskSuspend ()
|
||||
* will be made available for running again by a single call to
|
||||
* xTaskResumeFromISR ().
|
||||
*
|
||||
* @param pxTaskToResume Handle to the task being readied.
|
||||
*
|
||||
* \defgroup vTaskResumeFromISR vTaskResumeFromISR
|
||||
* \ingroup TaskCtrl
|
||||
*/
|
||||
portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume );
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* SCHEDULER CONTROL
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>void vTaskStartScheduler( void );</pre>
|
||||
*
|
||||
* Starts the real time kernel tick processing. After calling the kernel
|
||||
* has control over which tasks are executed and when. This function
|
||||
* does not return until an executing task calls vTaskEndScheduler ().
|
||||
*
|
||||
* At least one task should be created via a call to xTaskCreate ()
|
||||
* before calling vTaskStartScheduler (). The idle task is created
|
||||
* automatically when the first application task is created.
|
||||
*
|
||||
* See the demo application file main.c for an example of creating
|
||||
* tasks and starting the kernel.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
void vAFunction( void )
|
||||
{
|
||||
// Create at least one task before starting the kernel.
|
||||
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
|
||||
// Start the real time kernel with preemption.
|
||||
vTaskStartScheduler ();
|
||||
|
||||
// Will not get here unless a task calls vTaskEndScheduler ()
|
||||
}
|
||||
</pre>
|
||||
*
|
||||
* \defgroup vTaskStartScheduler vTaskStartScheduler
|
||||
* \ingroup SchedulerControl
|
||||
*/
|
||||
void vTaskStartScheduler( void );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>void vTaskEndScheduler( void );</pre>
|
||||
*
|
||||
* Stops the real time kernel tick. All created tasks will be automatically
|
||||
* deleted and multitasking (either preemptive or cooperative) will
|
||||
* stop. Execution then resumes from the point where vTaskStartScheduler ()
|
||||
* was called, as if vTaskStartScheduler () had just returned.
|
||||
*
|
||||
* See the demo application file main. c in the demo/PC directory for an
|
||||
* example that uses vTaskEndScheduler ().
|
||||
*
|
||||
* vTaskEndScheduler () requires an exit function to be defined within the
|
||||
* portable layer (see vPortEndScheduler () in port. c for the PC port). This
|
||||
* performs hardware specific operations such as stopping the kernel tick.
|
||||
*
|
||||
* vTaskEndScheduler () will cause all of the resources allocated by the
|
||||
* kernel to be freed - but will not free resources allocated by application
|
||||
* tasks.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
void vTaskCode( void * pvParameters )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
// Task code goes here.
|
||||
|
||||
// At some point we want to end the real time kernel processing
|
||||
// so call ...
|
||||
vTaskEndScheduler ();
|
||||
}
|
||||
}
|
||||
|
||||
void vAFunction( void )
|
||||
{
|
||||
// Create at least one task before starting the kernel.
|
||||
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
|
||||
// Start the real time kernel with preemption.
|
||||
vTaskStartScheduler ();
|
||||
|
||||
// Will only get here when the vTaskCode () task has called
|
||||
// vTaskEndScheduler (). When we get here we are back to single task
|
||||
// execution.
|
||||
}
|
||||
</pre>
|
||||
*
|
||||
* \defgroup vTaskEndScheduler vTaskEndScheduler
|
||||
* \ingroup SchedulerControl
|
||||
*/
|
||||
void vTaskEndScheduler( void );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>void vTaskSuspendAll( void );</pre>
|
||||
*
|
||||
* Suspends all real time kernel activity while keeping interrupts (including the
|
||||
* kernel tick) enabled.
|
||||
*
|
||||
* After calling vTaskSuspendAll () the calling task will continue to execute
|
||||
* without risk of being swapped out until a call to xTaskResumeAll () has been
|
||||
* made.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
void vTask1( void * pvParameters )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
// Task code goes here.
|
||||
|
||||
// ...
|
||||
|
||||
// At some point the task wants to perform a long operation during
|
||||
// which it does not want to get swapped out. It cannot use
|
||||
// taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
|
||||
// operation may cause interrupts to be missed - including the
|
||||
// ticks.
|
||||
|
||||
// Prevent the real time kernel swapping out the task.
|
||||
vTaskSuspendAll ();
|
||||
|
||||
// Perform the operation here. There is no need to use critical
|
||||
// sections as we have all the microcontroller processing time.
|
||||
// During this time interrupts will still operate and the kernel
|
||||
// tick count will be maintained.
|
||||
|
||||
// ...
|
||||
|
||||
// The operation is complete. Restart the kernel.
|
||||
xTaskResumeAll ();
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup vTaskSuspendAll vTaskSuspendAll
|
||||
* \ingroup SchedulerControl
|
||||
*/
|
||||
void vTaskSuspendAll( void );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>portCHAR xTaskResumeAll( void );</pre>
|
||||
*
|
||||
* Resumes real time kernel activity following a call to vTaskSuspendAll ().
|
||||
* After a call to vTaskSuspendAll () the kernel will take control of which
|
||||
* task is executing at any time.
|
||||
*
|
||||
* @return If resuming the scheduler caused a context switch then pdTRUE is
|
||||
* returned, otherwise pdFALSE is returned.
|
||||
*
|
||||
* Example usage:
|
||||
<pre>
|
||||
void vTask1( void * pvParameters )
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
// Task code goes here.
|
||||
|
||||
// ...
|
||||
|
||||
// At some point the task wants to perform a long operation during
|
||||
// which it does not want to get swapped out. It cannot use
|
||||
// taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
|
||||
// operation may cause interrupts to be missed - including the
|
||||
// ticks.
|
||||
|
||||
// Prevent the real time kernel swapping out the task.
|
||||
vTaskSuspendAll ();
|
||||
|
||||
// Perform the operation here. There is no need to use critical
|
||||
// sections as we have all the microcontroller processing time.
|
||||
// During this time interrupts will still operate and the real
|
||||
// time kernel tick count will be maintained.
|
||||
|
||||
// ...
|
||||
|
||||
// The operation is complete. Restart the kernel. We want to force
|
||||
// a context switch - but there is no point if resuming the scheduler
|
||||
// caused a context switch already.
|
||||
if( !xTaskResumeAll () )
|
||||
{
|
||||
taskYIELD ();
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
* \defgroup xTaskResumeAll xTaskResumeAll
|
||||
* \ingroup SchedulerControl
|
||||
*/
|
||||
signed portBASE_TYPE xTaskResumeAll( void );
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* TASK UTILITIES
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <PRE>volatile portTickType xTaskGetTickCount( void );</PRE>
|
||||
*
|
||||
* @return The count of ticks since vTaskStartScheduler was called.
|
||||
*
|
||||
* \page xTaskGetTickCount xTaskGetTickCount
|
||||
* \ingroup TaskUtils
|
||||
*/
|
||||
portTickType xTaskGetTickCount( void );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <PRE>unsigned portSHORT uxTaskGetNumberOfTasks( void );</PRE>
|
||||
*
|
||||
* @return The number of tasks that the real time kernel is currently managing.
|
||||
* This includes all ready, blocked and suspended tasks. A task that
|
||||
* has been deleted but not yet freed by the idle task will also be
|
||||
* included in the count.
|
||||
*
|
||||
* \page uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
|
||||
* \ingroup TaskUtils
|
||||
*/
|
||||
unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <PRE>void vTaskList( portCHAR *pcWriteBuffer );</PRE>
|
||||
*
|
||||
* configUSE_TRACE_FACILITY, INCLUDE_vTaskDelete and INCLUDE_vTaskSuspend
|
||||
* must all be defined as 1 for this function to be available.
|
||||
* See the configuration section for more information.
|
||||
*
|
||||
* NOTE: This function will disable interrupts for its duration. It is
|
||||
* not intended for normal application runtime use but as a debug aid.
|
||||
*
|
||||
* Lists all the current tasks, along with their current state and stack
|
||||
* usage high water mark.
|
||||
*
|
||||
* Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
|
||||
* suspended ('S').
|
||||
*
|
||||
* @param pcWriteBuffer A buffer into which the above mentioned details
|
||||
* will be written, in ascii form. This buffer is assumed to be large
|
||||
* enough to contain the generated report. Approximately 40 bytes per
|
||||
* task should be sufficient.
|
||||
*
|
||||
* \page vTaskList vTaskList
|
||||
* \ingroup TaskUtils
|
||||
*/
|
||||
void vTaskList( signed portCHAR *pcWriteBuffer );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <PRE>void vTaskStartTrace( portCHAR * pcBuffer, unsigned portBASE_TYPE uxBufferSize );</PRE>
|
||||
*
|
||||
* Starts a real time kernel activity trace. The trace logs the identity of
|
||||
* which task is running when.
|
||||
*
|
||||
* The trace file is stored in binary format. A separate DOS utility called
|
||||
* convtrce.exe is used to convert this into a tab delimited text file which
|
||||
* can be viewed and plotted in a spread sheet.
|
||||
*
|
||||
* @param pcBuffer The buffer into which the trace will be written.
|
||||
*
|
||||
* @param ulBufferSize The size of pcBuffer in bytes. The trace will continue
|
||||
* until either the buffer in full, or ulTaskEndTrace () is called.
|
||||
*
|
||||
* \page vTaskStartTrace vTaskStartTrace
|
||||
* \ingroup TaskUtils
|
||||
*/
|
||||
void vTaskStartTrace( signed portCHAR * pcBuffer, unsigned portLONG ulBufferSize );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <PRE>unsigned portLONG ulTaskEndTrace( void );</PRE>
|
||||
*
|
||||
* Stops a kernel activity trace. See vTaskStartTrace ().
|
||||
*
|
||||
* @return The number of bytes that have been written into the trace buffer.
|
||||
*
|
||||
* \page usTaskEndTrace usTaskEndTrace
|
||||
* \ingroup TaskUtils
|
||||
*/
|
||||
unsigned portLONG ulTaskEndTrace( void );
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
|
||||
* INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
|
||||
* AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
|
||||
*
|
||||
* Called from the real time kernel tick (either preemptive or cooperative),
|
||||
* this increments the tick count and checks if any tasks that are blocked
|
||||
* for a finite period required removing from a blocked list and placing on
|
||||
* a ready list.
|
||||
*/
|
||||
inline void vTaskIncrementTick( void );
|
||||
|
||||
/*
|
||||
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
|
||||
* INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
|
||||
*
|
||||
* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
|
||||
*
|
||||
* Removes the calling task from the ready list and places it both
|
||||
* on the list of tasks waiting for a particular event, and the
|
||||
* list of delayed tasks. The task will be removed from both lists
|
||||
* and replaced on the ready list should either the event occur (and
|
||||
* there be no higher priority tasks waiting on the same event) or
|
||||
* the delay period expires.
|
||||
*
|
||||
* @param pxEventList The list containing tasks that are blocked waiting
|
||||
* for the event to occur.
|
||||
*
|
||||
* @param xTicksToWait The maximum amount of time that the task should wait
|
||||
* for the event to occur. This is specified in kernel ticks,the constant
|
||||
* portTICK_RATE_MS can be used to convert kernel ticks into a real time
|
||||
* period.
|
||||
*/
|
||||
void vTaskPlaceOnEventList( xList *pxEventList, portTickType xTicksToWait );
|
||||
|
||||
/*
|
||||
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
|
||||
* INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
|
||||
*
|
||||
* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
|
||||
*
|
||||
* Removes a task from both the specified event list and the list of blocked
|
||||
* tasks, and places it on a ready queue.
|
||||
*
|
||||
* xTaskRemoveFromEventList () will be called if either an event occurs to
|
||||
* unblock a task, or the block timeout period expires.
|
||||
*
|
||||
* @return pdTRUE if the task being removed has a higher priority than the task
|
||||
* making the call, otherwise pdFALSE.
|
||||
*/
|
||||
signed portBASE_TYPE xTaskRemoveFromEventList( const xList *pxEventList );
|
||||
|
||||
/*
|
||||
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
|
||||
* INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
|
||||
*
|
||||
* INCLUDE_vTaskCleanUpResources and INCLUDE_vTaskSuspend must be defined as 1
|
||||
* for this function to be available.
|
||||
* See the configuration section for more information.
|
||||
*
|
||||
* Empties the ready and delayed queues of task control blocks, freeing the
|
||||
* memory allocated for the task control block and task stacks as it goes.
|
||||
*/
|
||||
void vTaskCleanUpResources( void );
|
||||
|
||||
/*
|
||||
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
|
||||
* INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
|
||||
* AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
|
||||
*
|
||||
* Sets the pointer to the current TCB to the TCB of the highest priority task
|
||||
* that is ready to run.
|
||||
*/
|
||||
inline void vTaskSwitchContext( void );
|
||||
|
||||
/*
|
||||
* Return the handle of the calling task.
|
||||
*/
|
||||
xTaskHandle xTaskGetCurrentTaskHandle( void );
|
||||
|
||||
/*
|
||||
* Capture the current time status for future reference.
|
||||
*/
|
||||
void vTaskSetTimeOutState( xTimeOutType *pxTimeOut );
|
||||
|
||||
/*
|
||||
* Compare the time status now with that previously captured to see if the
|
||||
* timeout has expired.
|
||||
*/
|
||||
portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType *pxTimeOut, portTickType * const pxTicksToWait );
|
||||
|
||||
/*
|
||||
* Shortcut used by the queue implementation to prevent unnecessary call to
|
||||
* taskYIELD();
|
||||
*/
|
||||
void vTaskMissedYield( void );
|
||||
|
||||
/*
|
||||
* Returns the scheduler state as taskSCHEDULER_RUNNING,
|
||||
* taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
|
||||
*/
|
||||
portBASE_TYPE xTaskGetSchedulerState( void );
|
||||
|
||||
#endif /* TASK_H */
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,204 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V1.2.0
|
||||
|
||||
+ Removed the volatile modifier from the function parameters. This was
|
||||
only ever included to prevent compiler warnings. Now warnings are
|
||||
removed by casting parameters where the calls are made.
|
||||
|
||||
+ prvListGetOwnerOfNextEntry() and prvListGetOwnerOfHeadEntry() have been
|
||||
removed from the c file and added as macros to the h file.
|
||||
|
||||
+ uxNumberOfItems has been added to the list structure. This removes the
|
||||
need for a pointer comparison when checking if a list is empty, and so
|
||||
is slightly faster.
|
||||
|
||||
+ Removed the NULL check in vListRemove(). This makes the call faster but
|
||||
necessitates any application code utilising the list implementation to
|
||||
ensure NULL pointers are not passed.
|
||||
|
||||
Changes from V2.0.0
|
||||
|
||||
+ Double linked the lists to allow faster removal item removal.
|
||||
|
||||
Changes from V2.6.1
|
||||
|
||||
+ Make use of the new portBASE_TYPE definition where ever appropriate.
|
||||
|
||||
Changes from V3.0.0
|
||||
|
||||
+ API changes as described on the FreeRTOS.org WEB site.
|
||||
|
||||
Changes from V3.2.4
|
||||
|
||||
+ Removed the pxHead member of the xList structure. This always pointed
|
||||
to the same place so has been removed to free a few bytes of RAM.
|
||||
|
||||
+ Introduced the xMiniListItem structure that does not include the
|
||||
xListItem members that are not required by the xListEnd member of a list.
|
||||
Again this was done to reduce RAM usage.
|
||||
|
||||
+ Changed the volatile definitions of some structure members to clean up
|
||||
the code where the list structures are used.
|
||||
|
||||
Changes from V4.0.4
|
||||
|
||||
+ Optimised vListInsert() in the case when the wake time is the maximum
|
||||
tick count value.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "list.h"
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* PUBLIC LIST API documented in list.h
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
void vListInitialise( xList *pxList )
|
||||
{
|
||||
/* The list structure contains a list item which is used to mark the
|
||||
end of the list. To initialise the list the list end is inserted
|
||||
as the only list entry. */
|
||||
pxList->pxIndex = ( xListItem * ) &( pxList->xListEnd );
|
||||
|
||||
/* The list end value is the highest possible value in the list to
|
||||
ensure it remains at the end of the list. */
|
||||
pxList->xListEnd.xItemValue = portMAX_DELAY;
|
||||
|
||||
/* The list end next and previous pointers point to itself so we know
|
||||
when the list is empty. */
|
||||
pxList->xListEnd.pxNext = ( xListItem * ) &( pxList->xListEnd );
|
||||
pxList->xListEnd.pxPrevious = ( xListItem * ) &( pxList->xListEnd );
|
||||
|
||||
pxList->uxNumberOfItems = 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vListInitialiseItem( xListItem *pxItem )
|
||||
{
|
||||
/* Make sure the list item is not recorded as being on a list. */
|
||||
pxItem->pvContainer = NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vListInsertEnd( xList *pxList, xListItem *pxNewListItem )
|
||||
{
|
||||
volatile xListItem * pxIndex;
|
||||
|
||||
/* Insert a new list item into pxList, but rather than sort the list,
|
||||
makes the new list item the last item to be removed by a call to
|
||||
pvListGetOwnerOfNextEntry. This means it has to be the item pointed to by
|
||||
the pxIndex member. */
|
||||
pxIndex = pxList->pxIndex;
|
||||
|
||||
pxNewListItem->pxNext = pxIndex->pxNext;
|
||||
pxNewListItem->pxPrevious = pxList->pxIndex;
|
||||
pxIndex->pxNext->pxPrevious = ( volatile xListItem * ) pxNewListItem;
|
||||
pxIndex->pxNext = ( volatile xListItem * ) pxNewListItem;
|
||||
pxList->pxIndex = ( volatile xListItem * ) pxNewListItem;
|
||||
|
||||
/* Remember which list the item is in. */
|
||||
pxNewListItem->pvContainer = ( void * ) pxList;
|
||||
|
||||
( pxList->uxNumberOfItems )++;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vListInsert( xList *pxList, xListItem *pxNewListItem )
|
||||
{
|
||||
volatile xListItem *pxIterator;
|
||||
portTickType xValueOfInsertion;
|
||||
|
||||
/* Insert the new list item into the list, sorted in ulListItem order. */
|
||||
xValueOfInsertion = pxNewListItem->xItemValue;
|
||||
|
||||
/* If the list already contains a list item with the same item value then
|
||||
the new list item should be placed after it. This ensures that TCB's which
|
||||
are stored in ready lists (all of which have the same ulListItem value)
|
||||
get an equal share of the CPU. However, if the xItemValue is the same as
|
||||
the back marker the iteration loop below will not end. This means we need
|
||||
to guard against this by checking the value first and modifying the
|
||||
algorithm slightly if necessary. */
|
||||
if( xValueOfInsertion == portMAX_DELAY )
|
||||
{
|
||||
pxIterator = pxList->xListEnd.pxPrevious;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext )
|
||||
{
|
||||
/* There is nothing to do here, we are just iterating to the
|
||||
wanted insertion position. */
|
||||
}
|
||||
}
|
||||
|
||||
pxNewListItem->pxNext = pxIterator->pxNext;
|
||||
pxNewListItem->pxNext->pxPrevious = ( volatile xListItem * ) pxNewListItem;
|
||||
pxNewListItem->pxPrevious = pxIterator;
|
||||
pxIterator->pxNext = ( volatile xListItem * ) pxNewListItem;
|
||||
|
||||
/* Remember which list the item is in. This allows fast removal of the
|
||||
item later. */
|
||||
pxNewListItem->pvContainer = ( void * ) pxList;
|
||||
|
||||
( pxList->uxNumberOfItems )++;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vListRemove( xListItem *pxItemToRemove )
|
||||
{
|
||||
xList * pxList;
|
||||
|
||||
pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious;
|
||||
pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext;
|
||||
|
||||
/* The list item knows which list it is in. Obtain the list from the list
|
||||
item. */
|
||||
pxList = ( xList * ) pxItemToRemove->pvContainer;
|
||||
|
||||
/* Make sure the index is left pointing to a valid item. */
|
||||
if( pxList->pxIndex == pxItemToRemove )
|
||||
{
|
||||
pxList->pxIndex = pxItemToRemove->pxPrevious;
|
||||
}
|
||||
|
||||
pxItemToRemove->pvContainer = NULL;
|
||||
( pxList->uxNumberOfItems )--;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
/*
|
||||
* MODBUS Library: SAM7X Port
|
||||
* Copyright (c) 2007 Christian Walter <wolti@sil.at>
|
||||
* All rights reserved.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
/*
|
||||
* FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
*
|
||||
* This file is part of the FreeRTOS.org distribution.
|
||||
*
|
||||
* FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with FreeRTOS.org; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* A special exception to the GPL can be applied should you wish to distribute
|
||||
* a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
* the source code for any proprietary components. See the licensing section
|
||||
* of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
* can be applied.
|
||||
*
|
||||
****************************************************************************
|
||||
* See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
* and contact details. Please ensure to read the configuration and relevant
|
||||
* port sections of the online documentation.
|
||||
*
|
||||
* Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
* with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/* ----------------------- System includes ----------------------------------*/
|
||||
#include <stdlib.h>
|
||||
|
||||
/* ----------------------- FreeRTOS includes --------------------------------*/
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* ----------------------- Platform includes --------------------------------*/
|
||||
#include "AT91SAM7X256.h"
|
||||
#include "lib_AT91SAM7X256.h"
|
||||
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
#define portINITIAL_SPSR ( ( portSTACK_TYPE ) 0x1f )
|
||||
#define portTHUMB_MODE_BIT ( ( portSTACK_TYPE ) 0x20 )
|
||||
#define portINSTRUCTION_SIZE ( ( portSTACK_TYPE ) 4 )
|
||||
#define portNO_CRITICAL_SECTION_NESTING ( ( portSTACK_TYPE ) 0 )
|
||||
|
||||
/*
|
||||
#define portPRESCALE_VALUE 0x00
|
||||
#define portINTERRUPT_ON_MATCH ( ( unsigned portLONG ) 0x01 )
|
||||
#define portRESET_COUNT_ON_MATCH ( ( unsigned portLONG ) 0x02 )
|
||||
|
||||
#define portPIT_CLOCK_DIVISOR ( ( unsigned portLONG ) 16 )
|
||||
#define portPIT_COUNTER_VALUE ( ( ( configCPU_CLOCK_HZ / portPIT_CLOCK_DIVISOR ) / 1000UL ) * portTICK_RATE_MS )
|
||||
|
||||
#define portINT_LEVEL_SENSITIVE 0
|
||||
#define portPIT_ENABLE ( ( unsigned portSHORT ) 0x1 << 24 )
|
||||
#define portPIT_INT_ENABLE ( ( unsigned portSHORT ) 0x1 << 25 )
|
||||
*/
|
||||
|
||||
/* ----------------------- Type definitions ---------------------------------*/
|
||||
|
||||
/* ----------------------- Static variables ---------------------------------*/
|
||||
|
||||
/* ----------------------- Function prototypes ------------------------------*/
|
||||
extern void vPortISRStartFirstTask( void );
|
||||
extern void vNonPreemptiveTick ( void );
|
||||
extern void vPreemptiveTick( void );
|
||||
|
||||
/* ----------------------- Static functions ---------------------------------*/
|
||||
static void prvSetupTimerInterrupt( void );
|
||||
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
|
||||
portSTACK_TYPE *
|
||||
pxPortInitialiseStack( portSTACK_TYPE * pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
|
||||
{
|
||||
portSTACK_TYPE *pxOriginalTOS;
|
||||
|
||||
pxOriginalTOS = pxTopOfStack;
|
||||
/* Setup the initial stack of the task. The stack is set exactly as
|
||||
* expected by the portRESTORE_CONTEXT() macro.
|
||||
*/
|
||||
|
||||
/* First on the stack is the return address - which in this case is the
|
||||
* start of the task. The offset is added to make the return address appear
|
||||
* as it would within an IRQ ISR.
|
||||
*/
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) pxCode + portINSTRUCTION_SIZE;
|
||||
pxTopOfStack--;
|
||||
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0xaaaaaaaa; /* R14 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) pxOriginalTOS; /* Stack used when task starts goes in R13. */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x12121212; /* R12 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x11111111; /* R11 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x10101010; /* R10 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x09090909; /* R9 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x08080808; /* R8 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x07070707; /* R7 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x06060606; /* R6 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x05050505; /* R5 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x04040404; /* R4 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x03030303; /* R3 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x02020202; /* R2 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x01010101; /* R1 */
|
||||
pxTopOfStack--;
|
||||
|
||||
/* When the task starts is will expect to find the function parameter in
|
||||
* R0.
|
||||
*/
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */
|
||||
pxTopOfStack--;
|
||||
|
||||
/* The last thing onto the stack is the status register, which is set for
|
||||
* system mode, with interrupts enabled.
|
||||
*/
|
||||
*pxTopOfStack = ( portSTACK_TYPE ) portINITIAL_SPSR;
|
||||
|
||||
#ifdef THUMB_INTERWORK
|
||||
{
|
||||
/* We want the task to start in thumb mode. */
|
||||
*pxTopOfStack |= portTHUMB_MODE_BIT;
|
||||
}
|
||||
#endif
|
||||
|
||||
pxTopOfStack--;
|
||||
|
||||
/* Some optimisation levels use the stack differently to others. This
|
||||
* means the interrupt flags cannot always be stored on the stack and will
|
||||
* instead be stored in a variable, which is then saved as part of the
|
||||
* tasks context.
|
||||
*/
|
||||
*pxTopOfStack = portNO_CRITICAL_SECTION_NESTING;
|
||||
|
||||
return pxTopOfStack;
|
||||
}
|
||||
|
||||
portBASE_TYPE
|
||||
xPortStartScheduler( void )
|
||||
{
|
||||
/* Start the timer that generates the tick ISR. Interrupts are disabled
|
||||
* here already.
|
||||
*/
|
||||
prvSetupTimerInterrupt( );
|
||||
|
||||
/* Start the first task. */
|
||||
vPortISRStartFirstTask( );
|
||||
|
||||
/* Should not get here! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
vPortEndScheduler( void )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup the timer 0 to generate the tick interrupts at the required frequency.
|
||||
*/
|
||||
static void
|
||||
prvSetupTimerInterrupt( void )
|
||||
{
|
||||
/* Setup the AIC for PIT interrupts. The interrupt routine chosen depends
|
||||
* on whether the preemptive or cooperative scheduler is being used.
|
||||
*/
|
||||
#if configUSE_PREEMPTION == 0
|
||||
AT91F_AIC_ConfigureIt( AT91C_BASE_AIC, AT91C_ID_SYS, AT91C_AIC_PRIOR_HIGHEST,
|
||||
AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
|
||||
( void ( * )( void ) )vNonPreemptiveTick );
|
||||
#else
|
||||
AT91F_AIC_ConfigureIt( AT91C_BASE_AIC, AT91C_ID_SYS, AT91C_AIC_PRIOR_HIGHEST,
|
||||
AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
|
||||
( void ( * )( void ) )vPreemptiveTick );
|
||||
|
||||
#endif
|
||||
|
||||
/* Configure the PIT period. */
|
||||
AT91F_PITInit( AT91C_BASE_PITC, portTICK_RATE_MS * 1000U, configCPU_CLOCK_HZ / 1000000U );
|
||||
AT91F_PITEnableInt( AT91C_BASE_PITC );
|
||||
AT91F_AIC_EnableIt( AT91C_BASE_AIC, AT91C_ID_SYS );
|
||||
}
|
||||
|
|
@ -1,225 +0,0 @@
|
|||
/*
|
||||
* MODBUS Library: SAM7X Port
|
||||
* Copyright (c) 2007 Christian Walter <wolti@sil.at>
|
||||
* All rights reserved.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
/*
|
||||
* FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
*
|
||||
* This file is part of the FreeRTOS.org distribution.
|
||||
*
|
||||
* FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with FreeRTOS.org; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* A special exception to the GPL can be applied should you wish to distribute
|
||||
* a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
* the source code for any proprietary components. See the licensing section
|
||||
* of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
* can be applied.
|
||||
*
|
||||
****************************************************************************
|
||||
* See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
* and contact details. Please ensure to read the configuration and relevant
|
||||
* port sections of the online documentation.
|
||||
*
|
||||
* Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
* with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/* ----------------------- System includes ----------------------------------*/
|
||||
#include <stdlib.h>
|
||||
|
||||
/* ----------------------- FreeRTOS includes --------------------------------*/
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* ----------------------- Platform includes --------------------------------*/
|
||||
#include "AT91SAM7X256.h"
|
||||
#include "lib_AT91SAM7X256.h"
|
||||
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
#define portTIMER_MATCH_ISR_BIT ( ( unsigned portCHAR ) 0x01 )
|
||||
#define portCLEAR_VIC_INTERRUPT ( ( unsigned portLONG ) 0 )
|
||||
#define portNO_CRITICAL_NESTING ( ( unsigned portLONG ) 0 )
|
||||
volatile unsigned portLONG ulCriticalNesting = 9999UL;
|
||||
|
||||
/* ----------------------- Type definitions ---------------------------------*/
|
||||
|
||||
/* ----------------------- Static variables ---------------------------------*/
|
||||
|
||||
/* ----------------------- Function prototypes ------------------------------*/
|
||||
void vPortDisableInterruptsFromThumb( void ) __attribute__ ( ( naked ) );
|
||||
void vPortEnableInterruptsFromThumb( void ) __attribute__ ( ( naked ) );
|
||||
void vNonPreemptiveTick( void ) __attribute__ ( ( interrupt( "IRQ" ) ) );
|
||||
void vPreemptiveTick( void ) __attribute__ ( ( naked ) );
|
||||
void vPortYieldProcessor( void ) __attribute__ ( ( interrupt( "SWI" ), naked ) );
|
||||
|
||||
void vPortISRStartFirstTask( void );
|
||||
|
||||
/* ----------------------- Static functions ---------------------------------*/
|
||||
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
|
||||
void
|
||||
vPortISRStartFirstTask( void )
|
||||
{
|
||||
/* Simply start the scheduler. This is included here as it can only be
|
||||
* called from ARM mode.
|
||||
*/
|
||||
portRESTORE_CONTEXT( );
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by portYIELD() or taskYIELD() to manually force a context switch.
|
||||
*
|
||||
* When a context switch is performed from the task level the saved task
|
||||
* context is made to look as if it occurred from within the tick ISR. This
|
||||
* way the same restore context function can be used when restoring the context
|
||||
* saved from the ISR or that saved from a call to vPortYieldProcessor.
|
||||
*/
|
||||
void
|
||||
vPortYieldProcessor( void )
|
||||
{
|
||||
/* Within an IRQ ISR the link register has an offset from the true return
|
||||
* address, but an SWI ISR does not. Add the offset manually so the same
|
||||
* ISR return code can be used in both cases.
|
||||
*/
|
||||
asm volatile ( "ADD LR, LR, #4" );
|
||||
|
||||
/* Perform the context switch. First save the context of the current task. */
|
||||
portSAVE_CONTEXT( );
|
||||
|
||||
/* Find the highest priority task that is ready to run. */
|
||||
vTaskSwitchContext( );
|
||||
|
||||
/* Restore the context of the new task. */
|
||||
portRESTORE_CONTEXT( );
|
||||
}
|
||||
|
||||
/*
|
||||
* The ISR used for the scheduler tick depends on whether the cooperative or
|
||||
* the preemptive scheduler is being used.
|
||||
*/
|
||||
#if configUSE_PREEMPTION == 0
|
||||
|
||||
|
||||
|
||||
void
|
||||
vNonPreemptiveTick( void )
|
||||
{
|
||||
unsigned portLONG ulDummy;
|
||||
|
||||
/* Increment the tick count - which may wake some tasks but as the
|
||||
* preemptive scheduler is not being used any woken task is not given
|
||||
* processor time no matter what its priority.
|
||||
*/
|
||||
vTaskIncrementTick( );
|
||||
|
||||
/* Clear the PIT interrupt. */
|
||||
AT91C_BASE_AIC->AIC_EOICR = AT91C_BASE_PITC->PITC_PIVR;
|
||||
}
|
||||
#else
|
||||
void
|
||||
vPreemptiveTick( void )
|
||||
{
|
||||
/* Save the context of the current task. */
|
||||
portSAVE_CONTEXT( );
|
||||
|
||||
/* Increment the tick count - this may wake a task. */
|
||||
vTaskIncrementTick( );
|
||||
|
||||
/* Find the highest priority task that is ready to run. */
|
||||
vTaskSwitchContext( );
|
||||
|
||||
/* End the interrupt in the AIC. */
|
||||
AT91C_BASE_AIC->AIC_EOICR = AT91C_BASE_PITC->PITC_PIVR;;
|
||||
|
||||
portRESTORE_CONTEXT( );
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The interrupt management utilities can only be called from ARM mode. When
|
||||
* THUMB_INTERWORK is defined the utilities are defined as functions here to
|
||||
* ensure a switch to ARM mode. When THUMB_INTERWORK is not defined then
|
||||
* the utilities are defined as macros in portmacro.h - as per other ports.
|
||||
*/
|
||||
void
|
||||
vPortDisableInterruptsFromThumb( void )
|
||||
{
|
||||
asm volatile ( "STMDB SP!, {R0}\n\t" /* Push R0. */
|
||||
"MRS R0, CPSR\n\t" /* Get CPSR. */
|
||||
"ORR R0, R0, #0xC0 \n\t" /* Disable IRQ, FIQ. */
|
||||
"MSR CPSR, R0\n\t" /* Write back modified value. */
|
||||
"LDMIA SP!, {R0}\n\t" /* Pop R0. */
|
||||
"BX R14" ); /* Return back to thumb. */
|
||||
}
|
||||
|
||||
void
|
||||
vPortEnableInterruptsFromThumb( void )
|
||||
{
|
||||
asm volatile ( "STMDB SP!, {R0}\n\t" /* Push R0. */
|
||||
"MRS R0, CPSR\n\t" /* Get CPSR. */
|
||||
"BIC R0, R0, #0xC0\n\t" /* Enable IRQ, FIQ. */
|
||||
"MSR CPSR, R0\n\t" /* Write back modified value. */
|
||||
"LDMIA SP!, {R0}\n\t" /* Pop R0. */
|
||||
"BX R14" ); /* Return back to thumb. */
|
||||
}
|
||||
|
||||
/* The code generated by the GCC compiler uses the stack in different ways at
|
||||
* different optimisation levels. The interrupt flags can therefore not always
|
||||
* be saved to the stack. Instead the critical section nesting level is stored
|
||||
* in a variable, which is then saved as part of the stack context.
|
||||
*/
|
||||
void
|
||||
vPortEnterCritical( void )
|
||||
{
|
||||
/* Disable interrupts as per portDISABLE_INTERRUPTS(); */
|
||||
asm volatile ( "STMDB SP!, {R0}\n\t" /* Push R0. */
|
||||
"MRS R0, CPSR\n\t" /* Get CPSR. */
|
||||
"ORR R0, R0, #0xC0\n\t" /* Disable IRQ, FIQ. */
|
||||
"MSR CPSR, R0\n\t" /* Write back modified value. */
|
||||
"LDMIA SP!, {R0}" ); /* Pop R0. */
|
||||
|
||||
/* Now interrupts are disabled ulCriticalNesting can be accessed
|
||||
* directly. Increment ulCriticalNesting to keep a count of how many times
|
||||
* portENTER_CRITICAL() has been called.
|
||||
*/
|
||||
ulCriticalNesting++;
|
||||
}
|
||||
|
||||
void
|
||||
vPortExitCritical( void )
|
||||
{
|
||||
if( ulCriticalNesting > portNO_CRITICAL_NESTING )
|
||||
{
|
||||
/* Decrement the nesting count as we are leaving a critical section. */
|
||||
ulCriticalNesting--;
|
||||
|
||||
/* If the nesting level has reached zero then interrupts should be
|
||||
re-enabled. */
|
||||
if( ulCriticalNesting == portNO_CRITICAL_NESTING )
|
||||
{
|
||||
/* Enable interrupts as per portEXIT_CRITICAL(). */
|
||||
asm volatile ( "STMDB SP!, {R0}\n\t" /* Push R0. */
|
||||
"MRS R0, CPSR\n\t" /* Get CPSR. */
|
||||
"BIC R0, R0, #0xC0\n\t" /* Enable IRQ, FIQ. */
|
||||
"MSR CPSR, R0\n\t" /* Write back modified value. */
|
||||
"LDMIA SP!, {R0}" ); /* Pop R0. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,230 +0,0 @@
|
|||
/*
|
||||
* MODBUS Library: SAM7X Port
|
||||
* Copyright (c) 2007 Christian Walter <wolti@sil.at>
|
||||
* All rights reserved.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
/*
|
||||
* FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
*
|
||||
* This file is part of the FreeRTOS.org distribution.
|
||||
*
|
||||
* FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with FreeRTOS.org; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* A special exception to the GPL can be applied should you wish to distribute
|
||||
* a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
* the source code for any proprietary components. See the licensing section
|
||||
* of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
* can be applied.
|
||||
*
|
||||
****************************************************************************
|
||||
* See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
* and contact details. Please ensure to read the configuration and relevant
|
||||
* port sections of the online documentation.
|
||||
*
|
||||
* Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
* with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
|
||||
/* ----------------------- Defines (Type definitions) -----------------------*/
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE unsigned portLONG
|
||||
#define portBASE_TYPE portLONG
|
||||
|
||||
#if( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef unsigned portSHORT portTickType;
|
||||
#define portMAX_DELAY ( portTickType ) 0xffff
|
||||
#else
|
||||
typedef unsigned portLONG portTickType;
|
||||
#define portMAX_DELAY ( portTickType ) 0xffffffff
|
||||
#endif
|
||||
|
||||
/* ----------------------- Defines (Architecture specific) ------------------*/
|
||||
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
|
||||
#define portBYTE_ALIGNMENT 4
|
||||
#define portNOP() asm volatile ( "NOP" );
|
||||
|
||||
/*
|
||||
* portRESTORE_CONTEXT, portRESTORE_CONTEXT, portENTER_SWITCHING_ISR
|
||||
* and portEXIT_SWITCHING_ISR can only be called from ARM mode, but
|
||||
* are included here for efficiency. An attempt to call one from
|
||||
* THUMB mode code will result in a compile time error.
|
||||
*/
|
||||
#define portRESTORE_CONTEXT() do { \
|
||||
extern volatile void * volatile pxCurrentTCB; \
|
||||
extern volatile unsigned portLONG ulCriticalNesting; \
|
||||
\
|
||||
/* Set the LR to the task stack. */ \
|
||||
asm volatile ( \
|
||||
"LDR R0, =pxCurrentTCB\n\t" \
|
||||
"LDR R0, [R0]\n\t" \
|
||||
"LDR LR, [R0]\n\t" \
|
||||
\
|
||||
/* The critical nesting depth is the first item on the stack. */ \
|
||||
/* Load it into the ulCriticalNesting variable. */ \
|
||||
"LDR R0, =ulCriticalNesting\n\t" \
|
||||
"LDMFD LR!, {R1}\n\t" \
|
||||
"STR R1, [R0]\n\t" \
|
||||
\
|
||||
/* Get the SPSR from the stack. */ \
|
||||
"LDMFD LR!, {R0}\n\t" \
|
||||
"MSR SPSR, R0\n\t" \
|
||||
\
|
||||
/* Restore all system mode registers for the task. */ \
|
||||
"LDMFD LR, {R0-R14}^\n\t" \
|
||||
"NOP\n\t" \
|
||||
\
|
||||
/* Restore the return address. */ \
|
||||
"LDR LR, [LR, #+60]\n\t" \
|
||||
\
|
||||
/* And return - correcting the offset in the LR to obtain the */ \
|
||||
/* correct address. */ \
|
||||
"SUBS PC, LR, #4\n\t" \
|
||||
); \
|
||||
( void ) ulCriticalNesting; \
|
||||
( void ) pxCurrentTCB; \
|
||||
} while( 0 )
|
||||
|
||||
#define portSAVE_CONTEXT() do { \
|
||||
extern volatile void * volatile pxCurrentTCB; \
|
||||
extern volatile unsigned portLONG ulCriticalNesting; \
|
||||
\
|
||||
/* Push R0 as we are going to use the register. */ \
|
||||
asm volatile ( \
|
||||
"STMDB SP!, {R0}\n\t" \
|
||||
\
|
||||
/* Set R0 to point to the task stack pointer. */ \
|
||||
"STMDB SP,{SP}^\n\t" \
|
||||
"NOP\n\t" \
|
||||
"SUB SP, SP, #4\n\t" \
|
||||
"LDMIA SP!,{R0}\n\t" \
|
||||
\
|
||||
/* Push the return address onto the stack. */ \
|
||||
"STMDB R0!, {LR}\n\t" \
|
||||
\
|
||||
/* Now we have saved LR we can use it instead of R0. */ \
|
||||
"MOV LR, R0\n\t" \
|
||||
\
|
||||
/* Pop R0 so we can save it onto the system mode stack. */ \
|
||||
"LDMIA SP!, {R0}\n\t" \
|
||||
\
|
||||
/* Push all the system mode registers onto the task stack. */ \
|
||||
"STMDB LR,{R0-LR}^\n\t" \
|
||||
"NOP\n\t" \
|
||||
"SUB LR, LR, #60\n\t" \
|
||||
\
|
||||
/* Push the SPSR onto the task stack. */ \
|
||||
"MRS R0, SPSR\n\t" \
|
||||
"STMDB LR!, {R0}\n\t" \
|
||||
\
|
||||
"LDR R0, =ulCriticalNesting\n\t" \
|
||||
"LDR R0, [R0]\n\t" \
|
||||
"STMDB LR!, {R0}\n\t" \
|
||||
\
|
||||
/* Store the new top of stack for the task. */ \
|
||||
"LDR R0, =pxCurrentTCB\n\t" \
|
||||
"LDR R0, [R0]\n\t" \
|
||||
"STR LR, [R0]\n\t" \
|
||||
); \
|
||||
( void ) ulCriticalNesting; \
|
||||
( void ) pxCurrentTCB; \
|
||||
} while( 0 )
|
||||
|
||||
#define portENTER_SWITCHING_ISR() do { \
|
||||
/* Save the context of the interrupted task. */ \
|
||||
portSAVE_CONTEXT(); \
|
||||
\
|
||||
/* We don't know the stack requirements for the ISR, so the frame */ \
|
||||
/* pointer will be set to the top of the task stack, and the stack*/ \
|
||||
/* pointer left where it is. The IRQ stack will get used for any */ \
|
||||
/* functions calls made by this ISR. */ \
|
||||
asm volatile ( "SUB R11, LR, #4" ); \
|
||||
{
|
||||
|
||||
#define portEXIT_SWITCHING_ISR( SwitchRequired ) \
|
||||
/* If a switch is required then we just need to call */ \
|
||||
/* vTaskSwitchContext() as the context has already been */ \
|
||||
/* saved. */ \
|
||||
if( SwitchRequired ) \
|
||||
{ \
|
||||
vTaskSwitchContext(); \
|
||||
} \
|
||||
} \
|
||||
/* Restore the context of which ever task is now the highest */ \
|
||||
/* priority that is ready to run. */ \
|
||||
portRESTORE_CONTEXT(); \
|
||||
} while( 0 )
|
||||
|
||||
#define portYIELD() asm volatile ( "SWI" );
|
||||
|
||||
/*
|
||||
* The interrupt management utilities can only be called from ARM mode. When
|
||||
* THUMB_INTERWORK is defined the utilities are defined as functions in
|
||||
* portISR.c to ensure a switch to ARM mode. When THUMB_INTERWORK is not
|
||||
* defined then the utilities are defined as macros here - as per other ports.
|
||||
*/
|
||||
#ifdef THUMB_INTERWORK
|
||||
|
||||
extern void vPortDisableInterruptsFromThumb( void ) __attribute__ ( ( naked ) );
|
||||
extern void vPortEnableInterruptsFromThumb( void ) __attribute__ ( ( naked ) );
|
||||
|
||||
#define portDISABLE_INTERRUPTS() vPortDisableInterruptsFromThumb()
|
||||
#define portENABLE_INTERRUPTS() vPortEnableInterruptsFromThumb()
|
||||
|
||||
#else
|
||||
|
||||
#define portDISABLE_INTERRUPTS() do { \
|
||||
asm volatile ( \
|
||||
"STMDB SP!, {R0}\n\t" /* Push R0. */ \
|
||||
"MRS R0, CPSR\n\t" /* Get CPSR. */ \
|
||||
"ORR R0, R0, #0xC0\n\t" /* Disable IRQ, FIQ. */ \
|
||||
"MSR CPSR, R0\n\t" /* Write back modified value. */ \
|
||||
"LDMIA SP!, {R0}" ); /* Pop R0. */ \
|
||||
} while( 0 )
|
||||
|
||||
#define portENABLE_INTERRUPTS() do { \
|
||||
asm volatile ( \
|
||||
"STMDB SP!, {R0}\n\t" /* Push R0. */ \
|
||||
"MRS R0, CPSR\n\t" /* Get CPSR. */ \
|
||||
"BIC R0, R0, #0xC0 \n\t" /* Enable IRQ, FIQ. */ \
|
||||
"MSR CPSR, R0\n\t" /* Write back modified value. */ \
|
||||
"LDMIA SP!, {R0}" ); /* Pop R0. */ \
|
||||
} while( 0 )
|
||||
#endif
|
||||
|
||||
extern void vPortEnterCritical( void );
|
||||
extern void vPortExitCritical( void );
|
||||
|
||||
#define portENTER_CRITICAL() vPortEnterCritical();
|
||||
#define portEXIT_CRITICAL() vPortExitCritical();
|
||||
|
||||
/* ----------------------- Defines (Other) ----------------------------------*/
|
||||
|
||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
||||
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
||||
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
|
||||
|
||||
#endif
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Changes between V2.5.1 and V2.5.1
|
||||
|
||||
+ The memory pool has been defined within a struct to ensure correct memory
|
||||
alignment on 32bit systems.
|
||||
|
||||
Changes between V2.6.1 and V3.0.0
|
||||
|
||||
+ An overflow check has been added to ensure the next free byte variable
|
||||
does not wrap around.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The simplest possible implementation of pvPortMalloc(). Note that this
|
||||
* implementation does NOT allow allocated memory to be freed again.
|
||||
*
|
||||
* See heap_2.c and heap_3.c for alternative implementations, and the memory
|
||||
* management pages of http://www.FreeRTOS.org for more information.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Setup the correct byte alignment mask for the defined byte alignment. */
|
||||
|
||||
#if portBYTE_ALIGNMENT == 8
|
||||
#define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0007 )
|
||||
#endif
|
||||
|
||||
#if portBYTE_ALIGNMENT == 4
|
||||
#define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0003 )
|
||||
#endif
|
||||
|
||||
#if portBYTE_ALIGNMENT == 2
|
||||
#define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0001 )
|
||||
#endif
|
||||
|
||||
#if portBYTE_ALIGNMENT == 1
|
||||
#define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0000 )
|
||||
#endif
|
||||
|
||||
#ifndef heapBYTE_ALIGNMENT_MASK
|
||||
#error "Invalid portBYTE_ALIGNMENT definition"
|
||||
#endif
|
||||
|
||||
/* Allocate the memory for the heap. The struct is used to force byte
|
||||
alignment without using any non-portable code. */
|
||||
static struct xRTOS_HEAP
|
||||
{
|
||||
unsigned portLONG ulDummy;
|
||||
unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ];
|
||||
} xHeap;
|
||||
|
||||
static size_t xNextFreeByte = ( size_t ) 0;
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void *pvPortMalloc( size_t xWantedSize )
|
||||
{
|
||||
void *pvReturn = NULL;
|
||||
|
||||
/* Ensure that blocks are always aligned to the required number of bytes. */
|
||||
#if portBYTE_ALIGNMENT != 1
|
||||
if( xWantedSize & heapBYTE_ALIGNMENT_MASK )
|
||||
{
|
||||
/* Byte alignment required. */
|
||||
xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & heapBYTE_ALIGNMENT_MASK ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
/* Check there is enough room left for the allocation. */
|
||||
if( ( ( xNextFreeByte + xWantedSize ) < configTOTAL_HEAP_SIZE ) &&
|
||||
( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) )/* Check for overflow. */
|
||||
{
|
||||
/* Return the next free byte then increment the index past this
|
||||
block. */
|
||||
pvReturn = &( xHeap.ucHeap[ xNextFreeByte ] );
|
||||
xNextFreeByte += xWantedSize;
|
||||
}
|
||||
}
|
||||
xTaskResumeAll();
|
||||
|
||||
return pvReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortFree( void *pv )
|
||||
{
|
||||
/* Memory cannot be freed using this scheme. See heap_2.c and heap_3.c
|
||||
for alternative implementations, and the memory management pages of
|
||||
http://www.FreeRTOS.org for more information. */
|
||||
( void ) pv;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortInitialiseBlocks( void )
|
||||
{
|
||||
/* Only required when static memory is not cleared. */
|
||||
xNextFreeByte = ( size_t ) 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,244 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* A sample implementation of pvPortMalloc() and vPortFree() that permits
|
||||
* allocated blocks to be freed, but does not combine adjacent free blocks
|
||||
* into a single larger block.
|
||||
*
|
||||
* See heap_1.c and heap_3.c for alternative implementations, and the memory
|
||||
* management pages of http://www.FreeRTOS.org for more information.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Setup the correct byte alignment mask for the defined byte alignment. */
|
||||
|
||||
#if portBYTE_ALIGNMENT == 8
|
||||
#define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0007 )
|
||||
#endif
|
||||
|
||||
#if portBYTE_ALIGNMENT == 4
|
||||
#define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0003 )
|
||||
#endif
|
||||
|
||||
#if portBYTE_ALIGNMENT == 2
|
||||
#define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0001 )
|
||||
#endif
|
||||
|
||||
#if portBYTE_ALIGNMENT == 1
|
||||
#define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0000 )
|
||||
#endif
|
||||
|
||||
#ifndef heapBYTE_ALIGNMENT_MASK
|
||||
#error "Invalid portBYTE_ALIGNMENT definition"
|
||||
#endif
|
||||
|
||||
/* Allocate the memory for the heap. The struct is used to force byte
|
||||
alignment without using any non-portable code. */
|
||||
static struct xRTOS_HEAP
|
||||
{
|
||||
unsigned portLONG ulDummy;
|
||||
unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ];
|
||||
} xHeap;
|
||||
|
||||
/* Define the linked list structure. This is used to link free blocks in order
|
||||
of their size. */
|
||||
typedef struct A_BLOCK_LINK
|
||||
{
|
||||
struct A_BLOCK_LINK *pxNextFreeBlock; /*<< The next free block in the list. */
|
||||
size_t xBlockSize; /*<< The size of the free block. */
|
||||
} xBlockLink;
|
||||
|
||||
|
||||
static const unsigned portSHORT heapSTRUCT_SIZE = ( sizeof( xBlockLink ) + ( sizeof( xBlockLink ) % portBYTE_ALIGNMENT ) );
|
||||
#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( heapSTRUCT_SIZE * 2 ) )
|
||||
|
||||
/* Create a couple of list links to mark the start and end of the list. */
|
||||
static xBlockLink xStart, xEnd;
|
||||
|
||||
/* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */
|
||||
|
||||
/*
|
||||
* Insert a block into the list of free blocks - which is ordered by size of
|
||||
* the block. Small blocks at the start of the list and large blocks at the end
|
||||
* of the list.
|
||||
*/
|
||||
#define prvInsertBlockIntoFreeList( pxBlockToInsert ) \
|
||||
{ \
|
||||
xBlockLink *pxIterator; \
|
||||
size_t xBlockSize; \
|
||||
\
|
||||
xBlockSize = pxBlockToInsert->xBlockSize; \
|
||||
\
|
||||
/* Iterate through the list until a block is found that has a larger size */ \
|
||||
/* than the block we are inserting. */ \
|
||||
for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock ) \
|
||||
{ \
|
||||
/* There is nothing to do here - just iterate to the correct position. */ \
|
||||
} \
|
||||
\
|
||||
/* Update the list to include the block being inserted in the correct */ \
|
||||
/* position. */ \
|
||||
pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; \
|
||||
pxIterator->pxNextFreeBlock = pxBlockToInsert; \
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define prvHeapInit() \
|
||||
{ \
|
||||
xBlockLink *pxFirstFreeBlock; \
|
||||
\
|
||||
/* xStart is used to hold a pointer to the first item in the list of free */ \
|
||||
/* blocks. The void cast is used to prevent compiler warnings. */ \
|
||||
xStart.pxNextFreeBlock = ( void * ) xHeap.ucHeap; \
|
||||
xStart.xBlockSize = ( size_t ) 0; \
|
||||
\
|
||||
/* xEnd is used to mark the end of the list of free blocks. */ \
|
||||
xEnd.xBlockSize = configTOTAL_HEAP_SIZE; \
|
||||
xEnd.pxNextFreeBlock = NULL; \
|
||||
\
|
||||
/* To start with there is a single free block that is sized to take up the \
|
||||
entire heap space. */ \
|
||||
pxFirstFreeBlock = ( void * ) xHeap.ucHeap; \
|
||||
pxFirstFreeBlock->xBlockSize = configTOTAL_HEAP_SIZE; \
|
||||
pxFirstFreeBlock->pxNextFreeBlock = &xEnd; \
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void *pvPortMalloc( size_t xWantedSize )
|
||||
{
|
||||
xBlockLink *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
|
||||
static portBASE_TYPE xHeapHasBeenInitialised = pdFALSE;
|
||||
void *pvReturn = NULL;
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
/* If this is the first call to malloc then the heap will require
|
||||
initialisation to setup the list of free blocks. */
|
||||
if( xHeapHasBeenInitialised == pdFALSE )
|
||||
{
|
||||
prvHeapInit();
|
||||
xHeapHasBeenInitialised = pdTRUE;
|
||||
}
|
||||
|
||||
/* The wanted size is increased so it can contain a xBlockLink
|
||||
structure in addition to the requested amount of bytes. */
|
||||
if( xWantedSize > 0 )
|
||||
{
|
||||
xWantedSize += heapSTRUCT_SIZE;
|
||||
|
||||
/* Ensure that blocks are always aligned to the required number of bytes. */
|
||||
if( xWantedSize & heapBYTE_ALIGNMENT_MASK )
|
||||
{
|
||||
/* Byte alignment required. */
|
||||
xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & heapBYTE_ALIGNMENT_MASK ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( ( xWantedSize > 0 ) && ( xWantedSize < configTOTAL_HEAP_SIZE ) )
|
||||
{
|
||||
/* Blocks are stored in byte order - traverse the list from the start
|
||||
(smallest) block until one of adequate size is found. */
|
||||
pxPreviousBlock = &xStart;
|
||||
pxBlock = xStart.pxNextFreeBlock;
|
||||
while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock ) )
|
||||
{
|
||||
pxPreviousBlock = pxBlock;
|
||||
pxBlock = pxBlock->pxNextFreeBlock;
|
||||
}
|
||||
|
||||
/* If we found the end marker then a block of adequate size was not found. */
|
||||
if( pxBlock != &xEnd )
|
||||
{
|
||||
/* Return the memory space - jumping over the xBlockLink structure
|
||||
at its start. */
|
||||
pvReturn = ( void * ) ( ( ( unsigned portCHAR * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE );
|
||||
|
||||
/* This block is being returned for use so must be taken our of the
|
||||
list of free blocks. */
|
||||
pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;
|
||||
|
||||
/* If the block is larger than required it can be split into two. */
|
||||
if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )
|
||||
{
|
||||
/* This block is to be split into two. Create a new block
|
||||
following the number of bytes requested. The void cast is
|
||||
used to prevent byte alignment warnings from the compiler. */
|
||||
pxNewBlockLink = ( void * ) ( ( ( unsigned portCHAR * ) pxBlock ) + xWantedSize );
|
||||
|
||||
/* Calculate the sizes of two blocks split from the single
|
||||
block. */
|
||||
pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;
|
||||
pxBlock->xBlockSize = xWantedSize;
|
||||
|
||||
/* Insert the new block into the list of free blocks. */
|
||||
prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
xTaskResumeAll();
|
||||
|
||||
return pvReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortFree( void *pv )
|
||||
{
|
||||
unsigned portCHAR *puc = ( unsigned portCHAR * ) pv;
|
||||
xBlockLink *pxLink;
|
||||
|
||||
if( pv )
|
||||
{
|
||||
/* The memory being freed will have an xBlockLink structure immediately
|
||||
before it. */
|
||||
puc -= heapSTRUCT_SIZE;
|
||||
|
||||
/* This casting is to keep the compiler from issuing warnings. */
|
||||
pxLink = ( void * ) puc;
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
/* Add this block to the list of free blocks. */
|
||||
prvInsertBlockIntoFreeList( ( ( xBlockLink * ) pxLink ) );
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Implementation of pvPortMalloc() and vPortFree() that relies on the
|
||||
* compilers own malloc() and free() implementations.
|
||||
*
|
||||
* This file can only be used if the linker is configured to to generate
|
||||
* a heap memory area.
|
||||
*
|
||||
* See heap_2.c and heap_1.c for alternative implementations, and the memory
|
||||
* management pages of http://www.FreeRTOS.org for more information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void *pvPortMalloc( size_t xWantedSize )
|
||||
{
|
||||
void *pvReturn;
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
pvReturn = malloc( xWantedSize );
|
||||
}
|
||||
xTaskResumeAll();
|
||||
|
||||
return pvReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortFree( void *pv )
|
||||
{
|
||||
if( pv )
|
||||
{
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
free( pv );
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,930 +0,0 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FreeRTOS.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
|
||||
with commercial development and support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V1.01
|
||||
|
||||
+ More use of 8bit data types.
|
||||
+ Function name prefixes changed where the data type returned has changed.
|
||||
|
||||
Changed from V2.0.0
|
||||
|
||||
+ Added the queue locking mechanism and make more use of the scheduler
|
||||
suspension feature to minimise the time interrupts have to be disabled
|
||||
when accessing a queue.
|
||||
|
||||
Changed from V2.2.0
|
||||
|
||||
+ Explicit use of 'signed' qualifier on portCHAR types added.
|
||||
|
||||
Changes from V3.0.0
|
||||
|
||||
+ API changes as described on the FreeRTOS.org WEB site.
|
||||
|
||||
Changes from V3.2.3
|
||||
|
||||
+ Added the queue functions that can be used from co-routines.
|
||||
|
||||
Changes from V4.0.5
|
||||
|
||||
+ Added a loop within xQueueSend() and xQueueReceive() to prevent the
|
||||
functions exiting when a block time remains and the function has
|
||||
not completed.
|
||||
|
||||
Changes from V4.1.2:
|
||||
|
||||
+ BUG FIX: Removed the call to prvIsQueueEmpty from within xQueueCRReceive
|
||||
as it exited with interrupts enabled. Thanks Paul Katz.
|
||||
|
||||
Changes from V4.1.3:
|
||||
|
||||
+ Modified xQueueSend() and xQueueReceive() to handle the (very unlikely)
|
||||
case whereby a task unblocking due to a temporal event can remove/send an
|
||||
item from/to a queue when a higher priority task is still blocked on the
|
||||
queue. This modification is a result of the SafeRTOS testing.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "croutine.h"
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* PUBLIC LIST API documented in list.h
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/* Constants used with the cRxLock and cTxLock structure members. */
|
||||
#define queueUNLOCKED ( ( signed portBASE_TYPE ) -1 )
|
||||
#define queueERRONEOUS_UNBLOCK ( -1 )
|
||||
|
||||
/*
|
||||
* Definition of the queue used by the scheduler.
|
||||
* Items are queued by copy, not reference.
|
||||
*/
|
||||
typedef struct QueueDefinition
|
||||
{
|
||||
signed portCHAR *pcHead; /*< Points to the beginning of the queue storage area. */
|
||||
signed portCHAR *pcTail; /*< Points to the byte at the end of the queue storage area. Once more byte is allocated than necessary to store the queue items, this is used as a marker. */
|
||||
|
||||
signed portCHAR *pcWriteTo; /*< Points to the free next place in the storage area. */
|
||||
signed portCHAR *pcReadFrom; /*< Points to the last place that a queued item was read from. */
|
||||
|
||||
xList xTasksWaitingToSend; /*< List of tasks that are blocked waiting to post onto this queue. Stored in priority order. */
|
||||
xList xTasksWaitingToReceive; /*< List of tasks that are blocked waiting to read from this queue. Stored in priority order. */
|
||||
|
||||
unsigned portBASE_TYPE uxMessagesWaiting;/*< The number of items currently in the queue. */
|
||||
unsigned portBASE_TYPE uxLength; /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */
|
||||
unsigned portBASE_TYPE uxItemSize; /*< The size of each items that the queue will hold. */
|
||||
|
||||
signed portBASE_TYPE xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */
|
||||
signed portBASE_TYPE xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */
|
||||
} xQUEUE;
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Inside this file xQueueHandle is a pointer to a xQUEUE structure.
|
||||
* To keep the definition private the API header file defines it as a
|
||||
* pointer to void.
|
||||
*/
|
||||
typedef xQUEUE * xQueueHandle;
|
||||
|
||||
/*
|
||||
* Prototypes for public functions are included here so we don't have to
|
||||
* include the API header file (as it defines xQueueHandle differently). These
|
||||
* functions are documented in the API header file.
|
||||
*/
|
||||
xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize );
|
||||
signed portBASE_TYPE xQueueSend( xQueueHandle xQueue, const void * pvItemToQueue, portTickType xTicksToWait );
|
||||
unsigned portBASE_TYPE uxQueueMessagesWaiting( xQueueHandle pxQueue );
|
||||
void vQueueDelete( xQueueHandle xQueue );
|
||||
signed portBASE_TYPE xQueueSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xTaskPreviouslyWoken );
|
||||
signed portBASE_TYPE xQueueReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait );
|
||||
signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken );
|
||||
|
||||
#if configUSE_CO_ROUTINES == 1
|
||||
signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken );
|
||||
signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken );
|
||||
signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait );
|
||||
signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Unlocks a queue locked by a call to prvLockQueue. Locking a queue does not
|
||||
* prevent an ISR from adding or removing items to the queue, but does prevent
|
||||
* an ISR from removing tasks from the queue event lists. If an ISR finds a
|
||||
* queue is locked it will instead increment the appropriate queue lock count
|
||||
* to indicate that a task may require unblocking. When the queue in unlocked
|
||||
* these lock counts are inspected, and the appropriate action taken.
|
||||
*/
|
||||
static void prvUnlockQueue( xQueueHandle pxQueue );
|
||||
|
||||
/*
|
||||
* Uses a critical section to determine if there is any data in a queue.
|
||||
*
|
||||
* @return pdTRUE if the queue contains no items, otherwise pdFALSE.
|
||||
*/
|
||||
static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue );
|
||||
|
||||
/*
|
||||
* Uses a critical section to determine if there is any space in a queue.
|
||||
*
|
||||
* @return pdTRUE if there is no space, otherwise pdFALSE;
|
||||
*/
|
||||
static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue );
|
||||
|
||||
/*
|
||||
* Macro that copies an item into the queue. This is done by copying the item
|
||||
* byte for byte, not by reference. Updates the queue state to ensure it's
|
||||
* integrity after the copy.
|
||||
*/
|
||||
#define prvCopyQueueData( pxQueue, pvItemToQueue ) \
|
||||
{ \
|
||||
memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize ); \
|
||||
++( pxQueue->uxMessagesWaiting ); \
|
||||
pxQueue->pcWriteTo += pxQueue->uxItemSize; \
|
||||
if( pxQueue->pcWriteTo >= pxQueue->pcTail ) \
|
||||
{ \
|
||||
pxQueue->pcWriteTo = pxQueue->pcHead; \
|
||||
} \
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Macro to mark a queue as locked. Locking a queue prevents an ISR from
|
||||
* accessing the queue event lists.
|
||||
*/
|
||||
#define prvLockQueue( pxQueue ) \
|
||||
{ \
|
||||
taskENTER_CRITICAL(); \
|
||||
++( pxQueue->xRxLock ); \
|
||||
++( pxQueue->xTxLock ); \
|
||||
taskEXIT_CRITICAL(); \
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* PUBLIC QUEUE MANAGEMENT API documented in queue.h
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize )
|
||||
{
|
||||
xQUEUE *pxNewQueue;
|
||||
size_t xQueueSizeInBytes;
|
||||
|
||||
/* Allocate the new queue structure. */
|
||||
if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) );
|
||||
if( pxNewQueue != NULL )
|
||||
{
|
||||
/* Create the list of pointers to queue items. The queue is one byte
|
||||
longer than asked for to make wrap checking easier/faster. */
|
||||
xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1;
|
||||
|
||||
pxNewQueue->pcHead = ( signed portCHAR * ) pvPortMalloc( xQueueSizeInBytes );
|
||||
if( pxNewQueue->pcHead != NULL )
|
||||
{
|
||||
/* Initialise the queue members as described above where the
|
||||
queue type is defined. */
|
||||
pxNewQueue->pcTail = pxNewQueue->pcHead + ( uxQueueLength * uxItemSize );
|
||||
pxNewQueue->uxMessagesWaiting = 0;
|
||||
pxNewQueue->pcWriteTo = pxNewQueue->pcHead;
|
||||
pxNewQueue->pcReadFrom = pxNewQueue->pcHead + ( ( uxQueueLength - 1 ) * uxItemSize );
|
||||
pxNewQueue->uxLength = uxQueueLength;
|
||||
pxNewQueue->uxItemSize = uxItemSize;
|
||||
pxNewQueue->xRxLock = queueUNLOCKED;
|
||||
pxNewQueue->xTxLock = queueUNLOCKED;
|
||||
|
||||
/* Likewise ensure the event queues start with the correct state. */
|
||||
vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );
|
||||
vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );
|
||||
|
||||
return pxNewQueue;
|
||||
}
|
||||
else
|
||||
{
|
||||
vPortFree( pxNewQueue );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Will only reach here if we could not allocate enough memory or no memory
|
||||
was required. */
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xQueueSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait )
|
||||
{
|
||||
signed portBASE_TYPE xReturn = pdPASS;
|
||||
xTimeOutType xTimeOut;
|
||||
|
||||
/* Make sure other tasks do not access the queue. */
|
||||
vTaskSuspendAll();
|
||||
|
||||
/* Capture the current time status for future reference. */
|
||||
vTaskSetTimeOutState( &xTimeOut );
|
||||
|
||||
/* It is important that this is the only thread/ISR that modifies the
|
||||
ready or delayed lists until xTaskResumeAll() is called. Places where
|
||||
the ready/delayed lists are modified include:
|
||||
|
||||
+ vTaskDelay() - Nothing can call vTaskDelay as the scheduler is
|
||||
suspended, vTaskDelay() cannot be called from an ISR.
|
||||
+ vTaskPrioritySet() - Has a critical section around the access.
|
||||
+ vTaskSwitchContext() - This will not get executed while the scheduler
|
||||
is suspended.
|
||||
+ prvCheckDelayedTasks() - This will not get executed while the
|
||||
scheduler is suspended.
|
||||
+ xTaskCreate() - Has a critical section around the access.
|
||||
+ vTaskResume() - Has a critical section around the access.
|
||||
+ xTaskResumeAll() - Has a critical section around the access.
|
||||
+ xTaskRemoveFromEventList - Checks to see if the scheduler is
|
||||
suspended. If so then the TCB being removed from the event is
|
||||
removed from the event and added to the xPendingReadyList.
|
||||
*/
|
||||
|
||||
/* Make sure interrupts do not access the queue event list. */
|
||||
prvLockQueue( pxQueue );
|
||||
|
||||
/* It is important that interrupts to not access the event list of the
|
||||
queue being modified here. Places where the event list is modified
|
||||
include:
|
||||
|
||||
+ xQueueSendFromISR(). This checks the lock on the queue to see if
|
||||
it has access. If the queue is locked then the Tx lock count is
|
||||
incremented to signify that a task waiting for data can be made ready
|
||||
once the queue lock is removed. If the queue is not locked then
|
||||
a task can be moved from the event list, but will not be removed
|
||||
from the delayed list or placed in the ready list until the scheduler
|
||||
is unlocked.
|
||||
|
||||
+ xQueueReceiveFromISR(). As per xQueueSendFromISR().
|
||||
*/
|
||||
|
||||
/* If the queue is already full we may have to block. */
|
||||
do
|
||||
{
|
||||
if( prvIsQueueFull( pxQueue ) )
|
||||
{
|
||||
/* The queue is full - do we want to block or just leave without
|
||||
posting? */
|
||||
if( xTicksToWait > ( portTickType ) 0 )
|
||||
{
|
||||
/* We are going to place ourselves on the xTasksWaitingToSend event
|
||||
list, and will get woken should the delay expire, or space become
|
||||
available on the queue.
|
||||
|
||||
As detailed above we do not require mutual exclusion on the event
|
||||
list as nothing else can modify it or the ready lists while we
|
||||
have the scheduler suspended and queue locked.
|
||||
|
||||
It is possible that an ISR has removed data from the queue since we
|
||||
checked if any was available. If this is the case then the data
|
||||
will have been copied from the queue, and the queue variables
|
||||
updated, but the event list will not yet have been checked to see if
|
||||
anything is waiting as the queue is locked. */
|
||||
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
|
||||
|
||||
/* Force a context switch now as we are blocked. We can do
|
||||
this from within a critical section as the task we are
|
||||
switching to has its own context. When we return here (i.e. we
|
||||
unblock) we will leave the critical section as normal.
|
||||
|
||||
It is possible that an ISR has caused an event on an unrelated and
|
||||
unlocked queue. If this was the case then the event list for that
|
||||
queue will have been updated but the ready lists left unchanged -
|
||||
instead the readied task will have been added to the pending ready
|
||||
list. */
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
/* We can safely unlock the queue and scheduler here as
|
||||
interrupts are disabled. We must not yield with anything
|
||||
locked, but we can yield from within a critical section.
|
||||
|
||||
Tasks that have been placed on the pending ready list cannot
|
||||
be tasks that are waiting for events on this queue. See
|
||||
in comment xTaskRemoveFromEventList(). */
|
||||
prvUnlockQueue( pxQueue );
|
||||
|
||||
/* Resuming the scheduler may cause a yield. If so then there
|
||||
is no point yielding again here. */
|
||||
if( !xTaskResumeAll() )
|
||||
{
|
||||
taskYIELD();
|
||||
}
|
||||
|
||||
/* We want to check to see if the queue is still full
|
||||
before leaving the critical section. This is to prevent
|
||||
this task placing an item into the queue due to an
|
||||
interrupt making space on the queue between critical
|
||||
sections (when there might be a higher priority task
|
||||
blocked on the queue that cannot run yet because the
|
||||
scheduler gets suspended). */
|
||||
if( pxQueue->uxMessagesWaiting == pxQueue->uxLength )
|
||||
{
|
||||
/* We unblocked but there is no space in the queue,
|
||||
we probably timed out. */
|
||||
xReturn = errQUEUE_FULL;
|
||||
}
|
||||
|
||||
/* Before leaving the critical section we have to ensure
|
||||
exclusive access again. */
|
||||
vTaskSuspendAll();
|
||||
prvLockQueue( pxQueue );
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
|
||||
/* If xReturn is errQUEUE_FULL then we unblocked when the queue
|
||||
was still full. Don't check it again now as it is possible that
|
||||
an interrupt has removed an item from the queue since we left the
|
||||
critical section and we don't want to write to the queue in case
|
||||
there is a task of higher priority blocked waiting for space to
|
||||
be available on the queue. If this is the case the higher priority
|
||||
task will execute when the scheduler is unsupended. */
|
||||
if( xReturn != errQUEUE_FULL )
|
||||
{
|
||||
/* When we are here it is possible that we unblocked as space became
|
||||
available on the queue. It is also possible that an ISR posted to the
|
||||
queue since we left the critical section, so it may be that again there
|
||||
is no space. This would only happen if a task and ISR post onto the
|
||||
same queue. */
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
|
||||
{
|
||||
/* There is room in the queue, copy the data into the queue. */
|
||||
prvCopyQueueData( pxQueue, pvItemToQueue );
|
||||
xReturn = pdPASS;
|
||||
|
||||
/* Update the TxLock count so prvUnlockQueue knows to check for
|
||||
tasks waiting for data to become available in the queue. */
|
||||
++( pxQueue->xTxLock );
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = errQUEUE_FULL;
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
if( xReturn == errQUEUE_FULL )
|
||||
{
|
||||
if( xTicksToWait > 0 )
|
||||
{
|
||||
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
||||
{
|
||||
xReturn = queueERRONEOUS_UNBLOCK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while( xReturn == queueERRONEOUS_UNBLOCK );
|
||||
|
||||
prvUnlockQueue( pxQueue );
|
||||
xTaskResumeAll();
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xQueueSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xTaskPreviouslyWoken )
|
||||
{
|
||||
/* Similar to xQueueSend, except we don't block if there is no room in the
|
||||
queue. Also we don't directly wake a task that was blocked on a queue
|
||||
read, instead we return a flag to say whether a context switch is required
|
||||
or not (i.e. has a task with a higher priority than us been woken by this
|
||||
post). */
|
||||
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
|
||||
{
|
||||
prvCopyQueueData( pxQueue, pvItemToQueue );
|
||||
|
||||
/* If the queue is locked we do not alter the event list. This will
|
||||
be done when the queue is unlocked later. */
|
||||
if( pxQueue->xTxLock == queueUNLOCKED )
|
||||
{
|
||||
/* We only want to wake one task per ISR, so check that a task has
|
||||
not already been woken. */
|
||||
if( !xTaskPreviouslyWoken )
|
||||
{
|
||||
if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )
|
||||
{
|
||||
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
|
||||
{
|
||||
/* The task waiting has a higher priority so record that a
|
||||
context switch is required. */
|
||||
return pdTRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Increment the lock count so the task that unlocks the queue
|
||||
knows that data was posted while it was locked. */
|
||||
++( pxQueue->xTxLock );
|
||||
}
|
||||
}
|
||||
|
||||
return xTaskPreviouslyWoken;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xQueueReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait )
|
||||
{
|
||||
signed portBASE_TYPE xReturn = pdTRUE;
|
||||
xTimeOutType xTimeOut;
|
||||
|
||||
/* This function is very similar to xQueueSend(). See comments within
|
||||
xQueueSend() for a more detailed explanation.
|
||||
|
||||
Make sure other tasks do not access the queue. */
|
||||
vTaskSuspendAll();
|
||||
|
||||
/* Capture the current time status for future reference. */
|
||||
vTaskSetTimeOutState( &xTimeOut );
|
||||
|
||||
/* Make sure interrupts do not access the queue. */
|
||||
prvLockQueue( pxQueue );
|
||||
|
||||
do
|
||||
{
|
||||
/* If there are no messages in the queue we may have to block. */
|
||||
if( prvIsQueueEmpty( pxQueue ) )
|
||||
{
|
||||
/* There are no messages in the queue, do we want to block or just
|
||||
leave with nothing? */
|
||||
if( xTicksToWait > ( portTickType ) 0 )
|
||||
{
|
||||
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
prvUnlockQueue( pxQueue );
|
||||
if( !xTaskResumeAll() )
|
||||
{
|
||||
taskYIELD();
|
||||
}
|
||||
|
||||
if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
/* We unblocked but the queue is empty. We probably
|
||||
timed out. */
|
||||
xReturn = errQUEUE_EMPTY;
|
||||
}
|
||||
|
||||
vTaskSuspendAll();
|
||||
prvLockQueue( pxQueue );
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
|
||||
if( xReturn != errQUEUE_EMPTY )
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
pxQueue->pcReadFrom += pxQueue->uxItemSize;
|
||||
if( pxQueue->pcReadFrom >= pxQueue->pcTail )
|
||||
{
|
||||
pxQueue->pcReadFrom = pxQueue->pcHead;
|
||||
}
|
||||
--( pxQueue->uxMessagesWaiting );
|
||||
memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
|
||||
|
||||
/* Increment the lock count so prvUnlockQueue knows to check for
|
||||
tasks waiting for space to become available on the queue. */
|
||||
++( pxQueue->xRxLock );
|
||||
xReturn = pdPASS;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = errQUEUE_EMPTY;
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
if( xReturn == errQUEUE_EMPTY )
|
||||
{
|
||||
if( xTicksToWait > 0 )
|
||||
{
|
||||
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
||||
{
|
||||
xReturn = queueERRONEOUS_UNBLOCK;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while( xReturn == queueERRONEOUS_UNBLOCK );
|
||||
|
||||
/* We no longer require exclusive access to the queue. */
|
||||
prvUnlockQueue( pxQueue );
|
||||
xTaskResumeAll();
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken )
|
||||
{
|
||||
signed portBASE_TYPE xReturn;
|
||||
|
||||
/* We cannot block from an ISR, so check there is data available. */
|
||||
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
/* Copy the data from the queue. */
|
||||
pxQueue->pcReadFrom += pxQueue->uxItemSize;
|
||||
if( pxQueue->pcReadFrom >= pxQueue->pcTail )
|
||||
{
|
||||
pxQueue->pcReadFrom = pxQueue->pcHead;
|
||||
}
|
||||
--( pxQueue->uxMessagesWaiting );
|
||||
memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
|
||||
|
||||
/* If the queue is locked we will not modify the event list. Instead
|
||||
we update the lock count so the task that unlocks the queue will know
|
||||
that an ISR has removed data while the queue was locked. */
|
||||
if( pxQueue->xRxLock == queueUNLOCKED )
|
||||
{
|
||||
/* We only want to wake one task per ISR, so check that a task has
|
||||
not already been woken. */
|
||||
if( !( *pxTaskWoken ) )
|
||||
{
|
||||
if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) )
|
||||
{
|
||||
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
|
||||
{
|
||||
/* The task waiting has a higher priority than us so
|
||||
force a context switch. */
|
||||
*pxTaskWoken = pdTRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Increment the lock count so the task that unlocks the queue
|
||||
knows that data was removed while it was locked. */
|
||||
++( pxQueue->xRxLock );
|
||||
}
|
||||
|
||||
xReturn = pdPASS;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = pdFAIL;
|
||||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
unsigned portBASE_TYPE uxQueueMessagesWaiting( xQueueHandle pxQueue )
|
||||
{
|
||||
unsigned portBASE_TYPE uxReturn;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
uxReturn = pxQueue->uxMessagesWaiting;
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
return uxReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vQueueDelete( xQueueHandle pxQueue )
|
||||
{
|
||||
vPortFree( pxQueue->pcHead );
|
||||
vPortFree( pxQueue );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvUnlockQueue( xQueueHandle pxQueue )
|
||||
{
|
||||
/* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. */
|
||||
|
||||
/* The lock counts contains the number of extra data items placed or
|
||||
removed from the queue while the queue was locked. When a queue is
|
||||
locked items can be added or removed, but the event lists cannot be
|
||||
updated. */
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
--( pxQueue->xTxLock );
|
||||
|
||||
/* See if data was added to the queue while it was locked. */
|
||||
if( pxQueue->xTxLock > queueUNLOCKED )
|
||||
{
|
||||
pxQueue->xTxLock = queueUNLOCKED;
|
||||
|
||||
/* Data was posted while the queue was locked. Are any tasks
|
||||
blocked waiting for data to become available? */
|
||||
if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )
|
||||
{
|
||||
/* Tasks that are removed from the event list will get added to
|
||||
the pending ready list as the scheduler is still suspended. */
|
||||
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
|
||||
{
|
||||
/* The task waiting has a higher priority so record that a
|
||||
context switch is required. */
|
||||
vTaskMissedYield();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
/* Do the same for the Rx lock. */
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
--( pxQueue->xRxLock );
|
||||
|
||||
if( pxQueue->xRxLock > queueUNLOCKED )
|
||||
{
|
||||
pxQueue->xRxLock = queueUNLOCKED;
|
||||
|
||||
if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) )
|
||||
{
|
||||
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
|
||||
{
|
||||
vTaskMissedYield();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue )
|
||||
{
|
||||
signed portBASE_TYPE xReturn;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
xReturn = ( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 );
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue )
|
||||
{
|
||||
signed portBASE_TYPE xReturn;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
xReturn = ( pxQueue->uxMessagesWaiting == pxQueue->uxLength );
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if configUSE_CO_ROUTINES == 1
|
||||
signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait )
|
||||
{
|
||||
signed portBASE_TYPE xReturn;
|
||||
|
||||
/* If the queue is already full we may have to block. A critical section
|
||||
is required to prevent an interrupt removing something from the queue
|
||||
between the check to see if the queue is full and blocking on the queue. */
|
||||
portDISABLE_INTERRUPTS();
|
||||
{
|
||||
if( prvIsQueueFull( pxQueue ) )
|
||||
{
|
||||
/* The queue is full - do we want to block or just leave without
|
||||
posting? */
|
||||
if( xTicksToWait > ( portTickType ) 0 )
|
||||
{
|
||||
/* As this is called from a coroutine we cannot block directly, but
|
||||
return indicating that we need to block. */
|
||||
vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) );
|
||||
portENABLE_INTERRUPTS();
|
||||
return errQUEUE_BLOCKED;
|
||||
}
|
||||
else
|
||||
{
|
||||
portENABLE_INTERRUPTS();
|
||||
return errQUEUE_FULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
portENABLE_INTERRUPTS();
|
||||
|
||||
portNOP();
|
||||
|
||||
portDISABLE_INTERRUPTS();
|
||||
{
|
||||
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
|
||||
{
|
||||
/* There is room in the queue, copy the data into the queue. */
|
||||
prvCopyQueueData( pxQueue, pvItemToQueue );
|
||||
xReturn = pdPASS;
|
||||
|
||||
/* Were any co-routines waiting for data to become available? */
|
||||
if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )
|
||||
{
|
||||
/* In this instance the co-routine could be placed directly
|
||||
into the ready list as we are within a critical section.
|
||||
Instead the same pending ready list mechansim is used as if
|
||||
the event were caused from within an interrupt. */
|
||||
if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
|
||||
{
|
||||
/* The co-routine waiting has a higher priority so record
|
||||
that a yield might be appropriate. */
|
||||
xReturn = errQUEUE_YIELD;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = errQUEUE_FULL;
|
||||
}
|
||||
}
|
||||
portENABLE_INTERRUPTS();
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if configUSE_CO_ROUTINES == 1
|
||||
signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait )
|
||||
{
|
||||
signed portBASE_TYPE xReturn;
|
||||
|
||||
/* If the queue is already empty we may have to block. A critical section
|
||||
is required to prevent an interrupt adding something to the queue
|
||||
between the check to see if the queue is empty and blocking on the queue. */
|
||||
portDISABLE_INTERRUPTS();
|
||||
{
|
||||
if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
/* There are no messages in the queue, do we want to block or just
|
||||
leave with nothing? */
|
||||
if( xTicksToWait > ( portTickType ) 0 )
|
||||
{
|
||||
/* As this is a co-routine we cannot block directly, but return
|
||||
indicating that we need to block. */
|
||||
vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToReceive ) );
|
||||
portENABLE_INTERRUPTS();
|
||||
return errQUEUE_BLOCKED;
|
||||
}
|
||||
else
|
||||
{
|
||||
portENABLE_INTERRUPTS();
|
||||
return errQUEUE_FULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
portENABLE_INTERRUPTS();
|
||||
|
||||
portNOP();
|
||||
|
||||
portDISABLE_INTERRUPTS();
|
||||
{
|
||||
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
/* Data is available from the queue. */
|
||||
pxQueue->pcReadFrom += pxQueue->uxItemSize;
|
||||
if( pxQueue->pcReadFrom >= pxQueue->pcTail )
|
||||
{
|
||||
pxQueue->pcReadFrom = pxQueue->pcHead;
|
||||
}
|
||||
--( pxQueue->uxMessagesWaiting );
|
||||
memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
|
||||
|
||||
xReturn = pdPASS;
|
||||
|
||||
/* Were any co-routines waiting for space to become available? */
|
||||
if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) )
|
||||
{
|
||||
/* In this instance the co-routine could be placed directly
|
||||
into the ready list as we are within a critical section.
|
||||
Instead the same pending ready list mechansim is used as if
|
||||
the event were caused from within an interrupt. */
|
||||
if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
|
||||
{
|
||||
xReturn = errQUEUE_YIELD;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = pdFAIL;
|
||||
}
|
||||
}
|
||||
portENABLE_INTERRUPTS();
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
#if configUSE_CO_ROUTINES == 1
|
||||
signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken )
|
||||
{
|
||||
/* Cannot block within an ISR so if there is no space on the queue then
|
||||
exit without doing anything. */
|
||||
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
|
||||
{
|
||||
prvCopyQueueData( pxQueue, pvItemToQueue );
|
||||
|
||||
/* We only want to wake one co-routine per ISR, so check that a
|
||||
co-routine has not already been woken. */
|
||||
if( !xCoRoutinePreviouslyWoken )
|
||||
{
|
||||
if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )
|
||||
{
|
||||
if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
|
||||
{
|
||||
return pdTRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return xCoRoutinePreviouslyWoken;
|
||||
}
|
||||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if configUSE_CO_ROUTINES == 1
|
||||
signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxCoRoutineWoken )
|
||||
{
|
||||
signed portBASE_TYPE xReturn;
|
||||
|
||||
/* We cannot block from an ISR, so check there is data available. If
|
||||
not then just leave without doing anything. */
|
||||
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
|
||||
{
|
||||
/* Copy the data from the queue. */
|
||||
pxQueue->pcReadFrom += pxQueue->uxItemSize;
|
||||
if( pxQueue->pcReadFrom >= pxQueue->pcTail )
|
||||
{
|
||||
pxQueue->pcReadFrom = pxQueue->pcHead;
|
||||
}
|
||||
--( pxQueue->uxMessagesWaiting );
|
||||
memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
|
||||
|
||||
if( !( *pxCoRoutineWoken ) )
|
||||
{
|
||||
if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) )
|
||||
{
|
||||
if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
|
||||
{
|
||||
*pxCoRoutineWoken = pdTRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xReturn = pdPASS;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = pdFAIL;
|
||||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* MODBUS Slave Library: A portable MODBUS slave for MODBUS ASCII/RTU/TCP.
|
||||
* Copyright (c) 2007 Christian Walter <wolti@sil.at>
|
||||
* All rights reserved.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
|
||||
#define vPortYieldProcessor swi_handler
|
||||
|
||||
#define configUSE_PREEMPTION ( 1 )
|
||||
#define configUSE_IDLE_HOOK ( 0 )
|
||||
#define configUSE_TICK_HOOK ( 1 )
|
||||
#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 48054857UL )
|
||||
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 128 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) 2048 )
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
#define configUSE_TRACE_FACILITY ( 1 )
|
||||
#define configUSE_16_BIT_TICKS ( 0 )
|
||||
#define configIDLE_SHOULD_YIELD ( 1 )
|
||||
#define configUSE_CO_ROUTINES ( 0 )
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
#define INCLUDE_vTaskPrioritySet ( 1 )
|
||||
#define INCLUDE_uxTaskPriorityGet ( 1 )
|
||||
#define INCLUDE_vTaskDelete ( 1 )
|
||||
#define INCLUDE_vTaskCleanUpResources ( 0 )
|
||||
#define INCLUDE_vTaskSuspend ( 1 )
|
||||
#define INCLUDE_vTaskDelayUntil ( 1 )
|
||||
#define INCLUDE_vTaskDelay ( 1 )
|
||||
#define INCLUDE_xTaskGetCurrentTaskHandle ( 1 )
|
||||
|
||||
#endif
|
||||
|
|
@ -1,187 +0,0 @@
|
|||
/*
|
||||
* FreeModbus Libary: ARM7 Demo Application
|
||||
* Copyright (C) 2006 Christian Walter <wolti@sil.at>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id$
|
||||
*/
|
||||
|
||||
/* ----------------------- System includes ----------------------------------*/
|
||||
#include "assert.h"
|
||||
|
||||
/* ----------------------- Platform includes --------------------------------*/
|
||||
#include "support/AT91SAM7X256.h"
|
||||
#include "support/lib_AT91SAM7X256.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* ----------------------- Modbus includes ----------------------------------*/
|
||||
#include "mb.h"
|
||||
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
#define REG_HOLDING_START 0x1000
|
||||
#define REG_HOLDING_NREGS 130
|
||||
#define REG_INPUT_START 0x1000
|
||||
#define REG_INPUT_NREGS 4
|
||||
|
||||
/* ----------------------- Static variables ---------------------------------*/
|
||||
static USHORT usRegHoldingStart = REG_HOLDING_START;
|
||||
static USHORT usRegHoldingBuf[REG_HOLDING_NREGS];
|
||||
static USHORT usRegInputStart = REG_INPUT_START;
|
||||
static USHORT usRegInputBuf[REG_INPUT_NREGS];
|
||||
|
||||
/* ----------------------- Static functions ---------------------------------*/
|
||||
STATIC void vModbusTask( void *pvParameters );
|
||||
STATIC void vSetupHardware( void );
|
||||
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
int
|
||||
main( void )
|
||||
{
|
||||
vSetupHardware( );
|
||||
|
||||
( void )xTaskCreate( vModbusTask, NULL, configMINIMAL_STACK_SIZE, NULL,
|
||||
tskIDLE_PRIORITY, NULL );
|
||||
|
||||
vTaskStartScheduler( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
vModbusTask( void *pvParameters )
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Select either ASCII or RTU Mode. */
|
||||
( void )eMBInit( MB_RTU, 0x0A, 0, 38400, MB_PAR_EVEN );
|
||||
|
||||
/* Initialize the holding register values before starting the
|
||||
* Modbus stack
|
||||
*/
|
||||
for( i = 0; i < REG_HOLDING_NREGS; i++ )
|
||||
{
|
||||
usRegHoldingBuf[i] = ( unsigned short )i;
|
||||
}
|
||||
/* Initialize the input register values before starting the
|
||||
* Modbus stack
|
||||
*/
|
||||
for( i = 0; i < REG_INPUT_NREGS; i++ )
|
||||
{
|
||||
usRegInputBuf[i] = ( unsigned short )i;
|
||||
}
|
||||
|
||||
/* Enable the Modbus Protocol Stack. */
|
||||
( void )eMBEnable( );
|
||||
for( ;; )
|
||||
{
|
||||
/* Call the main polling loop of the Modbus protocol stack. */
|
||||
( void )eMBPoll( );
|
||||
}
|
||||
}
|
||||
|
||||
eMBErrorCode
|
||||
eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs )
|
||||
{
|
||||
eMBErrorCode eStatus = MB_ENOERR;
|
||||
int iRegIndex;
|
||||
|
||||
if( ( usAddress >= REG_INPUT_START )
|
||||
&& ( usAddress + usNRegs <= REG_INPUT_START + REG_INPUT_NREGS ) )
|
||||
{
|
||||
iRegIndex = ( int )( usAddress - usRegInputStart );
|
||||
while( usNRegs > 0 )
|
||||
{
|
||||
*pucRegBuffer++ = ( unsigned char )( usRegInputBuf[iRegIndex] >> 8 );
|
||||
*pucRegBuffer++ = ( unsigned char )( usRegInputBuf[iRegIndex] & 0xFF );
|
||||
iRegIndex++;
|
||||
usNRegs--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eStatus = MB_ENOREG;
|
||||
}
|
||||
|
||||
return eStatus;
|
||||
}
|
||||
|
||||
eMBErrorCode
|
||||
eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs, eMBRegisterMode eMode )
|
||||
{
|
||||
eMBErrorCode eStatus = MB_ENOERR;
|
||||
int iRegIndex;
|
||||
|
||||
if( ( usAddress >= REG_HOLDING_START ) &&
|
||||
( usAddress + usNRegs <= REG_HOLDING_START + REG_HOLDING_NREGS ) )
|
||||
{
|
||||
iRegIndex = ( int )( usAddress - usRegHoldingStart );
|
||||
switch ( eMode )
|
||||
{
|
||||
/* Pass current register values to the protocol stack. */
|
||||
case MB_REG_READ:
|
||||
while( usNRegs > 0 )
|
||||
{
|
||||
*pucRegBuffer++ = ( unsigned char )( usRegHoldingBuf[iRegIndex] >> 8 );
|
||||
*pucRegBuffer++ = ( unsigned char )( usRegHoldingBuf[iRegIndex] & 0xFF );
|
||||
iRegIndex++;
|
||||
usNRegs--;
|
||||
}
|
||||
break;
|
||||
|
||||
/* Update current register values with new values from the
|
||||
* protocol stack. */
|
||||
case MB_REG_WRITE:
|
||||
while( usNRegs > 0 )
|
||||
{
|
||||
usRegHoldingBuf[iRegIndex] = *pucRegBuffer++ << 8;
|
||||
usRegHoldingBuf[iRegIndex] |= *pucRegBuffer++;
|
||||
iRegIndex++;
|
||||
usNRegs--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eStatus = MB_ENOREG;
|
||||
}
|
||||
return eStatus;
|
||||
}
|
||||
|
||||
|
||||
eMBErrorCode
|
||||
eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils, eMBRegisterMode eMode )
|
||||
{
|
||||
return MB_ENOREG;
|
||||
}
|
||||
|
||||
eMBErrorCode
|
||||
eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscrete )
|
||||
{
|
||||
return MB_ENOREG;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
vSetupHardware( void )
|
||||
{
|
||||
vMBPInit( );
|
||||
|
||||
/* Enable the peripheral clock. */
|
||||
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PIOA;
|
||||
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PIOB;
|
||||
}
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
<!DOCTYPE CrossStudio_Project_File>
|
||||
<solution version="1" Name="demo" >
|
||||
<project Name="demo" >
|
||||
<configuration c_enforce_ansi_checking="No" arm_target_loader_parameter="18432000" Target="AT91SAM7X256" arm_simulator_memory_simulation_parameter="0x40000;0x10000" property_groups_file_path="$(StudioDir)/targets/Atmel_AT91SAM7/propertyGroups.xml" oscillator_frequency="18.432MHz" linker_memory_map_file="$(StudioDir)/targets/Atmel_AT91SAM7/AT91SAM7X256_MemoryMap.xml" gcc_entry_point="reset_handler" build_quietly="No" build_treat_warnings_as_errors="No" arm_linker_fiq_stack_size="256" arm_architecture="v4T" c_user_include_directories="$(ProjectDir);$(ProjectDir)/port;$(ProjectDir)/support;$(ProjectDir)/FreeRTOS/include;$(ProjectDir)/../../modbus/include;$(ProjectDir)/../../modbus/ascii;$(ProjectDir)/../../modbus/rtu" target_reset_script="" project_directory="" arm_linker_irq_stack_size="256" project_type="Executable" c_additional_options="-Wall" arm_linker_stack_size="256" Name="Common" arm_target_debug_interface_type="ARM7TDI" arm_core_type="ARM7TDMI" arm_simulator_memory_simulation_filename="$(StudioDir)/targets/Atmel_AT91SAM7/AT91SAM7SimulatorMemory.dll" arm_linker_svc_stack_size="256" />
|
||||
<configuration linker_section_placement_file="$(StudioDir)/targets/sram_placement.xml" target_reset_script="RAMReset()" Name="RAM" Placement="RAM" />
|
||||
<configuration arm_target_flash_loader_file_path="$(StudioDir)/targets/Atmel_AT91SAM7/Release/Loader_rpc.elf" linker_section_placement_file="$(StudioDir)/targets/flash_placement.xml" target_reset_script="FLASHReset()" arm_target_flash_loader_type="LIBMEM RPC Loader" Name="Flash" Placement="Flash" />
|
||||
<folder Name="System" >
|
||||
<file file_name="system/crt0.s" Name="crt0.s" >
|
||||
<configuration c_preprocessor_definitions="SUPERVISOR_START=1" Name="ARM RAM Debug" />
|
||||
<configuration c_preprocessor_definitions="INITIALIZE_STACKS;SUPERVISOR_START" Name="Common" />
|
||||
</file>
|
||||
<file file_name="system/startup.s" Name="startup.s" >
|
||||
<configuration c_preprocessor_definitions="__FLASH_BUILD" Name="Flash" />
|
||||
</file>
|
||||
</folder>
|
||||
<folder Name="Tools" >
|
||||
<file file_name="support/AT91SAM7_Target.js" Name="AT91SAM7_Target.js" >
|
||||
<configuration build_exclude_from_build="No" Name="ARM Flash Debug" />
|
||||
<configuration Name="Common" file_type="Reset Script" />
|
||||
</file>
|
||||
</folder>
|
||||
<folder Name="Demo" >
|
||||
<file file_name="demo.c" Name="demo.c" />
|
||||
</folder>
|
||||
<folder Name="FreeRTOS" >
|
||||
<file file_name="FreeRTOS/tasks.c" Name="tasks.c" />
|
||||
<file file_name="FreeRTOS/croutine.c" Name="croutine.c" />
|
||||
<file file_name="FreeRTOS/list.c" Name="list.c" />
|
||||
<file file_name="FreeRTOS/queue.c" Name="queue.c" />
|
||||
<file file_name="FreeRTOS/include/task.h" Name="task.h" />
|
||||
<file file_name="FreeRTOS/include/croutine.h" Name="croutine.h" />
|
||||
<file file_name="FreeRTOS/include/FreeRTOS.h" Name="FreeRTOS.h" />
|
||||
<file file_name="FreeRTOS/include/list.h" Name="list.h" />
|
||||
<file file_name="FreeRTOS/include/portable.h" Name="portable.h" />
|
||||
<file file_name="FreeRTOS/include/projdefs.h" Name="projdefs.h" />
|
||||
<file file_name="FreeRTOS/include/queue.h" Name="queue.h" />
|
||||
<file file_name="FreeRTOS/include/semphr.h" Name="semphr.h" />
|
||||
<configuration arm_instruction_set="Thumb" Name="THUMB" />
|
||||
</folder>
|
||||
<folder Name="FreeRTOS Port" >
|
||||
<file file_name="FreeRTOS/portable/GCC/ARM7_AT91SAM7S/portmacro.h" Name="portmacro.h" />
|
||||
<file file_name="FreeRTOS/portable/GCC/ARM7_AT91SAM7S/port.c" Name="port.c" />
|
||||
<file file_name="FreeRTOS/portable/GCC/ARM7_AT91SAM7S/portISR.c" Name="portISR.c" >
|
||||
<configuration arm_instruction_set="ARM" Name="THUMB" />
|
||||
</file>
|
||||
<file file_name="FreeRTOS/portable/MemMang/heap_1.c" Name="heap_1.c" />
|
||||
</folder>
|
||||
<file file_name="FreeRTOSConfig.h" Name="FreeRTOSConfig.h" />
|
||||
<configuration build_treat_warnings_as_errors="No" arm_linker_fiq_stack_size="512" arm_linker_irq_stack_size="512" arm_linker_und_stack_size="512" arm_linker_stack_size="512" Name="ARM RAM Debug" arm_linker_svc_stack_size="512" />
|
||||
<folder Name="Support" >
|
||||
<file file_name="support/AT91SAM7X256.h" Name="AT91SAM7X256.h" />
|
||||
<file file_name="support/lib_AT91SAM7X256.h" Name="lib_AT91SAM7X256.h" />
|
||||
</folder>
|
||||
<folder Name="Templates" >
|
||||
<file file_name="../../tools/template.h" Name="template.h" >
|
||||
<configuration build_exclude_from_build="Yes" Name="Common" />
|
||||
</file>
|
||||
<file file_name="../../tools/template.c" Name="template.c" >
|
||||
<configuration build_exclude_from_build="Yes" Name="Common" />
|
||||
</file>
|
||||
</folder>
|
||||
<folder Name="MODBUS Port" >
|
||||
<file file_name="port/porttimer.c" Name="porttimer.c" />
|
||||
<file file_name="port/port.h" Name="port.h" />
|
||||
<file file_name="port/portevent.c" Name="portevent.c" />
|
||||
<file file_name="port/portother.c" Name="portother.c" />
|
||||
<file file_name="port/portserial.c" Name="portserial.c" />
|
||||
</folder>
|
||||
<folder Name="MODBUS" >
|
||||
<file file_name="../../modbus/mb.c" Name="mb.c" />
|
||||
<file file_name="../../modbus/include/mb.h" Name="mb.h" />
|
||||
<file file_name="../../modbus/include/mbconfig.h" Name="mbconfig.h" />
|
||||
<file file_name="../../modbus/include/mbframe.h" Name="mbframe.h" />
|
||||
<file file_name="../../modbus/include/mbfunc.h" Name="mbfunc.h" />
|
||||
<file file_name="../../modbus/include/mbport.h" Name="mbport.h" />
|
||||
<file file_name="../../modbus/include/mbproto.h" Name="mbproto.h" />
|
||||
<folder Name="MODBUS Functions" >
|
||||
<file file_name="../../modbus/functions/mbutils.c" Name="mbutils.c" />
|
||||
<file file_name="../../modbus/functions/mbfunccoils.c" Name="mbfunccoils.c" />
|
||||
<file file_name="../../modbus/functions/mbfuncdiag.c" Name="mbfuncdiag.c" />
|
||||
<file file_name="../../modbus/functions/mbfuncdisc.c" Name="mbfuncdisc.c" />
|
||||
<file file_name="../../modbus/functions/mbfuncholding.c" Name="mbfuncholding.c" />
|
||||
<file file_name="../../modbus/functions/mbfuncinput.c" Name="mbfuncinput.c" />
|
||||
<file file_name="../../modbus/functions/mbfuncother.c" Name="mbfuncother.c" />
|
||||
</folder>
|
||||
<file file_name="../../modbus/include/mbutils.h" Name="mbutils.h" />
|
||||
</folder>
|
||||
<folder Name="MODBUS RTU" >
|
||||
<file file_name="../../modbus/rtu/mbrtu.h" Name="mbrtu.h" />
|
||||
<file file_name="../../modbus/rtu/mbcrc.c" Name="mbcrc.c" />
|
||||
<file file_name="../../modbus/rtu/mbcrc.h" Name="mbcrc.h" />
|
||||
<file file_name="../../modbus/rtu/mbrtu.c" Name="mbrtu.c" />
|
||||
</folder>
|
||||
<configuration c_preprocessor_definitions="THUMB_INTERWORK" Name="THUMB" />
|
||||
<folder Name="MODBUS ASCII" >
|
||||
<file file_name="../../modbus/ascii/mbascii.h" Name="mbascii.h" />
|
||||
<file file_name="../../modbus/ascii/mbascii.c" Name="mbascii.c" />
|
||||
</folder>
|
||||
</project>
|
||||
<configuration inherited_configurations="ARM;RAM;Debug" Name="ARM RAM Debug" />
|
||||
<configuration arm_library_instruction_set="ARM" c_preprocessor_definitions="__ARM" arm_instruction_set="ARM" hidden="Yes" Name="ARM" />
|
||||
<configuration c_preprocessor_definitions="__RAM_BUILD" hidden="Yes" Name="RAM" />
|
||||
<configuration c_preprocessor_definitions="DEBUG" link_include_startup_code="No" gcc_optimization_level="None" build_debug_information="Yes" hidden="Yes" Name="Debug" />
|
||||
<configuration inherited_configurations="ARM;RAM;Release" Name="ARM RAM Release" />
|
||||
<configuration c_preprocessor_definitions="NDEBUG" link_include_startup_code="No" gcc_optimization_level="Level 1" build_debug_information="No" hidden="Yes" Name="Release" />
|
||||
<configuration inherited_configurations="THUMB;RAM;Debug" Name="THUMB RAM Debug" />
|
||||
<configuration arm_library_instruction_set="THUMB" c_preprocessor_definitions="__THUMB" arm_instruction_set="THUMB" hidden="Yes" Name="THUMB" />
|
||||
<configuration inherited_configurations="THUMB;RAM;Release" Name="THUMB RAM Release" />
|
||||
<configuration inherited_configurations="ARM;Flash;Debug" Name="ARM Flash Debug" />
|
||||
<configuration c_preprocessor_definitions="__FLASH_BUILD" hidden="Yes" Name="Flash" />
|
||||
<configuration inherited_configurations="ARM;Flash;Release" Name="ARM Flash Release" />
|
||||
<configuration inherited_configurations="THUMB;Flash;Debug" Name="THUMB Flash Debug" />
|
||||
<configuration inherited_configurations="THUMB;Flash;Release" Name="THUMB Flash Release" />
|
||||
<configuration c_preprocessor_definitions="SAM7_GCC=1" arm_linker_fiq_stack_size="128" arm_linker_irq_stack_size="128" arm_linker_stack_size="128" Name="Common" />
|
||||
</solution>
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
<!DOCTYPE CrossStudio_for_ARM_Session_File>
|
||||
<session>
|
||||
<Autos>
|
||||
<Watches active="0" />
|
||||
</Autos>
|
||||
<Bookmarks/>
|
||||
<Breakpoints>
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="110" length="0" triggertype="0" useHWbreakpoint="false" group="Breakpoints" breakdatatype="0" value="0" name="unnamed" counter="0" state="4" mask="0" comparison="0" expression="" filename="C:\Projects\modbus\mbmaster\demo\AT91SAM7X_ROWLEY\demo.c" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="320" length="0" triggertype="0" useHWbreakpoint="false" group="Breakpoints" breakdatatype="0" value="0" name="unnamed" counter="0" state="4" mask="0" comparison="0" expression="" filename="C:\Projects\modbus\mbmaster\demo\AT91SAM7X_ROWLEY\port\mbportserial.c" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="639" length="0" triggertype="0" useHWbreakpoint="false" group="Breakpoints" breakdatatype="0" value="0" name="unnamed" counter="0" state="4" mask="0" comparison="0" expression="" filename="C:\Projects\modbus\mbmaster\demo\AT91SAM7X_ROWLEY\FreeRTOS\tasks.c" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="646" length="0" triggertype="0" useHWbreakpoint="false" group="Breakpoints" breakdatatype="0" value="0" name="unnamed" counter="0" state="4" mask="0" comparison="0" expression="" filename="C:\Projects\modbus\mbmaster\demo\AT91SAM7X_ROWLEY\FreeRTOS\tasks.c" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="ARM Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="2" mask="0" comparison="0" expression="D_Abort" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="ARM Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="3" mask="0" comparison="0" expression="FIQ" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="ARM Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="3" mask="0" comparison="0" expression="IRQ" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="ARM Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="2" mask="0" comparison="0" expression="P_Abort" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="ARM Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="3" mask="0" comparison="0" expression="Reset" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="ARM Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="3" mask="0" comparison="0" expression="SWI" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="ARM Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="2" mask="0" comparison="0" expression="Undef" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="Cortex-M3 Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="2" mask="0" comparison="0" expression="BusFault" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="Cortex-M3 Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="2" mask="0" comparison="0" expression="ExceptionEntryReturnFault" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="Cortex-M3 Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="2" mask="0" comparison="0" expression="HardFault" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="Cortex-M3 Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="2" mask="0" comparison="0" expression="MemManage" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="Cortex-M3 Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="3" mask="0" comparison="0" expression="Reset" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="Cortex-M3 Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="2" mask="0" comparison="0" expression="UsageFault_CheckingError" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="Cortex-M3 Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="2" mask="0" comparison="0" expression="UsageFault_Coprocessor" filename="" />
|
||||
<BreakpointListItem actiontype="0" chainFrom="" line="-1" length="0" triggertype="0" useHWbreakpoint="false" group="Cortex-M3 Exceptions" breakdatatype="5" value="0" name="unnamed" counter="0" state="2" mask="0" comparison="0" expression="UsageFault_StateError" filename="" />
|
||||
</Breakpoints>
|
||||
<ExecutionCountWindow/>
|
||||
<Memory1>
|
||||
<MemoryWindow autoEvaluate="0" addressText="0x20ba54" numColumns="8" sizeText="200" dataSize="1" radix="16" addressSpace="" />
|
||||
</Memory1>
|
||||
<Memory2>
|
||||
<MemoryWindow autoEvaluate="0" addressText="" numColumns="8" sizeText="" dataSize="1" radix="16" addressSpace="" />
|
||||
</Memory2>
|
||||
<Memory3>
|
||||
<MemoryWindow autoEvaluate="0" addressText="" numColumns="8" sizeText="" dataSize="1" radix="16" addressSpace="" />
|
||||
</Memory3>
|
||||
<Memory4>
|
||||
<MemoryWindow autoEvaluate="0" addressText="" numColumns="8" sizeText="" dataSize="1" radix="16" addressSpace="" />
|
||||
</Memory4>
|
||||
<Project>
|
||||
<ProjectSessionItem path="demo" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo;Demo" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo;FreeRTOS" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo;FreeRTOS Port" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo;MODBUS" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo;MODBUS;MODBUS Functions" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo;MODBUS ASCII" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo;MODBUS Port" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo;MODBUS RTU" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo;Support" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo;System" name="unnamed" />
|
||||
<ProjectSessionItem path="demo;demo;Tools" name="unnamed" />
|
||||
</Project>
|
||||
<Register1>
|
||||
<RegisterWindow unsignedDisplays="" asciiDisplays="" octalDisplays="" openGroups="CPU - Current Mode" visibleGroups="CPU - Current Mode" decimalDisplays="" binaryDisplays="" />
|
||||
</Register1>
|
||||
<Register2>
|
||||
<RegisterWindow unsignedDisplays="" asciiDisplays="" octalDisplays="" openGroups="" visibleGroups="" decimalDisplays="" binaryDisplays="" />
|
||||
</Register2>
|
||||
<Register3>
|
||||
<RegisterWindow unsignedDisplays="" asciiDisplays="" octalDisplays="" openGroups="" visibleGroups="" decimalDisplays="" binaryDisplays="" />
|
||||
</Register3>
|
||||
<Register4>
|
||||
<RegisterWindow unsignedDisplays="" asciiDisplays="" octalDisplays="" openGroups="" visibleGroups="" decimalDisplays="" binaryDisplays="" />
|
||||
</Register4>
|
||||
<SourceNavigatorWindow/>
|
||||
<TraceWindow>
|
||||
<Trace wrap="Yes" type="1" enabled="Yes" />
|
||||
</TraceWindow>
|
||||
<Watch1>
|
||||
<Watches active="1" >
|
||||
<Watchpoint linenumber="160" radix="-1" name="usRcvBufferPos" expression="usRcvBufferPos" filename="C:\Projects\freemodbus\modbus\rtu\mbrtu.c" />
|
||||
</Watches>
|
||||
</Watch1>
|
||||
<Watch2>
|
||||
<Watches active="0" />
|
||||
</Watch2>
|
||||
<Watch3>
|
||||
<Watches active="0" />
|
||||
</Watch3>
|
||||
<Watch4>
|
||||
<Watches active="0" />
|
||||
</Watch4>
|
||||
<Files>
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="0" debugPath="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\FreeRTOS\include\FreeRTOS.h" y="0" useHTMLEdit="0" path="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\FreeRTOS\include\FreeRTOS.h" left="0" selected="0" name="unnamed" top="0" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="2" debugPath="c:\projects\freemodbus\demo\at91sam7x_rowley\system\crt0.s" y="34" useHTMLEdit="0" path="c:\projects\freemodbus\demo\at91sam7x_rowley\system\crt0.s" left="0" selected="0" name="unnamed" top="9" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="49" debugPath="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\demo.c" y="77" useHTMLEdit="0" path="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\demo.c" left="0" selected="1" name="unnamed" top="2" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="0" debugPath="C:\Projects\freemodbus\modbus\include\mb.h" y="33" useHTMLEdit="0" path="C:\Projects\freemodbus\modbus\include\mb.h" left="0" selected="0" name="unnamed" top="9" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="50" debugPath="C:\Projects\freemodbus\modbus\mb.c" y="389" useHTMLEdit="0" path="C:\Projects\freemodbus\modbus\mb.c" left="0" selected="0" name="unnamed" top="373" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="0" debugPath="C:\Projects\freemodbus\modbus\include\mbport.h" y="62" useHTMLEdit="0" path="C:\Projects\freemodbus\modbus\include\mbport.h" left="0" selected="0" name="unnamed" top="46" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="0" debugPath="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\port\port.h" y="74" useHTMLEdit="0" path="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\port\port.h" left="0" selected="0" name="unnamed" top="0" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="24" debugPath="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\port\porttimer.c" y="60" useHTMLEdit="0" path="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\port\porttimer.c" left="0" selected="0" name="unnamed" top="36" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="4" debugPath="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\port\portother.c" y="108" useHTMLEdit="0" path="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\port\portother.c" left="0" selected="0" name="unnamed" top="85" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="36" debugPath="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\port\portevent.c" y="78" useHTMLEdit="0" path="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\port\portevent.c" left="0" selected="0" name="unnamed" top="56" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="21" debugPath="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\port\portserial.c" y="256" useHTMLEdit="0" path="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\port\portserial.c" left="0" selected="0" name="unnamed" top="240" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="0" debugPath="C:\Projects\freemodbus\modbus\include\mbconfig.h" y="0" useHTMLEdit="0" path="C:\Projects\freemodbus\modbus\include\mbconfig.h" left="0" selected="0" name="unnamed" top="48" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="0" debugPath="C:\Projects\freemodbus\modbus\rtu\mbrtu.c" y="183" useHTMLEdit="0" path="C:\Projects\freemodbus\modbus\rtu\mbrtu.c" left="0" selected="0" name="unnamed" top="150" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="4" debugPath="C:\Projects\freemodbus\modbus\functions\mbutils.c" y="55" useHTMLEdit="0" path="C:\Projects\freemodbus\modbus\functions\mbutils.c" left="0" selected="0" name="unnamed" top="15" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="0" debugPath="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\FreeRTOS\tasks.c" y="1772" useHTMLEdit="0" path="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\FreeRTOS\tasks.c" left="0" selected="0" name="unnamed" top="1739" />
|
||||
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" x="0" debugPath="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\FreeRTOS\portable\GCC\ARM7_AT91SAM7S\portISR.c" y="0" useHTMLEdit="0" path="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\FreeRTOS\portable\GCC\ARM7_AT91SAM7S\portISR.c" left="0" selected="0" name="unnamed" top="16" />
|
||||
</Files>
|
||||
<ARMCrossStudioWindow activeProject="demo" autoConnectTarget="/Macraigor Wiggler (20 Pin)" debugSearchFileMap="" fileDialogInitialDirectory="C:\Projects\freemodbus\demo\AT91SAM7X_ROWLEY\port" fileDialogDefaultFilter="*" autoConnectCapabilities="1407" debugSearchPath="" buildConfiguration="ARM RAM Debug" />
|
||||
</session>
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* FreeModbus Libary: ARM7/AT91SAM7X Port
|
||||
* Copyright (C) 2006 Christian Walter <wolti@sil.at>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _PORT_H
|
||||
#define _PORT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#ifdef _cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
|
||||
#define INLINE inline
|
||||
#define STATIC static
|
||||
|
||||
#define PR_BEGIN_EXTERN_C extern "C" {
|
||||
#define PR_END_EXTERN_C }
|
||||
|
||||
#define MB_PORT_HAS_CLOSE 1
|
||||
#define ENTER_CRITICAL_SECTION( ) vMBPPortEnterCritical( )
|
||||
#define EXIT_CRITICAL_SECTION( ) vMBPPortExitCritical( )
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE ( BOOL )1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE ( BOOL )0
|
||||
#endif
|
||||
|
||||
/* ----------------------- Type definitions ---------------------------------*/
|
||||
typedef char BOOL;
|
||||
|
||||
typedef signed char BYTE;
|
||||
typedef unsigned char UBYTE;
|
||||
|
||||
typedef unsigned char UCHAR;
|
||||
typedef char CHAR;
|
||||
|
||||
typedef unsigned short USHORT;
|
||||
typedef short SHORT;
|
||||
|
||||
typedef unsigned long ULONG;
|
||||
typedef long LONG;
|
||||
|
||||
/* ----------------------- Function prototypes ------------------------------*/
|
||||
BOOL bMBPIsWithinException( void );
|
||||
void vMBPInit( void );
|
||||
void vMBPPortEnterCritical( void );
|
||||
void vMBPPortExitCritical( void );
|
||||
|
||||
#ifdef _cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* FreeModbus Libary: ARM7/AT91SAM7X Port
|
||||
* Copyright (C) 2006 Christian Walter <wolti@sil.at>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id$
|
||||
*/
|
||||
/* ----------------------- System includes ----------------------------------*/
|
||||
#include <stdlib.h>
|
||||
|
||||
/* ----------------------- Platform includes --------------------------------*/
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* ----------------------- Modbus includes ----------------------------------*/
|
||||
#include "mb.h"
|
||||
#include "mbport.h"
|
||||
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
#define HDL_RESET( x ) do { \
|
||||
( x )->xQueueHdl = 0; \
|
||||
} while( 0 );
|
||||
|
||||
/* ----------------------- Type definitions ---------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
xQueueHandle xQueueHdl;
|
||||
} xEventInternalHandle;
|
||||
|
||||
/* ----------------------- Static variables ---------------------------------*/
|
||||
STATIC BOOL bIsInitialized = FALSE;
|
||||
STATIC xEventInternalHandle arxEventHdls[1];
|
||||
|
||||
/* ----------------------- Static functions ---------------------------------*/
|
||||
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
|
||||
BOOL
|
||||
xMBPortEventInit( void )
|
||||
{
|
||||
BOOL bOkay = FALSE;
|
||||
xQueueHandle xQueueHdl;
|
||||
|
||||
ENTER_CRITICAL_SECTION( );
|
||||
xQueueHdl = xQueueCreate( 1, sizeof( eMBEventType ) );
|
||||
if( 0 != xQueueHdl )
|
||||
{
|
||||
arxEventHdls[0].xQueueHdl = xQueueHdl;
|
||||
bIsInitialized = TRUE;
|
||||
bOkay = TRUE;
|
||||
}
|
||||
EXIT_CRITICAL_SECTION( );
|
||||
|
||||
return bOkay;
|
||||
}
|
||||
|
||||
void
|
||||
vMBPortEventClose( )
|
||||
{
|
||||
ENTER_CRITICAL_SECTION( );
|
||||
if( bIsInitialized )
|
||||
{
|
||||
if( 0 != arxEventHdls[0].xQueueHdl )
|
||||
{
|
||||
vQueueDelete( arxEventHdls[0].xQueueHdl );
|
||||
}
|
||||
HDL_RESET( &arxEventHdls[0] );
|
||||
}
|
||||
EXIT_CRITICAL_SECTION( );
|
||||
}
|
||||
|
||||
BOOL
|
||||
xMBPortEventPost( eMBEventType eEvent )
|
||||
{
|
||||
portBASE_TYPE xEventSent = pdFALSE;
|
||||
|
||||
ENTER_CRITICAL_SECTION( );
|
||||
if( bIsInitialized )
|
||||
{
|
||||
if( bMBPIsWithinException( ) )
|
||||
{
|
||||
xEventSent =
|
||||
xQueueSendFromISR( arxEventHdls[0].xQueueHdl, ( const void * )&eEvent, pdFALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
xEventSent = xQueueSend( arxEventHdls[0].xQueueHdl, ( const void * )&eEvent, pdFALSE );
|
||||
}
|
||||
}
|
||||
EXIT_CRITICAL_SECTION( );
|
||||
return xEventSent == pdTRUE ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
xMBPortEventGet( eMBEventType * peEvent )
|
||||
{
|
||||
BOOL bEventInQueue = FALSE;
|
||||
|
||||
ENTER_CRITICAL_SECTION( );
|
||||
if( bIsInitialized )
|
||||
{
|
||||
if( pdTRUE == xQueueReceive( arxEventHdls[0].xQueueHdl, peEvent, portTICK_RATE_MS * 50 ) )
|
||||
{
|
||||
bEventInQueue = TRUE;
|
||||
}
|
||||
}
|
||||
EXIT_CRITICAL_SECTION( );
|
||||
return bEventInQueue;
|
||||
}
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
/*
|
||||
* FreeModbus Libary: ARM7/AT91SAM7X Port
|
||||
* Copyright (C) 2006 Christian Walter <wolti@sil.at>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id$
|
||||
*/
|
||||
|
||||
/* ----------------------- System includes ----------------------------------*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* ----------------------- Platform includes --------------------------------*/
|
||||
#include "AT91SAM7X256.h"
|
||||
#include "lib_AT91SAM7X256.h"
|
||||
|
||||
/* ----------------------- Modbus includes ----------------------------------*/
|
||||
#include "port.h"
|
||||
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
|
||||
/* ----------------------- Type definitions ---------------------------------*/
|
||||
|
||||
/* ----------------------- Function prototypes ------------------------------*/
|
||||
void vMBPortSerialClose( void );
|
||||
void vMBPortEventClose( void );
|
||||
void vMBPortTimerClose( void );
|
||||
|
||||
/* ----------------------- Static variables ---------------------------------*/
|
||||
|
||||
/* ----------------------- Static functions ---------------------------------*/
|
||||
STATIC void vDefaultHandler( void ) __attribute__ ( ( interrupt( "IRQ" ) ) );
|
||||
STATIC void vDefaultSpuriousHandler( void ) __attribute__ ( ( interrupt( "IRQ" ) ) );
|
||||
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
|
||||
void
|
||||
vMBPInit( void )
|
||||
{
|
||||
AT91F_AIC_Open( AT91C_BASE_AIC, AT91C_AIC_BRANCH_OPCODE, AT91C_AIC_BRANCH_OPCODE,
|
||||
vDefaultHandler, vDefaultSpuriousHandler, AT91C_AIC_DCR_PROT );
|
||||
}
|
||||
|
||||
void
|
||||
__assert( const char *pcFile, const char *pcAssertion, int iLine )
|
||||
{
|
||||
volatile BOOL bBreakOut = FALSE;
|
||||
|
||||
( void )pcFile;
|
||||
( void )pcAssertion;
|
||||
( void )iLine;
|
||||
ENTER_CRITICAL_SECTION( );
|
||||
while( !bBreakOut );
|
||||
}
|
||||
|
||||
BOOL
|
||||
bMBPIsWithinException( void )
|
||||
{
|
||||
BOOL bMBPIsWithinException = TRUE;
|
||||
unsigned int uiCPSR;
|
||||
asm volatile ( "MRS %0, CPSR":"=r" ( uiCPSR ): );
|
||||
|
||||
switch ( uiCPSR & 0x000000001F )
|
||||
{
|
||||
case 0x00000010U: /* User Mode */
|
||||
case 0x0000001FU: /* System Mode */
|
||||
bMBPIsWithinException = FALSE;
|
||||
break;
|
||||
}
|
||||
return bMBPIsWithinException;
|
||||
}
|
||||
|
||||
void
|
||||
vMBPPortEnterCritical( void )
|
||||
{
|
||||
if( !bMBPIsWithinException( ) )
|
||||
{
|
||||
portENTER_CRITICAL( );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vMBPPortExitCritical( void )
|
||||
{
|
||||
if( !bMBPIsWithinException( ) )
|
||||
{
|
||||
portEXIT_CRITICAL( );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vMBPortClose( void )
|
||||
{
|
||||
vMBPortSerialClose( );
|
||||
vMBPortEventClose( );
|
||||
vMBPortTimerClose( );
|
||||
}
|
||||
|
||||
void
|
||||
vDefaultSpuriousHandler( void )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
vDefaultHandler( void )
|
||||
{
|
||||
}
|
||||
|
|
@ -1,259 +0,0 @@
|
|||
/*
|
||||
* FreeModbus Libary: ARM7/AT91SAM7X Port
|
||||
* Copyright (C) 2006 Christian Walter <wolti@sil.at>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id$
|
||||
*/
|
||||
|
||||
/* ----------------------- System includes ----------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* ----------------------- Platform includes --------------------------------*/
|
||||
#include "AT91SAM7X256.h"
|
||||
#include "lib_AT91SAM7X256.h"
|
||||
|
||||
/* ----------------------- Modbus includes ----------------------------------*/
|
||||
#include "mb.h"
|
||||
#include "mbport.h"
|
||||
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
|
||||
#define USART_INTERRUPT_LEVEL ( 7 )
|
||||
#define USART_USART0_IDX ( 0 )
|
||||
#define USART_USART1_IDX ( 1 )
|
||||
|
||||
#define IDX_INVALID ( 255 )
|
||||
#define UART_BAUDRATE_MIN ( 300 )
|
||||
#define UART_BAUDRATE_MAX ( 115200 )
|
||||
|
||||
#define UART_INIT( ubIdx ) do { \
|
||||
if( AT91C_ID_US0 == ubIdx ) \
|
||||
{ \
|
||||
AT91F_PIO_CfgPeriph( AT91C_BASE_PIOA, AT91C_PA0_RXD0 | AT91C_PA1_TXD0 | AT91C_PA3_RTS0, 0 ); \
|
||||
} \
|
||||
else if( AT91C_ID_US1 == ubIdx ) \
|
||||
{ \
|
||||
AT91F_PIO_CfgPeriph( AT91C_BASE_PIOA, AT91C_PA5_RXD1 | AT91C_PA6_TXD1 | AT91C_PA8_RTS1, 0 ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
assert( 0 ); \
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
#define HDL_RESET( x ) do { \
|
||||
( x )->pxCOM = NULL; \
|
||||
( x )->uiAT91C_ID_USX = 0; \
|
||||
( x )->pvIRQHandlerFN = NULL; \
|
||||
( x )->bIsRxEnabled = FALSE; \
|
||||
( x )->bIsTxEnabled = FALSE; \
|
||||
} while( 0 );
|
||||
|
||||
/* ----------------------- Type definitions ---------------------------------*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
AT91PS_USART pxCOM;
|
||||
unsigned int uiAT91C_ID_USX;
|
||||
volatile BOOL bIsRxEnabled;
|
||||
volatile BOOL bIsTxEnabled;
|
||||
void ( *pvIRQHandlerFN ) ( void );
|
||||
} xMBPSerialIntHandle;
|
||||
|
||||
/* ----------------------- Static variables ---------------------------------*/
|
||||
STATIC xMBPSerialIntHandle xSerialHdls[1];
|
||||
STATIC BOOL bIsInitalized = FALSE;
|
||||
|
||||
/* ----------------------- Static functions ---------------------------------*/
|
||||
STATIC void vUSART0ISR( void ) __attribute__ ( ( interrupt( "IRQ" ) ) );
|
||||
STATIC void vUSART1ISR( void ) __attribute__ ( ( interrupt( "IRQ" ) ) );
|
||||
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
|
||||
BOOL
|
||||
xMBPortSerialInit( UCHAR ucPort, ULONG ulBaudRate, UCHAR ucDataBits, eMBParity eParity )
|
||||
{
|
||||
BOOL bOkay = TRUE;
|
||||
unsigned int uiUARTMode = 0;
|
||||
|
||||
ENTER_CRITICAL_SECTION( );
|
||||
if( !bIsInitalized )
|
||||
{
|
||||
HDL_RESET( &xSerialHdls[0] );
|
||||
bIsInitalized = TRUE;
|
||||
}
|
||||
|
||||
uiUARTMode = AT91C_US_USMODE_RS485 | AT91C_US_CLKS_CLOCK;
|
||||
switch ( eParity )
|
||||
{
|
||||
case MB_PAR_NONE:
|
||||
uiUARTMode |= AT91C_US_PAR_NONE;
|
||||
uiUARTMode |= AT91C_US_NBSTOP_2_BIT;
|
||||
break;
|
||||
case MB_PAR_EVEN:
|
||||
uiUARTMode |= AT91C_US_PAR_EVEN;
|
||||
uiUARTMode |= AT91C_US_NBSTOP_1_BIT;
|
||||
break;
|
||||
case MB_PAR_ODD:
|
||||
uiUARTMode |= AT91C_US_PAR_ODD;
|
||||
uiUARTMode |= AT91C_US_NBSTOP_1_BIT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch ( ucDataBits )
|
||||
{
|
||||
case 8:
|
||||
uiUARTMode |= AT91C_US_CHRL_8_BITS;
|
||||
break;
|
||||
case 7:
|
||||
uiUARTMode |= AT91C_US_CHRL_7_BITS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if( bOkay )
|
||||
{
|
||||
if( ( ucPort == USART_USART0_IDX ) && ( NULL == xSerialHdls[0].pxCOM ) )
|
||||
{
|
||||
xSerialHdls[0].pxCOM = AT91C_BASE_US0;
|
||||
xSerialHdls[0].uiAT91C_ID_USX = AT91C_ID_US0;
|
||||
xSerialHdls[0].pvIRQHandlerFN = vUSART0ISR;
|
||||
}
|
||||
else if( ( ucPort == USART_USART1_IDX ) && ( NULL == xSerialHdls[0].pxCOM ) )
|
||||
{
|
||||
xSerialHdls[0].pxCOM = AT91C_BASE_US1;
|
||||
xSerialHdls[0].uiAT91C_ID_USX = AT91C_ID_US1;
|
||||
xSerialHdls[0].pvIRQHandlerFN = vUSART1ISR;
|
||||
}
|
||||
else
|
||||
{
|
||||
bOkay = FALSE;
|
||||
}
|
||||
|
||||
if( bOkay )
|
||||
{
|
||||
AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, 1 << xSerialHdls[0].uiAT91C_ID_USX );
|
||||
AT91F_US_Configure( xSerialHdls[0].pxCOM, configCPU_CLOCK_HZ, uiUARTMode, ulBaudRate,
|
||||
0 );
|
||||
xSerialHdls[0].pxCOM->US_CR = AT91C_US_TXEN | AT91C_US_RXEN;
|
||||
AT91F_AIC_ConfigureIt( AT91C_BASE_AIC, xSerialHdls[0].uiAT91C_ID_USX,
|
||||
USART_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
|
||||
xSerialHdls[0].pvIRQHandlerFN );
|
||||
AT91F_AIC_EnableIt( AT91C_BASE_AIC, xSerialHdls[0].uiAT91C_ID_USX );
|
||||
UART_INIT( xSerialHdls[0].uiAT91C_ID_USX );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bOkay = FALSE;
|
||||
}
|
||||
|
||||
EXIT_CRITICAL_SECTION( );
|
||||
return bOkay;
|
||||
}
|
||||
|
||||
void
|
||||
vMBPortSerialClose( void )
|
||||
{
|
||||
if( bIsInitalized )
|
||||
{
|
||||
if( NULL != xSerialHdls[0].pxCOM )
|
||||
{
|
||||
AT91F_AIC_DisableIt( AT91C_BASE_AIC, xSerialHdls[0].uiAT91C_ID_USX );
|
||||
AT91F_US_Close( xSerialHdls[0].pxCOM );
|
||||
HDL_RESET( &xSerialHdls[0] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable )
|
||||
{
|
||||
ENTER_CRITICAL_SECTION( );
|
||||
assert( NULL != xSerialHdls[0].pxCOM );
|
||||
if( xRxEnable )
|
||||
{
|
||||
AT91F_US_EnableIt( xSerialHdls[0].pxCOM, AT91C_US_RXRDY );
|
||||
xSerialHdls[0].bIsRxEnabled = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
AT91F_US_DisableIt( xSerialHdls[0].pxCOM, AT91C_US_RXRDY );
|
||||
xSerialHdls[0].bIsRxEnabled = FALSE;
|
||||
}
|
||||
|
||||
if( xTxEnable )
|
||||
{
|
||||
AT91F_US_EnableIt( xSerialHdls[0].pxCOM, AT91C_US_TXRDY );
|
||||
xSerialHdls[0].bIsTxEnabled = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
AT91F_US_DisableIt( xSerialHdls[0].pxCOM, AT91C_US_TXRDY );
|
||||
xSerialHdls[0].bIsTxEnabled = FALSE;
|
||||
}
|
||||
EXIT_CRITICAL_SECTION( );
|
||||
}
|
||||
|
||||
STATIC INLINE void
|
||||
vUSARTIRQHandler( void )
|
||||
{
|
||||
unsigned int uiUSARTStatus = xSerialHdls[0].pxCOM->US_CSR;
|
||||
|
||||
if( xSerialHdls[0].bIsRxEnabled && ( uiUSARTStatus & AT91C_US_RXRDY ) )
|
||||
{
|
||||
pxMBFrameCBByteReceived( );
|
||||
}
|
||||
if( xSerialHdls[0].bIsTxEnabled && ( uiUSARTStatus & AT91C_US_TXRDY ) )
|
||||
{
|
||||
pxMBFrameCBTransmitterEmpty( );
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
xMBPortSerialPutByte( CHAR ucByte )
|
||||
{
|
||||
assert( NULL != xSerialHdls[0].pxCOM );
|
||||
AT91F_US_PutChar( xSerialHdls[0].pxCOM, ucByte );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
xMBPortSerialGetByte( CHAR * pucByte )
|
||||
{
|
||||
assert( NULL != xSerialHdls[0].pxCOM );
|
||||
*pucByte = ( CHAR ) AT91F_US_GetChar( xSerialHdls[0].pxCOM );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
vUSART0ISR( void )
|
||||
{
|
||||
assert( NULL != xSerialHdls[0].pxCOM );
|
||||
vUSARTIRQHandler( );
|
||||
AT91C_BASE_AIC->AIC_EOICR = 0;
|
||||
}
|
||||
|
||||
void
|
||||
vUSART1ISR( void )
|
||||
{
|
||||
assert( NULL != xSerialHdls[0].pxCOM );
|
||||
vUSARTIRQHandler( );
|
||||
AT91C_BASE_AIC->AIC_EOICR = 0;
|
||||
}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* MODBUS Library: AT91SAM7X/FreeRTOS port
|
||||
* Copyright (c) 2007 Christian Walter <wolti@sil.at>
|
||||
* All rights reserved.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/* ----------------------- System includes ----------------------------------*/
|
||||
#include <stdlib.h>
|
||||
|
||||
/* ----------------------- FreeRTOS includes --------------------------------*/
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* ----------------------- Platform includes --------------------------------*/
|
||||
#include "port.h"
|
||||
|
||||
/* ----------------------- Modbus includes ----------------------------------*/
|
||||
#include "mb.h"
|
||||
#include "mbport.h"
|
||||
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
#define TIMER_TIMEOUT_INVALID ( 65535U )
|
||||
|
||||
/* ----------------------- Type definitions ---------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
volatile USHORT usNTimeOutMS;
|
||||
volatile USHORT usNTimeLeft;
|
||||
} xTimerInternalHandle;
|
||||
|
||||
/* ----------------------- Static variables ---------------------------------*/
|
||||
STATIC xTimerInternalHandle arxTimerHdls[1];
|
||||
STATIC BOOL bIsInitalized = FALSE;
|
||||
|
||||
/* ----------------------- Static functions ---------------------------------*/
|
||||
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
|
||||
BOOL
|
||||
xMBPortTimersInit( USHORT usTim1Timerout50us )
|
||||
{
|
||||
USHORT usTimeoutMS;
|
||||
|
||||
ENTER_CRITICAL_SECTION( );
|
||||
usTimeoutMS = ( usTim1Timerout50us + 10 ) / 20;
|
||||
if( 0 == usTimeoutMS )
|
||||
{
|
||||
usTimeoutMS = 1;
|
||||
}
|
||||
arxTimerHdls[0].usNTimeOutMS = usTimeoutMS;
|
||||
arxTimerHdls[0].usNTimeLeft = TIMER_TIMEOUT_INVALID;
|
||||
bIsInitalized = TRUE;
|
||||
EXIT_CRITICAL_SECTION( );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
vMBPortTimerClose( void )
|
||||
{
|
||||
ENTER_CRITICAL_SECTION( );
|
||||
if( bIsInitalized )
|
||||
{
|
||||
arxTimerHdls[0].usNTimeLeft = TIMER_TIMEOUT_INVALID;
|
||||
bIsInitalized = FALSE;
|
||||
}
|
||||
EXIT_CRITICAL_SECTION( );
|
||||
}
|
||||
|
||||
void
|
||||
vMBPortTimersEnable( )
|
||||
{
|
||||
assert( bIsInitalized );
|
||||
ENTER_CRITICAL_SECTION( );
|
||||
arxTimerHdls[0].usNTimeLeft = arxTimerHdls[0].usNTimeOutMS;
|
||||
EXIT_CRITICAL_SECTION( );
|
||||
}
|
||||
|
||||
void
|
||||
vMBPortTimersDisable( )
|
||||
{
|
||||
assert( bIsInitalized );
|
||||
ENTER_CRITICAL_SECTION( );
|
||||
arxTimerHdls[0].usNTimeLeft = TIMER_TIMEOUT_INVALID;
|
||||
EXIT_CRITICAL_SECTION( );
|
||||
}
|
||||
|
||||
void
|
||||
vApplicationTickHook( void )
|
||||
{
|
||||
if( bIsInitalized )
|
||||
{
|
||||
if( TIMER_TIMEOUT_INVALID != arxTimerHdls[0].usNTimeLeft )
|
||||
{
|
||||
arxTimerHdls[0].usNTimeLeft--;
|
||||
if( 0 == arxTimerHdls[0].usNTimeLeft )
|
||||
{
|
||||
arxTimerHdls[0].usNTimeLeft = TIMER_TIMEOUT_INVALID;
|
||||
pxMBPortCBTimerExpired( );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,64 +0,0 @@
|
|||
/******************************************************************************
|
||||
Target Script for Atmel AT91SAM7.
|
||||
|
||||
Copyright (c) 2007 Rowley Associates Limited.
|
||||
|
||||
This file may be distributed under the terms of the License Agreement
|
||||
provided with this software.
|
||||
|
||||
THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
******************************************************************************/
|
||||
|
||||
function Reset()
|
||||
{
|
||||
/* Mask All interrupt pAic->AIC_IDCR = 0xFFFFFFFF; */
|
||||
TargetInterface.pokeWord(0xffffffff,0xFFFFF124);
|
||||
TargetInterface.pokeWord(0xffffffff,0xFFFFF128);
|
||||
/* disable peripheral clock Peripheral Clock Disable Register */
|
||||
TargetInterface.pokeWord(0xffffffff,0xFFFFFC14);
|
||||
|
||||
/* Reset and stop target */
|
||||
TargetInterface.stopAndReset(1);
|
||||
|
||||
CKGR_MOR_VAL = 0x00004001;
|
||||
CKGR_PLLR_VAL = 0x10483F0E; /* Set up the PLL (MCK, UDPCK = 18.432MHz * 73 / 14 / 2 = 48.05486MHz) */
|
||||
CKGR_MCKR_VAL1 = 0x00000004;
|
||||
CKGR_MCKR_VAL2 = 0x00000007;
|
||||
|
||||
if (TargetInterface.setMaximumJTAGFrequency)
|
||||
{
|
||||
/* Configure Clock (post 1.6 version) */
|
||||
TargetInterface.setMaximumJTAGFrequency(32768);
|
||||
TargetInterface.pokeWord(0xFFFFFC20, CKGR_MOR_VAL);
|
||||
TargetInterface.pokeWord(0xFFFFFC2C, CKGR_PLLR_VAL);
|
||||
TargetInterface.pokeWord(0xFFFFFC30, CKGR_MCKR_VAL1);
|
||||
TargetInterface.pokeWord(0xFFFFFC30, CKGR_MCKR_VAL2);
|
||||
TargetInterface.setMaximumJTAGFrequency(10000000);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Configure Clock (1.6 version) */
|
||||
TargetInterface.pokeWord(0xFFFFFC20, CKGR_MOR_VAL);
|
||||
TargetInterface.delay(10);
|
||||
TargetInterface.pokeWord(0xFFFFFC2C, CKGR_PLLR_VAL);
|
||||
TargetInterface.delay(10);
|
||||
TargetInterface.pokeWord(0xFFFFFC30, CKGR_MCKR_VAL1);
|
||||
TargetInterface.delay(10);
|
||||
TargetInterface.pokeWord(0xFFFFFC30, CKGR_MCKR_VAL2);
|
||||
TargetInterface.delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
function RAMReset()
|
||||
{
|
||||
Reset();
|
||||
/* Remap SRAM to 0x00000000 */
|
||||
TargetInterface.pokeWord(0xFFFFFF00, 1); // MC_RCR
|
||||
}
|
||||
|
||||
function FLASHReset()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,232 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2001, 2002 Rowley Associates Limited. *
|
||||
* *
|
||||
* This file may be distributed under the terms of the License Agreement *
|
||||
* provided with this software. *
|
||||
* *
|
||||
* THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE *
|
||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Preprocessor Definitions
|
||||
* ------------------------
|
||||
* APP_ENTRY_POINT
|
||||
*
|
||||
* Defines the application entry point function, if undefined this setting
|
||||
* defaults to "main".
|
||||
*
|
||||
* INITIALIZE_STACKS
|
||||
*
|
||||
* If defined, the contents of the stacks will be initialized to a the
|
||||
* value 0xCC.
|
||||
*
|
||||
* INITIALIZE_SECONDARY_SECTIONS
|
||||
*
|
||||
* If defined, the .text2, .data2 and .bss2 sections will be initialized.
|
||||
*
|
||||
* SUPERVISOR_START
|
||||
*
|
||||
* If defined, the application will start up in supervisor mode. If
|
||||
* undefined the application will start up in system mode.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
.section .init, "ax"
|
||||
.code 32
|
||||
.align 4
|
||||
|
||||
#ifndef APP_ENTRY_POINT
|
||||
#define APP_ENTRY_POINT main
|
||||
#endif
|
||||
|
||||
.weak _start
|
||||
.global __start
|
||||
.global __gccmain
|
||||
.extern APP_ENTRY_POINT
|
||||
.extern exit
|
||||
|
||||
/*****************************************************************************
|
||||
* Function : _start *
|
||||
* Description : Main entry point and startup code for C system. *
|
||||
*****************************************************************************/
|
||||
_start:
|
||||
__start:
|
||||
mrs r0, cpsr
|
||||
bic r0, r0, #0x1F
|
||||
|
||||
/* Setup stacks */
|
||||
orr r1, r0, #0x1B /* Undefined mode */
|
||||
msr cpsr_cxsf, r1
|
||||
ldr sp, =__stack_und_end__
|
||||
|
||||
orr r1, r0, #0x17 /* Abort mode */
|
||||
msr cpsr_cxsf, r1
|
||||
ldr sp, =__stack_abt_end__
|
||||
|
||||
orr r1, r0, #0x12 /* IRQ mode */
|
||||
msr cpsr_cxsf, r1
|
||||
ldr sp, =__stack_irq_end__
|
||||
|
||||
orr r1, r0, #0x11 /* FIQ mode */
|
||||
msr cpsr_cxsf, r1
|
||||
ldr sp, =__stack_fiq_end__
|
||||
|
||||
orr r1, r0, #0x13 /* Supervisor mode */
|
||||
msr cpsr_cxsf, r1
|
||||
ldr sp, =__stack_svc_end__
|
||||
#ifdef SUPERVISOR_START
|
||||
/* Start application in supervisor mode */
|
||||
ldr r1, =__stack_end__ /* Setup user/system mode stack */
|
||||
mov r2, sp
|
||||
stmfd r2!, {r1}
|
||||
ldmfd r2, {sp}^
|
||||
#else
|
||||
/* Start application in system mode */
|
||||
orr r1, r0, #0x1F /* System mode */
|
||||
msr cpsr_cxsf, r1
|
||||
ldr sp, =__stack_end__
|
||||
#endif
|
||||
|
||||
#ifdef INITIALIZE_STACKS
|
||||
mov r2, #0xCC
|
||||
ldr r0, =__stack_und_start__
|
||||
ldr r1, =__stack_und_end__
|
||||
bl memory_set
|
||||
ldr r0, =__stack_abt_start__
|
||||
ldr r1, =__stack_abt_end__
|
||||
bl memory_set
|
||||
ldr r0, =__stack_irq_start__
|
||||
ldr r1, =__stack_irq_end__
|
||||
bl memory_set
|
||||
ldr r0, =__stack_fiq_start__
|
||||
ldr r1, =__stack_fiq_end__
|
||||
bl memory_set
|
||||
ldr r0, =__stack_svc_start__
|
||||
ldr r1, =__stack_svc_end__
|
||||
bl memory_set
|
||||
ldr r0, =__stack_start__
|
||||
ldr r1, =__stack_end__
|
||||
bl memory_set
|
||||
#endif
|
||||
|
||||
/* Copy from initialised data section to data section (if necessary). */
|
||||
ldr r0, =__data_load_start__
|
||||
ldr r1, =__data_start__
|
||||
ldr r2, =__data_end__
|
||||
bl memory_copy
|
||||
|
||||
/* Copy from initialised text section to text section (if necessary). */
|
||||
ldr r0, =__text_load_start__
|
||||
ldr r1, =__text_start__
|
||||
ldr r2, =__text_end__
|
||||
bl memory_copy
|
||||
|
||||
/* Copy from initialised fast_text section to fast_text section (if necessary). */
|
||||
ldr r0, =__fast_load_start__
|
||||
ldr r1, =__fast_start__
|
||||
ldr r2, =__fast_end__
|
||||
bl memory_copy
|
||||
|
||||
/* Zero the bss. */
|
||||
ldr r0, =__bss_start__
|
||||
ldr r1, =__bss_end__
|
||||
mov r2, #0
|
||||
bl memory_set
|
||||
|
||||
#ifdef INITIALIZE_SECONDARY_SECTIONS
|
||||
ldr r0, =__data2_load_start__
|
||||
ldr r1, =__data2_start__
|
||||
ldr r2, =__data2_end__
|
||||
bl memory_copy
|
||||
|
||||
/* Copy from initialised text2 section to text2 section (if necessary). */
|
||||
ldr r0, =__text2_load_start__
|
||||
ldr r1, =__text2_start__
|
||||
ldr r2, =__text2_end__
|
||||
bl memory_copy
|
||||
|
||||
/* Zero bss2. */
|
||||
ldr r0, =__bss2_start__
|
||||
ldr r1, =__bss2_end__
|
||||
mov r2, #0
|
||||
bl memory_set
|
||||
|
||||
#endif /* #ifdef INITIALIZE_SECONDARY_SECTIONS */
|
||||
|
||||
/* Initialise the heap */
|
||||
ldr r0, = __heap_start__
|
||||
ldr r1, = __heap_end__
|
||||
sub r1, r1, r0 /* r1 = r1-r0 */
|
||||
mov r2, #0
|
||||
str r2, [r0], #+4 /* *r0++ = 0 */
|
||||
str r1, [r0] /* *r0 = __heap_end__ - __heap_start__ */
|
||||
|
||||
/* Call constructors */
|
||||
ldr r0, =__ctors_start__
|
||||
ldr r1, =__ctors_end__
|
||||
ctor_loop:
|
||||
cmp r0, r1
|
||||
beq ctor_end
|
||||
ldr r2, [r0], #+4
|
||||
stmfd sp!, {r0-r1}
|
||||
mov lr, pc
|
||||
mov pc, r2
|
||||
ldmfd sp!, {r0-r1}
|
||||
b ctor_loop
|
||||
ctor_end:
|
||||
|
||||
/* Setup initial call frame */
|
||||
mov lr, #4
|
||||
mov r12, sp
|
||||
stmfd sp!, {r11-r12, lr-pc}
|
||||
sub r11, r12, #0x00000004
|
||||
|
||||
start:
|
||||
/* Jump to application entry point */
|
||||
mov r0, #0
|
||||
mov r1, #0
|
||||
ldr r2, =APP_ENTRY_POINT
|
||||
mov lr, pc
|
||||
#ifdef __ARM_ARCH_3__
|
||||
mov pc, r2
|
||||
#else
|
||||
bx r2
|
||||
#endif
|
||||
|
||||
/* Call destructors */
|
||||
ldr r0, =__dtors_start__
|
||||
ldr r1, =__dtors_end__
|
||||
dtor_loop:
|
||||
cmp r0, r1
|
||||
beq dtor_end
|
||||
ldr r2, [r0], #+4
|
||||
stmfd sp!, {r0-r1}
|
||||
mov lr, pc
|
||||
mov pc, r2
|
||||
ldmfd sp!, {r0-r1}
|
||||
b dtor_loop
|
||||
dtor_end:
|
||||
|
||||
/* Returned from application entry point, loop forever. */
|
||||
exit_loop:
|
||||
b exit_loop
|
||||
|
||||
memory_copy:
|
||||
cmp r0, r1
|
||||
moveq pc, lr
|
||||
subs r2, r2, r1
|
||||
moveq pc, lr
|
||||
1:
|
||||
ldrb r3, [r0], #+1
|
||||
strb r3, [r1], #+1
|
||||
subs r2, r2, #1
|
||||
bne 1b
|
||||
mov pc, lr
|
||||
|
||||
memory_set:
|
||||
cmp r0, r1
|
||||
moveq pc, lr
|
||||
strb r2, [r0], #1
|
||||
b memory_set
|
||||
|
||||
|
|
@ -1,236 +0,0 @@
|
|||
/*****************************************************************************
|
||||
Exception handlers and startup code for Atmel AT91SAM7.
|
||||
|
||||
Copyright (c) 2004 Rowley Associates Limited.
|
||||
|
||||
This file may be distributed under the terms of the License Agreement
|
||||
provided with this software.
|
||||
|
||||
THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Preprocessor Definitions
|
||||
* ------------------------
|
||||
*
|
||||
* VECTORED_IRQ_INTERRUPTS
|
||||
*
|
||||
* Enable vectored IRQ interrupts. If defined, the PC register will be loaded
|
||||
* with the contents of the AIC_IVR register on an IRQ exception.
|
||||
*
|
||||
* STARTUP_FROM_RESET
|
||||
*
|
||||
* If defined, the program will startup from power-on/reset. If not defined
|
||||
* the program will just loop endlessly from power-on/reset.
|
||||
*
|
||||
* This definition is not defined by default on this target because the
|
||||
* debugger is unable to reset this target and maintain control of it over the
|
||||
* JTAG interface. The advantage of doing this is that it allows the debugger
|
||||
* to reset the CPU and run programs from a known reset CPU state on each run.
|
||||
* It also acts as a safety net if you accidently download a program in FLASH
|
||||
* that crashes and prevents the debugger from taking control over JTAG
|
||||
* rendering the target unusable over JTAG. The obvious disadvantage of doing
|
||||
* this is that your application will not startup without the debugger.
|
||||
*
|
||||
* We advise that on this target you keep STARTUP_FROM_RESET undefined whilst
|
||||
* you are developing and only define STARTUP_FROM_RESET when development is
|
||||
* complete.
|
||||
*
|
||||
* MC_FMR_FMCN_VAL
|
||||
*
|
||||
* Override the default Flash Mode Register FMCN value by defining
|
||||
* MC_FMR_FMCN_VAL.
|
||||
*
|
||||
* MC_FMR_FWS_VAL
|
||||
*
|
||||
* Override the default Flash Mode Register FWS value by defining
|
||||
* MC_FMR_FWS_VAL.
|
||||
*
|
||||
* CKGR_MOR_VAL
|
||||
*
|
||||
* Override the default Main Oscillator Register value by defining
|
||||
* CKGR_MOR_VAL.
|
||||
*
|
||||
* CKGR_PLLR_VAL
|
||||
*
|
||||
* Override the default Clock Generator PLL Register value by defining
|
||||
* CKGR_PLLR_VAL.
|
||||
*
|
||||
* NO_WATCHDOG_DISABLE
|
||||
*
|
||||
* If defined, the watchdog will not be disabled.
|
||||
*
|
||||
* NO_USER_RESET
|
||||
*
|
||||
* If defined, user reset will not be enabled.
|
||||
*
|
||||
* NO_PROTECTION_MODE
|
||||
*
|
||||
* If defined, AIC protection mode will not be enabled. AIC protection
|
||||
* mode allows the AIC_IVR register to be accessed by the debugger (for
|
||||
* example through the memory or register window). With protection mode
|
||||
* disabled accesses of the AIC_IVR register by the debugger are likely
|
||||
* to disrupt interrupt behaviour.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <targets/AT91SAM7.h>
|
||||
|
||||
#ifndef MC_FMR_FMCN_VAL
|
||||
#define MC_FMR_FMCN_VAL 72
|
||||
#endif
|
||||
|
||||
#ifndef MC_FMR_FWS_VAL
|
||||
#define MC_FMR_FWS_VAL 1
|
||||
#endif
|
||||
|
||||
#ifndef CKGR_MOR_VAL
|
||||
#define CKGR_MOR_VAL (0x40 << CKGR_MOR_OSCOUNT_BIT) | CKGR_MOR_MOSCEN
|
||||
#endif
|
||||
|
||||
#ifndef CKGR_PLLR_VAL
|
||||
#if OSCILLATOR_CLOCK_FREQUENCY==18432000
|
||||
/* MCK, UDPCK = 18.432MHz * 73 / 14 / 2 = 48.05486MHz */
|
||||
#define CKGR_PLLR_VAL (1 << CKGR_PLLR_USBDIV_BIT) | (72 << CKGR_PLLR_MUL_BIT) | (0 << CKGR_PLLR_OUT_BIT) | (63 << CKGR_PLLR_PLLCOUNT_BIT) | (14 << CKGR_PLLR_DIV_BIT)
|
||||
#else
|
||||
#error OSCILLATOR_CLOCK_FREQUENCY not supported
|
||||
#endif
|
||||
#endif
|
||||
|
||||
.section .vectors, "ax"
|
||||
.code 32
|
||||
.align 0
|
||||
.global _vectors
|
||||
.global reset_handler
|
||||
|
||||
/*****************************************************************************
|
||||
Exception Vectors
|
||||
*****************************************************************************/
|
||||
_vectors:
|
||||
#ifdef STARTUP_FROM_RESET
|
||||
ldr pc, [pc, #reset_handler_address - . - 8] /* reset */
|
||||
#else
|
||||
b . /* reset - infinite loop */
|
||||
#endif
|
||||
ldr pc, [pc, #undef_handler_address - . - 8] /* undefined instruction */
|
||||
ldr pc, [pc, #swi_handler_address - . - 8] /* swi handler */
|
||||
ldr pc, [pc, #pabort_handler_address - . - 8] /* abort prefetch */
|
||||
ldr pc, [pc, #dabort_handler_address - . - 8] /* abort data */
|
||||
nop
|
||||
ldr pc, [pc, #-0xF20] /* irq */
|
||||
ldr pc, [pc, #fiq_handler_address - . - 8] /* fiq */
|
||||
|
||||
reset_handler_address:
|
||||
.word reset_handler
|
||||
undef_handler_address:
|
||||
.word undef_handler
|
||||
swi_handler_address:
|
||||
.word swi_handler
|
||||
pabort_handler_address:
|
||||
.word pabort_handler
|
||||
dabort_handler_address:
|
||||
.word dabort_handler
|
||||
irq_handler_address:
|
||||
.word irq_handler
|
||||
fiq_handler_address:
|
||||
.word fiq_handler
|
||||
|
||||
.section .init, "ax"
|
||||
.code 32
|
||||
.align 0
|
||||
|
||||
/******************************************************************************
|
||||
Reset handler
|
||||
******************************************************************************/
|
||||
reset_handler:
|
||||
/* Set up FLASH wait state */
|
||||
ldr r1, =MC_BASE
|
||||
ldr r0, =(MC_FMR_FMCN_VAL << MC_FMR_FMCN_BIT) | (MC_FMR_FWS_VAL << MC_FMR_FWS_BIT)
|
||||
str r0, [r1, #MC_FMR_OFFSET]
|
||||
|
||||
/* Disable Watchdog */
|
||||
ldr r1, =WDT_BASE
|
||||
ldr r0, =WDT_MR_WDDIS
|
||||
str r0, [r1, #WDT_MR_OFFSET]
|
||||
|
||||
#ifndef NO_PROTECTION_MODE
|
||||
/* Enable protect mode */
|
||||
ldr r1, =AIC_BASE
|
||||
ldr r0, =0x00000001
|
||||
str r0, [r1, #AIC_DCR_OFFSET]
|
||||
#endif
|
||||
|
||||
/* Enable the main oscillator */
|
||||
ldr r1, =PMC_BASE
|
||||
ldr r0, =CKGR_MOR_VAL
|
||||
str r0, [r1, #CKGR_MOR_OFFSET]
|
||||
|
||||
1:/* Wait for main oscillator to stabilize */
|
||||
ldr r0, [r1, #PMC_SR_OFFSET]
|
||||
tst r0, #PMC_SR_MOSCS
|
||||
beq 1b
|
||||
|
||||
/* Set up the PLL */
|
||||
ldr r0, =CKGR_PLLR_VAL
|
||||
str r0, [r1, #CKGR_PLLR_OFFSET]
|
||||
|
||||
1:/* Wait for PLL to lock */
|
||||
ldr r0, [r1, #PMC_SR_OFFSET]
|
||||
tst r0, #PMC_SR_LOCK
|
||||
beq 1b
|
||||
|
||||
/* Set the master clock prescaler */
|
||||
ldr r0, =(1 << PMC_MCKR_PRES_BIT)
|
||||
str r0, [r1, #PMC_MCKR_OFFSET]
|
||||
|
||||
1:/* Wait for MCKRDY */
|
||||
ldr r0, [r1, #PMC_SR_OFFSET]
|
||||
tst r0, #PMC_SR_MCKRDY
|
||||
beq 1b
|
||||
|
||||
/* Select PLL as clock source */
|
||||
ldr r0, =((1 << PMC_MCKR_PRES_BIT) | 3 << PMC_MCKR_CSS_BIT)
|
||||
str r0, [r1, #PMC_MCKR_OFFSET]
|
||||
|
||||
#ifdef __FLASH_BUILD
|
||||
/* Copy exception vectors into Internal SRAM */
|
||||
mov r8, #0x00200000
|
||||
ldr r9, =_vectors
|
||||
ldmia r9!, {r0-r7}
|
||||
stmia r8!, {r0-r7}
|
||||
ldmia r9!, {r0-r6}
|
||||
stmia r8!, {r0-r6}
|
||||
|
||||
/* Remap Internal SRAM to 0x00000000 */
|
||||
ldr r1, =MC_BASE
|
||||
ldr r0, =1
|
||||
strb r0, [r1, #MC_RCR_OFFSET]
|
||||
#endif
|
||||
|
||||
/* Jump to the default C runtime startup code. */
|
||||
b _start
|
||||
|
||||
/******************************************************************************
|
||||
Default exception handlers
|
||||
(These are declared weak symbols so they can be redefined in user code)
|
||||
******************************************************************************/
|
||||
undef_handler:
|
||||
b . /* Endless loop */
|
||||
|
||||
swi_handler:
|
||||
b . /* Endless loop */
|
||||
|
||||
pabort_handler:
|
||||
b . /* Endless loop */
|
||||
|
||||
dabort_handler:
|
||||
b . /* Endless loop */
|
||||
|
||||
irq_handler:
|
||||
b . /* Endless loop */
|
||||
|
||||
fiq_handler:
|
||||
b . /* Endless loop */
|
||||
|
||||
.weak undef_handler, swi_handler, pabort_handler, dabort_handler, irq_handler, fiq_handler
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
|
||||
FREEMODBUS 1.5 ATSAM3S EXAMPLE
|
||||
==============================
|
||||
|
||||
REQUIREMENTS
|
||||
============
|
||||
|
||||
This example contains a simple demo program for FreeMODBUS for the AT91SAM3S
|
||||
Cortex M3 controllers on the SAM3S-EK [0] evaluation kit. It requires a wired
|
||||
RS485 connection to a host processor and a MODBUS master software on the PC
|
||||
side to be useful. Demo versions of MODBUS master stacks can be found in
|
||||
[1], [2] and [3]. Commercial MODBUS stacks are available from [4].
|
||||
|
||||
INSTALLATION
|
||||
============
|
||||
The SAM3S-EK evaluation board should be modified as following to enable RS485
|
||||
data transmission.
|
||||
|
||||
- Place Jumpers JP11, JP10 and JP12
|
||||
- Place a solder drop accross R25
|
||||
|
||||
Warning: The RS485 shares data lines with USART1. It is therefore absolutely
|
||||
necessary to set PA23 to a high level.
|
||||
|
||||
SOURCE
|
||||
======
|
||||
|
||||
TESTING
|
||||
=======
|
||||
|
||||
Start the MODBUS sample application and test if the input registers starting
|
||||
at protocol address 1000 can be read. There are four registers values avai-
|
||||
lable and the output should look like:
|
||||
|
||||
Polling slave (Ctrl-C to stop) ...
|
||||
[1000]: 6474
|
||||
[1001]: 0
|
||||
[1002]: 0
|
||||
[1003]: 0
|
||||
Polling slave (Ctrl-C to stop) ...
|
||||
[1000]: -8831
|
||||
[1001]: 0
|
||||
[1002]: 0
|
||||
[1003]: 0
|
||||
Polling slave (Ctrl-C to stop) ...
|
||||
|
||||
The simple testing utility used in the 'demo_rtu.bat' script can be found at
|
||||
[3].
|
||||
|
||||
PROBLEMS
|
||||
========
|
||||
|
||||
In case you can get no communication working make sure that the RS485 line is
|
||||
biased correctly. The SAM3S-EK does not populate the RS485 bias resistors by
|
||||
default and if you have a RS485 master which does not bias the lines either
|
||||
you will get wrong characters. For this R24 and R30 on the bottom side of the
|
||||
evaluation kit of the PCB should be populated.
|
||||
|
||||
REFERENCES
|
||||
==========
|
||||
|
||||
[0] Atmel SAM3S-EK: http://www.atmel.com/dyn/products/tools_card_v2.asp?tool_id=4678
|
||||
[1] WinTech ModScan32: http://www.win-tech.com/html/modscan32.htm
|
||||
[2] Modus Poll: http://www.modbustools.com/modbus_poll.asp
|
||||
[3] FieldTalk Modpoll: http://www.focus-sw.com/fieldtalk/modpoll.html
|
||||
[4] Embedded Solutions: http://www.embedded-solutions.at
|
||||
|
||||
Version: $Id: README.txt,v 1.1 2010/06/05 09:57:46 wolti Exp $
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,130 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \unit
|
||||
/// !Purpose
|
||||
///
|
||||
/// Definition of AT91SAM3S4 characteristics and features
|
||||
///
|
||||
/// !Usage
|
||||
/// -# For ARM core feature, see "AT91SAM3S4 - ARM core features".
|
||||
/// -# For IP features, see "AT91SAM3S4 - IP features".
|
||||
/// -# For misc, see "AT91SAM3S4 - Misc".
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef CHIP_H
|
||||
#define CHIP_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \page "AT91SAM3S4 - ARM core features"
|
||||
/// This page lists several characteristics related to the ARM core
|
||||
///
|
||||
|
||||
//ARM core features
|
||||
|
||||
/// ARM core definition.
|
||||
#define cortexm3
|
||||
|
||||
/// family definition.
|
||||
#define at91sam3s
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \page "AT91SAM3S4 - IP features"
|
||||
/// This page lists several characteristics related to the embedded IP
|
||||
///
|
||||
|
||||
//IP FEATURES
|
||||
|
||||
// EFC GPNVM number
|
||||
#define CHIP_EFC_NUM_GPNVMS 3
|
||||
|
||||
/// Indicates chip has an Enhanced EFC.
|
||||
#define CHIP_FLASH_EEFC
|
||||
|
||||
// DMA channels number
|
||||
#define CHIP_DMA_CHANNEL_NUM 4
|
||||
|
||||
// Indicate chip's MCI interface.
|
||||
#define MCI2_INTERFACE
|
||||
|
||||
// Indicate chip SSC has DMA interface.
|
||||
#define CHIP_SSC_DMA
|
||||
|
||||
// Indicate chip SPI has DMA interface.
|
||||
#define CHIP_SPI_DMA
|
||||
|
||||
/// Indicates chip has an UDP Full Speed.
|
||||
#define CHIP_USB_UDP
|
||||
|
||||
/// Indicates chip has an internal pull-up.
|
||||
#define CHIP_USB_PULLUP_INTERNAL
|
||||
|
||||
/// Number of USB endpoints
|
||||
#define CHIP_USB_NUMENDPOINTS 8
|
||||
|
||||
/// Endpoints max paxcket size
|
||||
#define CHIP_USB_ENDPOINTS_MAXPACKETSIZE(i) \
|
||||
((i == 0) ? 64 : \
|
||||
((i == 1) ? 64 : \
|
||||
((i == 2) ? 64 : \
|
||||
((i == 3) ? 64 : \
|
||||
((i == 4) ? 512 : \
|
||||
((i == 5) ? 512 : \
|
||||
((i == 6) ? 64 : \
|
||||
((i == 7) ? 64 : 0 ))))))))
|
||||
|
||||
/// Endpoints Number of Bank
|
||||
#define CHIP_USB_ENDPOINTS_BANKS(i) \
|
||||
((i == 0) ? 1 : \
|
||||
((i == 1) ? 2 : \
|
||||
((i == 2) ? 2 : \
|
||||
((i == 3) ? 1 : \
|
||||
((i == 4) ? 2 : \
|
||||
((i == 5) ? 2 : \
|
||||
((i == 6) ? 2 : \
|
||||
((i == 7) ? 2 : 0 ))))))))
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \page "AT91SAM3S4 - Misc "
|
||||
/// This page lists misc features
|
||||
///
|
||||
|
||||
//Misc
|
||||
|
||||
#endif //#ifndef CHIP_H
|
||||
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */
|
||||
/*-Vector table start*/
|
||||
define symbol __ICFEDIT_vector_start__ = 0x000400000; /*Add for CMSIS*/
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2000BFFF;
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x00400000;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0043FFFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x800;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
||||
|
||||
export symbol __ICFEDIT_vector_start__; /*Add for CMSIS*/
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
place at address mem:__ICFEDIT_vector_start__ { readonly section .vectors }; /*Add for CMSIS*/
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,,block CSTACK, block HEAP };
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Linker script for running in internal FLASH on the AT91SAM3S4
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(ResetException)
|
||||
|
||||
/* Memory Spaces Definitions */
|
||||
MEMORY
|
||||
{
|
||||
sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x0000C000 /* sram, 48K */
|
||||
flash (W!RX) : ORIGIN = 0x00400000, LENGTH = 0x00040000 /* Flash, 256K */
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.fixed :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sfixed = .;
|
||||
KEEP(*(.vectors))
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
. = ALIGN(4);
|
||||
_efixed = .; /* End of text section */
|
||||
} >flash
|
||||
|
||||
.relocate : AT (_efixed)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_srelocate = .;
|
||||
*(.ramfunc);
|
||||
*(.data);
|
||||
. = ALIGN(4);
|
||||
_erelocate = .;
|
||||
} >sram
|
||||
|
||||
.bss (NOLOAD) : {
|
||||
. = ALIGN(4);
|
||||
_szero = .;
|
||||
*(.bss)
|
||||
. = ALIGN(4);
|
||||
_ezero = .;
|
||||
} >sram
|
||||
|
||||
/* Stack in the end of SRAM */
|
||||
_estack = 0x2000BFFC;
|
||||
}
|
||||
end = .;
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */
|
||||
/*-Vector table start*/
|
||||
define symbol __ICFEDIT_vector_start__ = 0x20000000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2000BFFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x900;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
||||
/*-Exports-*/
|
||||
export symbol __ICFEDIT_vector_start__;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
/* define block RamVect with alignment = 8, size = __ICFEDIT_size_vectors__ { }; */
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
place at address mem:__ICFEDIT_vector_start__ { readonly section .vectors };
|
||||
place in RAM_region { readonly, readwrite, block CSTACK, block HEAP };
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Linker script for running in internal SRAM on the AT91SAM3S4
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(ResetException)
|
||||
|
||||
/* Memory Spaces Definitions */
|
||||
MEMORY
|
||||
{
|
||||
sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x0000C000 /* sram, 48K */
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.fixed :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sfixed = .;
|
||||
KEEP(*(.vectors))
|
||||
*(.text*)
|
||||
*(.ramfunc)
|
||||
*(.rodata*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
. = ALIGN(4);
|
||||
_efixed = .; /* End of text section */
|
||||
} > sram
|
||||
|
||||
.relocate : AT (_efixed)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_srelocate = .;
|
||||
*(.data)
|
||||
. = ALIGN(4);
|
||||
_erelocate = .;
|
||||
} >sram
|
||||
|
||||
.bss (NOLOAD) : {
|
||||
. = ALIGN(4);
|
||||
_szero = .;
|
||||
*(.bss)
|
||||
. = ALIGN(4);
|
||||
_ezero = .;
|
||||
} >sram
|
||||
|
||||
/* Stack in the end of SRAM */
|
||||
_estack = 0x2000BFFC;
|
||||
|
||||
}
|
||||
end = .;
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x0;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000040;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2000BFFF;
|
||||
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x0200;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x000;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
//initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
place at address mem:__ICFEDIT_intvec_start__ { section .intvec };
|
||||
|
||||
place at start of RAM_region { block RamTop with fixed order {readonly, section LOWEND}};
|
||||
place at end of RAM_region { block RamBottom with fixed order {section HIGHSTART, readwrite, section .init,
|
||||
block CSTACK, block HEAP}};
|
||||
|
||||
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Linker script for running in internal SRAM on the AT91SAM3S4
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(entry)
|
||||
|
||||
/* Memory Spaces Definitions */
|
||||
MEMORY
|
||||
{
|
||||
romcodesram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x01000
|
||||
sram (W!RX) : ORIGIN = 0x20001000, LENGTH = 0x0000B000 /* sram, 48K - sizeof(romcodesram) */
|
||||
}
|
||||
|
||||
/* Entry point */
|
||||
/*ENTRY (ResetException)*/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* startup code in the .isr_vector */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_stext = .;
|
||||
KEEP(*(.isr_vector .isr_vector.*))
|
||||
*(.mailbox)
|
||||
*(.text .text.*)
|
||||
*(.rodata .rodata.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.gcc_except_table)
|
||||
*(.rodata .rodata*)
|
||||
*(.gnu.linkonce.r.*)
|
||||
. = ALIGN(4);
|
||||
_etext = .;
|
||||
} > sram
|
||||
|
||||
/* data */
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sidata = .;
|
||||
_sdata = .;
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
. = ALIGN(4);
|
||||
_edata = .;
|
||||
} > sram
|
||||
|
||||
.bss (NOLOAD) : {
|
||||
_szero = .;
|
||||
*(.bss)
|
||||
. = ALIGN(4);
|
||||
_ezero = .;
|
||||
} >sram
|
||||
|
||||
/* Stack in SRAM */
|
||||
_sstack = 0x2000BFFC;
|
||||
}
|
||||
end = .;
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,77 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CHIP_H
|
||||
#define CHIP_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//ARM core features
|
||||
|
||||
// ARM core definition.
|
||||
#define cortexm3
|
||||
|
||||
// family definition.
|
||||
#define at91sam3u
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//IP FEATURES
|
||||
|
||||
// EFC GPNVM number
|
||||
#define CHIP_EFC_NUM_GPNVMS 3
|
||||
|
||||
// Indicates chip has an Enhanced EFC.
|
||||
#define CHIP_FLASH_EEFC
|
||||
|
||||
// DMA channels number
|
||||
#define CHIP_DMA_CHANNEL_NUM 4
|
||||
|
||||
// Indicate chip has a nandflash controller.
|
||||
#define CHIP_NAND_CTRL
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//Misc
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#endif //#ifndef CHIP_H
|
||||
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */
|
||||
/*-Vector table start*/
|
||||
define symbol __ICFEDIT_vector_start__ = 0x00080000; /*Add for CMSIS*/
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_RAM0_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM0_end__ = 0x20007FFF;
|
||||
define symbol __ICFEDIT_region_RAM1_start__ = 0x20080000;
|
||||
define symbol __ICFEDIT_region_RAM1_end__ = 0x20083FFF;
|
||||
define symbol __ICFEDIT_region_ROM0_start__ = 0x00080000;
|
||||
define symbol __ICFEDIT_region_ROM0_end__ = 0x0009FFFF;
|
||||
define symbol __ICFEDIT_region_ROM1_start__ = 0x00100000;
|
||||
define symbol __ICFEDIT_region_ROM1_end__ = 0x0011FFFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x800;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
||||
/*-Specials-*/
|
||||
/*define symbol __ICFEDIT_region_RAM_VECT_start__ = __ICFEDIT_region_RAM0_start__;*/ /*Referenced for CMSIS*/
|
||||
/*define symbol __ICFEDIT_size_vectors__ = 0x100;*/ /*Referenced for CMSIS*/
|
||||
/*-Exports-*/
|
||||
/*export symbol __ICFEDIT_region_RAM_VECT_start__;*/
|
||||
export symbol __ICFEDIT_vector_start__; /*Add for CMSIS*/
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define memory mem with size = 4G;
|
||||
/*define region RAM_VECT_region = mem:[from __ICFEDIT_region_RAM_VECT_start__ size __ICFEDIT_size_vectors__];*/ /*Referenced for CMSIS*/
|
||||
/*define region RAM0_region = mem:[from __ICFEDIT_region_RAM0_start__+__ICFEDIT_size_vectors__ to __ICFEDIT_region_RAM0_end__];*/ /*Referenced for CMSIS*/
|
||||
define region RAM0_region = mem:[from __ICFEDIT_region_RAM0_start__ to __ICFEDIT_region_RAM0_end__];
|
||||
define region RAM1_region = mem:[from __ICFEDIT_region_RAM1_start__ to __ICFEDIT_region_RAM1_end__];
|
||||
/*define region RAM_region = mem:[from __ICFEDIT_region_RAM0_start__+__ICFEDIT_size_vectors__ to __ICFEDIT_region_RAM0_end__] |
|
||||
mem:[from __ICFEDIT_region_RAM1_start__ to __ICFEDIT_region_RAM1_end__];*/ /*Referenced for CMSIS*/
|
||||
define region ROM0_region = mem:[from __ICFEDIT_region_ROM0_start__ to __ICFEDIT_region_ROM0_end__];
|
||||
define region ROM1_region = mem:[from __ICFEDIT_region_ROM1_start__ to __ICFEDIT_region_ROM1_end__];
|
||||
|
||||
/*define block RamVect with alignment = 8, size = __ICFEDIT_size_vectors__ { };*/
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
/*place at start of ROM0_region { readonly section .vectors };*/ /*Referenced for CMSIS*/
|
||||
place at address mem:__ICFEDIT_vector_start__ { readonly section .vectors }; /*Add for CMSIS*/
|
||||
place in ROM0_region { readonly };
|
||||
place in RAM0_region { readwrite, block CSTACK, block HEAP };
|
||||
/*place in RAM_VECT_region { block RamVect };*/ /*Referenced for CMSIS*/
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Linker script for running in internal FLASH on the AT91SAM3U4
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(ResetException)
|
||||
|
||||
/* Vector Definition */
|
||||
/* vector is put at very begin adress of SRAM0, the preserved size is 0x100 */
|
||||
_vect_start = 0x20000000;
|
||||
|
||||
/* Memory Spaces Definitions */
|
||||
MEMORY
|
||||
{
|
||||
sram0 (W!RX) : ORIGIN = 0x20000100, LENGTH = 0x00007F00 /* Sram0, 32K */
|
||||
sram1 (W!RX) : ORIGIN = 0x20080000, LENGTH = 0x00004000 /* Sram1, 16K */
|
||||
flash0 (W!RX) : ORIGIN = 0x00080000, LENGTH = 0x00020000 /* Flash0, 128K */
|
||||
flash1 (W!RX) : ORIGIN = 0x00100000, LENGTH = 0x00020000 /* Flash1, 128K */
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.fixed :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sfixed = .;
|
||||
KEEP(*(.vectors))
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
. = ALIGN(4);
|
||||
_efixed = .; /* End of text section */
|
||||
} >flash0
|
||||
|
||||
.relocate : AT (_efixed)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_srelocate = .;
|
||||
*(.ramfunc);
|
||||
*(.data);
|
||||
. = ALIGN(4);
|
||||
_erelocate = .;
|
||||
} >sram0
|
||||
|
||||
.bss (NOLOAD) : {
|
||||
. = ALIGN(4);
|
||||
_szero = .;
|
||||
*(.bss)
|
||||
. = ALIGN(4);
|
||||
_ezero = .;
|
||||
} >sram0
|
||||
|
||||
/* Stack in the end of SRAM0 */
|
||||
_estack = 0x20007FFC;
|
||||
}
|
||||
end = .;
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
; * ----------------------------------------------------------------------------
|
||||
; * ATMEL Microcontroller Software Support
|
||||
; * ----------------------------------------------------------------------------
|
||||
; * Copyright (c) 2008, Atmel Corporation
|
||||
; *
|
||||
; * All rights reserved.
|
||||
; *
|
||||
; * Redistribution and use in source and binary forms, with or without
|
||||
; * modification, are permitted provided that the following conditions are met:
|
||||
; *
|
||||
; * - Redistributions of source code must retain the above copyright notice,
|
||||
; * this list of conditions and the disclaimer below.
|
||||
; *
|
||||
; * Atmel's name may not be used to endorse or promote products derived from
|
||||
; * this software without specific prior written permission.
|
||||
; *
|
||||
; * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
; * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
; * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
; * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
; * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
; * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
; * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
; * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
; * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
; * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
; * ----------------------------------------------------------------------------
|
||||
|
||||
; *------------------------------------------------------------------------------
|
||||
; * Linker scatter for running in internal SRAM on the AT91SAM3U4
|
||||
; *----------------------------------------------------------------------------*/
|
||||
|
||||
; /* vector is put at very begin adress of SRAM0, the preserved size is 0x100 */
|
||||
Load_region 0x80000 0x20000
|
||||
{
|
||||
; Flash 128K
|
||||
Vector_region 0x80000
|
||||
{
|
||||
board_cstartup_keil.o (vectors, +FIRST)
|
||||
}
|
||||
Fixed_region +0
|
||||
{
|
||||
.ANY (+RO)
|
||||
}
|
||||
; SRAM0 32K
|
||||
Relocate_region 0x20000100 (0x8000-0x100)
|
||||
{
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
; Configure Stack and Heap
|
||||
ARM_LIB_HEAP 0x20007000 EMPTY 0x400
|
||||
{
|
||||
}
|
||||
|
||||
ARM_LIB_STACK 0x20007FFC EMPTY -0x400
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */
|
||||
/*-Vector table start*/
|
||||
define symbol __ICFEDIT_vector_start__ = 0x60000000; /*Add for CMSIS*/
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_RAM0_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM0_end__ = 0x20007FFF;
|
||||
define symbol __ICFEDIT_region_RAM1_start__ = 0x20080000;
|
||||
define symbol __ICFEDIT_region_RAM1_end__ = 0x20083FFF;
|
||||
define symbol __ICFEDIT_region_PSRAM_start__ = 0x60000000;
|
||||
define symbol __ICFEDIT_region_RSRAM_end__ = 0x600FFFFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
||||
/*-Specials-*/
|
||||
/*define symbol __ICFEDIT_region_RAM_VECT_start__ = __ICFEDIT_region_RAM0_start__;*/ /*Referenced for CMSIS*/
|
||||
/*define symbol __ICFEDIT_size_vectors__ = 0x100;*/ /*Referenced for CMSIS*/
|
||||
/*-Exports-*/
|
||||
export symbol __ICFEDIT_region_RAM_VECT_start__; /*Add for CMSIS*/
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define memory mem with size = 4G;
|
||||
/*define region RAM_VECT_region = mem:[from __ICFEDIT_region_RAM_VECT_start__ size __ICFEDIT_size_vectors__];*/
|
||||
/*define region RAM0_region = mem:[from __ICFEDIT_region_RAM0_start__+__ICFEDIT_size_vectors__ to __ICFEDIT_region_RAM0_end__];*/ /*Referenced for CMSIS*/
|
||||
define region RAM0_region = mem:[from __ICFEDIT_region_RAM0_start__ to __ICFEDIT_region_RAM0_end__];
|
||||
define region RAM1_region = mem:[from __ICFEDIT_region_RAM1_start__ to __ICFEDIT_region_RAM1_end__];
|
||||
/*define region RAM_region = mem:[from __ICFEDIT_region_RAM0_start__+__ICFEDIT_size_vectors__ to __ICFEDIT_region_RAM0_end__] |
|
||||
mem:[from __ICFEDIT_region_RAM1_start__ to __ICFEDIT_region_RAM1_end__];*/ /*Referenced for CMSIS*/
|
||||
define region PSRAM_region = mem:[from __ICFEDIT_region_PSRAM_start__ to __ICFEDIT_region_RSRAM_end__];
|
||||
|
||||
/*define block RamVect with alignment = 8, size = __ICFEDIT_size_vectors__ { };*/ /*Referenced for CMSIS*/
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
/*place at start of PSRAM_region { readonly section .vectors };*/ /*Referenced for CMSIS*/
|
||||
place at address mem:__ICFEDIT_vector_start__ { readonly section .vectors }; /*Add for CMSIS*/
|
||||
place in PSRAM_region { readonly };
|
||||
place in PSRAM_region { readwrite, block CSTACK, block HEAP };
|
||||
/*place in RAM_VECT_region { block RamVect };*/ /*Referenced for CMSIS*/
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Linker script for running in internal PSRAM on the AT91SAM3U4
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(ResetException)
|
||||
|
||||
/* Vector Definition */
|
||||
/* vector is put at very begin adress of SRAM0, the preserved size is 0x100 */
|
||||
_vect_start = 0x20000000;
|
||||
|
||||
/* Memory Spaces Definitions */
|
||||
MEMORY
|
||||
{
|
||||
sram0 (W!RX) : ORIGIN = 0x20000100, LENGTH = 0x00007F00 /* Sram0, 32K */
|
||||
sram1 (W!RX) : ORIGIN = 0x20080000, LENGTH = 0x00004000 /* Sram1, 16K */
|
||||
psram (W!RX) : ORIGIN = 0x60000000, LENGTH = 0x00100000 /* PSRAM, 1M */
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.fixed :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sfixed = .;
|
||||
KEEP(*(.vectors))
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.data)
|
||||
. = ALIGN(4);
|
||||
_efixed = .; /* End of text section */
|
||||
} >psram
|
||||
|
||||
.relocate : AT (_efixed)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_srelocate = .;
|
||||
*(.ramfunc);
|
||||
. = ALIGN(4);
|
||||
_erelocate = .;
|
||||
} >sram0
|
||||
|
||||
.bss (NOLOAD) : {
|
||||
. = ALIGN(4);
|
||||
_szero = .;
|
||||
*(.bss)
|
||||
. = ALIGN(4);
|
||||
_ezero = .;
|
||||
} >psram
|
||||
|
||||
/* Stack in the end of SRAM0 */
|
||||
_estack = 0x20007FFC;
|
||||
}
|
||||
end = .;
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
; * ----------------------------------------------------------------------------
|
||||
; * ATMEL Microcontroller Software Support
|
||||
; * ----------------------------------------------------------------------------
|
||||
; * Copyright (c) 2008, Atmel Corporation
|
||||
; *
|
||||
; * All rights reserved.
|
||||
; *
|
||||
; * Redistribution and use in source and binary forms, with or without
|
||||
; * modification, are permitted provided that the following conditions are met:
|
||||
; *
|
||||
; * - Redistributions of source code must retain the above copyright notice,
|
||||
; * this list of conditions and the disclaimer below.
|
||||
; *
|
||||
; * Atmel's name may not be used to endorse or promote products derived from
|
||||
; * this software without specific prior written permission.
|
||||
; *
|
||||
; * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
; * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
; * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
; * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
; * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
; * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
; * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
; * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
; * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
; * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
; * ----------------------------------------------------------------------------
|
||||
|
||||
; *------------------------------------------------------------------------------
|
||||
; * Linker scatter for running in internal SRAM on the AT91SAM3U4
|
||||
; *----------------------------------------------------------------------------*/
|
||||
|
||||
; /* vector is put at very begin adress of SRAM0, the preserved size is 0x100 */
|
||||
Load_region 0x60000000 0x100000
|
||||
{
|
||||
; PSRAM 1M
|
||||
Vector_region 0x60000000
|
||||
{
|
||||
board_cstartup_keil.o (vectors, +FIRST)
|
||||
}
|
||||
|
||||
Fixed_region +0
|
||||
{
|
||||
.ANY (+RO)
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
|
||||
; SRAM0 32K
|
||||
IVector_region 0x20000000 0x100 {}
|
||||
|
||||
; Configure Stack and Heap
|
||||
ARM_LIB_HEAP 0x20007000 EMPTY 0x400
|
||||
{
|
||||
}
|
||||
|
||||
ARM_LIB_STACK 0x20007FFC EMPTY -0x400
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */
|
||||
/*-Vector table start*/
|
||||
define symbol __ICFEDIT_vector_start__ = 0x20000000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_RAM0_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM0_end__ = 0x20007FFF;
|
||||
define symbol __ICFEDIT_region_RAM1_start__ = 0x20080000;
|
||||
define symbol __ICFEDIT_region_RAM1_end__ = 0x20083FFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
||||
/*-Exports-*/
|
||||
export symbol __ICFEDIT_vector_start__;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region RAM0_region = mem:[from __ICFEDIT_region_RAM0_start__ to __ICFEDIT_region_RAM0_end__];
|
||||
define region RAM1_region = mem:[from __ICFEDIT_region_RAM1_start__ to __ICFEDIT_region_RAM1_end__];
|
||||
/*define region RAM_region = mem:[from __ICFEDIT_region_RAM0_start__+__ICFEDIT_size_vectors__ to __ICFEDIT_region_RAM0_end__] |
|
||||
mem:[from __ICFEDIT_region_RAM1_start__ to __ICFEDIT_region_RAM1_end__];*/
|
||||
|
||||
/* define block RamVect with alignment = 8, size = __ICFEDIT_size_vectors__ { }; */
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
place at address mem:__ICFEDIT_vector_start__ { readonly section .vectors };
|
||||
place in RAM0_region { readonly };
|
||||
place in RAM1_region { readwrite, block CSTACK, block HEAP };
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Linker script for running in internal SRAM on the AT91SAM3U4
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(ResetException)
|
||||
|
||||
/* Vector Definition */
|
||||
_vect_start = 0x20000000;
|
||||
|
||||
/* Memory Spaces Definitions */
|
||||
MEMORY
|
||||
{
|
||||
sram0 (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* Sram0, 32K */
|
||||
sram1 (W!RX) : ORIGIN = 0x20080000, LENGTH = 0x00004000 /* Sram1, 16K */
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.fixed :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sfixed = .;
|
||||
KEEP(*(.vectors))
|
||||
*(.text*)
|
||||
*(.ramfunc)
|
||||
*(.rodata*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
. = ALIGN(4);
|
||||
_efixed = .; /* End of text section */
|
||||
} > sram0
|
||||
|
||||
.relocate : AT (_efixed)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_srelocate = .;
|
||||
*(.data)
|
||||
. = ALIGN(4);
|
||||
_erelocate = .;
|
||||
} >sram1
|
||||
|
||||
.bss (NOLOAD) : {
|
||||
. = ALIGN(4);
|
||||
_szero = .;
|
||||
*(.bss)
|
||||
. = ALIGN(4);
|
||||
_ezero = .;
|
||||
} >sram1
|
||||
|
||||
/* Stack in the end of SRAM1 */
|
||||
_estack = 0x20083FFC;
|
||||
}
|
||||
end = .;
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
; * ----------------------------------------------------------------------------
|
||||
; * ATMEL Microcontroller Software Support
|
||||
; * ----------------------------------------------------------------------------
|
||||
; * Copyright (c) 2008, Atmel Corporation
|
||||
; *
|
||||
; * All rights reserved.
|
||||
; *
|
||||
; * Redistribution and use in source and binary forms, with or without
|
||||
; * modification, are permitted provided that the following conditions are met:
|
||||
; *
|
||||
; * - Redistributions of source code must retain the above copyright notice,
|
||||
; * this list of conditions and the disclaimer below.
|
||||
; *
|
||||
; * Atmel's name may not be used to endorse or promote products derived from
|
||||
; * this software without specific prior written permission.
|
||||
; *
|
||||
; * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
; * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
; * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
; * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
; * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
; * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
; * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
; * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
; * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
; * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
; * ----------------------------------------------------------------------------
|
||||
|
||||
; *------------------------------------------------------------------------------
|
||||
; * Linker scatter for running in internal SRAM on the AT91SAM3U4
|
||||
; *----------------------------------------------------------------------------*/
|
||||
|
||||
Load_region 0x20000000 0x8000
|
||||
{
|
||||
; RAM0 32K
|
||||
Vector_region 0x20000000 0x100
|
||||
{
|
||||
board_cstartup_keil.o (vectors, +FIRST)
|
||||
}
|
||||
|
||||
Fixed_region +0
|
||||
{
|
||||
.ANY (+RO)
|
||||
}
|
||||
|
||||
; RAM1 16K
|
||||
Relocate_region 0x20080000 0x4000
|
||||
{
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
|
||||
; Configure Stack and Heap
|
||||
ARM_LIB_HEAP 0x20083000 EMPTY 0x400
|
||||
{
|
||||
}
|
||||
|
||||
ARM_LIB_STACK 0x20083FFC EMPTY -0x400
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Linker script for running in internal SRAM on the AT91SAM3U4
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(entry)
|
||||
|
||||
/* Memory Spaces Definitions */
|
||||
MEMORY
|
||||
{
|
||||
romcodesram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x01000
|
||||
sram0 (W!RX) : ORIGIN = 0x20001000, LENGTH = 0x00007000 /* Sram0, 32K */
|
||||
}
|
||||
|
||||
/* Entry point */
|
||||
/*ENTRY (ResetException)*/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* startup code in the .isr_vector */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_stext = .;
|
||||
KEEP(*(.isr_vector .isr_vector.*))
|
||||
*(.mailbox)
|
||||
*(.text .text.*)
|
||||
*(.rodata .rodata.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.gcc_except_table)
|
||||
*(.rodata .rodata*)
|
||||
*(.gnu.linkonce.r.*)
|
||||
. = ALIGN(4);
|
||||
_etext = .;
|
||||
} > sram0
|
||||
|
||||
/* data */
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sidata = .;
|
||||
_sdata = .;
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
. = ALIGN(4);
|
||||
_edata = .;
|
||||
} > sram0
|
||||
|
||||
.bss (NOLOAD) : {
|
||||
_szero = .;
|
||||
*(.bss)
|
||||
. = ALIGN(4);
|
||||
_ezero = .;
|
||||
} >sram0
|
||||
|
||||
/* Stack in SRAM0 */
|
||||
_sstack = 0x20008000;
|
||||
}
|
||||
end = .;
|
||||
|
||||
|
|
@ -1,665 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
* \page sam3s_ek_board_desc "SAM3S-EK - Board Description"
|
||||
*
|
||||
* \section
|
||||
* A file is dedicated to descibe the AT91SAM3S-EK board.
|
||||
*
|
||||
* \section Contents
|
||||
* - The code for booting the board is provided by board_cstartup.S and
|
||||
* board_lowlevel.c.
|
||||
* - For using board PIOs, board characteristics (clock, etc.) and external
|
||||
* components, see board.h.
|
||||
* - For manipulating memories (remapping, SDRAM, etc.), see board_memories.h.
|
||||
*
|
||||
* To get more software details and the full list of parameters related to the
|
||||
* SAM3S-EK board configuration, please have a look at the source file: \n
|
||||
* \ref board.h\n
|
||||
*
|
||||
* This file can be used as a template and modified to fit a custom board, with
|
||||
* specific PIOs usage or memory connections.
|
||||
**/
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \file board.h
|
||||
///
|
||||
/// \par Purpose
|
||||
///
|
||||
/// Definition of AT91SAM3S-EK characteristics, AT91SAM3S-dependant PIOs and
|
||||
/// external components interfacing.
|
||||
///
|
||||
/// \par Usage
|
||||
/// -# For operating frequency information, see "SAM3S-EK - Operating frequencies".
|
||||
/// -# For using portable PIO definitions, see "SAM3S-EK - PIO definitions".
|
||||
/// -# Several USB definitions are included here (see "SAM3S-EK - USB device").
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef BOARD_H
|
||||
#define BOARD_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/* These headers were introduced in C99 by working group ISO/IEC JTC1/SC22/WG14. */
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if defined(at91sam3s4)
|
||||
#include "at91sam3s4/chip.h"
|
||||
#include "at91sam3s4/AT91SAM3S4.h"
|
||||
#else
|
||||
#error Board does not support the specified chip.
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \par
|
||||
/// This page lists several definition related to the board description.
|
||||
///
|
||||
/// Definitions
|
||||
/// - BOARD_NAME
|
||||
|
||||
/// Name of the board.
|
||||
#define BOARD_NAME "AT91SAM3S-EK"
|
||||
/// Board definition.
|
||||
#define at91sam3sek
|
||||
/// Family definition (already defined).
|
||||
#define at91sam3s
|
||||
/// Core definition
|
||||
#define cortexm3
|
||||
|
||||
//#define BOARD_REV_A
|
||||
#define BOARD_REV_B
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \par sam3s_ek_opfreq "SAM3S-EK - Operating frequencies"
|
||||
/// This page lists several definition related to the board operating frequency
|
||||
/// (when using the initialization done by board_lowlevel.c).
|
||||
///
|
||||
/// !Definitions
|
||||
/// - BOARD_MAINOSC
|
||||
/// - BOARD_MCK
|
||||
|
||||
/// Frequency of the board main oscillator.
|
||||
#define BOARD_MAINOSC 12000000
|
||||
|
||||
/// Master clock frequency (when using board_lowlevel.c).
|
||||
//#define BOARD_MCK 48000000
|
||||
#define BOARD_MCK 64000000
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// ADC
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/// Startup time max, return from Idle mode (in µs)
|
||||
#define ADC_STARTUP_TIME_MAX 15
|
||||
/// Track and hold Acquisition Time min (in ns)
|
||||
#define ADC_TRACK_HOLD_TIME_MIN 1200
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// USB attributes configuration descriptor (bus or self powered, remote wakeup)
|
||||
//#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_RWAKEUP
|
||||
#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \par sam3s_ek_piodef "SAM3S-EK - PIO definitions"
|
||||
/// This pages lists all the pio definitions contained in board.h. The constants
|
||||
/// are named using the following convention: PIN_* for a constant which defines
|
||||
/// a single Pin instance (but may include several PIOs sharing the same
|
||||
/// controller), and PINS_* for a list of Pin instances.
|
||||
///
|
||||
/// !ADC
|
||||
/// - PIN_ADC0_AD0
|
||||
/// - PIN_ADC0_AD1
|
||||
/// - PIN_ADC0_AD2
|
||||
/// - PIN_ADC0_AD3
|
||||
/// - PIN_ADC0_AD4
|
||||
/// - PIN_ADC0_AD5
|
||||
/// - PIN_ADC0_AD6
|
||||
/// - PIN_ADC0_AD7
|
||||
/// - PINS_ADC0
|
||||
///
|
||||
/// !UART
|
||||
/// - PINS_UART
|
||||
///
|
||||
/// !EBI
|
||||
/// - PIN_EBI_DATA_BUS
|
||||
/// - PIN_EBI_NCS0
|
||||
/// - PIN_EBI_NRD
|
||||
/// - PIN_EBI_NWE
|
||||
/// - PIN_EBI_ADDR_BUS
|
||||
/// - PIN_EBI_PSRAM_NBS
|
||||
/// - PIN_EBI_A1
|
||||
/// - PIN_EBI_LCD_RS
|
||||
///
|
||||
/// !LEDs
|
||||
/// - PIN_LED_0
|
||||
/// - PIN_LED_1
|
||||
/// - PIN_LED_2
|
||||
/// - PINS_LEDS
|
||||
///
|
||||
/// !MCI
|
||||
/// - PINS_MCI
|
||||
///
|
||||
/// !Push buttons
|
||||
/// - PIN_PUSHBUTTON_1
|
||||
/// - PIN_PUSHBUTTON_2
|
||||
/// - PINS_PUSHBUTTONS
|
||||
/// - PUSHBUTTON_BP1
|
||||
/// - PUSHBUTTON_BP2
|
||||
///
|
||||
/// !PWMC
|
||||
/// - PIN_PWMC_PWMH0
|
||||
/// - PIN_PWMC_PWML0
|
||||
/// - PIN_PWMC_PWMH1
|
||||
/// - PIN_PWMC_PWML1
|
||||
/// - PIN_PWMC_PWMH2
|
||||
/// - PIN_PWMC_PWML2
|
||||
/// - PIN_PWMC_PWMH3
|
||||
/// - PIN_PWMC_PWML3
|
||||
/// - PIN_PWM_LED0
|
||||
/// - PIN_PWM_LED1
|
||||
/// - PIN_PWM_LED2
|
||||
/// - CHANNEL_PWM_LED0
|
||||
/// - CHANNEL_PWM_LED1
|
||||
/// - CHANNEL_PWM_LED2
|
||||
///
|
||||
/// !SPI
|
||||
/// - PIN_SPI_MISO
|
||||
/// - PIN_SPI_MOSI
|
||||
/// - PIN_SPI_SPCK
|
||||
/// - PINS_SPI
|
||||
/// - PIN_SPI_NPCS0_PA11
|
||||
///
|
||||
/// ! SSC
|
||||
/// - PIN_SSC_TD
|
||||
/// - PIN_SSC_TK
|
||||
/// - PIN_SSC_TF
|
||||
/// - PINS_SSC_CODEC
|
||||
///
|
||||
/// ! PCK0
|
||||
/// - PIN_PCK0
|
||||
///
|
||||
/// !TWI
|
||||
/// - PIN_TWI_TWD0
|
||||
/// - PIN_TWI_TWCK0
|
||||
/// - PINS_TWI
|
||||
///
|
||||
/// !USART0
|
||||
/// - PIN_USART0_RXD
|
||||
/// - PIN_USART0_TXD
|
||||
/// - PIN_USART0_CTS
|
||||
/// - PIN_USART0_RTS
|
||||
/// - PIN_USART0_SCK
|
||||
///
|
||||
/// !USB
|
||||
/// - PIN_USB_PULLUP
|
||||
///
|
||||
|
||||
/// ADC_AD0 pin definition.
|
||||
#define PIN_ADC0_AD0 {1 << 21, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
|
||||
/// ADC_AD1 pin definition.
|
||||
#define PIN_ADC0_AD1 {1 << 30, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
|
||||
/// ADC_AD2 pin definition.
|
||||
#define PIN_ADC0_AD2 {1 << 3, PIOB, ID_PIOB, PIO_INPUT, PIO_DEFAULT}
|
||||
/// ADC_AD3 pin definition.
|
||||
#define PIN_ADC0_AD3 {1 << 4, PIOB, ID_PIOB, PIO_INPUT, PIO_DEFAULT}
|
||||
/// ADC_AD4 pin definition.
|
||||
#define PIN_ADC0_AD4 {1 << 15, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
|
||||
/// ADC_AD5 pin definition.
|
||||
#define PIN_ADC0_AD5 {1 << 16, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
|
||||
/// ADC_AD6 pin definition.
|
||||
#define PIN_ADC0_AD6 {1 << 17, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
|
||||
/// ADC_AD7 pin definition.
|
||||
#define PIN_ADC0_AD7 {1 << 18, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
|
||||
|
||||
/// Pins ADC
|
||||
#define PINS_ADC PIN_ADC0_AD0, PIN_ADC0_AD1, PIN_ADC0_AD2, PIN_ADC0_AD3, PIN_ADC0_AD4, PIN_ADC0_AD5, PIN_ADC0_AD6, PIN_ADC0_AD7
|
||||
|
||||
/** UART pins (UTXD0 and URXD0) definitions, PA9,10. */
|
||||
#define PINS_UART {0x00000600, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
|
||||
/// EBI
|
||||
#define PIN_EBI_DATA_BUS {0xFF, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
|
||||
#define PIN_EBI_NRD {1 << 11, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
|
||||
#define PIN_EBI_NWE {1 << 8, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
|
||||
|
||||
#define PIN_EBI_NCS0 {1 << 20, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_PULLUP}
|
||||
#define PIN_EBI_PSRAM_ADDR_BUS {0x3f00fff, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
|
||||
#define PIN_EBI_PSRAM_NBS {1 << 7, PIOB, ID_PIOB, PIO_PERIPH_B, PIO_PULLUP}, \
|
||||
{1 << 15, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
|
||||
#define PIN_EBI_A1 {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
|
||||
|
||||
#define PIN_EBI_NCS1 {1 << 15, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} /* LCD CS pin */
|
||||
#define PIN_EBI_LCD_RS {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} /* LCD RS pin */
|
||||
|
||||
#ifdef BOARD_REV_A
|
||||
/** LED #0 pin definition. */
|
||||
#define PIN_LED_0 {1 << 20, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
/** LED #1 pin definition. */
|
||||
#define PIN_LED_1 {1 << 21, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
/** LED #2 pin definition. */
|
||||
#define PIN_LED_2 {1 << 22, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
#endif
|
||||
#ifdef BOARD_REV_B
|
||||
/** LED #0 pin definition. */
|
||||
#define PIN_LED_0 {1 << 19, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
/** LED #1 pin definition. */
|
||||
#define PIN_LED_1 {1 << 20, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
/** LED #2 pin definition. */
|
||||
#define PIN_LED_2 {1 << 20, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
#endif
|
||||
|
||||
/** List of all LEDs definitions. */
|
||||
#define PINS_LEDS PIN_LED_0, PIN_LED_1, PIN_LED_2
|
||||
|
||||
/// MCI pins definition.
|
||||
#define PINS_MCI {0x1f8, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_PULLUP}, \
|
||||
{1 << 3, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
|
||||
/// MCI pin Card Detect
|
||||
#define PIN_MCI_CD \
|
||||
{AT91C_PIO_PA25, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP}
|
||||
|
||||
/** Push button #0 definition. Attributes = pull-up + debounce + interrupt on rising edge. */
|
||||
#define PIN_PUSHBUTTON_1 {1 << 3, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE}
|
||||
/** Push button #1 definition. Attributes = pull-up + debounce + interrupt on falling edge. */
|
||||
#define PIN_PUSHBUTTON_2 {1 << 12, PIOC, ID_PIOC, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE}
|
||||
/** List of all push button definitions. */
|
||||
#define PINS_PUSHBUTTONS PIN_PUSHBUTTON_1, PIN_PUSHBUTTON_2
|
||||
|
||||
/** Push button #1 index. */
|
||||
#define PUSHBUTTON_BP1 0
|
||||
/** Push button #2 index. */
|
||||
#define PUSHBUTTON_BP2 1
|
||||
|
||||
/// Simulated joystick LEFT index.
|
||||
#define JOYSTICK_LEFT 0
|
||||
/// Simulated joystick RIGHT index.
|
||||
#define JOYSTICK_RIGHT 1
|
||||
|
||||
/** PWMC PWM0 pin definition. */
|
||||
#define PIN_PWMC_PWMH0 {1 << 18, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT}
|
||||
#define PIN_PWMC_PWML0 {1 << 19, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT}
|
||||
/** PWMC PWM1 pin definition. */
|
||||
#define PIN_PWMC_PWMH1 {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT}
|
||||
#define PIN_PWMC_PWML1 {1 << 20, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT}
|
||||
/** PWMC PWM2 pin definition. */
|
||||
#define PIN_PWMC_PWMH2 {1 << 20, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT}
|
||||
#define PIN_PWMC_PWML2 {1 << 16, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT}
|
||||
/** PWMC PWM3 pin definition. */
|
||||
#define PIN_PWMC_PWMH3 {1 << 21, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT}
|
||||
#define PIN_PWMC_PWML3 {1 << 15, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT}
|
||||
/** PWM pin definition for LED0 */
|
||||
#define PIN_PWM_LED0 PIN_PWMC_PWMH0, PIN_PWMC_PWML0
|
||||
/** PWM pin definition for LED1 */
|
||||
#define PIN_PWM_LED1 PIN_PWMC_PWMH2, PIN_PWMC_PWML2
|
||||
/** PWM pin definition for LED2 */
|
||||
#define PIN_PWM_LED2 PIN_PWMC_PWMH3, PIN_PWMC_PWML3
|
||||
/** PWM channel for LED0 */
|
||||
#define CHANNEL_PWM_LED0 0
|
||||
/** PWM channel for LED1 */
|
||||
#define CHANNEL_PWM_LED1 2
|
||||
/** PWM channel for LED2 */
|
||||
#define CHANNEL_PWM_LED2 3
|
||||
|
||||
/** SPI MISO pin definition. */
|
||||
#define PIN_SPI_MISO {1 << 12, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
/** SPI MOSI pin definition. */
|
||||
#define PIN_SPI_MOSI {1 << 13, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
/** SPI SPCK pin definition. */
|
||||
#define PIN_SPI_SPCK {1 << 14, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
/** SPI chip select pin definition. */
|
||||
#define PIN_SPI_NPCS0_PA11 {1 << 11, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
/** List of SPI pin definitions (MISO, MOSI & SPCK). */
|
||||
#define PINS_SPI PIN_SPI_MISO, PIN_SPI_MOSI, PIN_SPI_SPCK
|
||||
|
||||
/// SSC pins definition.
|
||||
#define PIN_SSC_TD {0x1 << 26, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_SSC_TK {0x1 << 28, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_SSC_TF {0x1 << 30, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PINS_SSC_CODEC PIN_SSC_TD, PIN_SSC_TK, PIN_SSC_TF
|
||||
|
||||
/// PCK0
|
||||
#define PIN_PCK0 {0x1 << 21, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT}
|
||||
|
||||
/// TWI pins definition.
|
||||
#define TWI_V3XX
|
||||
#define PIN_TWI_TWD0 {0x1 << 9, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_TWI_TWCK0 {0x1 << 10, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PINS_TWI0 PIN_TWI_TWD0, PIN_TWI_TWCK0
|
||||
#define PIN_TWI_TWD1 {0x1 << 24, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_TWI_TWCK1 {0x1 << 25, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PINS_TWI1 PIN_TWI_TWD1, PIN_TWI_TWCK1
|
||||
|
||||
/// USART0
|
||||
#define PIN_USART0_RXD {0x1 << 19, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_USART0_TXD {0x1 << 18, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_USART0_CTS {0x1 << 8, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_USART0_RTS {0x1 << 7, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_USART0_SCK {0x1 << 17, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
|
||||
/// USART1
|
||||
#define PIN_USART1_RXD {0x1 << 21, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_USART1_TXD {0x1 << 22, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_USART1_CTS {0x1 << 25, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_USART1_RTS {0x1 << 24, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_USART1_EN {0x1 << 23, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
|
||||
|
||||
|
||||
|
||||
/// USB VBus monitoring pin definition.
|
||||
#ifdef BOARD_REV_A
|
||||
#define PIN_USB_VBUS {1 << 23, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
|
||||
#endif
|
||||
#ifdef BOARD_REV_B
|
||||
#define PIN_USB_VBUS {1 << 21, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \par sam3s_ek_extcomp "SAM3S-EK - External components"
|
||||
/// This page lists the definitions related to external on-board components
|
||||
/// located in the board.h file for the AT91SAM3S-EK.
|
||||
///
|
||||
/// !AT45 Dataflash Card
|
||||
/// - BOARD_AT45_A_SPI_BASE
|
||||
/// - BOARD_AT45_A_SPI_ID
|
||||
/// - BOARD_AT45_A_SPI_PINS
|
||||
/// - BOARD_AT45_A_SPI
|
||||
/// - BOARD_AT45_A_NPCS
|
||||
/// - BOARD_AT45_A_NPCS_PIN
|
||||
///
|
||||
/// !AT45 Dataflash (serial onboard DataFlash)
|
||||
/// - BOARD_AT45_B_SPI_BASE
|
||||
/// - BOARD_AT45_B_SPI_ID
|
||||
/// - BOARD_AT45_B_SPI_PINS
|
||||
/// - BOARD_AT45_B_SPI
|
||||
/// - BOARD_AT45_B_NPCS
|
||||
/// - BOARD_AT45_B_NPCS_PIN
|
||||
///
|
||||
/// !AT26 Serial Flash
|
||||
/// - BOARD_AT26_A_SPI_BASE
|
||||
/// - BOARD_AT26_A_SPI_ID
|
||||
/// - BOARD_AT26_A_SPI_PINS
|
||||
/// - BOARD_AT26_A_SPI
|
||||
/// - BOARD_AT26_A_NPCS
|
||||
/// - BOARD_AT26_A_NPCS_PIN
|
||||
///
|
||||
/// !SD Card
|
||||
/// - MCI2_INTERFACE
|
||||
/// - BOARD_SD_MCI_BASE
|
||||
/// - BOARD_SD_MCI_ID
|
||||
/// - BOARD_SD_PINS
|
||||
/// - BOARD_SD_SLOT
|
||||
///
|
||||
/// !PSRAM
|
||||
/// - BOARD_PSRAM_PINS
|
||||
///
|
||||
/// !LCD
|
||||
/// - BOARD_LCD_ILI9325
|
||||
/// - BOARD_LCD_PINS
|
||||
/// - BOARD_BACKLIGHT_PIN
|
||||
/// - BOARD_LCD_BASE
|
||||
/// - BOARD_LCD_RS
|
||||
/// - BOARD_LCD_WIDTH
|
||||
/// - BOARD_LCD_HEIGHT
|
||||
///
|
||||
/// !TouchScreen
|
||||
/// - BOARD_TSC_ADS7843
|
||||
/// - PIN_TCS_IRQ
|
||||
/// - PIN_TCS_BUSY
|
||||
/// - BOARD_TSC_SPI_BASE
|
||||
/// - BOARD_TSC_SPI_ID
|
||||
/// - BOARD_TSC_SPI_PINS
|
||||
/// - BOARD_TSC_NPCS
|
||||
/// - BOARD_TSC_NPCS_PIN
|
||||
///
|
||||
/// Base address of SPI peripheral connected to the dataflash.
|
||||
//#define BOARD_AT45_A_SPI_BASE SPI0
|
||||
///// Identifier of SPI peripheral connected to the dataflash.
|
||||
//#define BOARD_AT45_A_SPI_ID ID_SPI0
|
||||
///// Pins of the SPI peripheral connected to the dataflash.
|
||||
//#define BOARD_AT45_A_SPI_PINS PINS_SPI0
|
||||
///// Dataflahs SPI number.
|
||||
//#define BOARD_AT45_A_SPI 0
|
||||
///// Chip select connected to the dataflash.
|
||||
//#define BOARD_AT45_A_NPCS 3
|
||||
///// Chip select pin connected to the dataflash.
|
||||
//#define BOARD_AT45_A_NPCS_PIN PIN_SPI0_NPCS3
|
||||
|
||||
/// Base address of SPI peripheral connected to the dataflash.
|
||||
//#define BOARD_AT45_B_SPI_BASE SPI1
|
||||
///// Identifier of SPI peripheral connected to the dataflash.
|
||||
//#define BOARD_AT45_B_SPI_ID ID_SPI1
|
||||
///// Pins of the SPI peripheral connected to the dataflash.
|
||||
//#define BOARD_AT45_B_SPI_PINS PINS_SPI1
|
||||
///// Dataflahs SPI number.
|
||||
//#define BOARD_AT45_B_SPI 1
|
||||
///// Chip select connected to the dataflash.
|
||||
//#define BOARD_AT45_B_NPCS 3
|
||||
///// Chip select pin connected to the dataflash.
|
||||
//#define BOARD_AT45_B_NPCS_PIN PIN_SPI1_NPCS3
|
||||
|
||||
/// Base address of SPI peripheral connected to the serialflash.
|
||||
//#define BOARD_AT26_A_SPI_BASE SPI0
|
||||
///// Identifier of SPI peripheral connected to the serialflash.
|
||||
//#define BOARD_AT26_A_SPI_ID ID_SPI0
|
||||
///// Pins of the SPI peripheral connected to the serialflash.
|
||||
//#define BOARD_AT26_A_SPI_PINS PINS_SPI0
|
||||
///// Serialflash SPI number.
|
||||
//#define BOARD_AT26_A_SPI 0
|
||||
///// Chip select connected to the serialflash.
|
||||
//#define BOARD_AT26_A_NPCS 3
|
||||
///// Chip select pin connected to the serialflash.
|
||||
//#define BOARD_AT26_A_NPCS_PIN PIN_SPI0_NPCS3
|
||||
|
||||
/// ISO7816
|
||||
/// - PIN_SMARTCARD_CONNECT
|
||||
/// - PIN_ISO7816_RSTMC
|
||||
/// - PINS_ISO7816
|
||||
|
||||
/// Smartcard detection pin
|
||||
//#define PIN_SMARTCARD_CONNECT {1 << 5, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
|
||||
/// PIN used for reset the smartcard
|
||||
//#define PIN_ISO7816_RSTMC {1 << 7, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
|
||||
/// Pins used for connect the smartcard
|
||||
//#define PINS_ISO7816 PIN_USART0_TXD, PIN_USART0_SCK, PIN_ISO7816_RSTMC
|
||||
|
||||
/// Dma channel number
|
||||
#define BOARD_MCI_DMA_CHANNEL 0
|
||||
/// MCI0 DMA hardware handshaking ID
|
||||
#define DMA_HW_SRC_REQ_ID_MCI0 AT91C_HDMA_SRC_PER_0
|
||||
#define DMA_HW_DEST_REQ_ID_MCI0 AT91C_HDMA_DST_PER_0
|
||||
/// MCI1 DMA hardware handshaking ID
|
||||
#define DMA_HW_SRC_REQ_ID_MCI1 AT91C_HDMA_SRC_PER_13
|
||||
#define DMA_HW_DEST_REQ_ID_MCI1 AT91C_HDMA_DST_PER_13
|
||||
/// SD DMA hardware handshaking ID
|
||||
#define BOARD_SD_DMA_HW_SRC_REQ_ID DMA_HW_SRC_REQ_ID_MCI0
|
||||
#define BOARD_SD_DMA_HW_DEST_REQ_ID DMA_HW_DEST_REQ_ID_MCI0
|
||||
|
||||
|
||||
/// HS MCI interface
|
||||
#define MCI2_INTERFACE
|
||||
/// Base address of the MCI peripheral connected to the SD card.
|
||||
#define BOARD_SD_MCI_BASE MCI0//MCI
|
||||
///// Peripheral identifier of the MCI connected to the SD card.
|
||||
#define BOARD_SD_MCI_ID ID_MCI0 //ID_MCI
|
||||
///// MCI pins that shall be configured to access the SD card.
|
||||
#define BOARD_SD_PINS PINS_MCI
|
||||
///// MCI slot to which the SD card is connected to.
|
||||
#define BOARD_SD_SLOT MCI_SD_SLOTA
|
||||
///// MCI Card Detect pin.
|
||||
#define BOARD_SD_PIN_CD PIN_MCI_CD
|
||||
|
||||
//#define BOARD_PSRAM_PINS PIN_EBI_DATA_BUS, PIN_EBI_NCS0, PIN_EBI_NRD, PIN_EBI_NWE, \
|
||||
PIN_EBI_PSRAM_ADDR_BUS, PIN_EBI_PSRAM_NBS, PIN_EBI_A1
|
||||
|
||||
/** Indicates board has an ILI9325 external component to manage LCD. */
|
||||
#define BOARD_LCD_ILI9325
|
||||
|
||||
/** LCD pins definition. */
|
||||
#define BOARD_LCD_PINS PIN_EBI_DATA_BUS, PIN_EBI_NRD, PIN_EBI_NWE, \
|
||||
PIN_EBI_NCS1, PIN_EBI_LCD_RS
|
||||
/** Backlight pin definition. */
|
||||
#define BOARD_BACKLIGHT_PIN {1 << 13, PIOC, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT}
|
||||
/** Define ILI9325 base address. */
|
||||
#define BOARD_LCD_BASE 0x61000000
|
||||
/** Define ILI9325 register select signal. */
|
||||
#define BOARD_LCD_RS (1 << 1)
|
||||
/** Display width in pixels. */
|
||||
#define BOARD_LCD_WIDTH 240
|
||||
/** Display height in pixels. */
|
||||
#define BOARD_LCD_HEIGHT 320
|
||||
|
||||
/** Indicates board has an ADS7843 external component to manage Touch Screen */
|
||||
#define BOARD_TSC_ADS7843
|
||||
|
||||
#ifdef BOARD_REV_A
|
||||
/** Touchscreen controller IRQ pin definition. */
|
||||
#define PIN_TCS_IRQ {PIO_PA4, PIOA, ID_PIOA, PIO_INPUT, PIO_DEBOUNCE | PIO_IT_AIME | PIO_IT_EDGE}
|
||||
#define PIN_TCS_IRQ_WUP_ID (1 << 3)
|
||||
/** Touchscreen controller Busy pin definition. */
|
||||
#define PIN_TCS_BUSY {PIO_PA5, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP}
|
||||
#endif
|
||||
#ifdef BOARD_REV_B
|
||||
/** Touchscreen controller IRQ pin definition. */
|
||||
#define PIN_TCS_IRQ {PIO_PA16, PIOA, ID_PIOA, PIO_INPUT, PIO_DEBOUNCE | PIO_IT_AIME | PIO_IT_EDGE}
|
||||
#define PIN_TCS_IRQ_WUP_ID (1 << 15)
|
||||
/** Touchscreen controller Busy pin definition. */
|
||||
#define PIN_TCS_BUSY {PIO_PA17, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP}
|
||||
#endif
|
||||
|
||||
/** Base address of SPI peripheral connected to the touchscreen controller. */
|
||||
#define BOARD_TSC_SPI_BASE SPI
|
||||
/** Identifier of SPI peripheral connected to the touchscreen controller. */
|
||||
#define BOARD_TSC_SPI_ID ID_SPI
|
||||
/** Pins of the SPI peripheral connected to the touchscreen controller. */
|
||||
#define BOARD_TSC_SPI_PINS PINS_SPI
|
||||
/** Chip select connected to the touchscreen controller. */
|
||||
#define BOARD_TSC_NPCS 0
|
||||
/** Chip select pin connected to the touchscreen controller. */
|
||||
#define BOARD_TSC_NPCS_PIN PIN_SPI_NPCS0_PA11
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \par sam3s_ek_mem "SAM3S-EK - Memories"
|
||||
/// This page lists definitions related to internal & external on-board memories.
|
||||
///
|
||||
/// !Embedded Flash
|
||||
/// - BOARD_FLASH_EFC
|
||||
|
||||
/// Internal SRAM address
|
||||
#define AT91C_ISRAM AT91C_IRAM
|
||||
#define AT91C_ISRAM_SIZE 0x00008000
|
||||
|
||||
#define AT91C_IFLASH_SIZE (0x40000)
|
||||
#define AT91C_IFLASH_PAGE_SIZE (256) // Internal FLASH 0 Page Size: 256 bytes
|
||||
#define AT91C_IFLASH_NB_OF_PAGES (1024) // Internal FLASH 0 Number of Pages: 512
|
||||
#define AT91C_IFLASH_LOCK_REGION_SIZE (16384) // Internal FLASH 0 Lock Region Size: 16 Kbytes
|
||||
#define AT91C_IFLASH_NB_OF_LOCK_BITS (16) // Internal FLASH 0 Number of Lock Bits: 16
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \section sam3s_ek_extcomp "SAM3S-EK - External components"
|
||||
/// This page lists the definitions related to external on-board components
|
||||
/// located in the board.h file for the SAM3S-EK.
|
||||
///
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \par sam3s_ek_chipdef "SAM3S-EK - Individual chip definition"
|
||||
/// This page lists the definitions related to different chip's definition
|
||||
/// located in the board.h file for the SAM3S-EK.
|
||||
|
||||
/// DBGU
|
||||
#define BOARD_DBGU_ID ID_DBGU
|
||||
|
||||
/// Rtc
|
||||
#define BOARD_RTC_ID ID_RTC
|
||||
|
||||
/// Twi eeprom
|
||||
#define BOARD_ID_TWI_EEPROM ID_TWI1
|
||||
#define BOARD_BASE_TWI_EEPROM TWI1
|
||||
#define BOARD_PINS_TWI_EEPROM PINS_TWI1
|
||||
|
||||
/// USART
|
||||
#define BOARD_PIN_USART_RXD PIN_USART1_RXD
|
||||
#define BOARD_PIN_USART_TXD PIN_USART1_TXD
|
||||
#define BOARD_PIN_USART_CTS PIN_USART1_CTS
|
||||
#define BOARD_PIN_USART_RTS PIN_USART1_RTS
|
||||
#define BOARD_PIN_USART_EN PIN_USART1_EN
|
||||
#define BOARD_USART_BASE USART1
|
||||
#define BOARD_ID_USART ID_USART1
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#define PIN_EBI_NANDOE {1 << 9, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
|
||||
#define PIN_EBI_NANDWE {1 << 10, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
|
||||
#define PIN_EBI_NANDCLE {1 << 17, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
|
||||
#define PIN_EBI_NANDALE {1 << 16, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
|
||||
#define PIN_EBI_NANDIO {0x000000FF, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
|
||||
|
||||
/// Nandflash chip enable pin definition.
|
||||
#define BOARD_NF_CE_PIN {1 << 14, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
/// Nandflash ready/busy pin definition.
|
||||
#define BOARD_NF_RB_PIN {1 << 18, PIOC, ID_PIOC, PIO_INPUT, PIO_PULLUP}
|
||||
|
||||
/// Nandflash controller peripheral pins definition.
|
||||
#define PINS_NANDFLASH PIN_EBI_NANDIO, BOARD_NF_CE_PIN, BOARD_NF_RB_PIN, PIN_EBI_NANDOE, \
|
||||
PIN_EBI_NANDWE, PIN_EBI_NANDCLE, PIN_EBI_NANDALE
|
||||
|
||||
/// Address for transferring command bytes to the nandflash.
|
||||
#define BOARD_NF_COMMAND_ADDR 0x60400000
|
||||
/// Address for transferring address bytes to the nandflash.
|
||||
#define BOARD_NF_ADDRESS_ADDR 0x60200000
|
||||
/// Address for transferring data bytes to the nandflash.
|
||||
#define BOARD_NF_DATA_ADDR 0x60000000
|
||||
|
||||
#endif //#ifndef BOARD_H
|
||||
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "board.h"
|
||||
#include "exceptions.h"
|
||||
#include "board_lowlevel.h"
|
||||
|
||||
#include <cmsis/core_cm3.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported variables
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Stack top */
|
||||
extern uint32_t _estack;
|
||||
|
||||
/* Initialize segments */
|
||||
extern uint32_t _sfixed;
|
||||
extern uint32_t _sfixed;
|
||||
extern uint32_t _efixed;
|
||||
extern uint32_t _srelocate;
|
||||
extern uint32_t _erelocate;
|
||||
extern uint32_t _szero;
|
||||
extern uint32_t _ezero;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* The mask of VTOR register */
|
||||
#define SCB_VTOR_MASK 0x3FFFFFF8
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* ProtoTypes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern int main(void);
|
||||
void ResetException(void);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Local variables
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Exception Table */
|
||||
__attribute__((section(".vectors")))
|
||||
IntFunc exception_table[] = {
|
||||
|
||||
/* Configure Initial Stack Pointer, using linker-generated symbols */
|
||||
(IntFunc)&_estack,
|
||||
ResetException,
|
||||
|
||||
NMI_Handler,
|
||||
HardFault_Handler,
|
||||
MemManage_Handler,
|
||||
BusFault_Handler,
|
||||
UsageFault_Handler,
|
||||
0, 0, 0, 0, /* Reserved */
|
||||
SVC_Handler,
|
||||
DebugMon_Handler,
|
||||
0, /* Reserved */
|
||||
PendSV_Handler,
|
||||
SysTick_Handler,
|
||||
|
||||
/* Configurable interrupts */
|
||||
SUPC_IrqHandler, /* 0 Supply Controller */
|
||||
RSTC_IrqHandler, /* 1 Reset Controller */
|
||||
RTC_IrqHandler, /* 2 Real Time Clock */
|
||||
RTT_IrqHandler, /* 3 Real Time Timer */
|
||||
WDT_IrqHandler, /* 4 Watchdog Timer */
|
||||
PMC_IrqHandler, /* 5 PMC */
|
||||
EEFC_IrqHandler, /* 6 EEFC */
|
||||
IrqHandlerNotUsed, /* 7 Reserved */
|
||||
UART0_IrqHandler, /* 8 UART0 */
|
||||
UART1_IrqHandler, /* 9 UART1 */
|
||||
SMC_IrqHandler, /* 10 SMC */
|
||||
PIOA_IrqHandler, /* 11 Parallel IO Controller A */
|
||||
PIOB_IrqHandler, /* 12 Parallel IO Controller B */
|
||||
PIOC_IrqHandler, /* 13 Parallel IO Controller C */
|
||||
USART0_IrqHandler, /* 14 USART 0 */
|
||||
USART1_IrqHandler, /* 15 USART 1 */
|
||||
IrqHandlerNotUsed, /* 16 Reserved */
|
||||
IrqHandlerNotUsed, /* 17 Reserved */
|
||||
MCI_IrqHandler, /* 18 MCI */
|
||||
TWI0_IrqHandler, /* 19 TWI 0 */
|
||||
TWI1_IrqHandler, /* 20 TWI 1 */
|
||||
SPI_IrqHandler, /* 21 SPI */
|
||||
SSC_IrqHandler, /* 22 SSC */
|
||||
TC0_IrqHandler, /* 23 Timer Counter 0 */
|
||||
TC1_IrqHandler, /* 24 Timer Counter 1 */
|
||||
TC2_IrqHandler, /* 25 Timer Counter 2 */
|
||||
TC3_IrqHandler, /* 26 Timer Counter 3 */
|
||||
TC4_IrqHandler, /* 27 Timer Counter 4 */
|
||||
TC5_IrqHandler, /* 28 Timer Counter 5 */
|
||||
ADC_IrqHandler, /* 29 ADC controller */
|
||||
DAC_IrqHandler, /* 30 DAC controller */
|
||||
PWM_IrqHandler, /* 31 PWM */
|
||||
CRCCU_IrqHandler, /* 32 CRC Calculation Unit */
|
||||
ACC_IrqHandler, /* 33 Analog Comparator */
|
||||
USBD_IrqHandler, /* 34 USB Device Port */
|
||||
IrqHandlerNotUsed /* 35 not used */
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief This is the code that gets called on processor reset.
|
||||
* To initialize the device, and call the main() routine.
|
||||
*/
|
||||
void ResetException(void)
|
||||
{
|
||||
uint32_t *pSrc, *pDest;
|
||||
|
||||
LowLevelInit();
|
||||
|
||||
/* Initialize the relocate segment */
|
||||
pSrc = &_efixed;
|
||||
pDest = &_srelocate;
|
||||
if (pSrc != pDest) {
|
||||
for(; pDest < &_erelocate;) {
|
||||
|
||||
*pDest++ = *pSrc++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear the zero segment */
|
||||
for(pDest = &_szero; pDest < &_ezero;) {
|
||||
|
||||
*pDest++ = 0;
|
||||
}
|
||||
|
||||
/* Set the vector table base address */
|
||||
pSrc = (uint32_t *)&_sfixed;
|
||||
SCB->VTOR = ((uint32_t)(pSrc)) & 0x2FFFFFF8;
|
||||
|
||||
/* Branch to main function */
|
||||
main();
|
||||
|
||||
/* Infinite loop */
|
||||
while(1);
|
||||
}
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "board.h"
|
||||
#include <cmsis/core_cm3.h>
|
||||
|
||||
#include "exceptions.h"
|
||||
#include "board_lowlevel.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
typedef union { IntFunc __fun; void * __ptr; } IntVector;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* ProtoTypes
|
||||
*------------------------------------------------------------------------------*/
|
||||
extern void __iar_program_start( void );
|
||||
|
||||
int __low_level_init( void );
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Variables
|
||||
*------------------------------------------------------------------------------*/
|
||||
extern unsigned int __ICFEDIT_vector_start__;
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exception Table
|
||||
*------------------------------------------------------------------------------*/
|
||||
#pragma language=extended
|
||||
#pragma segment="CSTACK"
|
||||
|
||||
/* The name "__vector_table" has special meaning for C-SPY: */
|
||||
/* it is where the SP start value is found, and the NVIC vector */
|
||||
/* table register (VTOR) is initialized to this address if != 0. */
|
||||
|
||||
#pragma section = ".vectors"
|
||||
#pragma location = ".vectors"
|
||||
const IntVector __vector_table[] =
|
||||
{
|
||||
{ .__ptr = __sfe( "CSTACK" ) },
|
||||
__iar_program_start,
|
||||
|
||||
NMI_Handler,
|
||||
HardFault_Handler,
|
||||
MemManage_Handler,
|
||||
BusFault_Handler,
|
||||
UsageFault_Handler,
|
||||
0, 0, 0, 0, /* Reserved */
|
||||
SVC_Handler,
|
||||
DebugMon_Handler,
|
||||
0, /* Reserved */
|
||||
PendSV_Handler,
|
||||
SysTick_Handler,
|
||||
|
||||
/* Configurable interrupts */
|
||||
SUPC_IrqHandler, /* 0 SUPPLY CONTROLLER */
|
||||
RSTC_IrqHandler, /* 1 RESET CONTROLLER */
|
||||
RTC_IrqHandler, /* 2 REAL TIME CLOCK */
|
||||
RTT_IrqHandler, /* 3 REAL TIME TIMER */
|
||||
WDT_IrqHandler, /* 4 WATCHDOG TIMER */
|
||||
PMC_IrqHandler, /* 5 PMC */
|
||||
EEFC_IrqHandler, /* 6 EEFC */
|
||||
IrqHandlerNotUsed, /* 7 Reserved */
|
||||
UART0_IrqHandler, /* 8 UART0 */
|
||||
UART1_IrqHandler, /* 9 UART1 */
|
||||
SMC_IrqHandler, /* 10 SMC */
|
||||
PIOA_IrqHandler, /* 11 Parallel IO Controller A */
|
||||
PIOB_IrqHandler, /* 12 Parallel IO Controller B */
|
||||
PIOC_IrqHandler, /* 13 Parallel IO Controller C */
|
||||
USART0_IrqHandler, /* 14 USART 0 */
|
||||
USART1_IrqHandler, /* 15 USART 1 */
|
||||
IrqHandlerNotUsed, /* 16 Reserved */
|
||||
IrqHandlerNotUsed, /* 17 Reserved */
|
||||
MCI_IrqHandler, /* 18 MCI */
|
||||
TWI0_IrqHandler, /* 19 TWI 0 */
|
||||
TWI1_IrqHandler, /* 20 TWI 1 */
|
||||
SPI_IrqHandler, /* 21 SPI */
|
||||
SSC_IrqHandler, /* 22 SSC */
|
||||
TC0_IrqHandler, /* 23 Timer Counter 0 */
|
||||
TC1_IrqHandler, /* 24 Timer Counter 1 */
|
||||
TC2_IrqHandler, /* 25 Timer Counter 2 */
|
||||
TC3_IrqHandler, /* 26 Timer Counter 3 */
|
||||
TC4_IrqHandler, /* 27 Timer Counter 4 */
|
||||
TC5_IrqHandler, /* 28 Timer Counter 5 */
|
||||
ADC_IrqHandler, /* 29 ADC controller */
|
||||
DAC_IrqHandler, /* 30 DAC controller */
|
||||
PWM_IrqHandler, /* 31 PWM */
|
||||
CRCCU_IrqHandler, /* 32 CRC Calculation Unit */
|
||||
ACC_IrqHandler, /* 33 Analog Comparator */
|
||||
USBD_IrqHandler, /* 34 USB Device Port */
|
||||
IrqHandlerNotUsed /* 35 not used */
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exception Table
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**------------------------------------------------------------------------------
|
||||
* This is the code that gets called on processor reset. To initialize the
|
||||
* device.
|
||||
*------------------------------------------------------------------------------*/
|
||||
int __low_level_init( void )
|
||||
{
|
||||
unsigned int * src = __section_begin(".vectors");
|
||||
|
||||
LowLevelInit();
|
||||
|
||||
SCB->VTOR = ((unsigned int)(src)) | (0x0 << 7);
|
||||
|
||||
return 1; /* if return 0, the data sections will not be initialized. */
|
||||
}
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
#include "board.h"
|
||||
#include "exceptions.h"
|
||||
#include "board_lowlevel.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Types
|
||||
//------------------------------------------------------------------------------
|
||||
typedef union { IntFunc __fun; void * __ptr; } IrqVector;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// ProtoTypes
|
||||
//------------------------------------------------------------------------------
|
||||
extern int Image$$ARM_LIB_STACK$$ZI$$Limit;
|
||||
extern int Image$$Vector_region$$Base;
|
||||
extern int Image$$Vector_region$$Limit;
|
||||
|
||||
extern void __main(void);
|
||||
void resetHandler( void );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Variables
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#pragma arm section rodata="vectors"
|
||||
const IrqVector __vector_table[] =
|
||||
{
|
||||
(IntFunc)&Image$$ARM_LIB_STACK$$ZI$$Limit,
|
||||
resetHandler,
|
||||
|
||||
NMI_Handler,
|
||||
HardFault_Handler,
|
||||
MemManage_Handler,
|
||||
BusFault_Handler,
|
||||
UsageFault_Handler,
|
||||
0, 0, 0, 0, // Reserved
|
||||
SVC_Handler,
|
||||
DebugMon_Handler,
|
||||
0, // Reserved
|
||||
PendSV_Handler,
|
||||
SysTick_Handler,
|
||||
|
||||
// Configurable interrupts
|
||||
SUPC_IrqHandler, // 0 SUPPLY CONTROLLER
|
||||
RSTC_IrqHandler, // 1 RESET CONTROLLER
|
||||
RTC_IrqHandler, // 2 REAL TIME CLOCK
|
||||
RTT_IrqHandler, // 3 REAL TIME TIMER
|
||||
WDT_IrqHandler, // 4 WATCHDOG TIMER
|
||||
PMC_IrqHandler, // 5 PMC
|
||||
EFC0_IrqHandler, // 6 EFC0
|
||||
EFC1_IrqHandler, // 7 EFC1
|
||||
DBGU_IrqHandler, // 8 DBGU
|
||||
HSMC4_IrqHandler, // 9 HSMC4
|
||||
PIOA_IrqHandler, // 10 Parallel IO Controller A
|
||||
PIOB_IrqHandler, // 11 Parallel IO Controller B
|
||||
PIOC_IrqHandler, // 12 Parallel IO Controller C
|
||||
USART0_IrqHandler, // 13 USART 0
|
||||
USART1_IrqHandler, // 14 USART 1
|
||||
USART2_IrqHandler, // 15 USART 2
|
||||
USART3_IrqHandler, // 16 USART 3
|
||||
MCI0_IrqHandler, // 17 Multimedia Card Interface
|
||||
TWI0_IrqHandler, // 18 TWI 0
|
||||
TWI1_IrqHandler, // 19 TWI 1
|
||||
SPI0_IrqHandler, // 20 Serial Peripheral Interface
|
||||
SSC0_IrqHandler, // 21 Serial Synchronous Controller 0
|
||||
TC0_IrqHandler, // 22 Timer Counter 0
|
||||
TC1_IrqHandler, // 23 Timer Counter 1
|
||||
TC2_IrqHandler, // 24 Timer Counter 2
|
||||
PWM_IrqHandler, // 25 Pulse Width Modulation Controller
|
||||
ADCC0_IrqHandler, // 26 ADC controller0
|
||||
ADCC1_IrqHandler, // 27 ADC controller1
|
||||
HDMA_IrqHandler, // 28 HDMA
|
||||
UDPD_IrqHandler, // 29 USB Device High Speed UDP_HS
|
||||
IrqHandlerNotUsed // 30 not used
|
||||
};
|
||||
#pragma arm section
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// This is the code that gets called on processor reset. To initialize the
|
||||
/// device.
|
||||
//------------------------------------------------------------------------------
|
||||
void resetHandler( void )
|
||||
{
|
||||
unsigned int *pSrc = (unsigned int *)&Image$$Vector_region$$Base;
|
||||
|
||||
// Low level Initialize
|
||||
LowLevelInit();
|
||||
|
||||
AT91C_BASE_NVIC->NVIC_VTOFFR = ((unsigned int)(pSrc)) | (0x0 << 7);
|
||||
|
||||
// Enter C library entry point
|
||||
__main();
|
||||
|
||||
/* Infinite loop */
|
||||
while(1);
|
||||
}
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "board.h"
|
||||
#include "board_memories.h"
|
||||
#include "board_lowlevel.h"
|
||||
#include <pio/pio.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Local definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
/** Define clock timeout */
|
||||
#define CLOCK_TIMEOUT 5000
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Local functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
static void BOARD_ConfigurePmc(void)
|
||||
{
|
||||
|
||||
#define AT91C_CKGR_MUL_SHIFT 16
|
||||
#define AT91C_CKGR_PLLCOUNT_SHIFT 8
|
||||
#define AT91C_CKGR_DIV_SHIFT 0
|
||||
|
||||
// Settings at 64 MHz for MCK
|
||||
|
||||
#define BOARD_OSCOUNT (CKGR_MOR_MOSCXTST & (0x8 << 8))
|
||||
|
||||
// PLLA Settings 64 MHz : 12 / 3 * 32
|
||||
#define BOARD_PLLAR ((1 << 29) | (0x1F << AT91C_CKGR_MUL_SHIFT) \
|
||||
| (0x1 << AT91C_CKGR_PLLCOUNT_SHIFT) | (0x3 << AT91C_CKGR_DIV_SHIFT))
|
||||
|
||||
// PLLB Settings 96 MHz
|
||||
#define BOARD_PLLBR ((1 << 29) | (0x7 << AT91C_CKGR_MUL_SHIFT) \
|
||||
| (0x1 << AT91C_CKGR_PLLCOUNT_SHIFT) | (0x1 << AT91C_CKGR_DIV_SHIFT))
|
||||
|
||||
// USB on PLLB, MCK/PCK on PLLA
|
||||
#define BOARD_MCKR ( PMC_MCKR_PRES_CLK_2 | PMC_MCKR_CSS_PLLA_CLK)
|
||||
|
||||
// Define clock timeout
|
||||
#undef CLOCK_TIMEOUT
|
||||
#define CLOCK_TIMEOUT 0xFFFFFFFF
|
||||
|
||||
uint32_t timeout = 0;
|
||||
|
||||
/* Enable NRST reset
|
||||
************************************/
|
||||
//AT91C_BASE_RSTC->RSTC_RMR |= AT91C_RSTC_URSTEN;
|
||||
|
||||
/* Initialize main oscillator
|
||||
****************************/
|
||||
if(!(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL))
|
||||
{
|
||||
|
||||
PMC->CKGR_MOR = (0x37 << 16) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN;
|
||||
timeout = 0;
|
||||
while (!(PMC->PMC_SR & PMC_SR_MOSCXTS) && (timeout++ < CLOCK_TIMEOUT));
|
||||
|
||||
}
|
||||
|
||||
/* Switch to 3-20MHz Xtal oscillator */
|
||||
PMC->CKGR_MOR = (0x37 << 16) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN | CKGR_MOR_MOSCSEL;
|
||||
timeout = 0;
|
||||
while (!(PMC->PMC_SR & PMC_SR_MOSCSELS) && (timeout++ < CLOCK_TIMEOUT));
|
||||
PMC->PMC_MCKR = (PMC->PMC_MCKR & ~(uint32_t)PMC_MCKR_CSS) | PMC_MCKR_CSS_MAIN_CLK;
|
||||
timeout = 0;
|
||||
while (!(PMC->PMC_SR & PMC_SR_MCKRDY) && (timeout++ < CLOCK_TIMEOUT));
|
||||
|
||||
/** Set 3 WS for Embedded Flash Access */
|
||||
EFC->EEFC_FMR = (3 << 8);
|
||||
|
||||
/* Initialize PLLA */
|
||||
PMC->CKGR_PLLAR = BOARD_PLLAR;
|
||||
timeout = 0;
|
||||
while (!(PMC->PMC_SR & PMC_SR_LOCKA) && (timeout++ < CLOCK_TIMEOUT));
|
||||
|
||||
/* Initialize PLLB */
|
||||
PMC->CKGR_PLLBR = BOARD_PLLBR;
|
||||
timeout = 0;
|
||||
while (!(PMC->PMC_SR & PMC_SR_LOCKB) && (timeout++ < CLOCK_TIMEOUT));
|
||||
|
||||
// Set USB clock on PLLB
|
||||
REG_PMC_USB = PMC_USB_USBS | (PMC_USB_USBDIV & (1 << 8));
|
||||
|
||||
/* Switch to fast clock
|
||||
**********************/
|
||||
PMC->PMC_MCKR = (BOARD_MCKR & ~PMC_MCKR_CSS) | PMC_MCKR_CSS_MAIN_CLK;
|
||||
timeout = 0;
|
||||
while (!(PMC->PMC_SR & PMC_SR_MCKRDY) && (timeout++ < CLOCK_TIMEOUT));
|
||||
|
||||
PMC->PMC_MCKR = BOARD_MCKR;
|
||||
timeout = 0;
|
||||
while (!(PMC->PMC_SR & PMC_SR_MCKRDY) && (timeout++ < CLOCK_TIMEOUT));
|
||||
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Performs the low-level initialization of the chip. This includes EFC,
|
||||
* master clock and watchdog configuration.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void LowLevelInit (void)
|
||||
{
|
||||
/** Configure PMC */
|
||||
BOARD_ConfigurePmc();
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \unit
|
||||
///
|
||||
/// !!!Purpose
|
||||
///
|
||||
/// Collection of methods for lowlevel.
|
||||
///
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef BOARD_LOWLEVEL_H
|
||||
#define BOARD_LOWLEVEL_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Exported functions
|
||||
//------------------------------------------------------------------------------
|
||||
extern void LowLevelInit(void);
|
||||
extern void OptimizeCpuSpeed(void);
|
||||
|
||||
#endif // BOARD_LOWLEVEL_H
|
||||
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
Title: Memories implementation
|
||||
*/
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <board.h>
|
||||
#include "board_memories.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
* \brief Configures the EBI for NandFlash access.
|
||||
*
|
||||
*/
|
||||
extern void BOARD_ConfigureNandFlash( void )
|
||||
{
|
||||
// Open EBI clock
|
||||
PMC->PMC_PCER0 = (1<< ID_SMC);
|
||||
// NCS0 is assigned to a NAND Flash (NANDOE and NANWE used for NCS0)
|
||||
MATRIX->CCFG_SMCNFCS = CCFG_SMCNFCS_SMC_NFCS0;
|
||||
|
||||
#if 0
|
||||
SMC->SMC_CS_NUMBER[0].SMC_SETUP = 0
|
||||
| ((0 << 0) & SMC_SETUP0_NWE_SETUP)
|
||||
| ((1 << 8) & SMC_SETUP0_NCS_WR_SETUP)
|
||||
| ((0 << 16) & SMC_SETUP0_NRD_SETUP)
|
||||
| ((1 << 24) & SMC_SETUP0_NCS_RD_SETUP);
|
||||
|
||||
SMC->SMC_CS_NUMBER[0].SMC_PULSE = 0
|
||||
| ((2 << 0) & SMC_PULSE0_NWE_PULSE)
|
||||
| ((3 << 8) & SMC_PULSE0_NCS_WR_PULSE)
|
||||
| ((4 << 16) & SMC_PULSE0_NRD_PULSE)
|
||||
| ((4 << 24) & SMC_PULSE0_NCS_RD_PULSE);
|
||||
|
||||
SMC->SMC_CS_NUMBER[0].SMC_CYCLE = 0
|
||||
| ((4 << 0) & SMC_CYCLE0_NWE_CYCLE)
|
||||
| ((7 << 16) & SMC_CYCLE0_NRD_CYCLE);
|
||||
|
||||
SMC->SMC_CS_NUMBER[0].SMC_MODE = SMC_MODE0_READ_MODE | SMC_MODE0_WRITE_MODE;
|
||||
#else
|
||||
SMC->SMC_CS_NUMBER[0].SMC_SETUP = 0
|
||||
| ((0 << 0) & SMC_SETUP0_NWE_SETUP)
|
||||
| ((0 << 8) & SMC_SETUP0_NCS_WR_SETUP)
|
||||
| ((0 << 16) & SMC_SETUP0_NRD_SETUP)
|
||||
| ((0 << 24) & SMC_SETUP0_NCS_RD_SETUP);
|
||||
|
||||
SMC->SMC_CS_NUMBER[0].SMC_PULSE = 0
|
||||
| ((2 << 0) & SMC_PULSE0_NWE_PULSE)
|
||||
| ((2 << 8) & SMC_PULSE0_NCS_WR_PULSE)
|
||||
| ((2 << 16) & SMC_PULSE0_NRD_PULSE)
|
||||
| ((2 << 24) & SMC_PULSE0_NCS_RD_PULSE);
|
||||
|
||||
SMC->SMC_CS_NUMBER[0].SMC_CYCLE = 0
|
||||
| ((3 << 0) & SMC_CYCLE0_NWE_CYCLE)
|
||||
| ((3 << 16) & SMC_CYCLE0_NRD_CYCLE);
|
||||
|
||||
SMC->SMC_CS_NUMBER[0].SMC_MODE = SMC_MODE1_READ_MODE | SMC_MODE1_WRITE_MODE;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \unit
|
||||
/// !Purpose
|
||||
///
|
||||
///
|
||||
/// !Usage
|
||||
///
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef BOARD_MEMORIES_H
|
||||
#define BOARD_MEMORIES_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Exported functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
extern void BOARD_ConfigureNandFlash( void ) ;
|
||||
|
||||
#endif //#ifndef BOARD_MEMORIES_H
|
||||
|
||||
|
|
@ -1,385 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* This file contains the default exception handlers.
|
||||
*
|
||||
* \note
|
||||
* The exception handler has weak aliases.
|
||||
* As they are weak aliases, any function with the same name will override
|
||||
* this definition.
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "exceptions.h"
|
||||
#include <board.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for not used irq.
|
||||
*/
|
||||
void IrqHandlerNotUsed(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default NMI interrupt handler.
|
||||
*/
|
||||
WEAK void NMI_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default HardFault interrupt handler.
|
||||
*/
|
||||
WEAK void HardFault_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default MemManage interrupt handler.
|
||||
*/
|
||||
WEAK void MemManage_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default BusFault interrupt handler.
|
||||
*/
|
||||
WEAK void BusFault_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default UsageFault interrupt handler.
|
||||
*/
|
||||
WEAK void UsageFault_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default SVC interrupt handler.
|
||||
*/
|
||||
WEAK void SVC_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default DebugMon interrupt handler.
|
||||
*/
|
||||
WEAK void DebugMon_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default PendSV interrupt handler.
|
||||
*/
|
||||
WEAK void PendSV_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default SysTick interrupt handler.
|
||||
*/
|
||||
WEAK void SysTick_Handler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for Supply Controller.
|
||||
*/
|
||||
WEAK void SUPC_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for Reset Controller.
|
||||
*/
|
||||
WEAK void RSTC_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for Real Time Clock.
|
||||
*/
|
||||
WEAK void RTC_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for Real Time Timer.
|
||||
*/
|
||||
WEAK void RTT_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for Watchdog Timer.
|
||||
*/
|
||||
WEAK void WDT_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for PMC.
|
||||
*/
|
||||
WEAK void PMC_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for EEFC.
|
||||
*/
|
||||
WEAK void EEFC_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for UART0.
|
||||
*/
|
||||
WEAK void UART0_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for UART1.
|
||||
*/
|
||||
WEAK void UART1_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for SMC.
|
||||
*/
|
||||
WEAK void SMC_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for PIOA Controller.
|
||||
*/
|
||||
WEAK void PIOA_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for PIOB Controller.
|
||||
*/
|
||||
WEAK void PIOB_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for PIOC Controller.
|
||||
*/
|
||||
WEAK void PIOC_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for USART0.
|
||||
*/
|
||||
WEAK void USART0_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for USART1.
|
||||
*/
|
||||
WEAK void USART1_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for MCI.
|
||||
*/
|
||||
WEAK void MCI_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for TWI0.
|
||||
*/
|
||||
WEAK void TWI0_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for TWI1.
|
||||
*/
|
||||
WEAK void TWI1_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for SPI.
|
||||
*/
|
||||
WEAK void SPI_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for SSC.
|
||||
*/
|
||||
WEAK void SSC_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for TC0.
|
||||
*/
|
||||
WEAK void TC0_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for TC1.
|
||||
*/
|
||||
WEAK void TC1_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for TC2.
|
||||
*/
|
||||
WEAK void TC2_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default SUPC interrupt handler for TC3.
|
||||
*/
|
||||
WEAK void TC3_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default SUPC interrupt handler for TC4.
|
||||
*/
|
||||
WEAK void TC4_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default SUPC interrupt handler for TC5.
|
||||
*/
|
||||
WEAK void TC5_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default SUPC interrupt handler for ADC.
|
||||
*/
|
||||
WEAK void ADC_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default SUPC interrupt handler for DAC.
|
||||
*/
|
||||
WEAK void DAC_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default SUPC interrupt handler for PWM.
|
||||
*/
|
||||
WEAK void PWM_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default SUPC interrupt handler for CRCCU.
|
||||
*/
|
||||
WEAK void CRCCU_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default SUPC interrupt handler for ACC.
|
||||
*/
|
||||
WEAK void ACC_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default SUPC interrupt handler for USBD.
|
||||
*/
|
||||
WEAK void USBD_IrqHandler(void)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Interface for default exception handlers.
|
||||
*/
|
||||
|
||||
#ifndef EXCEPTIONS_H
|
||||
#define EXCEPTIONS_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Function prototype for exception table items (interrupt handler). */
|
||||
typedef void( *IntFunc )( void );
|
||||
|
||||
/* Define WEAK attribute */
|
||||
#if defined ( __CC_ARM )
|
||||
#define WEAK __attribute__ ((weak))
|
||||
#elif defined ( __ICCARM__ )
|
||||
#define WEAK __weak
|
||||
#elif defined ( __GNUC__ )
|
||||
#define WEAK __attribute__ ((weak))
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void IrqHandlerNotUsed(void);
|
||||
|
||||
extern WEAK void NMI_Handler( void );
|
||||
extern WEAK void HardFault_Handler( void );
|
||||
extern WEAK void MemManage_Handler( void );
|
||||
extern WEAK void BusFault_Handler( void );
|
||||
extern WEAK void UsageFault_Handler( void );
|
||||
extern WEAK void SVC_Handler( void );
|
||||
extern WEAK void DebugMon_Handler( void );
|
||||
extern WEAK void PendSV_Handler( void );
|
||||
extern WEAK void SysTick_Handler( void );
|
||||
|
||||
extern WEAK void SUPC_IrqHandler(void);
|
||||
extern WEAK void RSTC_IrqHandler(void);
|
||||
extern WEAK void RTC_IrqHandler(void);
|
||||
extern WEAK void RTT_IrqHandler(void);
|
||||
extern WEAK void WDT_IrqHandler(void);
|
||||
extern WEAK void PMC_IrqHandler(void);
|
||||
extern WEAK void EEFC_IrqHandler(void);
|
||||
extern WEAK void UART0_IrqHandler(void);
|
||||
extern WEAK void UART1_IrqHandler(void);
|
||||
extern WEAK void SMC_IrqHandler(void);
|
||||
extern WEAK void PIOA_IrqHandler(void);
|
||||
extern WEAK void PIOB_IrqHandler(void);
|
||||
extern WEAK void PIOC_IrqHandler(void);
|
||||
extern WEAK void USART0_IrqHandler(void);
|
||||
extern WEAK void USART1_IrqHandler(void);
|
||||
extern WEAK void MCI_IrqHandler(void);
|
||||
extern WEAK void TWI0_IrqHandler(void);
|
||||
extern WEAK void TWI1_IrqHandler(void);
|
||||
extern WEAK void SPI_IrqHandler(void);
|
||||
extern WEAK void SSC_IrqHandler(void);
|
||||
extern WEAK void TC0_IrqHandler(void);
|
||||
extern WEAK void TC1_IrqHandler(void);
|
||||
extern WEAK void TC2_IrqHandler(void);
|
||||
extern WEAK void TC3_IrqHandler(void);
|
||||
extern WEAK void TC4_IrqHandler(void);
|
||||
extern WEAK void TC5_IrqHandler(void);
|
||||
extern WEAK void ADC_IrqHandler(void);
|
||||
extern WEAK void DAC_IrqHandler(void);
|
||||
extern WEAK void PWM_IrqHandler(void);
|
||||
extern WEAK void CRCCU_IrqHandler(void);
|
||||
extern WEAK void ACC_IrqHandler(void);
|
||||
extern WEAK void USBD_IrqHandler(void);
|
||||
|
||||
#endif /* #ifndef EXCEPTIONS_H */
|
||||
|
|
@ -1,187 +0,0 @@
|
|||
/*
|
||||
* FreeModbus Libary: Atmel AT91SAM3S Demo Application
|
||||
* Copyright (C) 2010 Christian Walter <cwalter@embedded-solutions.at>
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* IF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* File: $Id$
|
||||
*/
|
||||
|
||||
/* ----------------------- AT91SAM3S includes -------------------------------*/
|
||||
#include <board.h>
|
||||
#include <usart/usart.h>
|
||||
|
||||
/* ----------------------- Modbus includes ----------------------------------*/
|
||||
#include "mb.h"
|
||||
#include "mbport.h"
|
||||
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
#define REG_INPUT_START ( 1000 )
|
||||
#define REG_INPUT_NREGS ( 64 )
|
||||
|
||||
#define REG_HOLDING_START ( 1 )
|
||||
#define REG_HOLDING_NREGS ( 32 )
|
||||
|
||||
/* ----------------------- Static functions ---------------------------------*/
|
||||
static void _SetupHardware( void );
|
||||
|
||||
/* ----------------------- Static variables ---------------------------------*/
|
||||
static USHORT usRegInputStart = REG_INPUT_START;
|
||||
static USHORT usRegInputBuf[REG_INPUT_NREGS];
|
||||
static USHORT usRegHoldingStart = REG_HOLDING_START;
|
||||
static USHORT usRegHoldingBuf[REG_HOLDING_NREGS];
|
||||
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
int
|
||||
main( void )
|
||||
{
|
||||
_SetupHardware( );
|
||||
|
||||
const UCHAR ucSlaveID[] = { 0xAA, 0xBB, 0xCC };
|
||||
eMBErrorCode eStatus;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
if( MB_ENOERR != ( eStatus = eMBInit( MB_RTU, 0x0A, 1, 38400, MB_PAR_EVEN ) ) )
|
||||
{
|
||||
/* Can not initialize. Add error handling code here. */
|
||||
}
|
||||
else
|
||||
{
|
||||
if( MB_ENOERR != ( eStatus = eMBSetSlaveID( 0x34, TRUE, ucSlaveID, 3 ) ) )
|
||||
{
|
||||
/* Can not set slave id. Check arguments */
|
||||
}
|
||||
else if( MB_ENOERR != ( eStatus = eMBEnable( ) ) )
|
||||
{
|
||||
/* Enable failed. */
|
||||
}
|
||||
else
|
||||
{
|
||||
usRegHoldingBuf[0] = 1;
|
||||
do
|
||||
{
|
||||
( void )eMBPoll( );
|
||||
|
||||
/* Here we simply count the number of poll cycles. */
|
||||
usRegInputBuf[0]++;
|
||||
}
|
||||
while( usRegHoldingBuf[0] );
|
||||
( void )eMBDisable( );
|
||||
( void )eMBClose( );
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void _SetupHardware( void )
|
||||
{
|
||||
WDT_Disable( );
|
||||
|
||||
uint32_t i = 0;
|
||||
for( i = 0; i < 35; i++ )
|
||||
{
|
||||
NVIC_SetPriority( (IRQn_Type)i, 0xF << 4 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
eMBErrorCode
|
||||
eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs )
|
||||
{
|
||||
eMBErrorCode eStatus = MB_ENOERR;
|
||||
int iRegIndex;
|
||||
|
||||
if( ( usAddress >= REG_INPUT_START )
|
||||
&& ( usAddress + usNRegs <= REG_INPUT_START + REG_INPUT_NREGS ) )
|
||||
{
|
||||
iRegIndex = ( int )( usAddress - usRegInputStart );
|
||||
while( usNRegs > 0 )
|
||||
{
|
||||
*pucRegBuffer++ =
|
||||
( unsigned char )( usRegInputBuf[iRegIndex] >> 8 );
|
||||
*pucRegBuffer++ =
|
||||
( unsigned char )( usRegInputBuf[iRegIndex] & 0xFF );
|
||||
iRegIndex++;
|
||||
usNRegs--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eStatus = MB_ENOREG;
|
||||
}
|
||||
|
||||
return eStatus;
|
||||
}
|
||||
|
||||
eMBErrorCode
|
||||
eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs, eMBRegisterMode eMode )
|
||||
{
|
||||
eMBErrorCode eStatus = MB_ENOERR;
|
||||
int iRegIndex;
|
||||
|
||||
if( ( usAddress >= REG_HOLDING_START ) && ( usAddress + usNRegs <= REG_HOLDING_START + REG_HOLDING_NREGS ) )
|
||||
{
|
||||
iRegIndex = ( int )( usAddress - usRegHoldingStart );
|
||||
switch ( eMode )
|
||||
{
|
||||
case MB_REG_READ:
|
||||
while( usNRegs > 0 )
|
||||
{
|
||||
*pucRegBuffer++ = ( unsigned char )( usRegHoldingBuf[iRegIndex] >> 8 );
|
||||
*pucRegBuffer++ = ( unsigned char )( usRegHoldingBuf[iRegIndex] & 0xFF );
|
||||
iRegIndex++;
|
||||
usNRegs--;
|
||||
}
|
||||
break;
|
||||
|
||||
case MB_REG_WRITE:
|
||||
while( usNRegs > 0 )
|
||||
{
|
||||
usRegHoldingBuf[iRegIndex] = *pucRegBuffer++ << 8;
|
||||
usRegHoldingBuf[iRegIndex] |= *pucRegBuffer++;
|
||||
iRegIndex++;
|
||||
usNRegs--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eStatus = MB_ENOREG;
|
||||
}
|
||||
return eStatus;
|
||||
}
|
||||
|
||||
eMBErrorCode
|
||||
eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils,
|
||||
eMBRegisterMode eMode )
|
||||
{
|
||||
return MB_ENOREG;
|
||||
}
|
||||
|
||||
eMBErrorCode
|
||||
eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscrete )
|
||||
{
|
||||
return MB_ENOREG;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\demo.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
..\..\tools\modpoll.exe -m rtu -a 10 -r 1000 -c 4 -t 3 -b 38400 -d 8 -p even COM1
|
||||
|
|
@ -1,804 +0,0 @@
|
|||
/******************************************************************************
|
||||
* @file: core_cm3.c
|
||||
* @purpose: CMSIS Cortex-M3 Core Peripheral Access Layer Source File
|
||||
* @version: V1.10
|
||||
* @date: 24. Feb. 2009
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2009 ARM Limited. All rights reserved.
|
||||
*
|
||||
* ARM Limited (ARM) is supplying this software for use with Cortex-Mx
|
||||
* processor based microcontrollers. This file can be freely distributed
|
||||
* within development tools that are supporting such ARM based processors.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
||||
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
||||
* ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
|
||||
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* define compiler specific symbols */
|
||||
#if defined ( __CC_ARM )
|
||||
#define __ASM __asm /*!< asm keyword for armcc */
|
||||
#define __INLINE __inline /*!< inline keyword for armcc */
|
||||
|
||||
#elif defined ( __ICCARM__ )
|
||||
#define __ASM __asm /*!< asm keyword for iarcc */
|
||||
#define __INLINE inline /*!< inline keyword for iarcc. Only avaiable in High optimization mode! */
|
||||
#define __nop __no_operation /*!< no operation intrinsic in iarcc */
|
||||
|
||||
#elif defined ( __GNUC__ )
|
||||
#define __ASM asm /*!< asm keyword for gcc */
|
||||
#define __INLINE inline /*!< inline keyword for gcc */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
|
||||
|
||||
/**
|
||||
* @brief Return the Process Stack Pointer
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t ProcessStackPointer
|
||||
*
|
||||
* Return the actual process stack pointer
|
||||
*/
|
||||
__ASM uint32_t __get_PSP(void)
|
||||
{
|
||||
mrs r0, psp
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Process Stack Pointer
|
||||
*
|
||||
* @param uint32_t Process Stack Pointer
|
||||
* @return none
|
||||
*
|
||||
* Assign the value ProcessStackPointer to the MSP
|
||||
* (process stack pointer) Cortex processor register
|
||||
*/
|
||||
__ASM void __set_PSP(uint32_t topOfProcStack)
|
||||
{
|
||||
msr psp, r0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Main Stack Pointer
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t Main Stack Pointer
|
||||
*
|
||||
* Return the current value of the MSP (main stack pointer)
|
||||
* Cortex processor register
|
||||
*/
|
||||
__ASM uint32_t __get_MSP(void)
|
||||
{
|
||||
mrs r0, msp
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Main Stack Pointer
|
||||
*
|
||||
* @param uint32_t Main Stack Pointer
|
||||
* @return none
|
||||
*
|
||||
* Assign the value mainStackPointer to the MSP
|
||||
* (main stack pointer) Cortex processor register
|
||||
*/
|
||||
__ASM void __set_MSP(uint32_t mainStackPointer)
|
||||
{
|
||||
msr msp, r0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reverse byte order in unsigned short value
|
||||
*
|
||||
* @param uint16_t value to reverse
|
||||
* @return uint32_t reversed value
|
||||
*
|
||||
* Reverse byte order in unsigned short value
|
||||
*/
|
||||
__ASM uint32_t __REV16(uint16_t value)
|
||||
{
|
||||
rev16 r0, r0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reverse byte order in signed short value with sign extension to integer
|
||||
*
|
||||
* @param int16_t value to reverse
|
||||
* @return int32_t reversed value
|
||||
*
|
||||
* Reverse byte order in signed short value with sign extension to integer
|
||||
*/
|
||||
__ASM int32_t __REVSH(int16_t value)
|
||||
{
|
||||
revsh r0, r0
|
||||
bx lr
|
||||
}
|
||||
|
||||
|
||||
#if (__ARMCC_VERSION < 400000)
|
||||
|
||||
/**
|
||||
* @brief Remove the exclusive lock created by ldrex
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* Removes the exclusive lock which is created by ldrex.
|
||||
*/
|
||||
__ASM void __CLREX(void)
|
||||
{
|
||||
clrex
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Base Priority value
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t BasePriority
|
||||
*
|
||||
* Return the content of the base priority register
|
||||
*/
|
||||
__ASM uint32_t __get_BASEPRI(void)
|
||||
{
|
||||
mrs r0, basepri
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Base Priority value
|
||||
*
|
||||
* @param uint32_t BasePriority
|
||||
* @return none
|
||||
*
|
||||
* Set the base priority register
|
||||
*/
|
||||
__ASM void __set_BASEPRI(uint32_t basePri)
|
||||
{
|
||||
msr basepri, r0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Priority Mask value
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t PriMask
|
||||
*
|
||||
* Return the state of the priority mask bit from the priority mask
|
||||
* register
|
||||
*/
|
||||
__ASM uint32_t __get_PRIMASK(void)
|
||||
{
|
||||
mrs r0, primask
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Priority Mask value
|
||||
*
|
||||
* @param uint32_t PriMask
|
||||
* @return none
|
||||
*
|
||||
* Set the priority mask bit in the priority mask register
|
||||
*/
|
||||
__ASM void __set_PRIMASK(uint32_t priMask)
|
||||
{
|
||||
msr primask, r0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Fault Mask value
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t FaultMask
|
||||
*
|
||||
* Return the content of the fault mask register
|
||||
*/
|
||||
__ASM uint32_t __get_FAULTMASK(void)
|
||||
{
|
||||
mrs r0, faultmask
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Fault Mask value
|
||||
*
|
||||
* @param uint32_t faultMask value
|
||||
* @return none
|
||||
*
|
||||
* Set the fault mask register
|
||||
*/
|
||||
__ASM void __set_FAULTMASK(uint32_t faultMask)
|
||||
{
|
||||
msr faultmask, r0
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Control Register value
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t Control value
|
||||
*
|
||||
* Return the content of the control register
|
||||
*/
|
||||
__ASM uint32_t __get_CONTROL(void)
|
||||
{
|
||||
mrs r0, control
|
||||
bx lr
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Control Register value
|
||||
*
|
||||
* @param uint32_t Control value
|
||||
* @return none
|
||||
*
|
||||
* Set the control register
|
||||
*/
|
||||
__ASM void __set_CONTROL(uint32_t control)
|
||||
{
|
||||
msr control, r0
|
||||
bx lr
|
||||
}
|
||||
|
||||
#endif /* __ARMCC_VERSION */
|
||||
|
||||
|
||||
#elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/
|
||||
#pragma diag_suppress=Pe940
|
||||
|
||||
/**
|
||||
* @brief Return the Process Stack Pointer
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t ProcessStackPointer
|
||||
*
|
||||
* Return the actual process stack pointer
|
||||
*/
|
||||
uint32_t __get_PSP(void)
|
||||
{
|
||||
__ASM("mrs r0, psp");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Process Stack Pointer
|
||||
*
|
||||
* @param uint32_t Process Stack Pointer
|
||||
* @return none
|
||||
*
|
||||
* Assign the value ProcessStackPointer to the MSP
|
||||
* (process stack pointer) Cortex processor register
|
||||
*/
|
||||
void __set_PSP(uint32_t topOfProcStack)
|
||||
{
|
||||
__ASM("msr psp, r0");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Main Stack Pointer
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t Main Stack Pointer
|
||||
*
|
||||
* Return the current value of the MSP (main stack pointer)
|
||||
* Cortex processor register
|
||||
*/
|
||||
uint32_t __get_MSP(void)
|
||||
{
|
||||
__ASM("mrs r0, msp");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Main Stack Pointer
|
||||
*
|
||||
* @param uint32_t Main Stack Pointer
|
||||
* @return none
|
||||
*
|
||||
* Assign the value mainStackPointer to the MSP
|
||||
* (main stack pointer) Cortex processor register
|
||||
*/
|
||||
void __set_MSP(uint32_t topOfMainStack)
|
||||
{
|
||||
__ASM("msr msp, r0");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reverse byte order in unsigned short value
|
||||
*
|
||||
* @param uint16_t value to reverse
|
||||
* @return uint32_t reversed value
|
||||
*
|
||||
* Reverse byte order in unsigned short value
|
||||
*/
|
||||
uint32_t __REV16(uint16_t value)
|
||||
{
|
||||
__ASM("rev16 r0, r0");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reverse bit order of value
|
||||
*
|
||||
* @param uint32_t value to reverse
|
||||
* @return uint32_t reversed value
|
||||
*
|
||||
* Reverse bit order of value
|
||||
*/
|
||||
uint32_t __RBIT(uint32_t value)
|
||||
{
|
||||
__ASM("rbit r0, r0");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LDR Exclusive
|
||||
*
|
||||
* @param uint8_t* address
|
||||
* @return uint8_t value of (*address)
|
||||
*
|
||||
* Exclusive LDR command
|
||||
*/
|
||||
uint8_t __LDREXB(uint8_t *addr)
|
||||
{
|
||||
__ASM("ldrexb r0, [r0]");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LDR Exclusive
|
||||
*
|
||||
* @param uint16_t* address
|
||||
* @return uint16_t value of (*address)
|
||||
*
|
||||
* Exclusive LDR command
|
||||
*/
|
||||
uint16_t __LDREXH(uint16_t *addr)
|
||||
{
|
||||
__ASM("ldrexh r0, [r0]");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LDR Exclusive
|
||||
*
|
||||
* @param uint32_t* address
|
||||
* @return uint32_t value of (*address)
|
||||
*
|
||||
* Exclusive LDR command
|
||||
*/
|
||||
uint32_t __LDREXW(uint32_t *addr)
|
||||
{
|
||||
__ASM("ldrex r0, [r0]");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief STR Exclusive
|
||||
*
|
||||
* @param uint8_t *address
|
||||
* @param uint8_t value to store
|
||||
* @return uint32_t successful / failed
|
||||
*
|
||||
* Exclusive STR command
|
||||
*/
|
||||
uint32_t __STREXB(uint8_t value, uint8_t *addr)
|
||||
{
|
||||
__ASM("strexb r0, r0, [r1]");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief STR Exclusive
|
||||
*
|
||||
* @param uint16_t *address
|
||||
* @param uint16_t value to store
|
||||
* @return uint32_t successful / failed
|
||||
*
|
||||
* Exclusive STR command
|
||||
*/
|
||||
uint32_t __STREXH(uint16_t value, uint16_t *addr)
|
||||
{
|
||||
__ASM("strexh r0, r0, [r1]");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief STR Exclusive
|
||||
*
|
||||
* @param uint32_t *address
|
||||
* @param uint32_t value to store
|
||||
* @return uint32_t successful / failed
|
||||
*
|
||||
* Exclusive STR command
|
||||
*/
|
||||
uint32_t __STREXW(uint32_t value, uint32_t *addr)
|
||||
{
|
||||
__ASM("strex r0, r0, [r1]");
|
||||
__ASM("bx lr");
|
||||
}
|
||||
|
||||
#pragma diag_default=Pe940
|
||||
|
||||
|
||||
#elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/
|
||||
|
||||
/**
|
||||
* @brief Return the Process Stack Pointer
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t ProcessStackPointer
|
||||
*
|
||||
* Return the actual process stack pointer
|
||||
*/
|
||||
uint32_t __get_PSP(void)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("MRS %0, psp" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Process Stack Pointer
|
||||
*
|
||||
* @param uint32_t Process Stack Pointer
|
||||
* @return none
|
||||
*
|
||||
* Assign the value ProcessStackPointer to the MSP
|
||||
* (process stack pointer) Cortex processor register
|
||||
*/
|
||||
void __set_PSP(uint32_t topOfProcStack)
|
||||
{
|
||||
__ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Main Stack Pointer
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t Main Stack Pointer
|
||||
*
|
||||
* Return the current value of the MSP (main stack pointer)
|
||||
* Cortex processor register
|
||||
*/
|
||||
uint32_t __get_MSP(void)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("MRS %0, msp" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Main Stack Pointer
|
||||
*
|
||||
* @param uint32_t Main Stack Pointer
|
||||
* @return none
|
||||
*
|
||||
* Assign the value mainStackPointer to the MSP
|
||||
* (main stack pointer) Cortex processor register
|
||||
*/
|
||||
void __set_MSP(uint32_t topOfMainStack)
|
||||
{
|
||||
__ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Base Priority value
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t BasePriority
|
||||
*
|
||||
* Return the content of the base priority register
|
||||
*/
|
||||
uint32_t __get_BASEPRI(void)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("MRS %0, basepri_max" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Base Priority value
|
||||
*
|
||||
* @param uint32_t BasePriority
|
||||
* @return none
|
||||
*
|
||||
* Set the base priority register
|
||||
*/
|
||||
void __set_BASEPRI(uint32_t value)
|
||||
{
|
||||
__ASM volatile ("MSR basepri, %0" : : "r" (value) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Priority Mask value
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t PriMask
|
||||
*
|
||||
* Return the state of the priority mask bit from the priority mask
|
||||
* register
|
||||
*/
|
||||
uint32_t __get_PRIMASK(void)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("MRS %0, primask" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Priority Mask value
|
||||
*
|
||||
* @param uint32_t PriMask
|
||||
* @return none
|
||||
*
|
||||
* Set the priority mask bit in the priority mask register
|
||||
*/
|
||||
void __set_PRIMASK(uint32_t priMask)
|
||||
{
|
||||
__ASM volatile ("MSR primask, %0" : : "r" (priMask) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Fault Mask value
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t FaultMask
|
||||
*
|
||||
* Return the content of the fault mask register
|
||||
*/
|
||||
uint32_t __get_FAULTMASK(void)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("MRS %0, faultmask" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Fault Mask value
|
||||
*
|
||||
* @param uint32_t faultMask value
|
||||
* @return none
|
||||
*
|
||||
* Set the fault mask register
|
||||
*/
|
||||
void __set_FAULTMASK(uint32_t faultMask)
|
||||
{
|
||||
__ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reverse byte order in integer value
|
||||
*
|
||||
* @param uint32_t value to reverse
|
||||
* @return uint32_t reversed value
|
||||
*
|
||||
* Reverse byte order in integer value
|
||||
*/
|
||||
uint32_t __REV(uint32_t value)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("rev %0, %1" : "=r" (result) : "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reverse byte order in unsigned short value
|
||||
*
|
||||
* @param uint16_t value to reverse
|
||||
* @return uint32_t reversed value
|
||||
*
|
||||
* Reverse byte order in unsigned short value
|
||||
*/
|
||||
uint32_t __REV16(uint16_t value)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reverse byte order in signed short value with sign extension to integer
|
||||
*
|
||||
* @param int32_t value to reverse
|
||||
* @return int32_t reversed value
|
||||
*
|
||||
* Reverse byte order in signed short value with sign extension to integer
|
||||
*/
|
||||
int32_t __REVSH(int16_t value)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("revsh %0, %1" : "=r" (result) : "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reverse bit order of value
|
||||
*
|
||||
* @param uint32_t value to reverse
|
||||
* @return uint32_t reversed value
|
||||
*
|
||||
* Reverse bit order of value
|
||||
*/
|
||||
uint32_t __RBIT(uint32_t value)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LDR Exclusive
|
||||
*
|
||||
* @param uint8_t* address
|
||||
* @return uint8_t value of (*address)
|
||||
*
|
||||
* Exclusive LDR command
|
||||
*/
|
||||
uint8_t __LDREXB(uint8_t *addr)
|
||||
{
|
||||
uint8_t result=0;
|
||||
|
||||
__ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LDR Exclusive
|
||||
*
|
||||
* @param uint16_t* address
|
||||
* @return uint16_t value of (*address)
|
||||
*
|
||||
* Exclusive LDR command
|
||||
*/
|
||||
uint16_t __LDREXH(uint16_t *addr)
|
||||
{
|
||||
uint16_t result=0;
|
||||
|
||||
__ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LDR Exclusive
|
||||
*
|
||||
* @param uint32_t* address
|
||||
* @return uint32_t value of (*address)
|
||||
*
|
||||
* Exclusive LDR command
|
||||
*/
|
||||
uint32_t __LDREXW(uint32_t *addr)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("ldrex %0, [%1]" : "=r" (result) : "r" (addr) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief STR Exclusive
|
||||
*
|
||||
* @param uint8_t *address
|
||||
* @param uint8_t value to store
|
||||
* @return uint32_t successful / failed
|
||||
*
|
||||
* Exclusive STR command
|
||||
*/
|
||||
uint32_t __STREXB(uint8_t value, uint8_t *addr)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("strexb %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief STR Exclusive
|
||||
*
|
||||
* @param uint16_t *address
|
||||
* @param uint16_t value to store
|
||||
* @return uint32_t successful / failed
|
||||
*
|
||||
* Exclusive STR command
|
||||
*/
|
||||
uint32_t __STREXH(uint16_t value, uint16_t *addr)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("strexh %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief STR Exclusive
|
||||
*
|
||||
* @param uint32_t *address
|
||||
* @param uint32_t value to store
|
||||
* @return uint32_t successful / failed
|
||||
*
|
||||
* Exclusive STR command
|
||||
*/
|
||||
uint32_t __STREXW(uint32_t value, uint32_t *addr)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("strex %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Control Register value
|
||||
*
|
||||
* @param none
|
||||
* @return uint32_t Control value
|
||||
*
|
||||
* Return the content of the control register
|
||||
*/
|
||||
uint32_t __get_CONTROL(void)
|
||||
{
|
||||
uint32_t result=0;
|
||||
|
||||
__ASM volatile ("MRS %0, control" : "=r" (result) );
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Control Register value
|
||||
*
|
||||
* @param uint32_t Control value
|
||||
* @return none
|
||||
*
|
||||
* Set the control register
|
||||
*/
|
||||
void __set_CONTROL(uint32_t control)
|
||||
{
|
||||
__ASM volatile ("MSR control, %0" : : "r" (control) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,164 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \addtogroup adc_module Working with ACC
|
||||
* The ACC driver provides the interface to configure and use the ACC peripheral.\n
|
||||
*
|
||||
* It converts the analog input to digital format. The converted result could be 12bit
|
||||
* or 10bit. The ACC supports up to 16 analog lines.
|
||||
*
|
||||
* To Enable a ACC conversion,the user has to follow these few steps:
|
||||
* <ul>
|
||||
* <li> Select an appropriate reference voltage on ADVREF </li>
|
||||
* <li> Configure the ACC according to its requirements and special needs,which could be
|
||||
broken down into several parts:
|
||||
* -# Select the resolution by setting or clearing ACC_MR_LOWRES bit in ACC_MR (Mode Register)
|
||||
* -# Set ACC clock by setting ACC_MR_PRESCAL bits in ACC_MR, the clock is caculated with
|
||||
ACCClock = MCK / ( (PRESCAL+1) * 2 )
|
||||
* -# Set Startup Time,Tracking Clock cycles and Transfer Clock respeticively in ACC_MR.
|
||||
</li>
|
||||
* <li> Start conversion by setting ACC_CR_START in ACC_CR. </li>
|
||||
* </ul>
|
||||
*
|
||||
* For more accurate information, please look at the ACC section of the
|
||||
* Datasheet.
|
||||
*
|
||||
* Related files :\n
|
||||
* \ref adc.c\n
|
||||
* \ref adc.h\n
|
||||
*/
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <board.h>
|
||||
#include <acc/acc.h>
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Initialize the ACC controller
|
||||
* \param pAcc Pointer to an Acc instance.
|
||||
* \param idAcc ACC identifier
|
||||
* \param selplus input connected to inp, 0~7
|
||||
* \param selminus input connected to inm,0~7
|
||||
* \param ac_en Analog comprator enabled/disabled,use pattern
|
||||
* \param edge CF flag triggering mode,use pattern
|
||||
* \param invert INVert comparator output,use pattern defined in the device header
|
||||
file
|
||||
*/
|
||||
void ACC_Configure(Acc *pAcc,
|
||||
uint8_t idAcc,
|
||||
uint8_t selplus,
|
||||
uint8_t selminus,
|
||||
uint16_t ac_en,
|
||||
uint16_t edge,
|
||||
uint16_t invert)
|
||||
{
|
||||
|
||||
/* Enable peripheral clock*/
|
||||
PMC->PMC_PCER1 = 1 << (idAcc-32);
|
||||
|
||||
/* Reset the controller */
|
||||
pAcc->ACC_CR |= ACC_CR_SWRST;
|
||||
|
||||
/* Write to the MR register */
|
||||
ACC_CfgModeReg( pAcc,
|
||||
( selplus & ACC_MR_SELPLUS)
|
||||
| (( selminus<<4) & ACC_MR_SELMINUS)
|
||||
| ( ac_en & ACC_MR_ACEN)
|
||||
| ( edge & ACC_MR_EDGETYP)
|
||||
| ( invert & ACC_MR_INV) );
|
||||
//pAcc->ACC_MR |= (ACC_MR_SELFS_OUTPUT|ACC_MR_FE_EN);
|
||||
|
||||
pAcc->ACC_ACR = 0x7;
|
||||
|
||||
while(pAcc->ACC_ISR & (uint32_t)ACC_ISR_MASK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the Channel Converted Data
|
||||
* \param pAdc Pointer to an Adc instance.
|
||||
* \param channel channel to get converted value
|
||||
* \return Channel converted data of the specified channel
|
||||
*/
|
||||
void ACC_SetComparisionPair(Acc *pAcc, uint8_t selplus,uint8_t selminus)
|
||||
{
|
||||
|
||||
uint32_t temp;
|
||||
|
||||
ASSERT(selplus < 8 && selminus < 8,"The assigned channel number is invalid!");
|
||||
|
||||
temp = pAcc->ACC_MR;
|
||||
|
||||
pAcc->ACC_MR = temp & (~ACC_MR_SELMINUS)&(~ACC_MR_SELPLUS);
|
||||
|
||||
pAcc->ACC_MR |= ((selplus & ACC_MR_SELPLUS)|((selminus<<4) & ACC_MR_SELMINUS));
|
||||
|
||||
}
|
||||
/**
|
||||
* Return Comparison Result
|
||||
* \param pAcc Pointer to an Acc instance.
|
||||
* \param status value of ACC_ISR
|
||||
*/
|
||||
uint8_t ACC_GetComparisionResult(Acc *pAcc,uint32_t status)
|
||||
{
|
||||
uint32_t temp = pAcc->ACC_MR;
|
||||
if( (temp & ACC_MR_INV)== ACC_MR_INV)
|
||||
{
|
||||
|
||||
if( status & ACC_ISR_SCO)
|
||||
{
|
||||
return 0; /* inn>inp*/
|
||||
}
|
||||
else return 1;/* inp>inn*/
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if( status & ACC_ISR_SCO)
|
||||
{
|
||||
return 1; /* inp>inn*/
|
||||
}
|
||||
else return 0;/* inn>inp*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \unit
|
||||
*
|
||||
* !Purpose
|
||||
*
|
||||
* Interface for configuration the Analog-to-Digital Converter (ACC) peripheral.
|
||||
*
|
||||
* !Usage
|
||||
*
|
||||
* -# Configurate the pins for ACC
|
||||
* -# Initialize the ACC with ACC_Initialize().
|
||||
* -# Select the active channel using ACC_EnableChannel()
|
||||
* -# Start the conversion with ACC_StartConversion()
|
||||
* -# Wait the end of the conversion by polling status with ACC_GetStatus()
|
||||
* -# Finally, get the converted data using ACC_GetConvertedData()
|
||||
*
|
||||
*/
|
||||
#ifndef ACC_H
|
||||
#define ACC_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <utility/assert.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
#define ACC_SELPLUS_AD12B0 0
|
||||
#define ACC_SELPLUS_AD12B1 1
|
||||
#define ACC_SELPLUS_AD12B2 2
|
||||
#define ACC_SELPLUS_AD12B3 3
|
||||
#define ACC_SELPLUS_AD12B4 4
|
||||
#define ACC_SELPLUS_AD12B5 5
|
||||
#define ACC_SELPLUS_AD12B6 6
|
||||
#define ACC_SELPLUS_AD12B7 7
|
||||
#define ACC_SELMINUS_TS 0
|
||||
#define ACC_SELMINUS_ADVREF 1
|
||||
#define ACC_SELMINUS_DAC0 2
|
||||
#define ACC_SELMINUS_DAC1 3
|
||||
#define ACC_SELMINUS_AD12B0 4
|
||||
#define ACC_SELMINUS_AD12B1 5
|
||||
#define ACC_SELMINUS_AD12B2 6
|
||||
#define ACC_SELMINUS_AD12B3 7
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Macros function of register access
|
||||
*------------------------------------------------------------------------------*/
|
||||
#define ACC_CfgModeReg(pAcc, mode) { \
|
||||
(pAcc)->ACC_MR = (mode);\
|
||||
}
|
||||
|
||||
#define ACC_GetModeReg(pAcc) ((pAcc)->ACC_MR)
|
||||
|
||||
#define ACC_StartConversion(pAcc) ((pAcc)->ACC_CR = ACC_CR_START)
|
||||
|
||||
#define ACC_SoftReset(pAcc) ((pAcc)->ACC_CR = ACC_CR_SWRST)
|
||||
|
||||
#define ACC_EnableChannel(pAcc, channel) {\
|
||||
ASSERT(channel < 16, "ACC Channel not exist");\
|
||||
(pAcc)->ACC_CHER = (1 << (channel));\
|
||||
}
|
||||
|
||||
#define ACC_DisableChannel (pAcc, channel) {\
|
||||
ASSERT((channel) < 16, "ACC Channel not exist");\
|
||||
(pAcc)->ACC_CHDR = (1 << (channel));\
|
||||
}
|
||||
|
||||
#define ACC_EnableIt(pAcc, mode) {\
|
||||
ASSERT(((mode)&0xFFF00000)== 0, "ACC bad interrupt IER");\
|
||||
(pAcc)->ACC_IER = (mode);\
|
||||
}
|
||||
|
||||
#define ACC_DisableIt(pAcc, mode) {\
|
||||
ASSERT(((mode)&0xFFF00000)== 0, "ACC bad interrupt IDR");\
|
||||
(pAcc)->ACC_IDR = (mode);\
|
||||
}
|
||||
|
||||
#define ACC_EnableDataReadyIt(pAcc) ((pAcc)->ACC_IER = AT91C_ACC_DRDY)
|
||||
|
||||
#define ACC_GetStatus(pAcc) ((pAcc)->ACC_ISR)
|
||||
|
||||
#define ACC_GetChannelStatus(pAcc) ((pAcc)->ACC_CHSR)
|
||||
|
||||
#define ACC_GetInterruptMaskStatus(pAcc) ((pAcc)->ACC_IMR)
|
||||
|
||||
#define ACC_GetLastConvertedData(pAcc) ((pAcc)->ACC_LCDR)
|
||||
|
||||
#define ACC_CfgAnalogCtrlReg(pAcc,mode) {\
|
||||
ASSERT(((mode) & 0xFFFCFF3C)==0, "ACC bad analog control config");\
|
||||
(pAcc)->ACC_ACR = (mode);\
|
||||
}
|
||||
|
||||
#define ACC_CfgExtModeReg(pAcc, extmode) {\
|
||||
ASSERT(((extmode) & 0xFF00FFFE)==0, "ACC bad extended mode config");\
|
||||
(pAcc)->ACC_EMR = (extmode);\
|
||||
}
|
||||
|
||||
#define ACC_GetAnalogCtrlReg(pAcc) ((pAcc)->ACC_ACR)
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
void ACC_Configure(Acc *pAcc,
|
||||
uint8_t idAcc,
|
||||
uint8_t selplus,
|
||||
uint8_t selminus,
|
||||
uint16_t ac_en,
|
||||
uint16_t edge,
|
||||
uint16_t invert);
|
||||
|
||||
extern uint8_t ACC_GetComparisionResult(Acc *pAcc,uint32_t status);
|
||||
|
||||
#endif //#ifndef ACC_H
|
||||
|
|
@ -1,231 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \addtogroup adc_module Working with ADC
|
||||
* The ADC driver provides the interface to configure and use the ADC peripheral.
|
||||
* \n
|
||||
*
|
||||
* It converts the analog input to digital format. The converted result could be
|
||||
* 12bit or 10bit. The ADC supports up to 16 analog lines.
|
||||
*
|
||||
* To Enable a ADC conversion,the user has to follow these few steps:
|
||||
* <ul>
|
||||
* <li> Select an appropriate reference voltage on ADVREF </li>
|
||||
* <li> Configure the ADC according to its requirements and special needs,which
|
||||
* could be broken down into several parts:
|
||||
* -# Select the resolution by setting or clearing ADC_MR_LOWRES bit in
|
||||
* ADC_MR (Mode Register)
|
||||
* -# Set ADC clock by setting ADC_MR_PRESCAL bits in ADC_MR, the clock is
|
||||
* calculated with ADCClock = MCK / ( (PRESCAL+1) * 2 )
|
||||
* -# Set Startup Time,Tracking Clock cycles and Transfer Clock respectively
|
||||
* in ADC_MR.
|
||||
</li>
|
||||
* <li> Start conversion by setting ADC_CR_START in ADC_CR. </li>
|
||||
* </ul>
|
||||
*
|
||||
* For more accurate information, please look at the ADC section of the
|
||||
* Datasheet.
|
||||
*
|
||||
* Related files :\n
|
||||
* \ref adc.c\n
|
||||
* \ref adc.h\n
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <board.h>
|
||||
#include <adc/adc.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Initialize the ADC controller
|
||||
* \param pAdc Pointer to an Adc instance.
|
||||
* \param trgEn trigger mode, software or Hardware
|
||||
* \param trgSel hardware trigger selection
|
||||
* \param sleepMode sleep mode selection
|
||||
* \param resolution resolution selection 10 bits or 12 bits
|
||||
* \param mckClock value of MCK in Hz
|
||||
* \param adcClock value of the ADC clock in Hz
|
||||
* \param startupTime value of the start up time (in ADCClock) (see datasheet)
|
||||
* \param trackingt Tracking Time (in ADCClock cycle)
|
||||
*/
|
||||
void ADC_Initialize(Adc *pAdc, uint8_t idAdc, uint8_t trgEn, uint8_t trgSel,
|
||||
uint8_t sleepMode, uint8_t resolution, uint32_t mckClock,
|
||||
uint32_t adcClock, uint32_t startup, uint32_t tracking) {
|
||||
uint32_t prescal;
|
||||
prescal = (mckClock / (2*adcClock)) - 1;
|
||||
|
||||
ASSERT( (prescal<0x3F), "ADC Bad PRESCAL\n\r");
|
||||
|
||||
TRACE_DEBUG("adcClock:%lu MasterClock:%lu\n\r", (mckClock/((prescal+1)*2)),
|
||||
mckClock);
|
||||
|
||||
if( adcClock != (mckClock/((prescal+1)*2)) ) {
|
||||
TRACE_WARNING("User and calculated adcClocks are different : "
|
||||
"user=%lu calc=%lu\n\r",
|
||||
adcClock, (mckClock/((prescal+1)*2)));
|
||||
}
|
||||
|
||||
/* Enable peripheral clock*/
|
||||
PMC->PMC_PCER0 = 1 << idAdc;
|
||||
|
||||
/* Reset the controller */
|
||||
ADC_SoftReset(pAdc);
|
||||
|
||||
/* Write to the MR register */
|
||||
ADC_CfgModeReg( pAdc,
|
||||
( trgEn & ADC_MR_TRGEN)
|
||||
| ( trgSel & ADC_MR_TRGSEL)
|
||||
| ( resolution & ADC_MR_LOWRES)
|
||||
| ( sleepMode & ADC_MR_SLEEP)
|
||||
| ( (prescal<<8) & ADC_MR_PRESCAL)
|
||||
| ( (startup<<16) & ADC_MR_STARTUP)
|
||||
| ( (tracking<<24) & ADC_MR_TRACKTIM) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Channel Converted Data
|
||||
* \param pAdc Pointer to an Adc instance.
|
||||
* \param channel channel to get converted value
|
||||
*/
|
||||
uint32_t ADC_GetConvertedData(Adc *pAdc, uint32_t channel) {
|
||||
uint32_t data=0;
|
||||
|
||||
if (15 >= channel) {
|
||||
data = *((RoReg *)((uint32_t)&(pAdc->ADC_CDR0)+ channel*4));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* Set compare channel
|
||||
* \param pAdc Pointer to an Adc instance.
|
||||
* \param channel channel number to be set,16 for all channels
|
||||
*/
|
||||
void ADC_SetCompareChannel(Adc *pAdc, uint8_t channel) {
|
||||
ASSERT(channel<=16, "Invalid channel number");
|
||||
if (channel < 16) {
|
||||
pAdc->ADC_EMR &= ~(ADC_EMR_CMPALL);
|
||||
pAdc->ADC_EMR &= ~(ADC_EMR_CMPSEL);
|
||||
pAdc->ADC_EMR |= (channel << 4);
|
||||
} else {
|
||||
pAdc->ADC_EMR |= ADC_EMR_CMPALL;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set compare mode
|
||||
* \param pAdc Pointer to an Adc instance.
|
||||
* \param mode compare mode
|
||||
*/
|
||||
void ADC_SetCompareMode(Adc *pAdc, uint8_t mode) {
|
||||
pAdc->ADC_EMR &= ~(ADC_EMR_CMPMODE);
|
||||
pAdc->ADC_EMR |= mode;
|
||||
}
|
||||
/**
|
||||
* Set comparsion window,one thereshold each time
|
||||
* \param pAdc Pointer to an Adc instance.
|
||||
* \param hi_lo Comparison Window
|
||||
*/
|
||||
void ADC_SetComparisonWindow(Adc *pAdc, uint32_t hi_lo) {
|
||||
pAdc->ADC_CWR = hi_lo;
|
||||
}
|
||||
|
||||
/**----------------------------------------------------------------------------
|
||||
* Test if ADC Interrupt is Masked
|
||||
* \param pAdc Pointer to an Adc instance.
|
||||
* \param flag flag to be tested
|
||||
* \return 1 if interrupt is masked, otherwise 0
|
||||
*/
|
||||
uint32_t ADC_IsInterruptMasked(Adc *pAdc, uint32_t flag) {
|
||||
return (ADC_GetInterruptMaskStatus(pAdc) & flag);
|
||||
}
|
||||
|
||||
/**----------------------------------------------------------------------------
|
||||
* Test if ADC Status is Set
|
||||
* \param pAdc Pointer to an Adc instance.
|
||||
* \param flag flag to be tested
|
||||
* \return 1 if the staus is set; 0 otherwise
|
||||
*/
|
||||
uint32_t ADC_IsStatusSet(Adc *pAdc, uint32_t flag) {
|
||||
return (ADC_GetStatus(pAdc) & flag);
|
||||
}
|
||||
|
||||
/**----------------------------------------------------------------------------
|
||||
* Test if ADC channel interrupt Status is Set
|
||||
* \param adc_sr Value of SR register
|
||||
* \param channel Channel to be tested
|
||||
* \return 1 if interrupt status is set, otherwise 0
|
||||
*/
|
||||
uint8_t ADC_IsChannelInterruptStatusSet(uint32_t adc_sr, uint32_t channel) {
|
||||
uint8_t status;
|
||||
|
||||
if((adc_sr & (1<<channel)) == (1<<channel)) {
|
||||
status = 1;
|
||||
} else {
|
||||
status = 0;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Read converted data through PDC channel
|
||||
* \param padc the pointer of adc peripheral
|
||||
* \param pBuffer the destination buffer
|
||||
* \param size the size of the buffer
|
||||
*/
|
||||
int8_t ADC_ReadBuffer(Adc *pADC, int16_t *pBuffer, int32_t size) {
|
||||
|
||||
/* Check if the first PDC bank is free*/
|
||||
if ((pADC->ADC_RCR == 0) && (pADC->ADC_RNCR == 0)) {
|
||||
|
||||
pADC->ADC_RPR = (uint32_t) pBuffer;
|
||||
pADC->ADC_RCR = size;
|
||||
pADC->ADC_PTCR = ADC_PTCR_RXTEN;
|
||||
|
||||
return 1;
|
||||
}
|
||||
/* Check if the second PDC bank is free*/
|
||||
else if (pADC->ADC_RNCR == 0) {
|
||||
|
||||
pADC->ADC_RNPR = (uint32_t) pBuffer;
|
||||
pADC->ADC_RNCR = size;
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \unit
|
||||
*
|
||||
* !Purpose
|
||||
*
|
||||
* Interface for configuration the Analog-to-Digital Converter (ADC) peripheral.
|
||||
*
|
||||
* !Usage
|
||||
*
|
||||
* -# Configurate the pins for ADC
|
||||
* -# Initialize the ADC with ADC_Initialize().
|
||||
* -# Select the active channel using ADC_EnableChannel()
|
||||
* -# Start the conversion with ADC_StartConversion()
|
||||
* -# Wait the end of the conversion by polling status with ADC_GetStatus()
|
||||
* -# Finally, get the converted data using ADC_GetConvertedData()
|
||||
*
|
||||
*/
|
||||
#ifndef ADC_H
|
||||
#define ADC_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <utility/assert.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
#define ADC_CHANNEL_0 0
|
||||
#define ADC_CHANNEL_1 1
|
||||
#define ADC_CHANNEL_2 2
|
||||
#define ADC_CHANNEL_3 3
|
||||
#define ADC_CHANNEL_4 4
|
||||
#define ADC_CHANNEL_5 5
|
||||
#define ADC_CHANNEL_6 6
|
||||
#define ADC_CHANNEL_7 7
|
||||
#define ADC_CHANNEL_8 8
|
||||
#define ADC_CHANNEL_9 9
|
||||
#define ADC_CHANNEL_10 10
|
||||
#define ADC_CHANNEL_11 11
|
||||
#define ADC_CHANNEL_12 12
|
||||
#define ADC_CHANNEL_13 13
|
||||
#define ADC_CHANNEL_14 14
|
||||
#define ADC_CHANNEL_15 15
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Macros function of register access
|
||||
*------------------------------------------------------------------------------*/
|
||||
#define ADC_CfgModeReg(pAdc, mode) { \
|
||||
ASSERT(((mode)&0xF00000C0)== 0, "ADC Bad configuration ADC MR");\
|
||||
(pAdc)->ADC_MR = (mode);\
|
||||
}
|
||||
|
||||
#define ADC_GetModeReg(pAdc) ((pAdc)->ADC_MR)
|
||||
|
||||
#define ADC_StartConversion(pAdc) ((pAdc)->ADC_CR = ADC_CR_START)
|
||||
|
||||
#define ADC_SoftReset(pAdc) ((pAdc)->ADC_CR = ADC_CR_SWRST)
|
||||
|
||||
#define ADC_EnableChannel(pAdc, channel) {\
|
||||
ASSERT(channel < 16, "ADC Channel not exist");\
|
||||
(pAdc)->ADC_CHER = (1 << (channel));\
|
||||
}
|
||||
|
||||
#define ADC_DisableChannel (pAdc, channel) {\
|
||||
ASSERT((channel) < 16, "ADC Channel not exist");\
|
||||
(pAdc)->ADC_CHDR = (1 << (channel));\
|
||||
}
|
||||
|
||||
#define ADC_EnableIt(pAdc, mode) {\
|
||||
(pAdc)->ADC_IER = (mode);\
|
||||
}
|
||||
|
||||
#define ADC_DisableIt(pAdc, mode) {\
|
||||
(pAdc)->ADC_IDR = (mode);\
|
||||
}
|
||||
|
||||
#define ADC_EnbaleTS(pAdc,mode) {\
|
||||
(pAdc)->ADC_ACR |= mode;\
|
||||
}
|
||||
|
||||
#define ADC_EnableDataReadyIt(pAdc) ((pAdc)->ADC_IER = AT91C_ADC_DRDY)
|
||||
|
||||
#define ADC_GetStatus(pAdc) ((pAdc)->ADC_ISR)
|
||||
|
||||
#define ADC_GetCompareMode(pAdc) (((pAdc)->ADC_EMR)& (ADC_EMR_CMPMODE))
|
||||
|
||||
#define ADC_GetChannelStatus(pAdc) ((pAdc)->ADC_CHSR)
|
||||
|
||||
#define ADC_GetInterruptMaskStatus(pAdc) ((pAdc)->ADC_IMR)
|
||||
|
||||
#define ADC_GetLastConvertedData(pAdc) ((pAdc)->ADC_LCDR)
|
||||
|
||||
#define ADC_CfgAnalogCtrlReg(pAdc,mode) {\
|
||||
ASSERT(((mode) & 0xFFFCFF3C)==0, "ADC bad analog control config");\
|
||||
(pAdc)->ADC_ACR = (mode);\
|
||||
}
|
||||
|
||||
#define ADC_CfgExtModeReg(pAdc, extmode) {\
|
||||
ASSERT(((extmode) & 0xFF00FFFE)==0, "ADC bad extended mode config");\
|
||||
(pAdc)->ADC_EMR = (extmode);\
|
||||
}
|
||||
|
||||
#define ADC_GetAnalogCtrlReg(pAdc) ((pAdc)->ADC_ACR)
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
extern void ADC_Initialize (Adc *pAdc,
|
||||
uint8_t idAdc,
|
||||
uint8_t trgEn,
|
||||
uint8_t trgSel,
|
||||
uint8_t sleepMode,
|
||||
uint8_t resolution,
|
||||
uint32_t mckClock,
|
||||
uint32_t adcClock,
|
||||
uint32_t startupTime,
|
||||
uint32_t sampleAndHoldTime);
|
||||
extern uint32_t ADC_GetConvertedData(Adc *pAdc, uint32_t channel);
|
||||
extern void ADC_SetCompareChannel(Adc *pAdc, uint8_t channel);
|
||||
extern void ADC_SetCompareMode(Adc *pAdc, uint8_t mode);
|
||||
extern void ADC_SetComparisonWindow(Adc *pAdc, uint32_t hi_lo);
|
||||
extern uint32_t ADC_IsInterruptMasked(Adc *pAdc, uint32_t flag);
|
||||
extern uint32_t ADC_IsStatusSet(Adc *pAdc, uint32_t flag);
|
||||
extern uint8_t ADC_IsChannelInterruptStatusSet(uint32_t adc_sr,
|
||||
uint32_t channel);
|
||||
extern int8_t ADC_ReadBuffer(Adc *pADC,int16_t *pBuffer,int32_t size);
|
||||
|
||||
#endif //#ifndef ADC_H
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Provide a routine for asynchronos transfer.
|
||||
*
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <board.h>
|
||||
#include "async.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Returns 1 if the given transfer has ended; otherwise returns 0.
|
||||
* \param pAsync Pointer to an Async instance.
|
||||
*/
|
||||
uint8_t ASYNC_IsFinished(Async *pAsync)
|
||||
{
|
||||
return (pAsync->status != ASYNC_STATUS_PENDING);
|
||||
}
|
||||
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Provide a routine for asynchronos transfer.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ASYNC_H
|
||||
#define ASYNC_H
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definition
|
||||
*----------------------------------------------------------------------------*/
|
||||
/** Transfer is still pending.*/
|
||||
#define ASYNC_STATUS_PENDING 0xFF
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Type
|
||||
*----------------------------------------------------------------------------*/
|
||||
/** Asynchronous transfer descriptor. */
|
||||
typedef struct _Async {
|
||||
|
||||
/** Asynchronous transfer status.*/
|
||||
volatile uint8_t status;
|
||||
/** Callback function to invoke when transfer completes or fails.*/
|
||||
void *callback;
|
||||
/** Driver storage area; do not use.*/
|
||||
uint32_t pStorage[4];
|
||||
} Async;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern uint8_t ASYNC_IsFinished(Async *pAsync);
|
||||
|
||||
#endif //#ifndef ASYNC_H
|
||||
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \addtogroup crccu_module Working with CRCCU
|
||||
* The CRCCU driver provides the interface to configure and use the CRCCU
|
||||
* peripheral.
|
||||
*
|
||||
* It performs a CRC computation on a Memory Area. CRC computation is performed
|
||||
* from the LSB to MSB bit. Three different polynomials are available:
|
||||
* CCIT802.3, CASTAGNOLI and CCIT16.
|
||||
*
|
||||
* To computes CRC of a buffer, the user has to follow these few steps:
|
||||
* <ul>
|
||||
* <li>Reset initial CRC by setting RESET bit in CRCCU_CRC_CR,</li>
|
||||
* <li>Configure CRC descriptor and working mode,</li>
|
||||
* <li>Start to compute CRC by setting DMAEN in CRCCU_DMA_EN,</li>
|
||||
* <li>Get CRC value in CRCCU_CRC_SR.</li>
|
||||
* </ul>
|
||||
*
|
||||
* For more accurate information, please look at the CRCCU section of the
|
||||
* Datasheet.
|
||||
*
|
||||
* Related files :\n
|
||||
* \ref crccu.c\n
|
||||
* \ref crccu.h.\n
|
||||
*/
|
||||
/*@{*/
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Implementation of Cyclic Redundancy Check Calculation Unit (CRCCU).
|
||||
*
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "crccu.h"
|
||||
#include <utility/assert.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define CRCCU_TIMEOUT 0xFFFFFFFF
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Reset initial CRC to 0xFFFFFFFF.
|
||||
*/
|
||||
void CRCCU_ResetCrcValue(void)
|
||||
{
|
||||
Crccu *pCrccu = CRCCU;
|
||||
|
||||
pCrccu->CRCCU_CR = CRCCU_CR_RESET;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Configure the CRCCU.
|
||||
*
|
||||
* \param dscrAddr CRC decscriptor address.
|
||||
* \param mode CRC work mode
|
||||
*/
|
||||
void CRCCU_Configure(uint32_t dscrAddr, uint32_t mode)
|
||||
{
|
||||
Crccu *pCrccu = CRCCU;
|
||||
|
||||
pCrccu->CRCCU_DSCR = dscrAddr;
|
||||
pCrccu->CRCCU_MR = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Start to compute the CRC of a buffer.
|
||||
*
|
||||
* \return The CRC of the buffer.
|
||||
*/
|
||||
uint32_t CRCCU_ComputeCrc(void)
|
||||
{
|
||||
Crccu *pCrccu = CRCCU;
|
||||
uint32_t timeout = 0;
|
||||
|
||||
pCrccu->CRCCU_DMA_EN = CRCCU_DMA_EN_DMAEN;
|
||||
while (((pCrccu->CRCCU_DMA_SR & CRCCU_DMA_SR_DMASR) == CRCCU_DMA_SR_DMASR)
|
||||
&& (timeout++ < CRCCU_TIMEOUT));
|
||||
|
||||
return (pCrccu->CRCCU_SR);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Compare the CRC of a buffer is match to reference CRC.
|
||||
*
|
||||
* \return if 0 CRC is match, else dismatch.
|
||||
*/
|
||||
uint32_t CRCCU_CompareCrc(void)
|
||||
{
|
||||
Crccu *pCrccu = CRCCU;
|
||||
|
||||
if ((pCrccu->CRCCU_ISR & CRCCU_ISR_ERRISR) == CRCCU_ISR_ERRISR) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Interface for Cyclic Redundancy Check Calculation Unit (CRCCU).
|
||||
*/
|
||||
|
||||
#ifndef CRCCU_H
|
||||
#define CRCCU_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <board.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
typedef struct {
|
||||
unsigned int TR_ADDR;
|
||||
unsigned int TR_CTRL;
|
||||
unsigned int reserved[2];
|
||||
unsigned int TR_CRC;
|
||||
} CrcDscr;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
void CRCCU_ResetCrcValue(void);
|
||||
void CRCCU_Configure(uint32_t dscrAddr, uint32_t mode);
|
||||
uint32_t CRCCU_ComputeCrc(void);
|
||||
uint32_t CRCCU_CompareCrc(void);
|
||||
|
||||
#endif /* #ifndef CRCCU_H */
|
||||
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \addtogroup dacc_module Working with DACC
|
||||
* The DACC driver provides the interface to configure and use the DACC peripheral.\n
|
||||
*
|
||||
* The DACC(Digital-to-Analog Converter Controller) converts digital code to analog output.
|
||||
* The data to be converted are sent in a common register for all channels. It offers up to 2
|
||||
* analog outputs.The output voltage ranges from (1/6)ADVREF to (5/6)ADVREF.
|
||||
*
|
||||
* To Enable a DACC conversion,the user has to follow these few steps:
|
||||
* <ul>
|
||||
* <li> Select an appropriate reference voltage on ADVREF </li>
|
||||
* <li> Configure the DACC according to its requirements and special needs,which could be
|
||||
broken down into several parts:
|
||||
* -# Enable DACC in free running mode by clearing TRGEN in DACC_MR;
|
||||
* -# Configure Startup Time and Refresh Period through setting STARTUP and REFRESH fields
|
||||
* in DACC_MR; The refresh mechanism is used to protect the output analog value from
|
||||
* decreasing.
|
||||
* -# Enable channels and write digital code to DACC_CDR,in free running mode, the conversion
|
||||
* is started right after at least one channel is enabled and data is written .
|
||||
</li>
|
||||
* </ul>
|
||||
*
|
||||
* For more accurate information, please look at the DACC section of the
|
||||
* Datasheet.
|
||||
*
|
||||
* Related files :\n
|
||||
* \ref DACC.c\n
|
||||
* \ref DACC.h\n
|
||||
*/
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <board.h>
|
||||
#include <dacc/dacc.h>
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Initialize the DACC controller
|
||||
* \param pDACC Pointer to an DACC instance.
|
||||
* \param idDACC identifier of DAC peripheral
|
||||
* \param trgEn trigger mode, free running mode or external Hardware trigger
|
||||
* \param word transfer size,word or half word
|
||||
* \param trgSel hardware trigger selection
|
||||
* \param sleepMode sleep mode selection
|
||||
* \param mck value of MCK in Hz
|
||||
* \param refresh refresh period
|
||||
* \param user_sel user channel selection ,0 or 1
|
||||
* \param startup value of the start up time (in DACCClock) (see datasheet)
|
||||
*/
|
||||
void DACC_Initialize (Dacc *pDACC,
|
||||
uint8_t idDACC,
|
||||
uint8_t trgEn,
|
||||
uint8_t trgSel,
|
||||
uint8_t word,
|
||||
uint8_t sleepMode,
|
||||
uint32_t mck,
|
||||
uint8_t refresh,/*refresh period*/
|
||||
uint8_t user_sel,/*user channel selection*/
|
||||
uint32_t startup
|
||||
)
|
||||
{
|
||||
ASSERT(1024*refresh*1000/(mck/2)<20,"Refresh preriod is too big!");
|
||||
|
||||
|
||||
/* Enable peripheral clock*/
|
||||
PMC->PMC_PCER0 = 1 << idDACC;
|
||||
|
||||
/* Reset the controller */
|
||||
DACC_SoftReset(pDACC);
|
||||
|
||||
/* Write to the MR register */
|
||||
DACC_CfgModeReg( pDACC,
|
||||
( trgEn & DACC_MR_TRGEN)
|
||||
| ( trgSel & DACC_MR_TRGSEL)
|
||||
| ( word & DACC_MR_WORD)
|
||||
| ( sleepMode & DACC_MR_SLEEP)
|
||||
| ( (refresh<<8) & DACC_MR_REFRESH)
|
||||
| ( (user_sel<<16)& DACC_MR_USER_SEL)
|
||||
| ( (startup<<24) & DACC_MR_STARTUP));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the Conversion Data
|
||||
* \param pDACC Pointer to an Dacc instance.
|
||||
* \param channel channel to get converted value
|
||||
* \return Channel converted data of the specified channel
|
||||
*/
|
||||
void DACC_SetConversionData(Dacc *pDACC, uint32_t data)
|
||||
{
|
||||
uint32_t mr = pDACC->DACC_MR;
|
||||
|
||||
if(mr & DACC_MR_WORD)
|
||||
{
|
||||
pDACC->DACC_CDR = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
pDACC->DACC_CDR = (data&0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Write converted data through PDC channel
|
||||
* \param pDACC the pointer of DACC peripheral
|
||||
* \param pBuffer the destination buffer
|
||||
* \param size the size of the buffer
|
||||
*/
|
||||
int8_t DACC_WriteBuffer(Dacc *pDACC,int16_t *pBuffer,int32_t size)
|
||||
{
|
||||
|
||||
/* Check if the first PDC bank is free*/
|
||||
if ((pDACC->DACC_TCR == 0) && (pDACC->DACC_TNCR == 0)) {
|
||||
|
||||
pDACC->DACC_TPR = (uint32_t) pBuffer;
|
||||
pDACC->DACC_TCR = size;
|
||||
pDACC->DACC_PTCR = DACC_PTCR_RXTEN;
|
||||
|
||||
return 1;
|
||||
}
|
||||
/* Check if the second PDC bank is free*/
|
||||
else if (pDACC->DACC_TNCR == 0) {
|
||||
|
||||
pDACC->DACC_TNPR = (uint32_t) pBuffer;
|
||||
pDACC->DACC_TNCR = size;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \unit
|
||||
*
|
||||
* !Purpose
|
||||
*
|
||||
* Interface for configuration the Analog-to-Digital Converter (DACC) peripheral.
|
||||
*
|
||||
* !Usage
|
||||
*
|
||||
* -# Configurate the pins for DACC
|
||||
* -# Initialize the DACC with DACC_Initialize().
|
||||
* -# Select the active channel using DACC_EnableChannel()
|
||||
* -# Start the conversion with DACC_StartConversion()
|
||||
* -# Wait the end of the conversion by polling status with DACC_GetStatus()
|
||||
* -# Finally, get the converted data using DACC_GetConvertedData()
|
||||
*
|
||||
*/
|
||||
#ifndef DACC_H
|
||||
#define DACC_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <utility/assert.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
#define DACC_CHANNEL_0 0
|
||||
#define DACC_CHANNEL_1 1
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Macros function of register access
|
||||
*------------------------------------------------------------------------------*/
|
||||
#define DACC_CfgModeReg(pDACC, mode) { \
|
||||
(pDACC)->DACC_MR = (mode);\
|
||||
}
|
||||
|
||||
#define DACC_GetModeReg(pDACC) ((pDACC)->DACC_MR)
|
||||
|
||||
#define DACC_StartConversion(pDACC) ((pDACC)->DACC_CR = DACC_CR_START)
|
||||
|
||||
#define DACC_SoftReset(pDACC) ((pDACC)->DACC_CR = DACC_CR_SWRST)
|
||||
|
||||
#define DACC_EnableChannel(pDACC, channel) {\
|
||||
(pDACC)->DACC_CHER = (1 << (channel));\
|
||||
}
|
||||
|
||||
#define DACC_DisableChannel (pDACC, channel) {\
|
||||
(pDACC)->DACC_CHDR = (1 << (channel));\
|
||||
}
|
||||
|
||||
#define DACC_EnableIt(pDACC, mode) {\
|
||||
ASSERT(((mode)&0xFFF00000)== 0, "DACC bad interrupt IER");\
|
||||
(pDACC)->DACC_IER = (mode);\
|
||||
}
|
||||
|
||||
#define DACC_DisableIt(pDACC, mode) {\
|
||||
ASSERT(((mode)&0xFFF00000)== 0, "DACC bad interrupt IDR");\
|
||||
(pDACC)->DACC_IDR = (mode);\
|
||||
}
|
||||
|
||||
#define DACC_EnableDataReadyIt(pDACC) ((pDACC)->DACC_IER = AT91C_DACC_DRDY)
|
||||
|
||||
#define DACC_GetStatus(pDACC) ((pDACC)->DACC_ISR)
|
||||
|
||||
#define DACC_GetChannelStatus(pDACC) ((pDACC)->DACC_CHSR)
|
||||
|
||||
#define DACC_GetInterruptMaskStatus(pDACC) ((pDACC)->DACC_IMR)
|
||||
|
||||
#define DACC_GetLastConvertedData(pDACC) ((pDACC)->DACC_LCDR)
|
||||
|
||||
#define DACC_CfgAnalogCtrlReg(pDACC,mode) {\
|
||||
ASSERT(((mode) & 0xFFFCFF3C)==0, "DACC bad analog control config");\
|
||||
(pDACC)->DACC_ACR = (mode);\
|
||||
}
|
||||
|
||||
#define DACC_CfgExtModeReg(pDACC, extmode) {\
|
||||
ASSERT(((extmode) & 0xFF00FFFE)==0, "DACC bad extended mode config");\
|
||||
(pDACC)->DACC_EMR = (extmode);\
|
||||
}
|
||||
|
||||
#define DACC_GetAnalogCtrlReg(pDACC) ((pDACC)->DACC_ACR)
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
extern void DACC_Initialize (Dacc *pDACC,
|
||||
uint8_t idDACC,
|
||||
uint8_t trgEn,
|
||||
uint8_t trgSel,
|
||||
uint8_t word,
|
||||
uint8_t sleepMode,
|
||||
uint32_t mck,
|
||||
uint8_t refresh,/*refresh period*/
|
||||
uint8_t user_sel,/*user channel selection*/
|
||||
uint32_t startup
|
||||
);
|
||||
|
||||
|
||||
extern void DACC_SetConversionData(Dacc *pDACC, uint32_t data);
|
||||
|
||||
#endif //#ifndef DACC_H
|
||||
|
|
@ -1,286 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \addtogroup efc_module Working with Enhanced Embedded Flash
|
||||
* The EEFC driver provides the interface to configure and use the EEFC
|
||||
* peripheral.
|
||||
*
|
||||
* The user needs to set the number of wait states depending on the frequency used.\n
|
||||
* Configure number of cycles for flash read/write operations in the FWS field of EEFC_FMR.
|
||||
*
|
||||
* It offers a function to send flash command to EEFC and waits for the
|
||||
* flash to be ready.
|
||||
*
|
||||
* To send flash command, the user could do in either of following way:
|
||||
* <ul>
|
||||
* <li>Write a correct key, command and argument in EEFC_FCR. </li>
|
||||
* <li>Or, Use IAP (In Application Programming) function which is executed from
|
||||
* ROM directly, this allows flash programming to be done by code running in flash.</li>
|
||||
* <li>Once the command is achieved, it can be detected even by polling EEFC_FSR or interrupt.
|
||||
* </ul>
|
||||
*
|
||||
* The command argument could be a page number,GPNVM number or nothing, it depends on
|
||||
* the command itself. Some useful functions in this driver could help user tranlate physical
|
||||
* flash address into a page number and vice verse.
|
||||
*
|
||||
* For more accurate information, please look at the EEFC section of the
|
||||
* Datasheet.
|
||||
*
|
||||
* Related files :\n
|
||||
* \ref efc.c\n
|
||||
* \ref efc.h.\n
|
||||
*/
|
||||
/*@{*/
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Implementation of Emhance embedded Flash (EEFC) controller.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <board.h>
|
||||
#include "efc.h"
|
||||
#include <utility/assert.h>
|
||||
#include <utility/trace.h>
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Enables the flash ready interrupt source on the EEFC peripheral.
|
||||
*
|
||||
* \param efc Pointer to a Efc instance
|
||||
*/
|
||||
void EFC_EnableFrdyIt(Efc *efc)
|
||||
{
|
||||
efc->EEFC_FMR |= EEFC_FMR_FRDY;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Disables the flash ready interrupt source on the EEFC peripheral.
|
||||
*
|
||||
* \param efc Pointer to a Efc instance
|
||||
*/
|
||||
|
||||
void EFC_DisableFrdyIt(Efc *efc)
|
||||
{
|
||||
efc->EEFC_FMR &= ~EEFC_FMR_FRDY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set read/write wait state on the EEFC perpherial.
|
||||
*
|
||||
* \param efc Pointer to a Efc instance
|
||||
* \param cycles the number of wait states in cycle.
|
||||
*/
|
||||
|
||||
void EFC_SetWaitState(Efc *efc, uint8_t cycles)
|
||||
{
|
||||
uint32_t value;
|
||||
value = efc->EEFC_FMR;
|
||||
value &= ~EEFC_FMR_FWS;
|
||||
value |= cycles << 8;
|
||||
efc->EEFC_FMR = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the current status of the EEFC.
|
||||
*
|
||||
* \note Keep in mind that this function clears the value of some status bits (LOCKE, PROGE).
|
||||
*
|
||||
* \param efc Pointer to a Efc instance
|
||||
*/
|
||||
uint32_t EFC_GetStatus(Efc *efc)
|
||||
{
|
||||
return efc->EEFC_FSR;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the result of the last executed command.
|
||||
*
|
||||
* \param efc Pointer to a Efc instance
|
||||
*/
|
||||
uint32_t EFC_GetResult(Efc *efc) {
|
||||
|
||||
return efc->EEFC_FRR;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Translates the given address page and offset values.
|
||||
* \note The resulting values are stored in the provided variables if they are not null.
|
||||
*
|
||||
* \param efc Pointer to a Efc instance
|
||||
* \param address Address to translate.
|
||||
* \param pPage First page accessed.
|
||||
* \param pOffset Byte offset in first page.
|
||||
*/
|
||||
void EFC_TranslateAddress(
|
||||
Efc **efc,
|
||||
uint32_t address,
|
||||
unsigned short *pPage,
|
||||
unsigned short *pOffset)
|
||||
{
|
||||
Efc *pEfc;
|
||||
unsigned short page;
|
||||
unsigned short offset;
|
||||
|
||||
SANITY_CHECK(address >= AT91C_IFLASH);
|
||||
SANITY_CHECK(address <= (AT91C_IFLASH + AT91C_IFLASH_SIZE));
|
||||
|
||||
pEfc = EFC;
|
||||
page = (address - AT91C_IFLASH) / AT91C_IFLASH_PAGE_SIZE;
|
||||
offset = (address - AT91C_IFLASH) % AT91C_IFLASH_PAGE_SIZE;
|
||||
|
||||
TRACE_DEBUG("Translated 0x%08X to page=%d and offset=%d\n\r", address, page, offset);
|
||||
// Store values
|
||||
if (pEfc) {
|
||||
*efc = pEfc;
|
||||
}
|
||||
if (pPage) {
|
||||
*pPage = page;
|
||||
}
|
||||
if (pOffset) {
|
||||
*pOffset = offset;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Computes the address of a flash access given the page and offset.
|
||||
*
|
||||
* \param efc Pointer to a Efc instance
|
||||
* \param page Page number.
|
||||
* \param offset Byte offset inside page.
|
||||
* \param pAddress Computed address (optional).
|
||||
*/
|
||||
void EFC_ComputeAddress(
|
||||
Efc *efc,
|
||||
unsigned short page,
|
||||
unsigned short offset,
|
||||
uint32_t *pAddress)
|
||||
{
|
||||
uint32_t address;
|
||||
SANITY_CHECK(efc);
|
||||
SANITY_CHECK(page <= AT91C_IFLASH_NB_OF_PAGES);
|
||||
SANITY_CHECK(offset < AT91C_IFLASH_PAGE_SIZE);
|
||||
// Compute address
|
||||
address = AT91C_IFLASH + page * AT91C_IFLASH_PAGE_SIZE + offset;
|
||||
// Store result
|
||||
if (pAddress) {
|
||||
*pAddress = address;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Starts the executing the given command on the EEFC and returns as soon as the command is started.
|
||||
*
|
||||
* \note It does NOT set the FMCN field automatically.
|
||||
* \param efc Pointer to a Efc instance
|
||||
* \param command Command to execute.
|
||||
* \param argument Command argument (should be 0 if not used).
|
||||
*/
|
||||
void EFC_StartCommand(Efc *efc, uint8_t command, unsigned short argument)
|
||||
{
|
||||
// Check command & argument
|
||||
switch (command) {
|
||||
|
||||
case EFC_FCMD_WP:
|
||||
case EFC_FCMD_WPL:
|
||||
case EFC_FCMD_EWP:
|
||||
case EFC_FCMD_EWPL:
|
||||
case EFC_FCMD_SLB:
|
||||
case EFC_FCMD_CLB:
|
||||
ASSERT(argument < AT91C_IFLASH_NB_OF_PAGES,
|
||||
"-F- Embedded flash has only %d pages\n\r",
|
||||
AT91C_IFLASH_NB_OF_PAGES);
|
||||
break;
|
||||
|
||||
case EFC_FCMD_SFB:
|
||||
case EFC_FCMD_CFB:
|
||||
ASSERT(argument < 2, "-F- Embedded flash has only %d GPNVMs\n\r", 2);
|
||||
break;
|
||||
|
||||
case EFC_FCMD_GETD:
|
||||
case EFC_FCMD_EA:
|
||||
case EFC_FCMD_GLB:
|
||||
case EFC_FCMD_GFB:
|
||||
case EFC_FCMD_STUI:
|
||||
ASSERT(argument == 0, "-F- Argument is meaningless for the given command.\n\r");
|
||||
break;
|
||||
|
||||
default: ASSERT(0, "-F- Unknown command %d\n\r", command);
|
||||
}
|
||||
|
||||
// Start command Embedded flash
|
||||
ASSERT((efc->EEFC_FSR & EEFC_FMR_FRDY) == EEFC_FMR_FRDY, "-F- EEFC is not ready\n\r");
|
||||
efc->EEFC_FCR = (0x5A << 24) | (argument << 8) | command;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Performs the given command and wait until its completion (or an error).
|
||||
*
|
||||
* \param efc Pointer to a Efc instance
|
||||
* \param command Command to perform.
|
||||
* \param argument Optional command argument.
|
||||
* \return 0 if successful, otherwise returns an error code.
|
||||
*/
|
||||
|
||||
uint8_t EFC_PerformCommand(Efc *efc, uint8_t command, unsigned short argument)
|
||||
{
|
||||
|
||||
#if defined(flash) || defined(USE_IAP_FEATURE)
|
||||
// Pointer on IAP function in ROM
|
||||
static uint32_t (*IAP_PerformCommand)(uint32_t, uint32_t);
|
||||
IAP_PerformCommand = (uint32_t (*)(uint32_t, uint32_t)) *((uint32_t *) CHIP_FLASH_IAP_ADDRESS);
|
||||
IAP_PerformCommand(0, (0x5A << 24) | (argument << 8) | command);
|
||||
return (efc->EEFC_FSR & (EEFC_FSR_FLOCKE | EEFC_FSR_FCMDE));
|
||||
|
||||
#else
|
||||
uint32_t status;
|
||||
efc->EEFC_FCR = (0x5A << 24) | (argument << 8) | command;
|
||||
do {
|
||||
|
||||
status = efc->EEFC_FSR;
|
||||
}
|
||||
while ((status & EEFC_FSR_FRDY) != EEFC_FSR_FRDY);
|
||||
|
||||
return (status & (EEFC_FSR_FLOCKE | EEFC_FSR_FCMDE));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \par Purpose
|
||||
*
|
||||
* Interface for configuration the Enhanced Embedded Flash Controller (EEFC) peripheral.
|
||||
*
|
||||
* \par Usage
|
||||
*
|
||||
* -# Enable/disable %flash ready interrupt sources using EFC_EnableFrdyIt()
|
||||
* and EFC_DisableFrdyIt().
|
||||
* -# Translates the given address into which EEFC, page and offset values
|
||||
* for difference density %flash memory using EFC_TranslateAddress().
|
||||
* -# Computes the address of a %flash access given the EFC, page and offset
|
||||
* for difference density %flash memory using EFC_ComputeAddress().
|
||||
* -# Start the executing command with EFC_StartCommand()
|
||||
* -# Retrieve the current status of the EFC using EFC_GetStatus().
|
||||
* -# Retrieve the result of the last executed command with EFC_GetResult().
|
||||
*/
|
||||
|
||||
#ifndef EFC_H
|
||||
#define EFC_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
/* EFC command */
|
||||
#define EFC_FCMD_GETD 0x00
|
||||
#define EFC_FCMD_WP 0x01
|
||||
#define EFC_FCMD_WPL 0x02
|
||||
#define EFC_FCMD_EWP 0x03
|
||||
#define EFC_FCMD_EWPL 0x04
|
||||
#define EFC_FCMD_EA 0x05
|
||||
#define EFC_FCMD_SLB 0x08
|
||||
#define EFC_FCMD_CLB 0x09
|
||||
#define EFC_FCMD_GLB 0x0A
|
||||
#define EFC_FCMD_SFB 0x0B
|
||||
#define EFC_FCMD_CFB 0x0C
|
||||
#define EFC_FCMD_GFB 0x0D
|
||||
#define EFC_FCMD_STUI 0x0E
|
||||
#define EFC_FCMD_SPUI 0x0F
|
||||
|
||||
/* The IAP function entry addreass */
|
||||
#define CHIP_FLASH_IAP_ADDRESS (0x00800008)
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void EFC_EnableFrdyIt(Efc *efc);
|
||||
|
||||
extern void EFC_DisableFrdyIt(Efc *efc);
|
||||
|
||||
extern void EFC_SetWaitState(Efc *efc, uint8_t cycles);
|
||||
|
||||
extern void EFC_TranslateAddress(
|
||||
Efc **pEfc,
|
||||
uint32_t address,
|
||||
unsigned short *pPage,
|
||||
unsigned short *pOffset);
|
||||
|
||||
extern void EFC_ComputeAddress(
|
||||
Efc *efc,
|
||||
unsigned short page,
|
||||
unsigned short offset,
|
||||
uint32_t *pAddress);
|
||||
|
||||
extern void EFC_StartCommand(
|
||||
Efc *efc,
|
||||
uint8_t command,
|
||||
unsigned short argument);
|
||||
|
||||
extern uint8_t EFC_PerformCommand(
|
||||
Efc *efc,
|
||||
uint8_t command,
|
||||
unsigned short argument);
|
||||
|
||||
extern uint32_t EFC_GetStatus(Efc *efc);
|
||||
|
||||
extern uint32_t EFC_GetResult(Efc *efc);
|
||||
|
||||
#endif //#ifndef EFC_H
|
||||
|
||||
|
|
@ -1,494 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \addtogroup flashd_module Flash Memory Interface
|
||||
* The flash driver manages the programming, erasing, locking and unlocking sequences
|
||||
* with dedicated commands.
|
||||
*
|
||||
* To implement flash programing operation, the user has to follow these few steps :
|
||||
* <ul>
|
||||
* <li>Configue flash wait states to initializes the flash. </li>
|
||||
* <li>Checks whether a region to be programmed is locked. </li>
|
||||
* <li>Unlocks the user region to be programmed if the region have locked before.</li>
|
||||
* <li>Erases the user page before program (optional).</li>
|
||||
* <li>Writes the user page from the page buffer.</li>
|
||||
* <li>Locks the region of programmed area if any.</li>
|
||||
* </ul>
|
||||
*
|
||||
* Writing 8-bit and 16-bit data is not allowed and may lead to unpredictable data corruption.
|
||||
* A check of this validity and padding for 32-bit alignment should be done in write algorithm.
|
||||
|
||||
* Lock/unlock range associated with the user address range is automatically translated.
|
||||
*
|
||||
* This security bit can be enabled through the command "Set General Purpose NVM Bit 0".
|
||||
*
|
||||
* A 128-bit factory programmed unique ID could be read to serve several purposes.
|
||||
*
|
||||
* The driver accesses the flash memory by calling the lowlevel module provided in \ref efc_module.
|
||||
* For more accurate information, please look at the EEFC section of the Datasheet.
|
||||
*
|
||||
* Related files :\n
|
||||
* \ref flashd.c\n
|
||||
* \ref flashd.h.\n
|
||||
* \ref efc.c\n
|
||||
* \ref efc.h.\n
|
||||
*/
|
||||
/*@{*/
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* The flash driver provides the unified interface for flash program operations.
|
||||
*
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "flashd.h"
|
||||
#include <board.h>
|
||||
|
||||
#include <efc/efc.h>
|
||||
#include <utility/math.h>
|
||||
#include <utility/assert.h>
|
||||
#include <utility/trace.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Local functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Computes the lock range associated with the given address range.
|
||||
*
|
||||
* \param start Start address of lock range.
|
||||
* \param end End address of lock range.
|
||||
* \param pActualStart Actual start address of lock range.
|
||||
* \param pActualEnd Actual end address of lock range.
|
||||
*/
|
||||
static void ComputeLockRange(
|
||||
uint32_t start,
|
||||
uint32_t end,
|
||||
uint32_t *pActualStart,
|
||||
uint32_t *pActualEnd)
|
||||
{
|
||||
Efc *pStartEfc, *pEndEfc;
|
||||
uint16_t startPage, endPage;
|
||||
uint16_t numPagesInRegion;
|
||||
uint16_t actualStartPage, actualEndPage;
|
||||
|
||||
// Convert start and end address in page numbers
|
||||
EFC_TranslateAddress(&pStartEfc, start, &startPage, 0);
|
||||
EFC_TranslateAddress(&pEndEfc, end, &endPage, 0);
|
||||
|
||||
// Find out the first page of the first region to lock
|
||||
numPagesInRegion = AT91C_IFLASH_LOCK_REGION_SIZE / AT91C_IFLASH_PAGE_SIZE;
|
||||
actualStartPage = startPage - (startPage % numPagesInRegion);
|
||||
actualEndPage = endPage;
|
||||
if ((endPage % numPagesInRegion) != 0) {
|
||||
|
||||
actualEndPage += numPagesInRegion - (endPage % numPagesInRegion);
|
||||
}
|
||||
// Store actual page numbers
|
||||
EFC_ComputeAddress(pStartEfc, actualStartPage, 0, pActualStart);
|
||||
EFC_ComputeAddress(pEndEfc, actualEndPage, 0, pActualEnd);
|
||||
TRACE_DEBUG("Actual lock range is 0x%06X - 0x%06X\n\r", *pActualStart, *pActualEnd);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Initializes the flash driver.
|
||||
*
|
||||
* \param mck Master clock frequency in Hz.
|
||||
*/
|
||||
|
||||
void FLASHD_Initialize(uint32_t mck)
|
||||
{
|
||||
EFC_DisableFrdyIt(EFC);
|
||||
if ((mck/1000000) >= 64) {
|
||||
EFC_SetWaitState(EFC, 2);
|
||||
}
|
||||
else if ((mck/1000000) >= 50) {
|
||||
EFC_SetWaitState(EFC, 1);
|
||||
}
|
||||
else {
|
||||
EFC_SetWaitState(EFC, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Erases the entire flash.
|
||||
*
|
||||
* \param address Flash start address.
|
||||
* \return 0 if successful; otherwise returns an error code.
|
||||
*/
|
||||
uint8_t FLASHD_Erase(uint32_t address)
|
||||
{
|
||||
Efc *pEfc;
|
||||
uint16_t page;
|
||||
uint16_t offset;
|
||||
uint8_t error;
|
||||
SANITY_CHECK((address >=AT91C_IFLASH) || (address <= (AT91C_IFLASH + AT91C_IFLASH_SIZE)));
|
||||
// Translate write address
|
||||
EFC_TranslateAddress(&pEfc, address, &page, &offset);
|
||||
error = EFC_PerformCommand(pEfc, EFC_FCMD_EA, 0);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static uint8_t pPageBuffer[AT91C_IFLASH_PAGE_SIZE];
|
||||
/**
|
||||
* \brief Writes a data buffer in the internal flash
|
||||
*
|
||||
* \note This function works in polling mode, and thus only returns when the
|
||||
* data has been effectively written.
|
||||
* \param address Write address.
|
||||
* \param pBuffer Data buffer.
|
||||
* \param size Size of data buffer in bytes.
|
||||
* \return 0 if successful, otherwise returns an error code.
|
||||
*/
|
||||
uint8_t FLASHD_Write(
|
||||
uint32_t address,
|
||||
const void *pBuffer,
|
||||
uint32_t size)
|
||||
{
|
||||
Efc *pEfc;
|
||||
uint16_t page;
|
||||
uint16_t offset;
|
||||
uint32_t writeSize;
|
||||
uint32_t pageAddress;
|
||||
uint16_t padding;
|
||||
uint8_t error;
|
||||
|
||||
uint32_t sizeTmp;
|
||||
uint32_t *pAlignedDestination;
|
||||
uint32_t *pAlignedSource;
|
||||
|
||||
SANITY_CHECK(pBuffer);
|
||||
SANITY_CHECK(address >=AT91C_IFLASH);
|
||||
SANITY_CHECK((address + size) <= (AT91C_IFLASH + AT91C_IFLASH_SIZE));
|
||||
// Translate write address
|
||||
EFC_TranslateAddress(&pEfc, address, &page, &offset);
|
||||
|
||||
// Write all pages
|
||||
while (size > 0) {
|
||||
|
||||
// Copy data in temporary buffer to avoid alignment problems
|
||||
writeSize = min(AT91C_IFLASH_PAGE_SIZE - offset, size);
|
||||
EFC_ComputeAddress(pEfc, page, 0, &pageAddress);
|
||||
padding = AT91C_IFLASH_PAGE_SIZE - offset - writeSize;
|
||||
|
||||
// Pre-buffer data
|
||||
memcpy(pPageBuffer, (void *) pageAddress, offset);
|
||||
|
||||
// Buffer data
|
||||
memcpy(pPageBuffer + offset, pBuffer, writeSize);
|
||||
|
||||
// Post-buffer data
|
||||
memcpy(pPageBuffer + offset + writeSize, (void *) (pageAddress + offset + writeSize), padding);
|
||||
|
||||
// Write page
|
||||
// Writing 8-bit and 16-bit data is not allowed
|
||||
// and may lead to unpredictable data corruption
|
||||
pAlignedDestination = (uint32_t*)pageAddress;
|
||||
pAlignedSource = (uint32_t*)pPageBuffer;
|
||||
sizeTmp = AT91C_IFLASH_PAGE_SIZE;
|
||||
while (sizeTmp >= 4) {
|
||||
|
||||
*pAlignedDestination++ = *pAlignedSource++;
|
||||
sizeTmp -= 4;
|
||||
}
|
||||
|
||||
// Send writing command
|
||||
error = EFC_PerformCommand(pEfc, EFC_FCMD_EWP, page);
|
||||
if (error) {
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
// Progression
|
||||
address += AT91C_IFLASH_PAGE_SIZE;
|
||||
pBuffer = (void *) ((uint32_t) pBuffer + writeSize);
|
||||
size -= writeSize;
|
||||
page++;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* \brief Locks all the regions in the given address range. The actual lock range is
|
||||
* reported through two output parameters.
|
||||
* \param address Start address of lock range.
|
||||
* \param end End address of lock range.
|
||||
* \param pActualStart Start address of the actual lock range (optional).
|
||||
* \param pActualEnd End address of the actual lock range (optional).
|
||||
* \return 0 if successful, otherwise returns an error code.
|
||||
*/
|
||||
uint8_t FLASHD_Lock(
|
||||
uint32_t start,
|
||||
uint32_t end,
|
||||
uint32_t *pActualStart,
|
||||
uint32_t *pActualEnd)
|
||||
{
|
||||
Efc *pEfc;
|
||||
uint32_t actualStart, actualEnd;
|
||||
uint16_t startPage, endPage;
|
||||
uint8_t error;
|
||||
uint16_t numPagesInRegion = AT91C_IFLASH_LOCK_REGION_SIZE / AT91C_IFLASH_PAGE_SIZE;
|
||||
|
||||
// Compute actual lock range and store it
|
||||
ComputeLockRange(start, end, &actualStart, &actualEnd);
|
||||
if (pActualStart) {
|
||||
|
||||
*pActualStart = actualStart;
|
||||
}
|
||||
if (pActualEnd) {
|
||||
|
||||
*pActualEnd = actualEnd;
|
||||
}
|
||||
|
||||
// Compute page numbers
|
||||
EFC_TranslateAddress(&pEfc, actualStart, &startPage, 0);
|
||||
EFC_TranslateAddress(0, actualEnd, &endPage, 0);
|
||||
|
||||
// Lock all pages
|
||||
while (startPage < endPage) {
|
||||
|
||||
error = EFC_PerformCommand(pEfc, EFC_FCMD_SLB, startPage);
|
||||
if (error) {
|
||||
|
||||
return error;
|
||||
}
|
||||
startPage += numPagesInRegion;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Unlocks all the regions in the given address range. The actual unlock range is
|
||||
* reported through two output parameters.
|
||||
* \param address Start address of unlock range.
|
||||
* \param end End address of unlock range.
|
||||
* \param pActualStart Start address of the actual unlock range (optional).
|
||||
* \param pActualEnd End address of the actual unlock range (optional).
|
||||
* \return 0 if successful, otherwise returns an error code.
|
||||
*/
|
||||
uint8_t FLASHD_Unlock(
|
||||
uint32_t start,
|
||||
uint32_t end,
|
||||
uint32_t *pActualStart,
|
||||
uint32_t *pActualEnd)
|
||||
{
|
||||
Efc *pEfc;
|
||||
uint32_t actualStart, actualEnd;
|
||||
uint16_t startPage, endPage;
|
||||
uint8_t error;
|
||||
uint16_t numPagesInRegion = AT91C_IFLASH_LOCK_REGION_SIZE / AT91C_IFLASH_PAGE_SIZE;
|
||||
|
||||
// Compute actual unlock range and store it
|
||||
ComputeLockRange(start, end, &actualStart, &actualEnd);
|
||||
if (pActualStart) {
|
||||
|
||||
*pActualStart = actualStart;
|
||||
}
|
||||
if (pActualEnd) {
|
||||
|
||||
*pActualEnd = actualEnd;
|
||||
}
|
||||
|
||||
// Compute page numbers
|
||||
EFC_TranslateAddress(&pEfc, actualStart, &startPage, 0);
|
||||
EFC_TranslateAddress(0, actualEnd, &endPage, 0);
|
||||
|
||||
// Unlock all pages
|
||||
while (startPage < endPage) {
|
||||
|
||||
error = EFC_PerformCommand(pEfc, EFC_FCMD_CLB, startPage);
|
||||
if (error) {
|
||||
|
||||
return error;
|
||||
}
|
||||
startPage += numPagesInRegion;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the number of locked regions inside the given address range.
|
||||
*
|
||||
* \param address Start address of range
|
||||
* \param end End address of range.
|
||||
*/
|
||||
uint8_t FLASHD_IsLocked(uint32_t start, uint32_t end)
|
||||
{
|
||||
Efc *pEfc;
|
||||
uint16_t startPage, endPage;
|
||||
uint8_t startRegion, endRegion;
|
||||
uint32_t numPagesInRegion;
|
||||
uint32_t status;
|
||||
uint8_t error;
|
||||
uint32_t numLockedRegions = 0;
|
||||
|
||||
SANITY_CHECK(end >= start);
|
||||
SANITY_CHECK((start >=AT91C_IFLASH) && (end <= AT91C_IFLASH + AT91C_IFLASH_SIZE));
|
||||
|
||||
// Compute page numbers
|
||||
EFC_TranslateAddress(&pEfc, start, &startPage, 0);
|
||||
EFC_TranslateAddress(0, end, &endPage, 0);
|
||||
|
||||
// Compute region numbers
|
||||
numPagesInRegion = AT91C_IFLASH_LOCK_REGION_SIZE / AT91C_IFLASH_PAGE_SIZE;
|
||||
startRegion = startPage / numPagesInRegion;
|
||||
endRegion = endPage / numPagesInRegion;
|
||||
if ((endPage % numPagesInRegion) != 0) {
|
||||
|
||||
endRegion++;
|
||||
}
|
||||
|
||||
// Retrieve lock status
|
||||
error = EFC_PerformCommand(pEfc, EFC_FCMD_GLB, 0);
|
||||
ASSERT(!error, "-F- Error while trying to fetch lock bits status (0x%02X)\n\r", error);
|
||||
status = EFC_GetResult(pEfc);
|
||||
|
||||
// Check status of each involved region
|
||||
while (startRegion < endRegion) {
|
||||
|
||||
if ((status & (1 << startRegion)) != 0) {
|
||||
|
||||
numLockedRegions++;
|
||||
}
|
||||
startRegion++;
|
||||
}
|
||||
|
||||
return numLockedRegions;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check if the given GPNVM bit is set or not.
|
||||
*
|
||||
* \param gpnvm GPNVM bit index.
|
||||
* \returns 1 if the given GPNVM bit is currently set; otherwise returns 0.
|
||||
*/
|
||||
uint8_t FLASHD_IsGPNVMSet(uint8_t gpnvm)
|
||||
{
|
||||
uint8_t error;
|
||||
uint32_t status;
|
||||
|
||||
SANITY_CHECK(gpnvm < 2);
|
||||
|
||||
// Get GPNVMs status
|
||||
error = EFC_PerformCommand(EFC, EFC_FCMD_GFB, 0);
|
||||
ASSERT(!error, "-F- Error while trying to fetch GPNVMs status (0x%02X)\n\r", error);
|
||||
status = EFC_GetResult(EFC);
|
||||
|
||||
// Check if GPNVM is set
|
||||
if ((status & (1 << gpnvm)) != 0) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* \brief Sets the selected GPNVM bit.
|
||||
*
|
||||
* \param gpnvm GPNVM bit index.
|
||||
* \returns 0 if successful; otherwise returns an error code.
|
||||
*/
|
||||
uint8_t FLASHD_SetGPNVM(uint8_t gpnvm)
|
||||
{
|
||||
SANITY_CHECK(gpnvm < 2);
|
||||
|
||||
if (!FLASHD_IsGPNVMSet(gpnvm)) {
|
||||
|
||||
return EFC_PerformCommand(EFC, EFC_FCMD_SFB, gpnvm);
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Clears the selected GPNVM bit.
|
||||
*
|
||||
* \param gpnvm GPNVM bit index.
|
||||
* \returns 0 if successful; otherwise returns an error code.
|
||||
*/
|
||||
uint8_t FLASHD_ClearGPNVM(uint8_t gpnvm)
|
||||
{
|
||||
SANITY_CHECK(gpnvm < 2);
|
||||
|
||||
if (FLASHD_IsGPNVMSet(gpnvm)) {
|
||||
|
||||
return EFC_PerformCommand(EFC, EFC_FCMD_CFB, gpnvm);
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* \brief Read the unique ID.
|
||||
*
|
||||
* \param uniqueID pointer on a 4bytes char containing the unique ID value.
|
||||
* \returns 0 if successful; otherwise returns an error code.
|
||||
*/
|
||||
uint8_t FLASHD_ReadUniqueID (uint32_t * uniqueID)
|
||||
{
|
||||
uint8_t error;
|
||||
SANITY_CHECK(uniqueID != NULL);
|
||||
|
||||
uniqueID[0] = 0;
|
||||
uniqueID[1] = 0;
|
||||
uniqueID[2] = 0;
|
||||
uniqueID[3] = 0;
|
||||
|
||||
EFC_StartCommand(EFC, EFC_FCMD_STUI, 0);
|
||||
|
||||
uniqueID[0] = *(uint32_t *)AT91C_IFLASH;
|
||||
uniqueID[1] = *(uint32_t *)(AT91C_IFLASH + 4);
|
||||
uniqueID[2] = *(uint32_t *)(AT91C_IFLASH + 8);
|
||||
uniqueID[3] = *(uint32_t *)(AT91C_IFLASH + 12);
|
||||
|
||||
error = EFC_PerformCommand(EFC, EFC_FCMD_SPUI, 0);
|
||||
if (error) return error;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* The flash driver provides the unified interface for flash program operations.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FLASHD_H
|
||||
#define FLASHD_H
|
||||
|
||||
#include <board.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void FLASHD_Initialize(uint32_t mck);
|
||||
|
||||
extern uint8_t FLASHD_Erase(uint32_t address);
|
||||
|
||||
extern uint8_t FLASHD_Write(
|
||||
uint32_t address,
|
||||
const void *pBuffer,
|
||||
uint32_t size);
|
||||
|
||||
extern uint8_t FLASHD_Lock(
|
||||
uint32_t start,
|
||||
uint32_t end,
|
||||
uint32_t *pActualStart,
|
||||
uint32_t *pActualEnd);
|
||||
|
||||
extern uint8_t FLASHD_Unlock(
|
||||
uint32_t start,
|
||||
uint32_t end,
|
||||
uint32_t *pActualStart,
|
||||
uint32_t *pActualEnd);
|
||||
|
||||
extern uint8_t FLASHD_IsLocked(
|
||||
uint32_t start,
|
||||
uint32_t end);
|
||||
|
||||
extern uint8_t FLASHD_SetGPNVM(uint8_t gpnvm);
|
||||
|
||||
extern uint8_t FLASHD_ClearGPNVM(uint8_t gpnvm);
|
||||
|
||||
extern uint8_t FLASHD_IsGPNVMSet(uint8_t gpnvm);
|
||||
|
||||
#define FLASHD_IsSecurityBitSet() FLASHD_IsGPNVMSet(0)
|
||||
|
||||
#define FLASHD_SetSecurityBit() FLASHD_SetGPNVM(0)
|
||||
|
||||
extern uint8_t FLASHD_ReadUniqueID(uint32_t * uniqueID);
|
||||
|
||||
#endif //#ifndef FLASHD_H
|
||||
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef COLOR_H
|
||||
#define COLOR_H
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* RGB 24-bits color table definition.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* RGB 24 Bpp
|
||||
* RGB 888
|
||||
* R7R6R5R4 R3R2R1R0 G7G6G5G4 G3G2G1G0 B7B6B5B4 B3B2B1B0
|
||||
*/
|
||||
#define COLOR_BLACK 0x000000
|
||||
#define COLOR_WHITE 0xFFFFFF
|
||||
|
||||
#define COLOR_BLUE 0x0000FF
|
||||
#define COLOR_GREEN 0x00FF00
|
||||
#define COLOR_RED 0xFF0000
|
||||
|
||||
#define COLOR_NAVY 0x000080
|
||||
#define COLOR_DARKBLUE 0x00008B
|
||||
#define COLOR_DARKGREEN 0x006400
|
||||
#define COLOR_DARKCYAN 0x008B8B
|
||||
#define COLOR_CYAN 0x00FFFF
|
||||
#define COLOR_TURQUOISE 0x40E0D0
|
||||
#define COLOR_INDIGO 0x4B0082
|
||||
#define COLOR_DARKRED 0x800000
|
||||
#define COLOR_OLIVE 0x808000
|
||||
#define COLOR_GRAY 0x808080
|
||||
#define COLOR_SKYBLUE 0x87CEEB
|
||||
#define COLOR_BLUEVIOLET 0x8A2BE2
|
||||
#define COLOR_LIGHTGREEN 0x90EE90
|
||||
#define COLOR_DARKVIOLET 0x9400D3
|
||||
#define COLOR_YELLOWGREEN 0x9ACD32
|
||||
#define COLOR_BROWN 0xA52A2A
|
||||
#define COLOR_DARKGRAY 0xA9A9A9
|
||||
#define COLOR_SIENNA 0xA0522D
|
||||
#define COLOR_LIGHTBLUE 0xADD8E6
|
||||
#define COLOR_GREENYELLOW 0xADFF2F
|
||||
#define COLOR_SILVER 0xC0C0C0
|
||||
#define COLOR_LIGHTGREY 0xD3D3D3
|
||||
#define COLOR_LIGHTCYAN 0xE0FFFF
|
||||
#define COLOR_VIOLET 0xEE82EE
|
||||
#define COLOR_AZUR 0xF0FFFF
|
||||
#define COLOR_BEIGE 0xF5F5DC
|
||||
#define COLOR_MAGENTA 0xFF00FF
|
||||
#define COLOR_TOMATO 0xFF6347
|
||||
#define COLOR_GOLD 0xFFD700
|
||||
#define COLOR_ORANGE 0xFFA500
|
||||
#define COLOR_SNOW 0xFFFAFA
|
||||
#define COLOR_YELLOW 0xFFFF00
|
||||
|
||||
#endif /* #define COLOR_H */
|
||||
|
|
@ -1,333 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Implementation of draw function on LCD, Include draw text, image
|
||||
* and basic shapes (line, rectangle, circle).
|
||||
*
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "draw.h"
|
||||
#include "font.h"
|
||||
#include <board.h>
|
||||
#include <utility/assert.h>
|
||||
#include <ili9325/ili9325.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Fills the given LCD buffer with a particular color.
|
||||
*
|
||||
* \param color Fill color.
|
||||
*/
|
||||
void LCDD_Fill(uint32_t color)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
LCD_SetCursor(0, 0);
|
||||
LCD_WriteRAM_Prepare();
|
||||
for (i = 0; i < (BOARD_LCD_WIDTH * BOARD_LCD_HEIGHT); i++) {
|
||||
|
||||
LCD_WriteRAM(color);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Draw a pixel on LCD of given color.
|
||||
*
|
||||
* \param x X-coordinate of pixel.
|
||||
* \param y Y-coordinate of pixel.
|
||||
* \param color Pixel color.
|
||||
*/
|
||||
void LCDD_DrawPixel(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t color)
|
||||
{
|
||||
LCD_SetCursor(x, y);
|
||||
LCD_WriteRAM_Prepare();
|
||||
LCD_WriteRAM(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Read a pixel from LCD.
|
||||
*
|
||||
* \param x X-coordinate of pixel.
|
||||
* \param y Y-coordinate of pixel.
|
||||
*
|
||||
* \return color Readed pixel color.
|
||||
*/
|
||||
uint32_t LCDD_ReadPixel(
|
||||
uint32_t x,
|
||||
uint32_t y)
|
||||
{
|
||||
uint32_t color;
|
||||
|
||||
LCD_SetCursor(x, y);
|
||||
LCD_ReadRAM_Prepare();
|
||||
color = LCD_ReadRAM();
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Draw a line on LCD, horizontal and vertical line are supported.
|
||||
*
|
||||
* \param x X-coordinate of line start.
|
||||
* \param y Y-coordinate of line start.
|
||||
* \param length line length.
|
||||
* \param direction line direction: 0 - horizontal, 1 - vertical.
|
||||
* \param color Pixel color.
|
||||
*/
|
||||
void LCDD_DrawLine(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t length,
|
||||
uint32_t direction,
|
||||
uint32_t color)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
|
||||
LCD_SetCursor(x, y);
|
||||
|
||||
if(direction == DIRECTION_HLINE) {
|
||||
LCD_WriteRAM_Prepare();
|
||||
for(i = 0; i < length; i++) {
|
||||
LCD_WriteRAM(color);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i = 0; i < length; i++) {
|
||||
LCD_WriteRAM_Prepare();
|
||||
LCD_WriteRAM(color);
|
||||
y++;
|
||||
LCD_SetCursor(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Draws a rectangle on LCD, at the given coordinates.
|
||||
*
|
||||
* \param x X-coordinate of upper-left rectangle corner.
|
||||
* \param y Y-coordinate of upper-left rectangle corner.
|
||||
* \param width Rectangle width in pixels.
|
||||
* \param height Rectangle height in pixels.
|
||||
* \param color Rectangle color.
|
||||
*/
|
||||
void LCDD_DrawRectangle(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t color)
|
||||
{
|
||||
LCDD_DrawLine(x, y, width, DIRECTION_HLINE, color);
|
||||
LCDD_DrawLine(x, (y + height), width, DIRECTION_HLINE, color);
|
||||
|
||||
LCDD_DrawLine(x, y, height, DIRECTION_VLINE, color);
|
||||
LCDD_DrawLine((x + width), y, height, DIRECTION_VLINE, color);
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Draws a rectangle with fill inside on LCD, at the given coordinates.
|
||||
*
|
||||
* \param x X-coordinate of upper-left rectangle corner.
|
||||
* \param y Y-coordinate of upper-left rectangle corner.
|
||||
* \param width Rectangle width in pixels.
|
||||
* \param height Rectangle height in pixels.
|
||||
* \param color Rectangle color.
|
||||
*/
|
||||
void LCDD_DrawRectangleWithFill(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t color)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < height; i++) {
|
||||
LCDD_DrawLine(x, y+i, width, DIRECTION_HLINE, color);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Draws a circle on LCD, at the given coordinates.
|
||||
*
|
||||
* \param x X-coordinate of circle center.
|
||||
* \param y Y-coordinate of circle center.
|
||||
* \param r circle radius.
|
||||
* \param color circle color.
|
||||
*/
|
||||
void LCDD_DrawCircle(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t r,
|
||||
uint32_t color)
|
||||
{
|
||||
signed int d; /* Decision Variable */
|
||||
uint32_t curX; /* Current X Value */
|
||||
uint32_t curY; /* Current Y Value */
|
||||
|
||||
d = 3 - (r << 1);
|
||||
curX = 0;
|
||||
curY = r;
|
||||
|
||||
while (curX <= curY)
|
||||
{
|
||||
LCDD_DrawPixel(x + curX, y + curY, color);
|
||||
LCDD_DrawPixel(x + curX, y - curY, color);
|
||||
LCDD_DrawPixel(x - curX, y + curY, color);
|
||||
LCDD_DrawPixel(x - curX, y - curY, color);
|
||||
LCDD_DrawPixel(x + curY, y + curX, color);
|
||||
LCDD_DrawPixel(x + curY, y - curX, color);
|
||||
LCDD_DrawPixel(x - curY, y + curX, color);
|
||||
LCDD_DrawPixel(x - curY, y - curX, color);
|
||||
|
||||
if (d < 0) {
|
||||
d += (curX << 2) + 6;
|
||||
}
|
||||
else {
|
||||
d += ((curX - curY) << 2) + 10;
|
||||
curY--;
|
||||
}
|
||||
curX++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Draws a string inside a LCD buffer, at the given coordinates. Line breaks
|
||||
* will be honored.
|
||||
*
|
||||
* \param x X-coordinate of string top-left corner.
|
||||
* \param y Y-coordinate of string top-left corner.
|
||||
* \param pString String to display.
|
||||
* \param color String color.
|
||||
*/
|
||||
void LCDD_DrawString(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
const uint8_t *pString,
|
||||
uint32_t color)
|
||||
{
|
||||
unsigned xorg = x;
|
||||
|
||||
while (*pString != 0) {
|
||||
if (*pString == '\n') {
|
||||
|
||||
y += gFont.height + 2;
|
||||
x = xorg;
|
||||
}
|
||||
else {
|
||||
|
||||
LCDD_DrawChar(x, y, *pString, color);
|
||||
x += gFont.width + 2;
|
||||
}
|
||||
pString++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the width & height in pixels that a string will occupy on the screen
|
||||
* if drawn using LCDD_DrawString.
|
||||
*
|
||||
* \param pString String.
|
||||
* \param pWidth Pointer for storing the string width (optional).
|
||||
* \param pHeight Pointer for storing the string height (optional).
|
||||
*
|
||||
* \return String width in pixels.
|
||||
*/
|
||||
void LCDD_GetStringSize(
|
||||
const uint8_t *pString,
|
||||
uint32_t *pWidth,
|
||||
uint32_t *pHeight)
|
||||
{
|
||||
uint32_t width = 0;
|
||||
uint32_t height = gFont.height;
|
||||
|
||||
while (*pString != 0) {
|
||||
|
||||
if (*pString == '\n') {
|
||||
|
||||
height += gFont.height + 2;
|
||||
}
|
||||
else {
|
||||
|
||||
width += gFont.width + 2;
|
||||
}
|
||||
pString++;
|
||||
}
|
||||
|
||||
if (width > 0) width -= 2;
|
||||
|
||||
if (pWidth) *pWidth = width;
|
||||
if (pHeight) *pHeight = height;
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Draw a raw image at given position on LCD.
|
||||
*
|
||||
* \param x X-coordinate of image start.
|
||||
* \param y Y-coordinate of image start.
|
||||
* \param pImage Image buffer.
|
||||
* \param width Image width.
|
||||
* \param height Image height.
|
||||
*/
|
||||
void LCDD_DrawImage(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
const uint8_t *pImage,
|
||||
uint32_t width,
|
||||
uint32_t height)
|
||||
{
|
||||
uint32_t row, col;
|
||||
|
||||
for(row = y; row < (y + height); row++) {
|
||||
LCD_SetCursor(x, row);
|
||||
LCD_WriteRAM_Prepare();
|
||||
for(col = x; col < (x + width); col++) {
|
||||
LCD_D() = *pImage++;
|
||||
LCD_D() = *pImage++;
|
||||
LCD_D() = *pImage++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Interface for draw function on LCD.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DRAW_H
|
||||
#define DRAW_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** Horizontal direction line definition */
|
||||
#define DIRECTION_HLINE 0
|
||||
/** Vertical direction line definition */
|
||||
#define DIRECTION_VLINE 1
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern void LCDD_Fill(uint32_t color);
|
||||
|
||||
extern void LCDD_DrawPixel(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t c);
|
||||
|
||||
extern uint32_t LCDD_ReadPixel(
|
||||
uint32_t x,
|
||||
uint32_t y);
|
||||
|
||||
extern void LCDD_DrawLine(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t length,
|
||||
uint32_t direction,
|
||||
uint32_t color);
|
||||
|
||||
extern void LCDD_DrawRectangle(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t color);
|
||||
|
||||
extern void LCDD_DrawRectangleWithFill(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t color);
|
||||
|
||||
extern void LCDD_DrawCircle(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t r,
|
||||
uint32_t color);
|
||||
|
||||
extern void LCDD_DrawString(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
const uint8_t *pString,
|
||||
uint32_t color);
|
||||
|
||||
extern void LCDD_GetStringSize(
|
||||
const uint8_t *pString,
|
||||
uint32_t *pWidth,
|
||||
uint32_t *pHeight);
|
||||
|
||||
extern void LCDD_DrawImage(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
const uint8_t *pImage,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
|
||||
#endif /* #ifndef DRAW_H */
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Implementation of draw font on LCD.
|
||||
*
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "color.h"
|
||||
#include "font.h"
|
||||
#include "draw.h"
|
||||
#include "font10x14.h"
|
||||
#include <utility/assert.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Local variables
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** Global variable describing the font being instancied. */
|
||||
const Font gFont = {10, 14};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Draws an ASCII character on LCD.
|
||||
*
|
||||
* \param x X-coordinate of character upper-left corner.
|
||||
* \param y Y-coordinate of character upper-left corner.
|
||||
* \param c Character to output.
|
||||
* \param color Character color.
|
||||
*/
|
||||
void LCDD_DrawChar(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint8_t c,
|
||||
uint32_t color)
|
||||
{
|
||||
uint32_t row, col;
|
||||
|
||||
SANITY_CHECK((c >= 0x20) && (c <= 0x7F));
|
||||
|
||||
for (col = 0; col < 10; col++) {
|
||||
|
||||
for (row = 0; row < 8; row++) {
|
||||
|
||||
if ((pCharset10x14[((c - 0x20) * 20) + col * 2] >> (7 - row)) & 0x1) {
|
||||
|
||||
LCDD_DrawPixel(x+col, y+row, color);
|
||||
}
|
||||
}
|
||||
for (row = 0; row < 6; row++) {
|
||||
|
||||
if ((pCharset10x14[((c - 0x20) * 20) + col * 2 + 1] >> (7 - row)) & 0x1) {
|
||||
|
||||
LCDD_DrawPixel(x+col, y+row+8, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Interface for draw font on LCD.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* The font.h files declares a font structure and a LCDD_DrawChar function
|
||||
* that must be implemented by a font definition file to be used with the
|
||||
* LCDD_DrawString method of draw.h.
|
||||
*
|
||||
* The font10x14.c implements the necessary variable and function for a 10x14
|
||||
* font.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Declare a gFont global variable with the necessary Font information.
|
||||
* -# Implement an LCDD_DrawChar function which displays the specified
|
||||
* character on the LCD.
|
||||
* -# Use the LCDD_DrawString method defined in draw.h to display a complete
|
||||
* string.
|
||||
*/
|
||||
|
||||
#ifndef FONT_H
|
||||
#define FONT_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/** Describes the font (width, height, supported characters, etc.) used by
|
||||
* the LCD driver draw API.
|
||||
*/
|
||||
typedef struct _Font {
|
||||
/* Font width in pixels. */
|
||||
uint8_t width;
|
||||
/* Font height in pixels. */
|
||||
uint8_t height;
|
||||
} Font;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Variables
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** Global variable describing the font being instancied. */
|
||||
extern const Font gFont;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void LCDD_DrawChar(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint8_t c,
|
||||
uint32_t color);
|
||||
|
||||
#endif /* #ifndef FONT_H */
|
||||
|
|
@ -1,236 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Font 10x14 table definition.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LCD_FONT_10x14_H
|
||||
#define LCD_FONT_10x14_H
|
||||
|
||||
/** Char set of font 10x14 */
|
||||
const uint8_t pCharset10x14[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xCC,
|
||||
0xFF, 0xCC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0C, 0xC0, 0x0C, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x0C, 0xC0,
|
||||
0x0C, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x0C, 0xC0, 0x0C, 0xC0,
|
||||
0x0C, 0x60, 0x1E, 0x70, 0x3F, 0x30, 0x33, 0x30, 0xFF, 0xFC,
|
||||
0xFF, 0xFC, 0x33, 0x30, 0x33, 0xF0, 0x39, 0xE0, 0x18, 0xC0,
|
||||
0x60, 0x00, 0xF0, 0x0C, 0xF0, 0x3C, 0x60, 0xF0, 0x03, 0xC0,
|
||||
0x0F, 0x00, 0x3C, 0x18, 0xF0, 0x3C, 0xC0, 0x3C, 0x00, 0x18,
|
||||
0x3C, 0xF0, 0x7F, 0xF8, 0xC3, 0x1C, 0xC7, 0x8C, 0xCF, 0xCC,
|
||||
0xDC, 0xEC, 0x78, 0x78, 0x30, 0x30, 0x00, 0xFC, 0x00, 0xCC,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0xEC, 0x00,
|
||||
0xF8, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0F, 0xC0, 0x3F, 0xF0, 0x78, 0x78,
|
||||
0x60, 0x18, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0x60, 0x18,
|
||||
0x78, 0x78, 0x3F, 0xF0, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0C, 0x60, 0x0E, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x3F, 0xF8,
|
||||
0x3F, 0xF8, 0x03, 0x80, 0x07, 0xC0, 0x0E, 0xE0, 0x0C, 0x60,
|
||||
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x3F, 0xF0,
|
||||
0x3F, 0xF0, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
|
||||
0x00, 0x44, 0x00, 0xEC, 0x00, 0xF8, 0x00, 0x70, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
|
||||
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
|
||||
0x00, 0x18, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x18, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF0, 0x03, 0xC0,
|
||||
0x0F, 0x00, 0x3C, 0x00, 0xF0, 0x00, 0xC0, 0x00, 0x00, 0x00,
|
||||
0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0xFC, 0xC1, 0xCC, 0xC3, 0x8C,
|
||||
0xC7, 0x0C, 0xCE, 0x0C, 0xFC, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0,
|
||||
0x00, 0x00, 0x00, 0x00, 0x30, 0x0C, 0x70, 0x0C, 0xFF, 0xFC,
|
||||
0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
|
||||
0x30, 0x0C, 0x70, 0x1C, 0xE0, 0x3C, 0xC0, 0x7C, 0xC0, 0xEC,
|
||||
0xC1, 0xCC, 0xC3, 0x8C, 0xE7, 0x0C, 0x7E, 0x0C, 0x3C, 0x0C,
|
||||
0x30, 0x30, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C,
|
||||
0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x1C, 0x7F, 0xF8, 0x3C, 0xF0,
|
||||
0x03, 0xC0, 0x07, 0xC0, 0x0E, 0xC0, 0x1C, 0xC0, 0x38, 0xC0,
|
||||
0x70, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0xC0, 0x00, 0xC0,
|
||||
0xFC, 0x30, 0xFC, 0x38, 0xCC, 0x1C, 0xCC, 0x0C, 0xCC, 0x0C,
|
||||
0xCC, 0x0C, 0xCC, 0x0C, 0xCE, 0x1C, 0xC7, 0xF8, 0xC3, 0xF0,
|
||||
0x3F, 0xF0, 0x7F, 0xF8, 0xE3, 0x1C, 0xC3, 0x0C, 0xC3, 0x0C,
|
||||
0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x9C, 0x71, 0xF8, 0x30, 0xF0,
|
||||
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC3, 0xFC,
|
||||
0xC7, 0xFC, 0xCE, 0x00, 0xDC, 0x00, 0xF8, 0x00, 0xF0, 0x00,
|
||||
0x3C, 0xF0, 0x7F, 0xF8, 0xE7, 0x9C, 0xC3, 0x0C, 0xC3, 0x0C,
|
||||
0xC3, 0x0C, 0xC3, 0x0C, 0xE7, 0x9C, 0x7F, 0xF8, 0x3C, 0xF0,
|
||||
0x3C, 0x00, 0x7E, 0x00, 0xE7, 0x0C, 0xC3, 0x0C, 0xC3, 0x1C,
|
||||
0xC3, 0x38, 0xC3, 0x70, 0xE7, 0xE0, 0x7F, 0xC0, 0x3F, 0x80,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x60, 0x3C, 0xF0,
|
||||
0x3C, 0xF0, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x44, 0x3C, 0xEC,
|
||||
0x3C, 0xF8, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1C, 0xE0,
|
||||
0x38, 0x70, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C, 0x00, 0x00,
|
||||
0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0,
|
||||
0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0,
|
||||
0x00, 0x00, 0xC0, 0x0C, 0xE0, 0x1C, 0x70, 0x38, 0x38, 0x70,
|
||||
0x1C, 0xE0, 0x0F, 0xC0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00,
|
||||
0x30, 0x00, 0x70, 0x00, 0xE0, 0x00, 0xC0, 0x00, 0xC1, 0xEC,
|
||||
0xC3, 0xEC, 0xC3, 0x00, 0xE6, 0x00, 0x7E, 0x00, 0x3C, 0x00,
|
||||
0x30, 0xF0, 0x71, 0xF8, 0xE3, 0x9C, 0xC3, 0x0C, 0xC3, 0xFC,
|
||||
0xC3, 0xFC, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0,
|
||||
0x3F, 0xFC, 0x7F, 0xFC, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
|
||||
0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xC0, 0x7F, 0xFC, 0x3F, 0xFC,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C,
|
||||
0xC3, 0x0C, 0xC3, 0x0C, 0xE7, 0x9C, 0x7F, 0xF8, 0x3C, 0xF0,
|
||||
0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C,
|
||||
0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x70, 0x38, 0x30, 0x30,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C,
|
||||
0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C,
|
||||
0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00,
|
||||
0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0xC0, 0x00, 0xC0, 0x00,
|
||||
0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C,
|
||||
0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x1C, 0x73, 0xF8, 0x33, 0xF0,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
|
||||
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0xFF, 0xFC, 0xFF, 0xFC,
|
||||
0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xFF, 0xFC,
|
||||
0xFF, 0xFC, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x30, 0x00, 0x38, 0xC0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C,
|
||||
0xC0, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0, 0xC0, 0x00, 0xC0, 0x00,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0x07, 0x80, 0x07, 0x80, 0x0F, 0xC0,
|
||||
0x1C, 0xE0, 0x38, 0x70, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C,
|
||||
0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0x70, 0x00, 0x38, 0x00, 0x1F, 0x00,
|
||||
0x1F, 0x00, 0x38, 0x00, 0x70, 0x00, 0xFF, 0xFC, 0xFF, 0xFC,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x00,
|
||||
0x03, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0xFF, 0xFC, 0xFF, 0xFC,
|
||||
0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C,
|
||||
0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00,
|
||||
0xC3, 0x00, 0xC3, 0x00, 0xE7, 0x00, 0x7E, 0x00, 0x3C, 0x00,
|
||||
0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0xCC,
|
||||
0xC0, 0xEC, 0xC0, 0x7C, 0xE0, 0x38, 0x7F, 0xFC, 0x3F, 0xEC,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x80, 0xC3, 0x80,
|
||||
0xC3, 0xC0, 0xC3, 0xC0, 0xE7, 0x70, 0x7E, 0x3C, 0x3C, 0x1C,
|
||||
0x3C, 0x18, 0x7E, 0x1C, 0xE7, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C,
|
||||
0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x9C, 0xE1, 0xF8, 0x60, 0xF0,
|
||||
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xFC,
|
||||
0xFF, 0xFC, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
|
||||
0xFF, 0xF0, 0xFF, 0xF8, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x0C,
|
||||
0x00, 0x0C, 0x00, 0x0C, 0x00, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0,
|
||||
0xFF, 0xC0, 0xFF, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C,
|
||||
0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0xFF, 0xE0, 0xFF, 0xC0,
|
||||
0xFF, 0xF0, 0xFF, 0xF8, 0x00, 0x1C, 0x00, 0x3C, 0x00, 0xF8,
|
||||
0x00, 0xF8, 0x00, 0x3C, 0x00, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0,
|
||||
0xF0, 0x3C, 0xF8, 0x7C, 0x1C, 0xE0, 0x0F, 0xC0, 0x07, 0x80,
|
||||
0x07, 0x80, 0x0F, 0xC0, 0x1C, 0xE0, 0xF8, 0x7C, 0xF0, 0x3C,
|
||||
0xFC, 0x00, 0xFE, 0x00, 0x07, 0x00, 0x03, 0x80, 0x01, 0xFC,
|
||||
0x01, 0xFC, 0x03, 0x80, 0x07, 0x00, 0xFE, 0x00, 0xFC, 0x00,
|
||||
0xC0, 0x3C, 0xC0, 0x7C, 0xC0, 0xEC, 0xC1, 0xCC, 0xC3, 0x8C,
|
||||
0xC7, 0x0C, 0xCE, 0x0C, 0xDC, 0x0C, 0xF8, 0x0C, 0xF0, 0x0C,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, 0xC0, 0x0C,
|
||||
0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x30, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x03, 0x00,
|
||||
0x03, 0x00, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0x30, 0x00, 0x30,
|
||||
0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0C, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x00,
|
||||
0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0C, 0x00,
|
||||
0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C,
|
||||
0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C,
|
||||
0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0xE0, 0x00, 0x70, 0x00,
|
||||
0x38, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x30, 0x06, 0x78, 0x0E, 0xFC, 0x0C, 0xCC, 0x0C, 0xCC,
|
||||
0x0C, 0xCC, 0x0C, 0xCC, 0x0E, 0xCC, 0x07, 0xFC, 0x03, 0xF8,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x0C, 0x03, 0x0C, 0x03, 0x0C,
|
||||
0x03, 0x0C, 0x03, 0x0C, 0x03, 0x9C, 0x01, 0xF8, 0x00, 0xF0,
|
||||
0x03, 0xF0, 0x07, 0xF8, 0x0E, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C,
|
||||
0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0x30,
|
||||
0x00, 0xF0, 0x01, 0xF8, 0x03, 0x9C, 0x03, 0x0C, 0x03, 0x0C,
|
||||
0x03, 0x0C, 0x03, 0x0C, 0x03, 0x0C, 0xFF, 0xFC, 0xFF, 0xFC,
|
||||
0x03, 0xF0, 0x07, 0xF8, 0x0E, 0xDC, 0x0C, 0xCC, 0x0C, 0xCC,
|
||||
0x0C, 0xCC, 0x0C, 0xCC, 0x0E, 0xDC, 0x07, 0xD8, 0x03, 0x90,
|
||||
0x00, 0x00, 0x03, 0x00, 0x3F, 0xFC, 0x7F, 0xFC, 0xE3, 0x00,
|
||||
0xE3, 0x00, 0x70, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x03, 0x18, 0x07, 0x9C, 0x0F, 0xCC, 0x0C, 0xCC, 0x0C, 0xCC,
|
||||
0x0C, 0xCC, 0x0C, 0xCC, 0x0C, 0xDC, 0x0F, 0xF8, 0x07, 0xF0,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
|
||||
0x03, 0x00, 0x03, 0x80, 0x01, 0xFC, 0x00, 0xFC, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0xFC,
|
||||
0x1B, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0C,
|
||||
0x00, 0x0C, 0x00, 0x1C, 0xCF, 0xF8, 0xCF, 0xF0, 0x00, 0x00,
|
||||
0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0xE0, 0x01, 0xE0,
|
||||
0x03, 0xF0, 0x07, 0x38, 0x0E, 0x1C, 0x0C, 0x0C, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xFF, 0xFC,
|
||||
0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0F, 0xFC, 0x0F, 0xFC, 0x0E, 0x00, 0x07, 0x00, 0x03, 0xC0,
|
||||
0x03, 0xC0, 0x07, 0x00, 0x0E, 0x00, 0x0F, 0xFC, 0x0F, 0xFC,
|
||||
0x0F, 0xFC, 0x0F, 0xFC, 0x03, 0x00, 0x07, 0x00, 0x0E, 0x00,
|
||||
0x0C, 0x00, 0x0C, 0x00, 0x0E, 0x00, 0x07, 0xFC, 0x03, 0xFC,
|
||||
0x03, 0xF0, 0x07, 0xF8, 0x0E, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C,
|
||||
0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0xF8, 0x03, 0xF0,
|
||||
0x0F, 0xFC, 0x0F, 0xFC, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0,
|
||||
0x0C, 0xC0, 0x0C, 0xC0, 0x0F, 0xC0, 0x07, 0x80, 0x03, 0x00,
|
||||
0x03, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0,
|
||||
0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0F, 0xFC, 0x0F, 0xFC,
|
||||
0x0F, 0xFC, 0x0F, 0xFC, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00,
|
||||
0x0C, 0x00, 0x0C, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x03, 0x00,
|
||||
0x03, 0x18, 0x07, 0x9C, 0x0F, 0xCC, 0x0C, 0xCC, 0x0C, 0xCC,
|
||||
0x0C, 0xCC, 0x0C, 0xCC, 0x0C, 0xFC, 0x0E, 0x78, 0x06, 0x30,
|
||||
0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0xFF, 0xF0, 0xFF, 0xF8,
|
||||
0x0C, 0x1C, 0x0C, 0x1C, 0x0C, 0x38, 0x0C, 0x30, 0x00, 0x00,
|
||||
0x0F, 0xF0, 0x0F, 0xF8, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x0C,
|
||||
0x00, 0x0C, 0x00, 0x0C, 0x00, 0x1C, 0x0F, 0xF8, 0x0F, 0xF0,
|
||||
0x0F, 0xC0, 0x0F, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C,
|
||||
0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x0F, 0xE0, 0x0F, 0xC0,
|
||||
0x0F, 0xF0, 0x0F, 0xF8, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0xF8,
|
||||
0x00, 0xF8, 0x00, 0x1C, 0x00, 0x1C, 0x0F, 0xF8, 0x0F, 0xF0,
|
||||
0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0xF0, 0x01, 0xE0,
|
||||
0x01, 0xE0, 0x03, 0xF0, 0x07, 0x38, 0x0E, 0x1C, 0x0C, 0x0C,
|
||||
0x0C, 0x00, 0x0E, 0x00, 0x07, 0x0C, 0x03, 0x9C, 0x01, 0xF8,
|
||||
0x01, 0xF0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x0C, 0x00,
|
||||
0x0C, 0x0C, 0x0C, 0x1C, 0x0C, 0x3C, 0x0C, 0x7C, 0x0C, 0xEC,
|
||||
0x0D, 0xCC, 0x0F, 0x8C, 0x0F, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C,
|
||||
0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x3F, 0xF0, 0x7C, 0xF8,
|
||||
0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00,
|
||||
0x03, 0x0C, 0x03, 0x0C, 0x3F, 0xFC, 0x7F, 0xFC, 0xE3, 0x0C,
|
||||
0xC3, 0x0C, 0xC0, 0x0C, 0xE0, 0x0C, 0x70, 0x0C, 0x30, 0x0C,
|
||||
0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C,
|
||||
0x7C, 0xF8, 0x3F, 0xF0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00,
|
||||
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
|
||||
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC,
|
||||
0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC
|
||||
};
|
||||
|
||||
#endif /* #ifdef _LCD_FONT_10x14_h */
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Implementation of LCD driver, Include LCD initialization,
|
||||
* LCD on/off and LCD backlight control.
|
||||
*
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lcdd.h"
|
||||
#include <board.h>
|
||||
#include <pmc/pmc.h>
|
||||
#include <ili9325/ili9325.h>
|
||||
#include <pio/pio.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Initializes the LCD controller.
|
||||
* Configure SMC to access LCD controller at 64MHz MCK.
|
||||
*/
|
||||
void LCDD_Initialize(void)
|
||||
{
|
||||
const Pin pPins[] = {BOARD_LCD_PINS};
|
||||
Smc *pSmc = SMC;
|
||||
|
||||
/* Enable pins */
|
||||
PIO_Configure(pPins, PIO_LISTSIZE(pPins));
|
||||
|
||||
/* Enable peripheral clock */
|
||||
PMC_EnablePeripheral(ID_SMC);
|
||||
|
||||
/* EBI SMC Configuration */
|
||||
pSmc->SMC_CS_NUMBER[1].SMC_SETUP = 0
|
||||
| ((2 << 0) & SMC_SETUP1_NWE_SETUP)
|
||||
| ((2 << 8) & SMC_SETUP1_NCS_WR_SETUP)
|
||||
| ((2 << 16) & SMC_SETUP1_NRD_SETUP)
|
||||
| ((2 << 24) & SMC_SETUP1_NCS_RD_SETUP)
|
||||
;
|
||||
|
||||
pSmc->SMC_CS_NUMBER[1].SMC_PULSE = 0
|
||||
| ((4 << 0) & SMC_PULSE1_NWE_PULSE)
|
||||
| ((4 << 8) & SMC_PULSE1_NCS_WR_PULSE)
|
||||
| ((10 << 16) & SMC_PULSE1_NRD_PULSE)
|
||||
| ((10 << 24) & SMC_PULSE1_NCS_RD_PULSE)
|
||||
;
|
||||
|
||||
pSmc->SMC_CS_NUMBER[1].SMC_CYCLE = 0
|
||||
| ((10 << 0) & SMC_CYCLE1_NWE_CYCLE)
|
||||
| ((22 << 16) & SMC_CYCLE1_NRD_CYCLE)
|
||||
;
|
||||
|
||||
pSmc->SMC_CS_NUMBER[1].SMC_MODE = 0
|
||||
| (SMC_MODE1_READ_MODE)
|
||||
| (SMC_MODE1_WRITE_MODE)
|
||||
| (0) /* Set 8 bit width. TODO: replace with definition in device header file */
|
||||
;
|
||||
|
||||
/* Initialize LCD controller */
|
||||
LCD_Initialize();
|
||||
|
||||
/* Set LCD backlight */
|
||||
LCDD_SetBacklight(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Turn on the LCD.
|
||||
*/
|
||||
void LCDD_On(void)
|
||||
{
|
||||
LCD_On();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Turn off the LCD.
|
||||
*/
|
||||
void LCDD_Off(void)
|
||||
{
|
||||
LCD_Off();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set the backlight of the LCD.
|
||||
*
|
||||
* \param level Backlight brightness level [1..16], 1 means maximum brightness.
|
||||
*/
|
||||
void LCDD_SetBacklight (uint32_t level)
|
||||
{
|
||||
uint32_t i;
|
||||
const Pin pPins[] = {BOARD_BACKLIGHT_PIN};
|
||||
|
||||
/* Ensure valid level */
|
||||
level = (level < 1) ? 1 : level;
|
||||
level = (level > 16) ? 16 : level;
|
||||
|
||||
/* Enable pins */
|
||||
PIO_Configure(pPins, PIO_LISTSIZE(pPins));
|
||||
|
||||
/* Switch off backlight */
|
||||
PIO_Clear(pPins);
|
||||
i = 600 * (BOARD_MCK / 1000000); /* wait for at least 500us */
|
||||
while(i--);
|
||||
|
||||
/* Set new backlight level */
|
||||
for (i = 0; i < level; i++) {
|
||||
PIO_Clear(pPins);
|
||||
PIO_Clear(pPins);
|
||||
PIO_Clear(pPins);
|
||||
|
||||
PIO_Set(pPins);
|
||||
PIO_Set(pPins);
|
||||
PIO_Set(pPins);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Interface for LCD driver.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LCDD_H
|
||||
#define LCDD_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern void LCDD_Initialize(void);
|
||||
|
||||
extern void LCDD_On(void);
|
||||
|
||||
extern void LCDD_Off(void);
|
||||
|
||||
extern void LCDD_SetBacklight (uint32_t step);
|
||||
|
||||
#endif /* #ifndef LCDD_H */
|
||||
|
|
@ -1,464 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/// \file
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "pio.h"
|
||||
#include <board.h>
|
||||
#include <pmc/pmc.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Local Functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Configures one or more pin(s) of a PIO controller as being controlled by
|
||||
/// peripheral A. Optionally, the corresponding internal pull-up(s) can be
|
||||
/// enabled.
|
||||
/// \param pio Pointer to a PIO controller.
|
||||
/// \param mask Bitmask of one or more pin(s) to configure.
|
||||
/// \param enablePullUp Indicates if the pin(s) internal pull-up shall be
|
||||
/// configured.
|
||||
//------------------------------------------------------------------------------
|
||||
static void PIO_SetPeripheralA(
|
||||
Pio *pio,
|
||||
unsigned int mask,
|
||||
unsigned char enablePullUp)
|
||||
{
|
||||
unsigned int abcdsr;
|
||||
// Disable interrupts on the pin(s)
|
||||
pio->PIO_IDR = mask;
|
||||
|
||||
// Enable the pull-up(s) if necessary
|
||||
if (enablePullUp) {
|
||||
pio->PIO_PUER = mask;
|
||||
}
|
||||
else {
|
||||
|
||||
pio->PIO_PUDR = mask;
|
||||
}
|
||||
|
||||
abcdsr = pio->PIO_ABCDSR[0];
|
||||
pio->PIO_ABCDSR[0] &= (~mask & abcdsr);
|
||||
abcdsr = pio->PIO_ABCDSR[1];
|
||||
pio->PIO_ABCDSR[1] &= (~mask & abcdsr);
|
||||
pio->PIO_PDR = mask;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Configures one or more pin(s) of a PIO controller as being controlled by
|
||||
/// peripheral B. Optionally, the corresponding internal pull-up(s) can be
|
||||
/// enabled.
|
||||
/// \param pio Pointer to a PIO controller.
|
||||
/// \param mask Bitmask of one or more pin(s) to configure.
|
||||
/// \param enablePullUp Indicates if the pin(s) internal pull-up shall be
|
||||
/// configured.
|
||||
//------------------------------------------------------------------------------
|
||||
static void PIO_SetPeripheralB(
|
||||
Pio *pio,
|
||||
unsigned int mask,
|
||||
unsigned char enablePullUp)
|
||||
{
|
||||
unsigned int abcdsr;
|
||||
// Disable interrupts on the pin(s)
|
||||
pio->PIO_IDR = mask;
|
||||
|
||||
// Enable the pull-up(s) if necessary
|
||||
if (enablePullUp) {
|
||||
|
||||
pio->PIO_PUER = mask;
|
||||
}
|
||||
else {
|
||||
|
||||
pio->PIO_PUDR = mask;
|
||||
}
|
||||
|
||||
abcdsr = pio->PIO_ABCDSR[0];
|
||||
pio->PIO_ABCDSR[0] = (mask | abcdsr);
|
||||
abcdsr = pio->PIO_ABCDSR[1];
|
||||
pio->PIO_ABCDSR[1] &= (~mask & abcdsr);
|
||||
|
||||
pio->PIO_PDR = mask;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Configures one or more pin(s) of a PIO controller as being controlled by
|
||||
/// peripheral C. Optionally, the corresponding internal pull-up(s) can be
|
||||
/// enabled.
|
||||
/// \param pio Pointer to a PIO controller.
|
||||
/// \param mask Bitmask of one or more pin(s) to configure.
|
||||
/// \param enablePullUp Indicates if the pin(s) internal pull-up shall be
|
||||
/// configured.
|
||||
//------------------------------------------------------------------------------
|
||||
static void PIO_SetPeripheralC(
|
||||
Pio *pio,
|
||||
unsigned int mask,
|
||||
unsigned char enablePullUp)
|
||||
{
|
||||
unsigned int abcdsr;
|
||||
// Disable interrupts on the pin(s)
|
||||
pio->PIO_IDR = mask;
|
||||
|
||||
// Enable the pull-up(s) if necessary
|
||||
if (enablePullUp) {
|
||||
|
||||
pio->PIO_PUER = mask;
|
||||
}
|
||||
else {
|
||||
|
||||
pio->PIO_PUDR = mask;
|
||||
}
|
||||
|
||||
abcdsr = pio->PIO_ABCDSR[0];
|
||||
pio->PIO_ABCDSR[0] &= (~mask & abcdsr);
|
||||
abcdsr = pio->PIO_ABCDSR[1];
|
||||
pio->PIO_ABCDSR[1] = (mask | abcdsr);
|
||||
|
||||
pio->PIO_PDR = mask;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Configures one or more pin(s) of a PIO controller as being controlled by
|
||||
/// peripheral D. Optionally, the corresponding internal pull-up(s) can be
|
||||
/// enabled.
|
||||
/// \param pio Pointer to a PIO controller.
|
||||
/// \param mask Bitmask of one or more pin(s) to configure.
|
||||
/// \param enablePullUp Indicates if the pin(s) internal pull-up shall be
|
||||
/// configured.
|
||||
//------------------------------------------------------------------------------
|
||||
static void PIO_SetPeripheralD(
|
||||
Pio *pio,
|
||||
unsigned int mask,
|
||||
unsigned char enablePullUp)
|
||||
{
|
||||
unsigned int abcdsr;
|
||||
// Disable interrupts on the pin(s)
|
||||
pio->PIO_IDR = mask;
|
||||
|
||||
// Enable the pull-up(s) if necessary
|
||||
if (enablePullUp) {
|
||||
|
||||
pio->PIO_PUER = mask;
|
||||
}
|
||||
else {
|
||||
|
||||
pio->PIO_PUDR = mask;
|
||||
}
|
||||
|
||||
abcdsr = pio->PIO_ABCDSR[0];
|
||||
pio->PIO_ABCDSR[0] = (mask | abcdsr);
|
||||
abcdsr = pio->PIO_ABCDSR[1];
|
||||
pio->PIO_ABCDSR[1] = (mask | abcdsr);
|
||||
|
||||
pio->PIO_PDR = mask;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Configures one or more pin(s) or a PIO controller as inputs. Optionally,
|
||||
/// the corresponding internal pull-up(s) and glitch filter(s) can be
|
||||
/// enabled.
|
||||
/// \param pio Pointer to a PIO controller.
|
||||
/// \param mask Bitmask indicating which pin(s) to configure as input(s).
|
||||
/// \param enablePullUp Indicates if the internal pull-up(s) must be enabled.
|
||||
/// \param enableFilter Indicates if the glitch filter(s) must be enabled.
|
||||
//------------------------------------------------------------------------------
|
||||
static void PIO_SetInput(
|
||||
Pio *pio,
|
||||
unsigned int mask,
|
||||
unsigned char attribute)
|
||||
{
|
||||
// Disable interrupts
|
||||
pio->PIO_IDR = mask;
|
||||
|
||||
// Enable pull-up(s) if necessary
|
||||
if (attribute & PIO_PULLUP)
|
||||
pio->PIO_PUER = mask;
|
||||
else
|
||||
pio->PIO_PUDR = mask;
|
||||
|
||||
// Enable de-glitch(s) if necessary
|
||||
if (attribute & PIO_DEGLITCH)
|
||||
pio->PIO_IFER = mask;
|
||||
else
|
||||
pio->PIO_IFDR = mask;
|
||||
|
||||
// Enable de-bounce if necessary
|
||||
if (attribute & PIO_DEBOUNCE) {
|
||||
pio->PIO_DIFSR = mask;
|
||||
}
|
||||
|
||||
// Configure pin as input
|
||||
pio->PIO_ODR = mask;
|
||||
pio->PIO_PER = mask;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Configures one or more pin(s) of a PIO controller as outputs, with the
|
||||
/// given default value. Optionally, the multi-drive feature can be enabled
|
||||
/// on the pin(s).
|
||||
/// \param pio Pointer to a PIO controller.
|
||||
/// \param mask Bitmask indicating which pin(s) to configure.
|
||||
/// \param defaultValue Default level on the pin(s).
|
||||
/// \param enableMultiDrive Indicates if the pin(s) shall be configured as
|
||||
/// open-drain.
|
||||
/// \param enablePullUp Indicates if the pin shall have its pull-up activated.
|
||||
//------------------------------------------------------------------------------
|
||||
static void PIO_SetOutput(
|
||||
Pio *pio,
|
||||
unsigned int mask,
|
||||
unsigned char defaultValue,
|
||||
unsigned char enableMultiDrive,
|
||||
unsigned char enablePullUp)
|
||||
{
|
||||
// Disable interrupts
|
||||
pio->PIO_IDR = mask;
|
||||
|
||||
// Enable pull-up(s) if necessary
|
||||
if (enablePullUp) {
|
||||
|
||||
pio->PIO_PUER = mask;
|
||||
}
|
||||
else {
|
||||
|
||||
pio->PIO_PUDR = mask;
|
||||
}
|
||||
|
||||
// Enable multi-drive if necessary
|
||||
if (enableMultiDrive) {
|
||||
|
||||
pio->PIO_MDER = mask;
|
||||
}
|
||||
else {
|
||||
|
||||
pio->PIO_MDDR = mask;
|
||||
}
|
||||
|
||||
// Set default value
|
||||
if (defaultValue) {
|
||||
|
||||
pio->PIO_SODR = mask;
|
||||
}
|
||||
else {
|
||||
|
||||
pio->PIO_CODR = mask;
|
||||
}
|
||||
|
||||
// Configure pin(s) as output(s)
|
||||
pio->PIO_OER = mask;
|
||||
pio->PIO_PER = mask;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Configures interrupt mode for input Pins
|
||||
/// \param pio Pointer to a PIO controller.
|
||||
/// \param mask Bitmask indicating which pin(s) to configure.
|
||||
/// \param additionnalItMode Enable Pio Additionnal It Mode.
|
||||
/// \param edgeMode Enable the edge mode.
|
||||
/// \param risingEdgeOrHighLevel Enable IT on rising edge or high level.
|
||||
//------------------------------------------------------------------------------
|
||||
static void PIO_SetInterrupt(
|
||||
Pio *pio,
|
||||
unsigned int mask,
|
||||
unsigned char additionnalItMode,
|
||||
unsigned char edgeMode,
|
||||
unsigned char risingEdgeOrHighLevel)
|
||||
{
|
||||
/* Configure the Interrupt mode in the PIO controller */
|
||||
if (additionnalItMode) {
|
||||
/* enable additional interrupt mode */
|
||||
pio->PIO_AIMER = mask;
|
||||
|
||||
/* if bit field of selected pin is 1, set as Rising Edge/High level detection event */
|
||||
if (risingEdgeOrHighLevel)
|
||||
pio->PIO_REHLSR = mask;
|
||||
else
|
||||
pio->PIO_FELLSR = mask;
|
||||
|
||||
/* if bit field of selected pin is 1, set as edge detection source */
|
||||
if (edgeMode)
|
||||
pio->PIO_ESR = mask;
|
||||
else
|
||||
pio->PIO_LSR = mask;
|
||||
} else {
|
||||
/* disable additional interrupt mode */
|
||||
pio->PIO_AIMDR = mask;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Global Functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Configures a list of Pin instances, each of which can either hold a single
|
||||
/// pin or a group of pins, depending on the mask value; all pins are configured
|
||||
/// by this function. The size of the array must also be provided and is easily
|
||||
/// computed using PIO_LISTSIZE whenever its length is not known in advance.
|
||||
/// \param list Pointer to a list of Pin instances.
|
||||
/// \param size Size of the Pin list (calculated using PIO_LISTSIZE).
|
||||
/// \return 1 if the pins have been configured properly; otherwise 0.
|
||||
//------------------------------------------------------------------------------
|
||||
unsigned char PIO_Configure(const Pin *list, unsigned int size)
|
||||
{
|
||||
// Configure pins
|
||||
while (size > 0) {
|
||||
|
||||
switch (list->type) {
|
||||
|
||||
case PIO_PERIPH_A:
|
||||
PIO_SetPeripheralA(list->pio,
|
||||
list->mask,
|
||||
(list->attribute & PIO_PULLUP) ? 1 : 0);
|
||||
break;
|
||||
|
||||
case PIO_PERIPH_B:
|
||||
PIO_SetPeripheralB(list->pio,
|
||||
list->mask,
|
||||
(list->attribute & PIO_PULLUP) ? 1 : 0);
|
||||
break;
|
||||
|
||||
case PIO_PERIPH_C:
|
||||
PIO_SetPeripheralC(list->pio,
|
||||
list->mask,
|
||||
(list->attribute & PIO_PULLUP) ? 1 : 0);
|
||||
break;
|
||||
|
||||
case PIO_PERIPH_D:
|
||||
PIO_SetPeripheralD(list->pio,
|
||||
list->mask,
|
||||
(list->attribute & PIO_PULLUP) ? 1 : 0);
|
||||
break;
|
||||
case PIO_INPUT:
|
||||
PMC_EnablePeripheral(list->id);
|
||||
PIO_SetInput(list->pio,
|
||||
list->mask,
|
||||
list->attribute);
|
||||
PIO_SetInterrupt(list->pio,
|
||||
list->mask,
|
||||
(list->attribute & PIO_IT_AIME) ? 1 : 0,
|
||||
(list->attribute & PIO_IT_EDGE) ? 1 : 0,
|
||||
(list->attribute & PIO_IT_RE_OR_HL) ? 1 : 0);
|
||||
break;
|
||||
|
||||
case PIO_OUTPUT_0:
|
||||
case PIO_OUTPUT_1:
|
||||
PIO_SetOutput(list->pio,
|
||||
list->mask,
|
||||
(list->type == PIO_OUTPUT_1),
|
||||
(list->attribute & PIO_OPENDRAIN) ? 1 : 0,
|
||||
(list->attribute & PIO_PULLUP) ? 1 : 0);
|
||||
break;
|
||||
|
||||
default: return 0;
|
||||
}
|
||||
|
||||
list++;
|
||||
size--;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Sets a high output level on all the PIOs defined in the given Pin instance.
|
||||
/// This has no immediate effects on PIOs that are not output, but the PIO
|
||||
/// controller will memorize the value they are changed to outputs.
|
||||
/// \param pin Pointer to a Pin instance describing one or more pins.
|
||||
//------------------------------------------------------------------------------
|
||||
void PIO_Set(const Pin *pin)
|
||||
{
|
||||
pin->pio->PIO_SODR = pin->mask;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Sets a low output level on all the PIOs defined in the given Pin instance.
|
||||
/// This has no immediate effects on PIOs that are not output, but the PIO
|
||||
/// controller will memorize the value they are changed to outputs.
|
||||
/// \param pin Pointer to a Pin instance describing one or more pins.
|
||||
//------------------------------------------------------------------------------
|
||||
void PIO_Clear(const Pin *pin)
|
||||
{
|
||||
pin->pio->PIO_CODR = pin->mask;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Returns 1 if one or more PIO of the given Pin instance currently have a high
|
||||
/// level; otherwise returns 0. This method returns the actual value that is
|
||||
/// being read on the pin. To return the supposed output value of a pin, use
|
||||
/// PIO_GetOutputDataStatus() instead.
|
||||
/// \param pin Pointer to a Pin instance describing one or more pins.
|
||||
/// \return 1 if the Pin instance contains at least one PIO that currently has
|
||||
/// a high level; otherwise 0.
|
||||
//------------------------------------------------------------------------------
|
||||
unsigned char PIO_Get(const Pin *pin)
|
||||
{
|
||||
unsigned int reg;
|
||||
if ((pin->type == PIO_OUTPUT_0) || (pin->type == PIO_OUTPUT_1)) {
|
||||
|
||||
reg = pin->pio->PIO_ODSR;
|
||||
}
|
||||
else {
|
||||
|
||||
reg = pin->pio->PIO_PDSR;
|
||||
}
|
||||
|
||||
if ((reg & pin->mask) == 0) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Returns 1 if one or more PIO of the given Pin are configured to output a
|
||||
/// high level (even if they are not output).
|
||||
/// To get the actual value of the pin, use PIO_Get() instead.
|
||||
/// \param pin Pointer to a Pin instance describing one or more pins.
|
||||
/// \return 1 if the Pin instance contains at least one PIO that is configured
|
||||
/// to output a high level; otherwise 0.
|
||||
//------------------------------------------------------------------------------
|
||||
unsigned char PIO_GetOutputDataStatus(const Pin *pin)
|
||||
{
|
||||
if ((pin->pio->PIO_ODSR & pin->mask) == 0) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue