Initial public release.
This commit is contained in:
parent
7b169e8116
commit
dac4af8d25
255 changed files with 68595 additions and 2 deletions
31
.gitignore
vendored
Normal file
31
.gitignore
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# Ignore file for the KTag 2020TPC PSoC Creator workspace.
|
||||||
|
|
||||||
|
*.log
|
||||||
|
*/codegentemp/*
|
||||||
|
*/CortexM0p/*
|
||||||
|
*/CortexM4/ARM_GCC_541/*
|
||||||
|
*/Export/*
|
||||||
|
*/Generated_Source/*
|
||||||
|
/2020TPC.cywrk.*
|
||||||
|
|
||||||
|
/2020TPCApp0.cydsn/2020TPCApp0_timing.html
|
||||||
|
/2020TPCApp0.cydsn/2020TPCApp0.cycdx
|
||||||
|
/2020TPCApp0.cydsn/2020TPCApp0.cyfit
|
||||||
|
/2020TPCApp0.cydsn/2020TPCApp0.cyprj.*
|
||||||
|
/2020TPCApp0.cydsn/2020TPCApp0.rpt
|
||||||
|
|
||||||
|
/2020TPCApp1.cydsn/2020TPCApp1_timing.html
|
||||||
|
/2020TPCApp1.cydsn/2020TPCApp1.cycdx
|
||||||
|
/2020TPCApp1.cydsn/2020TPCApp1.cyfit
|
||||||
|
/2020TPCApp1.cydsn/2020TPCApp1.cyprj.*
|
||||||
|
/2020TPCApp1.cydsn/2020TPCApp1.rpt
|
||||||
|
/2020TPCApp1.cydsn/2020TPCApp1.svd
|
||||||
|
|
||||||
|
/2020TPCAppNoDFU.cydsn/2020TPCAppNoDFU_timing.html
|
||||||
|
/2020TPCAppNoDFU.cydsn/2020TPCAppNoDFU.cycdx
|
||||||
|
/2020TPCAppNoDFU.cydsn/2020TPCAppNoDFU.cyfit
|
||||||
|
/2020TPCAppNoDFU.cydsn/2020TPCAppNoDFU.cyprj.*
|
||||||
|
/2020TPCAppNoDFU.cydsn/2020TPCAppNoDFU.rpt
|
||||||
|
/2020TPCAppNoDFU.cydsn/2020TPCAppNoDFU.svd
|
||||||
|
|
||||||
|
/Keys/*.txt
|
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[submodule "2020TPCApp1.cydsn/SystemK"]
|
||||||
|
path = 2020TPCApp1.cydsn/SystemK
|
||||||
|
url = https://git.ktag.clubk.club/Software/SystemK
|
||||||
|
[submodule "2020TPCAppNoDFU.cydsn/SystemK"]
|
||||||
|
path = 2020TPCAppNoDFU.cydsn/SystemK
|
||||||
|
url = https://git.ktag.clubk.club/Software/SystemK
|
BIN
2020TPC Nonvolatile Memory.xlsx
Normal file
BIN
2020TPC Nonvolatile Memory.xlsx
Normal file
Binary file not shown.
24
2020TPC.cywrk
Normal file
24
2020TPC.cywrk
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<CyXmlSerializer>
|
||||||
|
<!--This file is machine generated and read. It is not intended to be edited by hand.-->
|
||||||
|
<!--Due to this, there is no schema for this file.-->
|
||||||
|
<CyGuid_2867d519-54d2-4c01-9830-c51cb08bc3dd type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtWorkspaceSerialize" version="5" xml_contents_version="3" name="2020TPC" persistent="2020TPC.cywrk" platform="NOT_USED">
|
||||||
|
<current_project name=".\2020TPCApp1.cydsn\2020TPCApp1.cyprj" />
|
||||||
|
<wrkspc_folders />
|
||||||
|
<files />
|
||||||
|
<projects>
|
||||||
|
<v>.\2020TPCApp0.cydsn\2020TPCApp0.cyprj</v>
|
||||||
|
<v>.\2020TPCApp1.cydsn\2020TPCApp1.cyprj</v>
|
||||||
|
<v>.\2020TPCAppNoDFU.cydsn\2020TPCAppNoDFU.cyprj</v>
|
||||||
|
</projects>
|
||||||
|
<workspace_id v="93090419-7958-4262-9bcb-6a3d5e88c6b9" />
|
||||||
|
<WriteAppVersionLastSavedWith v="4.4.0.80" />
|
||||||
|
<WriteAppMarketingVersionLastSavedWith v="4.4" />
|
||||||
|
<CyGuid_dcbd9771-0334-43dc-9cc3-fe99dc3c5316 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtWorkspaceSerialize+CyPrjDependencyList" version="4">
|
||||||
|
<wrkspc_dependencies />
|
||||||
|
</CyGuid_dcbd9771-0334-43dc-9cc3-fe99dc3c5316>
|
||||||
|
<CyGuid_63b68103-67f5-4406-8da6-5c8625765b82 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtWorkspaceSerialize+CyIgnoredSystemDepsList" version="1">
|
||||||
|
<wrkspc_dependencies />
|
||||||
|
</CyGuid_63b68103-67f5-4406-8da6-5c8625765b82>
|
||||||
|
</CyGuid_2867d519-54d2-4c01-9830-c51cb08bc3dd>
|
||||||
|
</CyXmlSerializer>
|
711
2020TPCApp0.cydsn/2020TPCApp0.cydwr
Normal file
711
2020TPCApp0.cydsn/2020TPCApp0.cydwr
Normal file
|
@ -0,0 +1,711 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<DesignWideResources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://cypress.com/xsd/cydwr">
|
||||||
|
<Group key="Component">
|
||||||
|
<Group key="v1">
|
||||||
|
<Data key="LIN_Dynamic" value="LIN_Dynamic_v4_0" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Data key="DataVersionKey" value="2" />
|
||||||
|
<Group key="DWRInstGuidMapping">
|
||||||
|
<Group key="Clock">
|
||||||
|
<Data key="6a193d05-b64b-451d-acf3-e3facd8c438d/b68e5b9d-7828-482d-a282-930f990e3b3e" value="UART_DEB_SCBCLK" />
|
||||||
|
</Group>
|
||||||
|
<Group key="Pin">
|
||||||
|
<Data key="2b5567f1-f32a-4160-a53f-69e9456f9b8c" value="PIN_SW2" />
|
||||||
|
<Data key="6a193d05-b64b-451d-acf3-e3facd8c438d/65f3af6c-759b-4ccb-8c66-5c95ba1f5f4f" value="UART_DEB_tx" />
|
||||||
|
<Data key="6a193d05-b64b-451d-acf3-e3facd8c438d/b7e8018e-1ef7-49c0-b5a5-61641a03e31c" value="UART_DEB_rx" />
|
||||||
|
<Data key="9d38c8a9-8e67-42cf-aadd-aa4ff9265154" value="PIN_LED_GREEN" />
|
||||||
|
<Data key="120d8658-29e0-4f03-bc08-8768eec2d8f2" value="PIN_LED_RED" />
|
||||||
|
<Data key="373ac181-e5a7-4dc3-90cc-59173ad1ca56" value="Pin_GreenLED" />
|
||||||
|
<Data key="a61270bc-07ec-447d-ac9e-34cfe85c30e9" value="Pin_1" />
|
||||||
|
<Data key="aa9833be-078f-43bb-bfa1-32a88558ac1e" value="PIN_LED_BLUE" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="M0S8Clock">
|
||||||
|
<Group key="DesigneWideClks">
|
||||||
|
<Group key="8AF878A3-9701-44BB-864C-92E241DEEFC9">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="NAMED_FREQ" />
|
||||||
|
<Data key="desired_freq" value="24" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="3" />
|
||||||
|
<Data key="enabled" value="False" />
|
||||||
|
<Data key="fract_divider_denominator" value="0" />
|
||||||
|
<Data key="fract_divider_numerator" value="0" />
|
||||||
|
<Data key="minus_tolerance" value="10" />
|
||||||
|
<Data key="name" value="Clk_PumpPeri" />
|
||||||
|
<Data key="netlist_name" value="PumpClkPeri" />
|
||||||
|
<Data key="ph_align_clock_id" value="" />
|
||||||
|
<Data key="ph_align_clock_name" value="" />
|
||||||
|
<Data key="plus_tolerance" value="10" />
|
||||||
|
<Data key="scope" value="GLOBAL" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="2FB4EC85-8328-4C5A-9ED9-8B63060178EB" />
|
||||||
|
<Data key="src_clk_name" value="Clk_Peri" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
<Data key="uses_fract_divider" value="False" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="LocalClks">
|
||||||
|
<Group key="6a193d05-b64b-451d-acf3-e3facd8c438d/b68e5b9d-7828-482d-a282-930f990e3b3e">
|
||||||
|
<Data key="check_tolerance" value="True" />
|
||||||
|
<Data key="derive_type" value="AUTO" />
|
||||||
|
<Data key="desired_freq" value="1.3824" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="54" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="fract_divider_denominator" value="0" />
|
||||||
|
<Data key="fract_divider_numerator" value="0" />
|
||||||
|
<Data key="minus_tolerance" value="5" />
|
||||||
|
<Data key="name" value="UART_DEB_SCBCLK" />
|
||||||
|
<Data key="netlist_name" value="\UART_DEB:SCBCLK\" />
|
||||||
|
<Data key="ph_align_clock_id" value="" />
|
||||||
|
<Data key="ph_align_clock_name" value="" />
|
||||||
|
<Data key="plus_tolerance" value="5" />
|
||||||
|
<Data key="scope" value="LOCAL" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="2FB4EC85-8328-4C5A-9ED9-8B63060178EB" />
|
||||||
|
<Data key="src_clk_name" value="Clk_Peri" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
<Data key="uses_fract_divider" value="False" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="SystemClks">
|
||||||
|
<Group key="0A08FE05-F885-497B-A02E-BF29CD90D1E9">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="8" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="IMO" />
|
||||||
|
<Data key="netlist_name" value="IMO" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="" />
|
||||||
|
<Data key="src_clk_name" value="" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
<Data key="trim_with" value="NONE" />
|
||||||
|
</Group>
|
||||||
|
<Group key="1BBDCBF8-BEDC-475F-91D6-B7000D3ACFC0">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="32.768" />
|
||||||
|
<Data key="desired_unit" value="3" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_LF" />
|
||||||
|
<Data key="netlist_name" value="LFClk" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0.015" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0.015" />
|
||||||
|
<Data key="src_clk_id" value="3A033BA1-EB59-48AA-A483-E956063B58F7" />
|
||||||
|
<Data key="src_clk_name" value="WCO" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="2A8967C4-B635-4C8A-8C91-90EE65E329AC">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="8" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="PathMux1" />
|
||||||
|
<Data key="netlist_name" value="PathMux1" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="0A08FE05-F885-497B-A02E-BF29CD90D1E9" />
|
||||||
|
<Data key="src_clk_name" value="IMO" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="2FB4EC85-8328-4C5A-9ED9-8B63060178EB">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="75" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="2" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_Peri" />
|
||||||
|
<Data key="netlist_name" value="PeriClk" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="30F7C581-E9BB-4075-AE9E-3D10352921CE" />
|
||||||
|
<Data key="src_clk_name" value="Clk_HF0" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="3A033BA1-EB59-48AA-A483-E956063B58F7">
|
||||||
|
<Data key="accuracy_display_unit" value="0" />
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="32768" />
|
||||||
|
<Data key="desired_unit" value="0" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="WCO" />
|
||||||
|
<Data key="netlist_name" value="WCO" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="single_ended" value="False" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0.015" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0.015" />
|
||||||
|
<Data key="src_clk_id" value="" />
|
||||||
|
<Data key="src_clk_name" value="" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
</Group>
|
||||||
|
<Group key="3B75F9AC-44ED-4CB5-8723-10BBE7669CF0">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="0" />
|
||||||
|
<Data key="desired_unit" value="0" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="False" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="DigSig1" />
|
||||||
|
<Data key="netlist_name" value="DigSig1" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0" />
|
||||||
|
<Data key="src_clk_id" value="" />
|
||||||
|
<Data key="src_clk_name" value="" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
</Group>
|
||||||
|
<Group key="5B1637F6-006C-4FD5-94A0-99A2269F6E18">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="32.768" />
|
||||||
|
<Data key="desired_unit" value="3" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="False" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="PILO" />
|
||||||
|
<Data key="netlist_name" value="PILO" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="2" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="2" />
|
||||||
|
<Data key="src_clk_id" value="" />
|
||||||
|
<Data key="src_clk_name" value="" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
</Group>
|
||||||
|
<Group key="5C4F238B-1818-4FC7-84C6-4E205116253D">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="50" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="1" />
|
||||||
|
<Data key="enabled" value="False" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_HF1" />
|
||||||
|
<Data key="netlist_name" value="HFClk1" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0.25" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0.25" />
|
||||||
|
<Data key="src_clk_id" value="343F3593-1AA2-4B14-BFF9-C9A56BDE27C9" />
|
||||||
|
<Data key="src_clk_name" value="FLL" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
</Group>
|
||||||
|
<Group key="6EACA723-B6E0-41AC-AE21-41E3ED0E6CA7">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="150" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="1" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_Fast" />
|
||||||
|
<Data key="netlist_name" value="FastClk" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="30F7C581-E9BB-4075-AE9E-3D10352921CE" />
|
||||||
|
<Data key="src_clk_name" value="Clk_HF0" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="14CA2D02-47B3-450D-8582-9F89752FD19F">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="25" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="2" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_Pump" />
|
||||||
|
<Data key="netlist_name" value="PumpClk" />
|
||||||
|
<Data key="peri_divider" value="1" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="pump_mode" value="HighPerformance" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="2.4" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="2.4" />
|
||||||
|
<Data key="src_clk_id" value="343F3593-1AA2-4B14-BFF9-C9A56BDE27C9" />
|
||||||
|
<Data key="src_clk_name" value="FLL" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="30F7C581-E9BB-4075-AE9E-3D10352921CE">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="150" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="1" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_HF0" />
|
||||||
|
<Data key="netlist_name" value="HFClk0" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="A6AA470B-43FB-48E8-AAE4-172941809D61" />
|
||||||
|
<Data key="src_clk_name" value="PLL0" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="43B2A111-B593-448F-A298-491D36F976AF">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="32.768" />
|
||||||
|
<Data key="desired_unit" value="3" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_AltSysTick" />
|
||||||
|
<Data key="netlist_name" value="AltSysTickClk" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0.015" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0.015" />
|
||||||
|
<Data key="src_clk_id" value="1BBDCBF8-BEDC-475F-91D6-B7000D3ACFC0" />
|
||||||
|
<Data key="src_clk_name" value="Clk_LF" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="82BF9508-65AC-4E3C-A121-369F517EB9A1">
|
||||||
|
<Data key="accuracy_display_unit" value="1" />
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="24" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="False" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="ExtClk" />
|
||||||
|
<Data key="netlist_name" value="ExtClk" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="port_number" value="0" />
|
||||||
|
<Data key="port_offset" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0" />
|
||||||
|
<Data key="src_clk_id" value="" />
|
||||||
|
<Data key="src_clk_name" value="" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
</Group>
|
||||||
|
<Group key="90A0AFF0-F028-4772-9ECA-35D832B188BB">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="8" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="PathMux0" />
|
||||||
|
<Data key="netlist_name" value="PathMux0" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="0A08FE05-F885-497B-A02E-BF29CD90D1E9" />
|
||||||
|
<Data key="src_clk_name" value="IMO" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="343F3593-1AA2-4B14-BFF9-C9A56BDE27C9">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="50" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="LOCK_TOLERANCE" value="35" />
|
||||||
|
<Data key="MANUAL" value="False" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="MULTIPLIER" value="500" />
|
||||||
|
<Data key="name" value="FLL" />
|
||||||
|
<Data key="netlist_name" value="FLL" />
|
||||||
|
<Data key="OUTPUT" value="True" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="REFERENCE" value="40" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="2.4" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="2.4" />
|
||||||
|
<Data key="src_clk_id" value="90A0AFF0-F028-4772-9ECA-35D832B188BB" />
|
||||||
|
<Data key="src_clk_name" value="PathMux0" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="627FD272-4308-4363-80FD-BD4E238E9E1E">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="0" />
|
||||||
|
<Data key="desired_unit" value="0" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="False" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="DigSig2" />
|
||||||
|
<Data key="netlist_name" value="DigSig2" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0" />
|
||||||
|
<Data key="src_clk_id" value="" />
|
||||||
|
<Data key="src_clk_name" value="" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
</Group>
|
||||||
|
<Group key="4952BDB5-B02C-44C1-9796-82E591C05DF5">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="50" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="1" />
|
||||||
|
<Data key="enabled" value="False" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_HF4" />
|
||||||
|
<Data key="netlist_name" value="HFClk4" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0.25" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0.25" />
|
||||||
|
<Data key="src_clk_id" value="343F3593-1AA2-4B14-BFF9-C9A56BDE27C9" />
|
||||||
|
<Data key="src_clk_name" value="FLL" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
</Group>
|
||||||
|
<Group key="9409D4F0-F30E-4F72-8632-37B364B69CCA">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="32.768" />
|
||||||
|
<Data key="desired_unit" value="3" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_Bak" />
|
||||||
|
<Data key="netlist_name" value="BakClk" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0.015" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0.015" />
|
||||||
|
<Data key="src_clk_id" value="3A033BA1-EB59-48AA-A483-E956063B58F7" />
|
||||||
|
<Data key="src_clk_name" value="WCO" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="67311D8D-96F4-4A9C-A630-E23D8F4190B9">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="50" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="1" />
|
||||||
|
<Data key="enabled" value="False" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_HF2" />
|
||||||
|
<Data key="netlist_name" value="HFClk2" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0.25" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0.25" />
|
||||||
|
<Data key="src_clk_id" value="343F3593-1AA2-4B14-BFF9-C9A56BDE27C9" />
|
||||||
|
<Data key="src_clk_name" value="FLL" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
</Group>
|
||||||
|
<Group key="86410BAB-C607-4C16-A245-8987C7D5B200">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="32" />
|
||||||
|
<Data key="desired_unit" value="3" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="ILO" />
|
||||||
|
<Data key="netlist_name" value="ILO" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="run_in_hibernate" value="True" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="10" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="10" />
|
||||||
|
<Data key="src_clk_id" value="" />
|
||||||
|
<Data key="src_clk_name" value="" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="88997D52-6DD5-4C9C-92CA-966A10C3C276">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="8" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="PathMux2" />
|
||||||
|
<Data key="netlist_name" value="PathMux2" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="0A08FE05-F885-497B-A02E-BF29CD90D1E9" />
|
||||||
|
<Data key="src_clk_name" value="IMO" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="A6AA470B-43FB-48E8-AAE4-172941809D61">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="150" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="FEEDBACK" value="75" />
|
||||||
|
<Data key="LOW_FREQUENCY" value="False" />
|
||||||
|
<Data key="MANUAL" value="False" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="PLL0" />
|
||||||
|
<Data key="netlist_name" value="PLL0" />
|
||||||
|
<Data key="OPTIMIZATION" value="MIN_JITTER" />
|
||||||
|
<Data key="OUTPUT" value="2" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="REFERENCE" value="2" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="2A8967C4-B635-4C8A-8C91-90EE65E329AC" />
|
||||||
|
<Data key="src_clk_name" value="PathMux1" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
</Group>
|
||||||
|
<Group key="A43118E8-985E-494A-967B-3EAE88168DCB">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="50" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="1" />
|
||||||
|
<Data key="enabled" value="False" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_HF3" />
|
||||||
|
<Data key="netlist_name" value="HFClk3" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0.25" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0.25" />
|
||||||
|
<Data key="src_clk_id" value="343F3593-1AA2-4B14-BFF9-C9A56BDE27C9" />
|
||||||
|
<Data key="src_clk_name" value="FLL" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
</Group>
|
||||||
|
<Group key="ADA77A51-2EDA-49E0-9358-E7A5F2860024">
|
||||||
|
<Data key="accuracy_display_unit" value="1" />
|
||||||
|
<Data key="AccuracyMinus" value="0" />
|
||||||
|
<Data key="AccuracyPlus" value="0" />
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="32" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="Divider" value="1" />
|
||||||
|
<Data key="ECO Frequency" value="32 MHz" />
|
||||||
|
<Data key="enabled" value="False" />
|
||||||
|
<Data key="Load cap (pF)" value="17.025" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="AltHF" />
|
||||||
|
<Data key="netlist_name" value="AltHF" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0" />
|
||||||
|
<Data key="src_clk_id" value="" />
|
||||||
|
<Data key="src_clk_name" value="" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
<Data key="Startup time (μs)" value="1500" />
|
||||||
|
</Group>
|
||||||
|
<Group key="BAE5EB24-1ECF-44AC-90E5-F6AE7E694F04">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="75" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="1" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_Slow" />
|
||||||
|
<Data key="netlist_name" value="SlowClk" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="2FB4EC85-8328-4C5A-9ED9-8B63060178EB" />
|
||||||
|
<Data key="src_clk_name" value="Clk_Peri" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="C6FE41CF-98FF-4698-8F2D-2E52D350A99C">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="8" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="1" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="hf0_div" value="1" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="Clk_Timer" />
|
||||||
|
<Data key="netlist_name" value="TimerClk" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="0A08FE05-F885-497B-A02E-BF29CD90D1E9" />
|
||||||
|
<Data key="src_clk_name" value="IMO" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="D75D74B8-A7D4-4EDE-81F8-A16DF63D7E1D">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="8" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="PathMux4" />
|
||||||
|
<Data key="netlist_name" value="PathMux4" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="0A08FE05-F885-497B-A02E-BF29CD90D1E9" />
|
||||||
|
<Data key="src_clk_name" value="IMO" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="DA284A0E-4F7B-459E-94F0-90A7FE6053BD">
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="8" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="enabled" value="True" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="PathMux3" />
|
||||||
|
<Data key="netlist_name" value="PathMux3" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="1" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="1" />
|
||||||
|
<Data key="src_clk_id" value="0A08FE05-F885-497B-A02E-BF29CD90D1E9" />
|
||||||
|
<Data key="src_clk_name" value="IMO" />
|
||||||
|
<Data key="start_on_reset" value="True" />
|
||||||
|
</Group>
|
||||||
|
<Group key="E7D3001A-7972-446E-BD84-625E3AAB61E9">
|
||||||
|
<Data key="accuracy_display_unit" value="1" />
|
||||||
|
<Data key="c_load" value="18" />
|
||||||
|
<Data key="check_tolerance" value="False" />
|
||||||
|
<Data key="derive_type" value="BUILTIN" />
|
||||||
|
<Data key="desired_freq" value="24" />
|
||||||
|
<Data key="desired_unit" value="6" />
|
||||||
|
<Data key="divider" value="0" />
|
||||||
|
<Data key="drive_level" value="100" />
|
||||||
|
<Data key="enabled" value="False" />
|
||||||
|
<Data key="esr" value="50" />
|
||||||
|
<Data key="minus_tolerance" value="0" />
|
||||||
|
<Data key="name" value="ECO" />
|
||||||
|
<Data key="netlist_name" value="ECO" />
|
||||||
|
<Data key="plus_tolerance" value="0" />
|
||||||
|
<Data key="scope" value="BUILTIN" />
|
||||||
|
<Data key="sourceClk_minus_acuracy_name" value="0" />
|
||||||
|
<Data key="sourceClk_plus_acuracy_name" value="0" />
|
||||||
|
<Data key="src_clk_id" value="" />
|
||||||
|
<Data key="src_clk_name" value="" />
|
||||||
|
<Data key="start_on_reset" value="False" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="Pin2">
|
||||||
|
<Group key="2b5567f1-f32a-4160-a53f-69e9456f9b8c">
|
||||||
|
<Group key="0">
|
||||||
|
<Data key="Port Format" value="0,4" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="6a193d05-b64b-451d-acf3-e3facd8c438d/65f3af6c-759b-4ccb-8c66-5c95ba1f5f4f">
|
||||||
|
<Group key="0">
|
||||||
|
<Data key="Port Format" value="5,1" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="6a193d05-b64b-451d-acf3-e3facd8c438d/b7e8018e-1ef7-49c0-b5a5-61641a03e31c">
|
||||||
|
<Group key="0">
|
||||||
|
<Data key="Port Format" value="5,0" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="9d38c8a9-8e67-42cf-aadd-aa4ff9265154">
|
||||||
|
<Group key="0">
|
||||||
|
<Data key="Port Format" value="7,1" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="120d8658-29e0-4f03-bc08-8768eec2d8f2">
|
||||||
|
<Group key="0">
|
||||||
|
<Data key="Port Format" value="6,3" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="373ac181-e5a7-4dc3-90cc-59173ad1ca56">
|
||||||
|
<Group key="0">
|
||||||
|
<Data key="Port Format" value="1,1" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="a61270bc-07ec-447d-ac9e-34cfe85c30e9">
|
||||||
|
<Group key="0">
|
||||||
|
<Data key="Port Format" value="12,4" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="aa9833be-078f-43bb-bfa1-32a88558ac1e">
|
||||||
|
<Group key="0">
|
||||||
|
<Data key="Port Format" value="11,1" />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Group key="PlaceDir">
|
||||||
|
<Data key="count" value="0" />
|
||||||
|
</Group>
|
||||||
|
<Group key="System3">
|
||||||
|
<Data key="CYDEV_APP_IMAGE_SECURITY" value="NONE" />
|
||||||
|
<Data key="CYDEV_CHIP_SECURITY" value="NORMAL" />
|
||||||
|
<Data key="CYDEV_CONFIG_UNUSED_IO" value="AllowButWarn" />
|
||||||
|
<Data key="CYDEV_CONFIGURATION_MODE" value="COMPRESSED" />
|
||||||
|
<Data key="CYDEV_CPUSS0_TRACE_CLOCK" value="P70" />
|
||||||
|
<Data key="CYDEV_CPUSS0_TRACE_DATA0" value="P77" />
|
||||||
|
<Data key="CYDEV_CPUSS0_TRACE_DATA1" value="P76" />
|
||||||
|
<Data key="CYDEV_CPUSS0_TRACE_DATA2" value="P75" />
|
||||||
|
<Data key="CYDEV_CPUSS0_TRACE_DATA3" value="P74" />
|
||||||
|
<Data key="CYDEV_DEBUGGING_DPS" value="SWD" />
|
||||||
|
<Data key="CYDEV_FLASH_BOOT_SECURE_DATA0" value="" />
|
||||||
|
<Data key="CYDEV_FLASH_BOOT_SECURE_DATA1" value="" />
|
||||||
|
<Data key="CYDEV_FLASH_BOOT_SECURE_DATA2" value="" />
|
||||||
|
<Data key="CYDEV_PMIC_MODE" value="DISABLED" />
|
||||||
|
<Data key="CYDEV_POWER_MODE" value="LDO_LINEAR_REG_1_1V" />
|
||||||
|
<Data key="CYDEV_SECURITY_IMAGE" value="" />
|
||||||
|
<Data key="CYDEV_SECURITY_KEYS" value="" />
|
||||||
|
<Data key="CYDEV_SYSTEM_AREF_CURRENT" value="HIGH" />
|
||||||
|
<Data key="CYDEV_SYSTEM_AREF_DEEPSLEEP" value="False" />
|
||||||
|
<Data key="CYDEV_SYSTEM_AREF_SOURCE" value="LOCAL_1_2V" />
|
||||||
|
<Data key="CYDEV_TEMPERATURE" value="-40C - 85C" />
|
||||||
|
<Data key="CYDEV_TRACE_ENABLED" value="False" />
|
||||||
|
<Data key="CYDEV_VARIABLE_VDDA" value="False" />
|
||||||
|
<Data key="CYDEV_VBAC_SUPPLY" value="VDDD" />
|
||||||
|
<Data key="CYDEV_VBACKUP" value="3.3" />
|
||||||
|
<Data key="CYDEV_VDD" value="3.3" />
|
||||||
|
<Data key="CYDEV_VDD_NS" value="3.3" />
|
||||||
|
<Data key="CYDEV_VDDA" value="3.3" />
|
||||||
|
<Data key="CYDEV_VDDD" value="3.3" />
|
||||||
|
<Data key="CYDEV_VDDIO0" value="3.3" />
|
||||||
|
<Data key="CYDEV_VDDIO1" value="3.3" />
|
||||||
|
<Data key="CYDEV_VDDR_HVL" value="3.3" />
|
||||||
|
</Group>
|
||||||
|
</DesignWideResources>
|
3572
2020TPCApp0.cydsn/2020TPCApp0.cyprj
Normal file
3572
2020TPCApp0.cydsn/2020TPCApp0.cyprj
Normal file
File diff suppressed because it is too large
Load diff
BIN
2020TPCApp0.cydsn/TopDesign/TopDesign.cysch
Normal file
BIN
2020TPCApp0.cydsn/TopDesign/TopDesign.cysch
Normal file
Binary file not shown.
218
2020TPCApp0.cydsn/cy8c6xx7_cm0plus.icf
Normal file
218
2020TPCApp0.cydsn/cy8c6xx7_cm0plus.icf
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file cy8c6xx7_cm0plus.icf
|
||||||
|
* \version 2.20
|
||||||
|
*
|
||||||
|
* Linker file for the IAR compiler.
|
||||||
|
*
|
||||||
|
* The main purpose of the linker script is to describe how the sections in the
|
||||||
|
* input files should be mapped into the output file, and to control the memory
|
||||||
|
* layout of the output file.
|
||||||
|
*
|
||||||
|
* \note The entry point is fixed and starts at 0x10000000. The valid application
|
||||||
|
* image should be placed there.
|
||||||
|
*
|
||||||
|
* \note The linker files included with the PDL template projects must be generic
|
||||||
|
* and handle all common use cases. Your project may not use every section
|
||||||
|
* defined in the linker files. In that case you may see warnings during the
|
||||||
|
* build process. In your project, you can simply comment out or remove the
|
||||||
|
* relevant code in the linker file.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||||
|
/*-Editor annotation file-*/
|
||||||
|
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_4.xml" */
|
||||||
|
/*-Specials-*/
|
||||||
|
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
|
||||||
|
|
||||||
|
/* The symbols below define the location and size of blocks of memory in the target.
|
||||||
|
* Use these symbols to specify the memory regions available for allocation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The following symbols control RAM and flash memory allocation for the CM0+ core.
|
||||||
|
* You can change the memory allocation by editing RAM and Flash symbols.
|
||||||
|
* Your changes must be aligned with the corresponding symbols for CM4 core in 'xx_cm4_dual.icf',
|
||||||
|
* where 'xx' is the device group; for example, 'cy8c6xx7_cm4_dual.icf'.
|
||||||
|
*/
|
||||||
|
/* RAM */
|
||||||
|
define symbol __ICFEDIT_region_IRAM1_start__ = 0x08000000;
|
||||||
|
define symbol __ICFEDIT_region_IRAM1_end__ = 0x08024000;
|
||||||
|
/* Flash */
|
||||||
|
define symbol __ICFEDIT_region_IROM1_start__ = 0x10000000;
|
||||||
|
define symbol __ICFEDIT_region_IROM1_end__ = 0x10080000;
|
||||||
|
|
||||||
|
/* The following symbols define a 32K flash region used for EEPROM emulation.
|
||||||
|
* This region can also be used as the general purpose flash.
|
||||||
|
* You can assign sections to this memory region for only one of the cores.
|
||||||
|
* Note some middleware (e.g. BLE, Emulated EEPROM) can place their data into this memory region.
|
||||||
|
* Therefore, repurposing this memory region will prevent such middleware from operation.
|
||||||
|
*/
|
||||||
|
define symbol __ICFEDIT_region_IROM2_start__ = 0x14000000;
|
||||||
|
define symbol __ICFEDIT_region_IROM2_end__ = 0x14007FFF;
|
||||||
|
|
||||||
|
/* The following symbols define device specific memory regions and must not be changed. */
|
||||||
|
/* Supervisory FLASH - User Data */
|
||||||
|
define symbol __ICFEDIT_region_IROM3_start__ = 0x16000800;
|
||||||
|
define symbol __ICFEDIT_region_IROM3_end__ = 0x160007FF;
|
||||||
|
|
||||||
|
/* Supervisory FLASH - Normal Access Restrictions (NAR) */
|
||||||
|
define symbol __ICFEDIT_region_IROM4_start__ = 0x16001A00;
|
||||||
|
define symbol __ICFEDIT_region_IROM4_end__ = 0x16001BFF;
|
||||||
|
|
||||||
|
/* Supervisory FLASH - Public Key */
|
||||||
|
define symbol __ICFEDIT_region_IROM5_start__ = 0x16005A00;
|
||||||
|
define symbol __ICFEDIT_region_IROM5_end__ = 0x160065FF;
|
||||||
|
|
||||||
|
/* Supervisory FLASH - Table of Content # 2 */
|
||||||
|
define symbol __ICFEDIT_region_IROM6_start__ = 0x16007C00;
|
||||||
|
define symbol __ICFEDIT_region_IROM6_end__ = 0x16007DFF;
|
||||||
|
|
||||||
|
/* Supervisory FLASH - Table of Content # 2 Copy */
|
||||||
|
define symbol __ICFEDIT_region_IROM7_start__ = 0x16007E00;
|
||||||
|
define symbol __ICFEDIT_region_IROM7_end__ = 0x16007FFF;
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
define symbol __ICFEDIT_region_IROM8_start__ = 0x90700000;
|
||||||
|
define symbol __ICFEDIT_region_IROM8_end__ = 0x907FFFFF;
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
define symbol __ICFEDIT_region_EROM1_start__ = 0x18000000;
|
||||||
|
define symbol __ICFEDIT_region_EROM1_end__ = 0x1FFFFFFF;
|
||||||
|
|
||||||
|
define symbol __ICFEDIT_region_EROM2_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_EROM2_end__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_EROM3_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_EROM3_end__ = 0x0;
|
||||||
|
|
||||||
|
|
||||||
|
define symbol __ICFEDIT_region_IRAM2_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_IRAM2_end__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM1_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM1_end__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM2_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM2_end__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM3_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM3_end__ = 0x0;
|
||||||
|
/*-Sizes-*/
|
||||||
|
if (!isdefinedsymbol(__STACK_SIZE)) {
|
||||||
|
define symbol __ICFEDIT_size_cstack__ = 0x1000;
|
||||||
|
} else {
|
||||||
|
define symbol __ICFEDIT_size_cstack__ = __STACK_SIZE;
|
||||||
|
}
|
||||||
|
define symbol __ICFEDIT_size_proc_stack__ = 0x0;
|
||||||
|
if (!isdefinedsymbol(__HEAP_SIZE)) {
|
||||||
|
define symbol __ICFEDIT_size_heap__ = 0x0400;
|
||||||
|
} else {
|
||||||
|
define symbol __ICFEDIT_size_heap__ = __HEAP_SIZE;
|
||||||
|
}
|
||||||
|
/**** End of ICF editor section. ###ICF###*/
|
||||||
|
|
||||||
|
|
||||||
|
define memory mem with size = 4G;
|
||||||
|
define region IROM1_region = mem:[from __ICFEDIT_region_IROM1_start__ to __ICFEDIT_region_IROM1_end__];
|
||||||
|
define region IROM2_region = mem:[from __ICFEDIT_region_IROM2_start__ to __ICFEDIT_region_IROM2_end__];
|
||||||
|
define region IROM3_region = mem:[from __ICFEDIT_region_IROM3_start__ to __ICFEDIT_region_IROM3_end__];
|
||||||
|
define region IROM4_region = mem:[from __ICFEDIT_region_IROM4_start__ to __ICFEDIT_region_IROM4_end__];
|
||||||
|
define region IROM5_region = mem:[from __ICFEDIT_region_IROM5_start__ to __ICFEDIT_region_IROM5_end__];
|
||||||
|
define region IROM6_region = mem:[from __ICFEDIT_region_IROM6_start__ to __ICFEDIT_region_IROM6_end__];
|
||||||
|
define region IROM7_region = mem:[from __ICFEDIT_region_IROM7_start__ to __ICFEDIT_region_IROM7_end__];
|
||||||
|
define region IROM8_region = mem:[from __ICFEDIT_region_IROM8_start__ to __ICFEDIT_region_IROM8_end__];
|
||||||
|
define region EROM1_region = mem:[from __ICFEDIT_region_EROM1_start__ to __ICFEDIT_region_EROM1_end__];
|
||||||
|
define region IRAM1_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__];
|
||||||
|
|
||||||
|
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||||
|
define block PROC_STACK with alignment = 8, size = __ICFEDIT_size_proc_stack__ { };
|
||||||
|
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||||
|
define block HSTACK {block HEAP, block PROC_STACK, last block CSTACK};
|
||||||
|
define block RO {first section .intvec, readonly};
|
||||||
|
|
||||||
|
/*-Initializations-*/
|
||||||
|
initialize by copy { readwrite };
|
||||||
|
do not initialize { section .noinit, section .intvec_ram };
|
||||||
|
|
||||||
|
|
||||||
|
/*-Placement-*/
|
||||||
|
|
||||||
|
/* Flash */
|
||||||
|
".cy_app_header" : place at start of IROM1_region { section .cy_app_header };
|
||||||
|
place in IROM1_region { block RO };
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
".cy_em_eeprom" : place at start of IROM2_region { section .cy_em_eeprom };
|
||||||
|
|
||||||
|
/* Supervisory Flash - User Data */
|
||||||
|
".cy_sflash_user_data" : place at start of IROM3_region { section .cy_sflash_user_data };
|
||||||
|
|
||||||
|
/* Supervisory Flash - NAR */
|
||||||
|
".cy_sflash_nar" : place at start of IROM4_region { section .cy_sflash_nar };
|
||||||
|
|
||||||
|
/* Supervisory Flash - Public Key */
|
||||||
|
".cy_sflash_public_key" : place at start of IROM5_region { section .cy_sflash_public_key };
|
||||||
|
|
||||||
|
/* Supervisory Flash - TOC2 */
|
||||||
|
".cy_toc_part2" : place at start of IROM6_region { section .cy_toc_part2 };
|
||||||
|
|
||||||
|
/* Supervisory Flash - RTOC2 */
|
||||||
|
".cy_rtoc_part2" : place at start of IROM7_region { section .cy_rtoc_part2 };
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
".cy_efuse" : place at start of IROM8_region { section .cy_efuse };
|
||||||
|
|
||||||
|
/* Execute in Place (XIP). See the smif driver documentation for details. */
|
||||||
|
".cy_xip" : place at start of EROM1_region { section .cy_xip };
|
||||||
|
|
||||||
|
/* RAM */
|
||||||
|
place at start of IRAM1_region { readwrite section .intvec_ram};
|
||||||
|
place in IRAM1_region { readwrite };
|
||||||
|
place at end of IRAM1_region { block HSTACK };
|
||||||
|
|
||||||
|
/* These sections are used for additional metadata (silicon revision, Silicon/JTAG ID, etc.) storage. */
|
||||||
|
".cymeta" : place at address mem : 0x90500000 { readonly section .cymeta };
|
||||||
|
|
||||||
|
|
||||||
|
keep { section .cy_app_header,
|
||||||
|
section .cy_em_eeprom,
|
||||||
|
section .cy_sflash_user_data,
|
||||||
|
section .cy_sflash_nar,
|
||||||
|
section .cy_sflash_public_key,
|
||||||
|
section .cy_toc_part2,
|
||||||
|
section .cy_rtoc_part2,
|
||||||
|
section .cy_efuse,
|
||||||
|
section .cy_xip,
|
||||||
|
section .cymeta,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* The following symbols used by the cymcuelftool. */
|
||||||
|
/* Flash */
|
||||||
|
define exported symbol __cy_memory_0_start = 0x10000000;
|
||||||
|
define exported symbol __cy_memory_0_length = 0x00100000;
|
||||||
|
define exported symbol __cy_memory_0_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
define exported symbol __cy_memory_1_start = 0x14000000;
|
||||||
|
define exported symbol __cy_memory_1_length = 0x8000;
|
||||||
|
define exported symbol __cy_memory_1_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
define exported symbol __cy_memory_2_start = 0x16000000;
|
||||||
|
define exported symbol __cy_memory_2_length = 0x8000;
|
||||||
|
define exported symbol __cy_memory_2_row_size = 0x200;
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
define exported symbol __cy_memory_3_start = 0x18000000;
|
||||||
|
define exported symbol __cy_memory_3_length = 0x08000000;
|
||||||
|
define exported symbol __cy_memory_3_row_size = 0x200;
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
define exported symbol __cy_memory_4_start = 0x90700000;
|
||||||
|
define exported symbol __cy_memory_4_length = 0x100000;
|
||||||
|
define exported symbol __cy_memory_4_row_size = 1;
|
||||||
|
|
||||||
|
/* EOF */
|
402
2020TPCApp0.cydsn/cy8c6xx7_cm0plus.ld
Normal file
402
2020TPCApp0.cydsn/cy8c6xx7_cm0plus.ld
Normal file
|
@ -0,0 +1,402 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file cy8c6xx7_cm0plus.ld
|
||||||
|
* \version 2.20
|
||||||
|
*
|
||||||
|
* Linker file for the GNU C compiler.
|
||||||
|
*
|
||||||
|
* The main purpose of the linker script is to describe how the sections in the
|
||||||
|
* input files should be mapped into the output file, and to control the memory
|
||||||
|
* layout of the output file.
|
||||||
|
*
|
||||||
|
* \note The entry point location is fixed and starts at 0x10000000. The valid
|
||||||
|
* application image should be placed there.
|
||||||
|
*
|
||||||
|
* \note The linker files included with the PDL template projects must be generic
|
||||||
|
* and handle all common use cases. Your project may not use every section
|
||||||
|
* defined in the linker files. In that case you may see warnings during the
|
||||||
|
* build process. In your project, you can simply comment out or remove the
|
||||||
|
* relevant code in the linker file.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||||
|
SEARCH_DIR(.)
|
||||||
|
GROUP(-lgcc -lc -lnosys)
|
||||||
|
ENTRY(Reset_Handler)
|
||||||
|
|
||||||
|
|
||||||
|
/* Force symbol to be entered in the output file as an undefined symbol. Doing
|
||||||
|
* this may, for example, trigger linking of additional modules from standard
|
||||||
|
* libraries. You may list several symbols for each EXTERN, and you may use
|
||||||
|
* EXTERN multiple times. This command has the same effect as the -u command-line
|
||||||
|
* option.
|
||||||
|
*/
|
||||||
|
EXTERN(Reset_Handler)
|
||||||
|
|
||||||
|
/* The MEMORY section below describes the location and size of blocks of memory in the target.
|
||||||
|
* Use this section to specify the memory regions available for allocation.
|
||||||
|
*/
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
/* The ram and flash regions control RAM and flash memory allocation for the CM0+ core.
|
||||||
|
* You can change the memory allocation by editing the 'ram' and 'flash' regions.
|
||||||
|
* Your changes must be aligned with the corresponding memory regions for the CM4 core in 'xx_cm4_dual.ld',
|
||||||
|
* where 'xx' is the device group; for example, 'cy8c6xx7_cm4_dual.ld'.
|
||||||
|
*/
|
||||||
|
ram (rwx) : ORIGIN = 0x08000000, LENGTH = 0x24000
|
||||||
|
flash (rx) : ORIGIN = 0x10000000, LENGTH = 0x80000
|
||||||
|
|
||||||
|
/* This is a 32K flash region used for EEPROM emulation. This region can also be used as the general purpose flash.
|
||||||
|
* You can assign sections to this memory region for only one of the cores.
|
||||||
|
* Note some middleware (e.g. BLE, Emulated EEPROM) can place their data into this memory region.
|
||||||
|
* Therefore, repurposing this memory region will prevent such middleware from operation.
|
||||||
|
*/
|
||||||
|
em_eeprom (rx) : ORIGIN = 0x14000000, LENGTH = 0x8000 /* 32 KB */
|
||||||
|
|
||||||
|
/* The following regions define device specific memory regions and must not be changed. */
|
||||||
|
sflash_user_data (rx) : ORIGIN = 0x16000800, LENGTH = 0x800 /* Supervisory flash: User data */
|
||||||
|
sflash_nar (rx) : ORIGIN = 0x16001A00, LENGTH = 0x200 /* Supervisory flash: Normal Access Restrictions (NAR) */
|
||||||
|
sflash_public_key (rx) : ORIGIN = 0x16005A00, LENGTH = 0xC00 /* Supervisory flash: Public Key */
|
||||||
|
sflash_toc_2 (rx) : ORIGIN = 0x16007C00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 */
|
||||||
|
sflash_rtoc_2 (rx) : ORIGIN = 0x16007E00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 Copy */
|
||||||
|
xip (rx) : ORIGIN = 0x18000000, LENGTH = 0x8000000 /* 128 MB */
|
||||||
|
efuse (r) : ORIGIN = 0x90700000, LENGTH = 0x100000 /* 1 MB */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Library configurations */
|
||||||
|
GROUP(libgcc.a libc.a libm.a libnosys.a)
|
||||||
|
|
||||||
|
/* Linker script to place sections and symbol values. Should be used together
|
||||||
|
* with other linker script that defines memory regions FLASH and RAM.
|
||||||
|
* It references following symbols, which must be defined in code:
|
||||||
|
* Reset_Handler : Entry of reset handler
|
||||||
|
*
|
||||||
|
* It defines following symbols, which code can use without definition:
|
||||||
|
* __exidx_start
|
||||||
|
* __exidx_end
|
||||||
|
* __copy_table_start__
|
||||||
|
* __copy_table_end__
|
||||||
|
* __zero_table_start__
|
||||||
|
* __zero_table_end__
|
||||||
|
* __etext
|
||||||
|
* __data_start__
|
||||||
|
* __preinit_array_start
|
||||||
|
* __preinit_array_end
|
||||||
|
* __init_array_start
|
||||||
|
* __init_array_end
|
||||||
|
* __fini_array_start
|
||||||
|
* __fini_array_end
|
||||||
|
* __data_end__
|
||||||
|
* __bss_start__
|
||||||
|
* __bss_end__
|
||||||
|
* __end__
|
||||||
|
* end
|
||||||
|
* __HeapLimit
|
||||||
|
* __StackLimit
|
||||||
|
* __StackTop
|
||||||
|
* __stack
|
||||||
|
* __Vectors_End
|
||||||
|
* __Vectors_Size
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.cy_app_header :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_app_header))
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__Vectors = . ;
|
||||||
|
KEEP(*(.vectors))
|
||||||
|
. = ALIGN(4);
|
||||||
|
__Vectors_End = .;
|
||||||
|
__Vectors_Size = __Vectors_End - __Vectors;
|
||||||
|
__end__ = .;
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(.text*)
|
||||||
|
|
||||||
|
KEEP(*(.init))
|
||||||
|
KEEP(*(.fini))
|
||||||
|
|
||||||
|
/* .ctors */
|
||||||
|
*crtbegin.o(.ctors)
|
||||||
|
*crtbegin?.o(.ctors)
|
||||||
|
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||||
|
*(SORT(.ctors.*))
|
||||||
|
*(.ctors)
|
||||||
|
|
||||||
|
/* .dtors */
|
||||||
|
*crtbegin.o(.dtors)
|
||||||
|
*crtbegin?.o(.dtors)
|
||||||
|
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||||
|
*(SORT(.dtors.*))
|
||||||
|
*(.dtors)
|
||||||
|
|
||||||
|
/* Read-only code (constants). */
|
||||||
|
*(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*)
|
||||||
|
|
||||||
|
KEEP(*(.eh_frame*))
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
|
||||||
|
.ARM.extab :
|
||||||
|
{
|
||||||
|
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
__exidx_start = .;
|
||||||
|
|
||||||
|
.ARM.exidx :
|
||||||
|
{
|
||||||
|
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||||
|
} > flash
|
||||||
|
__exidx_end = .;
|
||||||
|
|
||||||
|
|
||||||
|
/* To copy multiple ROM to RAM sections,
|
||||||
|
* uncomment .copy.table section and,
|
||||||
|
* define __STARTUP_COPY_MULTIPLE in startup_psoc6_01_cm0plus.S */
|
||||||
|
.copy.table :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__copy_table_start__ = .;
|
||||||
|
|
||||||
|
/* Copy interrupt vectors from flash to RAM */
|
||||||
|
LONG (__Vectors) /* From */
|
||||||
|
LONG (__ram_vectors_start__) /* To */
|
||||||
|
LONG (__Vectors_End - __Vectors) /* Size */
|
||||||
|
|
||||||
|
/* Copy data section to RAM */
|
||||||
|
LONG (__etext) /* From */
|
||||||
|
LONG (__data_start__) /* To */
|
||||||
|
LONG (__data_end__ - __data_start__) /* Size */
|
||||||
|
|
||||||
|
__copy_table_end__ = .;
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
|
||||||
|
/* To clear multiple BSS sections,
|
||||||
|
* uncomment .zero.table section and,
|
||||||
|
* define __STARTUP_CLEAR_BSS_MULTIPLE in startup_psoc6_01_cm0plus.S */
|
||||||
|
.zero.table :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__zero_table_start__ = .;
|
||||||
|
LONG (__bss_start__)
|
||||||
|
LONG (__bss_end__ - __bss_start__)
|
||||||
|
__zero_table_end__ = .;
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
__etext = . ;
|
||||||
|
|
||||||
|
|
||||||
|
.ramVectors (NOLOAD) : ALIGN(8)
|
||||||
|
{
|
||||||
|
__ram_vectors_start__ = .;
|
||||||
|
KEEP(*(.ram_vectors))
|
||||||
|
__ram_vectors_end__ = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
.data __ram_vectors_end__ : AT (__etext)
|
||||||
|
{
|
||||||
|
__data_start__ = .;
|
||||||
|
|
||||||
|
*(vtable)
|
||||||
|
*(.data*)
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* preinit data */
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||||
|
KEEP(*(.preinit_array))
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* init data */
|
||||||
|
PROVIDE_HIDDEN (__init_array_start = .);
|
||||||
|
KEEP(*(SORT(.init_array.*)))
|
||||||
|
KEEP(*(.init_array))
|
||||||
|
PROVIDE_HIDDEN (__init_array_end = .);
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* finit data */
|
||||||
|
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||||
|
KEEP(*(SORT(.fini_array.*)))
|
||||||
|
KEEP(*(.fini_array))
|
||||||
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||||
|
|
||||||
|
KEEP(*(.jcr*))
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
KEEP(*(.cy_ramfunc*))
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
__data_end__ = .;
|
||||||
|
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* Place variables in the section that should not be initialized during the
|
||||||
|
* device startup.
|
||||||
|
*/
|
||||||
|
.noinit (NOLOAD) : ALIGN(8)
|
||||||
|
{
|
||||||
|
KEEP(*(.noinit))
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* The uninitialized global or static variables are placed in this section.
|
||||||
|
*
|
||||||
|
* The NOLOAD attribute tells linker that .bss section does not consume
|
||||||
|
* any space in the image. The NOLOAD attribute changes the .bss type to
|
||||||
|
* NOBITS, and that makes linker to A) not allocate section in memory, and
|
||||||
|
* A) put information to clear the section with all zeros during application
|
||||||
|
* loading.
|
||||||
|
*
|
||||||
|
* Without the NOLOAD attribute, the .bss section might get PROGBITS type.
|
||||||
|
* This makes linker to A) allocate zeroed section in memory, and B) copy
|
||||||
|
* this section to RAM during application loading.
|
||||||
|
*/
|
||||||
|
.bss (NOLOAD):
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__bss_start__ = .;
|
||||||
|
*(.bss*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(4);
|
||||||
|
__bss_end__ = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
.heap (NOLOAD):
|
||||||
|
{
|
||||||
|
__HeapBase = .;
|
||||||
|
__end__ = .;
|
||||||
|
end = __end__;
|
||||||
|
KEEP(*(.heap*))
|
||||||
|
__HeapLimit = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||||
|
* used for linker to calculate size of stack sections, and assign
|
||||||
|
* values to stack symbols later */
|
||||||
|
.stack_dummy (NOLOAD):
|
||||||
|
{
|
||||||
|
KEEP(*(.stack*))
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* Set stack top to end of RAM, and stack limit move down by
|
||||||
|
* size of stack_dummy section */
|
||||||
|
__StackTop = ORIGIN(ram) + LENGTH(ram);
|
||||||
|
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||||
|
PROVIDE(__stack = __StackTop);
|
||||||
|
|
||||||
|
/* Check if data + heap + stack exceeds RAM limit */
|
||||||
|
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||||
|
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
.cy_em_eeprom :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_em_eeprom))
|
||||||
|
} > em_eeprom
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: User data */
|
||||||
|
.cy_sflash_user_data :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_user_data))
|
||||||
|
} > sflash_user_data
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Normal Access Restrictions (NAR) */
|
||||||
|
.cy_sflash_nar :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_nar))
|
||||||
|
} > sflash_nar
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Public Key */
|
||||||
|
.cy_sflash_public_key :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_public_key))
|
||||||
|
} > sflash_public_key
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Table of Content # 2 */
|
||||||
|
.cy_toc_part2 :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_toc_part2))
|
||||||
|
} > sflash_toc_2
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Table of Content # 2 Copy */
|
||||||
|
.cy_rtoc_part2 :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_rtoc_part2))
|
||||||
|
} > sflash_rtoc_2
|
||||||
|
|
||||||
|
|
||||||
|
/* Places the code in the Execute in Place (XIP) section. See the smif driver
|
||||||
|
* documentation for details.
|
||||||
|
*/
|
||||||
|
.cy_xip :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_xip))
|
||||||
|
} > xip
|
||||||
|
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
.cy_efuse :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_efuse))
|
||||||
|
} > efuse
|
||||||
|
|
||||||
|
|
||||||
|
/* These sections are used for additional metadata (silicon revision,
|
||||||
|
* Silicon/JTAG ID, etc.) storage.
|
||||||
|
*/
|
||||||
|
.cymeta 0x90500000 : { KEEP(*(.cymeta)) } :NONE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* The following symbols used by the cymcuelftool. */
|
||||||
|
/* Flash */
|
||||||
|
__cy_memory_0_start = 0x10000000;
|
||||||
|
__cy_memory_0_length = 0x00100000;
|
||||||
|
__cy_memory_0_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
__cy_memory_1_start = 0x14000000;
|
||||||
|
__cy_memory_1_length = 0x8000;
|
||||||
|
__cy_memory_1_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
__cy_memory_2_start = 0x16000000;
|
||||||
|
__cy_memory_2_length = 0x8000;
|
||||||
|
__cy_memory_2_row_size = 0x200;
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
__cy_memory_3_start = 0x18000000;
|
||||||
|
__cy_memory_3_length = 0x08000000;
|
||||||
|
__cy_memory_3_row_size = 0x200;
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
__cy_memory_4_start = 0x90700000;
|
||||||
|
__cy_memory_4_length = 0x100000;
|
||||||
|
__cy_memory_4_row_size = 1;
|
||||||
|
|
||||||
|
/* EOF */
|
207
2020TPCApp0.cydsn/cy8c6xx7_cm0plus.scat
Normal file
207
2020TPCApp0.cydsn/cy8c6xx7_cm0plus.scat
Normal file
|
@ -0,0 +1,207 @@
|
||||||
|
#! armcc -E
|
||||||
|
; The first line specifies a preprocessor command that the linker invokes
|
||||||
|
; to pass a scatter file through a C preprocessor.
|
||||||
|
|
||||||
|
;*******************************************************************************
|
||||||
|
;* \file cy8c6xx7_cm0plus.scat
|
||||||
|
;* \version 2.20
|
||||||
|
;*
|
||||||
|
;* Linker file for the ARMCC.
|
||||||
|
;*
|
||||||
|
;* The main purpose of the linker script is to describe how the sections in the
|
||||||
|
;* input files should be mapped into the output file, and to control the memory
|
||||||
|
;* layout of the output file.
|
||||||
|
;*
|
||||||
|
;* \note The entry point location is fixed and starts at 0x10000000. The valid
|
||||||
|
;* application image should be placed there.
|
||||||
|
;*
|
||||||
|
;* \note The linker files included with the PDL template projects must be
|
||||||
|
;* generic and handle all common use cases. Your project may not use every
|
||||||
|
;* section defined in the linker files. In that case you may see the warnings
|
||||||
|
;* during the build process: L6314W (no section matches pattern) and/or L6329W
|
||||||
|
;* (pattern only matches removed unused sections). In your project, you can
|
||||||
|
;* suppress the warning by passing the "--diag_suppress=L6314W,L6329W" option to
|
||||||
|
;* the linker, simply comment out or remove the relevant code in the linker
|
||||||
|
;* file.
|
||||||
|
;*
|
||||||
|
;*******************************************************************************
|
||||||
|
;* \copyright
|
||||||
|
;* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
;* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
;* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
;* the software package with which this file was provided.
|
||||||
|
;******************************************************************************/
|
||||||
|
|
||||||
|
; The defines below describe the location and size of blocks of memory in the target.
|
||||||
|
; Use these defines to specify the memory regions available for allocation.
|
||||||
|
|
||||||
|
; The following defines control RAM and flash memory allocation for the CM0+ core.
|
||||||
|
; You can change the memory allocation by editing the RAM and Flash defines.
|
||||||
|
; Your changes must be aligned with the corresponding defines for the CM4 core in 'xx_cm4_dual.scat',
|
||||||
|
; where 'xx' is the device group; for example, 'cy8c6xx7_cm4_dual.scat'.
|
||||||
|
; RAM
|
||||||
|
#define RAM_START 0x08000000
|
||||||
|
#define RAM_SIZE 0x00024000
|
||||||
|
; Flash
|
||||||
|
#define FLASH_START 0x10000000
|
||||||
|
#define FLASH_SIZE 0x00080000
|
||||||
|
|
||||||
|
; The following defines describe a 32K flash region used for EEPROM emulation.
|
||||||
|
; This region can also be used as the general purpose flash.
|
||||||
|
; You can assign sections to this memory region for only one of the cores.
|
||||||
|
; Note some middleware (e.g. BLE, Emulated EEPROM) can place their data into this memory region.
|
||||||
|
; Therefore, repurposing this memory region will prevent such middleware from operation.
|
||||||
|
#define EM_EEPROM_START 0x14000000
|
||||||
|
#define EM_EEPROM_SIZE 0x8000
|
||||||
|
|
||||||
|
; The following defines describe device specific memory regions and must not be changed.
|
||||||
|
; Supervisory flash: User data
|
||||||
|
#define SFLASH_USER_DATA_START 0x16000800
|
||||||
|
#define SFLASH_USER_DATA_SIZE 0x00000800
|
||||||
|
|
||||||
|
; Supervisory flash: Normal Access Restrictions (NAR)
|
||||||
|
#define SFLASH_NAR_START 0x16001A00
|
||||||
|
#define SFLASH_NAR_SIZE 0x00000200
|
||||||
|
|
||||||
|
; Supervisory flash: Public Key
|
||||||
|
#define SFLASH_PUBLIC_KEY_START 0x16005A00
|
||||||
|
#define SFLASH_PUBLIC_KEY_SIZE 0x00000C00
|
||||||
|
|
||||||
|
; Supervisory flash: Table of Content # 2
|
||||||
|
#define SFLASH_TOC_2_START 0x16007C00
|
||||||
|
#define SFLASH_TOC_2_SIZE 0x00000200
|
||||||
|
|
||||||
|
; Supervisory flash: Table of Content # 2 Copy
|
||||||
|
#define SFLASH_RTOC_2_START 0x16007E00
|
||||||
|
#define SFLASH_RTOC_2_SIZE 0x00000200
|
||||||
|
|
||||||
|
; External memory
|
||||||
|
#define XIP_START 0x18000000
|
||||||
|
#define XIP_SIZE 0x08000000
|
||||||
|
|
||||||
|
; eFuse
|
||||||
|
#define EFUSE_START 0x90700000
|
||||||
|
#define EFUSE_SIZE 0x100000
|
||||||
|
|
||||||
|
|
||||||
|
LR_FLASH FLASH_START FLASH_SIZE
|
||||||
|
{
|
||||||
|
.cy_app_header +0
|
||||||
|
{
|
||||||
|
* (.cy_app_header)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_FLASH_VECTORS +0
|
||||||
|
{
|
||||||
|
* (RESET, +FIRST)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_FLASH_CODE +0 FIXED
|
||||||
|
{
|
||||||
|
* (InRoot$$Sections)
|
||||||
|
* (+RO)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_RAM_VECTORS RAM_START UNINIT
|
||||||
|
{
|
||||||
|
* (RESET_RAM, +FIRST)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_RAM_DATA +0
|
||||||
|
{
|
||||||
|
* (.cy_ramfunc)
|
||||||
|
.ANY (+RW, +ZI)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Place variables in the section that should not be initialized during the
|
||||||
|
; device startup.
|
||||||
|
ER_RAM_NOINIT_DATA +0 UNINIT
|
||||||
|
{
|
||||||
|
* (.noinit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; Emulated EEPROM Flash area
|
||||||
|
LR_EM_EEPROM EM_EEPROM_START EM_EEPROM_SIZE
|
||||||
|
{
|
||||||
|
.cy_em_eeprom +0
|
||||||
|
{
|
||||||
|
* (.cy_em_eeprom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: User data
|
||||||
|
LR_SFLASH_USER_DATA SFLASH_USER_DATA_START SFLASH_USER_DATA_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_user_data +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_user_data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: Normal Access Restrictions (NAR)
|
||||||
|
LR_SFLASH_NAR SFLASH_NAR_START SFLASH_NAR_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_nar +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_nar)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: Public Key
|
||||||
|
LR_SFLASH_PUBLIC_KEY SFLASH_PUBLIC_KEY_START SFLASH_PUBLIC_KEY_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_public_key +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_public_key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: Table of Content # 2
|
||||||
|
LR_SFLASH_TOC_2 SFLASH_TOC_2_START SFLASH_TOC_2_SIZE
|
||||||
|
{
|
||||||
|
.cy_toc_part2 +0
|
||||||
|
{
|
||||||
|
* (.cy_toc_part2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: Table of Content # 2 Copy
|
||||||
|
LR_SFLASH_RTOC_2 SFLASH_RTOC_2_START SFLASH_RTOC_2_SIZE
|
||||||
|
{
|
||||||
|
.cy_rtoc_part2 +0
|
||||||
|
{
|
||||||
|
* (.cy_rtoc_part2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; Places the code in the Execute in Place (XIP) section. See the smif driver documentation for details.
|
||||||
|
LR_EROM XIP_START XIP_SIZE
|
||||||
|
{
|
||||||
|
.cy_xip +0
|
||||||
|
{
|
||||||
|
* (.cy_xip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; eFuse
|
||||||
|
LR_EFUSE EFUSE_START EFUSE_SIZE
|
||||||
|
{
|
||||||
|
.cy_efuse +0
|
||||||
|
{
|
||||||
|
* (.cy_efuse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; The section is used for additional metadata (silicon revision, Silicon/JTAG ID, etc.) storage.
|
||||||
|
CYMETA 0x90500000
|
||||||
|
{
|
||||||
|
.cymeta +0 { * (.cymeta) }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
219
2020TPCApp0.cydsn/cy8c6xx7_cm4_dual.icf
Normal file
219
2020TPCApp0.cydsn/cy8c6xx7_cm4_dual.icf
Normal file
|
@ -0,0 +1,219 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file cy8c6xx7_cm4_dual.icf
|
||||||
|
* \version 2.20
|
||||||
|
*
|
||||||
|
* Linker file for the IAR compiler.
|
||||||
|
*
|
||||||
|
* The main purpose of the linker script is to describe how the sections in the
|
||||||
|
* input files should be mapped into the output file, and to control the memory
|
||||||
|
* layout of the output file.
|
||||||
|
*
|
||||||
|
* \note The entry point is fixed and starts at 0x10000000. The valid application
|
||||||
|
* image should be placed there.
|
||||||
|
*
|
||||||
|
* \note The linker files included with the PDL template projects must be generic
|
||||||
|
* and handle all common use cases. Your project may not use every section
|
||||||
|
* defined in the linker files. In that case you may see warnings during the
|
||||||
|
* build process. In your project, you can simply comment out or remove the
|
||||||
|
* relevant code in the linker file.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||||
|
/*-Editor annotation file-*/
|
||||||
|
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_4.xml" */
|
||||||
|
/*-Specials-*/
|
||||||
|
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
|
||||||
|
|
||||||
|
/* The symbols below define the location and size of blocks of memory in the target.
|
||||||
|
* Use these symbols to specify the memory regions available for allocation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The following symbols control RAM and flash memory allocation for the CM4 core.
|
||||||
|
* You can change the memory allocation by editing RAM and Flash symbols.
|
||||||
|
* Note that 2 KB of RAM (at the end of the RAM section) are reserved for system use.
|
||||||
|
* Using this memory region for other purposes will lead to unexpected behavior.
|
||||||
|
* Your changes must be aligned with the corresponding symbols for CM0+ core in 'xx_cm0plus.icf',
|
||||||
|
* where 'xx' is the device group; for example, 'cy8c6xx7_cm0plus.icf'.
|
||||||
|
*/
|
||||||
|
/* RAM */
|
||||||
|
define symbol __ICFEDIT_region_IRAM1_start__ = 0x08024000;
|
||||||
|
define symbol __ICFEDIT_region_IRAM1_end__ = 0x08047800;
|
||||||
|
/* Flash */
|
||||||
|
define symbol __ICFEDIT_region_IROM1_start__ = 0x10080000;
|
||||||
|
define symbol __ICFEDIT_region_IROM1_end__ = 0x10100000;
|
||||||
|
|
||||||
|
/* The following symbols define a 32K flash region used for EEPROM emulation.
|
||||||
|
* This region can also be used as the general purpose flash.
|
||||||
|
* You can assign sections to this memory region for only one of the cores.
|
||||||
|
* Note some middleware (e.g. BLE, Emulated EEPROM) can place their data into this memory region.
|
||||||
|
* Therefore, repurposing this memory region will prevent such middleware from operation.
|
||||||
|
*/
|
||||||
|
define symbol __ICFEDIT_region_IROM2_start__ = 0x14000000;
|
||||||
|
define symbol __ICFEDIT_region_IROM2_end__ = 0x14007FFF;
|
||||||
|
|
||||||
|
/* The following symbols define device specific memory regions and must not be changed. */
|
||||||
|
/* Supervisory FLASH - User Data */
|
||||||
|
define symbol __ICFEDIT_region_IROM3_start__ = 0x16000800;
|
||||||
|
define symbol __ICFEDIT_region_IROM3_end__ = 0x160007FF;
|
||||||
|
|
||||||
|
/* Supervisory FLASH - Normal Access Restrictions (NAR) */
|
||||||
|
define symbol __ICFEDIT_region_IROM4_start__ = 0x16001A00;
|
||||||
|
define symbol __ICFEDIT_region_IROM4_end__ = 0x16001BFF;
|
||||||
|
|
||||||
|
/* Supervisory FLASH - Public Key */
|
||||||
|
define symbol __ICFEDIT_region_IROM5_start__ = 0x16005A00;
|
||||||
|
define symbol __ICFEDIT_region_IROM5_end__ = 0x160065FF;
|
||||||
|
|
||||||
|
/* Supervisory FLASH - Table of Content # 2 */
|
||||||
|
define symbol __ICFEDIT_region_IROM6_start__ = 0x16007C00;
|
||||||
|
define symbol __ICFEDIT_region_IROM6_end__ = 0x16007DFF;
|
||||||
|
|
||||||
|
/* Supervisory FLASH - Table of Content # 2 Copy */
|
||||||
|
define symbol __ICFEDIT_region_IROM7_start__ = 0x16007E00;
|
||||||
|
define symbol __ICFEDIT_region_IROM7_end__ = 0x16007FFF;
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
define symbol __ICFEDIT_region_IROM8_start__ = 0x90700000;
|
||||||
|
define symbol __ICFEDIT_region_IROM8_end__ = 0x907FFFFF;
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
define symbol __ICFEDIT_region_EROM1_start__ = 0x18000000;
|
||||||
|
define symbol __ICFEDIT_region_EROM1_end__ = 0x1FFFFFFF;
|
||||||
|
|
||||||
|
define symbol __ICFEDIT_region_EROM2_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_EROM2_end__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_EROM3_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_EROM3_end__ = 0x0;
|
||||||
|
|
||||||
|
|
||||||
|
define symbol __ICFEDIT_region_IRAM2_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_IRAM2_end__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM1_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM1_end__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM2_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM2_end__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM3_start__ = 0x0;
|
||||||
|
define symbol __ICFEDIT_region_ERAM3_end__ = 0x0;
|
||||||
|
/*-Sizes-*/
|
||||||
|
if (!isdefinedsymbol(__STACK_SIZE)) {
|
||||||
|
define symbol __ICFEDIT_size_cstack__ = 0x1000;
|
||||||
|
} else {
|
||||||
|
define symbol __ICFEDIT_size_cstack__ = __STACK_SIZE;
|
||||||
|
}
|
||||||
|
define symbol __ICFEDIT_size_proc_stack__ = 0x0;
|
||||||
|
if (!isdefinedsymbol(__HEAP_SIZE)) {
|
||||||
|
define symbol __ICFEDIT_size_heap__ = 0x0400;
|
||||||
|
} else {
|
||||||
|
define symbol __ICFEDIT_size_heap__ = __HEAP_SIZE;
|
||||||
|
}
|
||||||
|
/**** End of ICF editor section. ###ICF###*/
|
||||||
|
|
||||||
|
define memory mem with size = 4G;
|
||||||
|
define region IROM1_region = mem:[from __ICFEDIT_region_IROM1_start__ to __ICFEDIT_region_IROM1_end__];
|
||||||
|
define region IROM2_region = mem:[from __ICFEDIT_region_IROM2_start__ to __ICFEDIT_region_IROM2_end__];
|
||||||
|
define region IROM3_region = mem:[from __ICFEDIT_region_IROM3_start__ to __ICFEDIT_region_IROM3_end__];
|
||||||
|
define region IROM4_region = mem:[from __ICFEDIT_region_IROM4_start__ to __ICFEDIT_region_IROM4_end__];
|
||||||
|
define region IROM5_region = mem:[from __ICFEDIT_region_IROM5_start__ to __ICFEDIT_region_IROM5_end__];
|
||||||
|
define region IROM6_region = mem:[from __ICFEDIT_region_IROM6_start__ to __ICFEDIT_region_IROM6_end__];
|
||||||
|
define region IROM7_region = mem:[from __ICFEDIT_region_IROM7_start__ to __ICFEDIT_region_IROM7_end__];
|
||||||
|
define region IROM8_region = mem:[from __ICFEDIT_region_IROM8_start__ to __ICFEDIT_region_IROM8_end__];
|
||||||
|
define region EROM1_region = mem:[from __ICFEDIT_region_EROM1_start__ to __ICFEDIT_region_EROM1_end__];
|
||||||
|
define region IRAM1_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__];
|
||||||
|
|
||||||
|
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||||
|
define block PROC_STACK with alignment = 8, size = __ICFEDIT_size_proc_stack__ { };
|
||||||
|
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||||
|
define block HSTACK {block HEAP, block PROC_STACK, last block CSTACK};
|
||||||
|
define block RO {first section .intvec, readonly};
|
||||||
|
|
||||||
|
/*-Initializations-*/
|
||||||
|
initialize by copy { readwrite };
|
||||||
|
do not initialize { section .noinit, section .intvec_ram };
|
||||||
|
|
||||||
|
|
||||||
|
/*-Placement-*/
|
||||||
|
|
||||||
|
/* Flash */
|
||||||
|
place at start of IROM1_region { block RO };
|
||||||
|
".cy_app_signature" : place at address (__ICFEDIT_region_IROM1_end__ - 0x200) { section .cy_app_signature };
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
".cy_em_eeprom" : place at start of IROM2_region { section .cy_em_eeprom };
|
||||||
|
|
||||||
|
/* Supervisory Flash - User Data */
|
||||||
|
".cy_sflash_user_data" : place at start of IROM3_region { section .cy_sflash_user_data };
|
||||||
|
|
||||||
|
/* Supervisory Flash - NAR */
|
||||||
|
".cy_sflash_nar" : place at start of IROM4_region { section .cy_sflash_nar };
|
||||||
|
|
||||||
|
/* Supervisory Flash - Public Key */
|
||||||
|
".cy_sflash_public_key" : place at start of IROM5_region { section .cy_sflash_public_key };
|
||||||
|
|
||||||
|
/* Supervisory Flash - TOC2 */
|
||||||
|
".cy_toc_part2" : place at start of IROM6_region { section .cy_toc_part2 };
|
||||||
|
|
||||||
|
/* Supervisory Flash - RTOC2 */
|
||||||
|
".cy_rtoc_part2" : place at start of IROM7_region { section .cy_rtoc_part2 };
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
".cy_efuse" : place at start of IROM8_region { section .cy_efuse };
|
||||||
|
|
||||||
|
/* Execute in Place (XIP). See the smif driver documentation for details. */
|
||||||
|
".cy_xip" : place at start of EROM1_region { section .cy_xip };
|
||||||
|
|
||||||
|
/* RAM */
|
||||||
|
place at start of IRAM1_region { readwrite section .intvec_ram};
|
||||||
|
place in IRAM1_region { readwrite };
|
||||||
|
place at end of IRAM1_region { block HSTACK };
|
||||||
|
|
||||||
|
/* These sections are used for additional metadata (silicon revision, Silicon/JTAG ID, etc.) storage. */
|
||||||
|
".cymeta" : place at address mem : 0x90500000 { readonly section .cymeta };
|
||||||
|
|
||||||
|
|
||||||
|
keep { section .cy_app_signature,
|
||||||
|
section .cy_em_eeprom,
|
||||||
|
section .cy_sflash_user_data,
|
||||||
|
section .cy_sflash_nar,
|
||||||
|
section .cy_sflash_public_key,
|
||||||
|
section .cy_toc_part2,
|
||||||
|
section .cy_rtoc_part2,
|
||||||
|
section .cy_efuse,
|
||||||
|
section .cy_xip,
|
||||||
|
section .cymeta,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* The following symbols used by the cymcuelftool. */
|
||||||
|
/* Flash */
|
||||||
|
define exported symbol __cy_memory_0_start = 0x10000000;
|
||||||
|
define exported symbol __cy_memory_0_length = 0x00100000;
|
||||||
|
define exported symbol __cy_memory_0_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
define exported symbol __cy_memory_1_start = 0x14000000;
|
||||||
|
define exported symbol __cy_memory_1_length = 0x8000;
|
||||||
|
define exported symbol __cy_memory_1_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
define exported symbol __cy_memory_2_start = 0x16000000;
|
||||||
|
define exported symbol __cy_memory_2_length = 0x8000;
|
||||||
|
define exported symbol __cy_memory_2_row_size = 0x200;
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
define exported symbol __cy_memory_3_start = 0x18000000;
|
||||||
|
define exported symbol __cy_memory_3_length = 0x08000000;
|
||||||
|
define exported symbol __cy_memory_3_row_size = 0x200;
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
define exported symbol __cy_memory_4_start = 0x90700000;
|
||||||
|
define exported symbol __cy_memory_4_length = 0x100000;
|
||||||
|
define exported symbol __cy_memory_4_row_size = 1;
|
||||||
|
|
||||||
|
/* EOF */
|
408
2020TPCApp0.cydsn/cy8c6xx7_cm4_dual.ld
Normal file
408
2020TPCApp0.cydsn/cy8c6xx7_cm4_dual.ld
Normal file
|
@ -0,0 +1,408 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file cy8c6xx7_cm4_dual.ld
|
||||||
|
* \version 2.20
|
||||||
|
*
|
||||||
|
* Linker file for the GNU C compiler.
|
||||||
|
*
|
||||||
|
* The main purpose of the linker script is to describe how the sections in the
|
||||||
|
* input files should be mapped into the output file, and to control the memory
|
||||||
|
* layout of the output file.
|
||||||
|
*
|
||||||
|
* \note The entry point location is fixed and starts at 0x10000000. The valid
|
||||||
|
* application image should be placed there.
|
||||||
|
*
|
||||||
|
* \note The linker files included with the PDL template projects must be generic
|
||||||
|
* and handle all common use cases. Your project may not use every section
|
||||||
|
* defined in the linker files. In that case you may see warnings during the
|
||||||
|
* build process. In your project, you can simply comment out or remove the
|
||||||
|
* relevant code in the linker file.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||||
|
SEARCH_DIR(.)
|
||||||
|
GROUP(-lgcc -lc -lnosys)
|
||||||
|
ENTRY(Reset_Handler)
|
||||||
|
|
||||||
|
|
||||||
|
/* Force symbol to be entered in the output file as an undefined symbol. Doing
|
||||||
|
* this may, for example, trigger linking of additional modules from standard
|
||||||
|
* libraries. You may list several symbols for each EXTERN, and you may use
|
||||||
|
* EXTERN multiple times. This command has the same effect as the -u command-line
|
||||||
|
* option.
|
||||||
|
*/
|
||||||
|
EXTERN(Reset_Handler)
|
||||||
|
|
||||||
|
/* The MEMORY section below describes the location and size of blocks of memory in the target.
|
||||||
|
* Use this section to specify the memory regions available for allocation.
|
||||||
|
*/
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
/* The ram and flash regions control RAM and flash memory allocation for the CM4 core.
|
||||||
|
* You can change the memory allocation by editing the 'ram' and 'flash' regions.
|
||||||
|
* Note that 2 KB of RAM (at the end of the RAM section) are reserved for system use.
|
||||||
|
* Using this memory region for other purposes will lead to unexpected behavior.
|
||||||
|
* Your changes must be aligned with the corresponding memory regions for CM0+ core in 'xx_cm0plus.ld',
|
||||||
|
* where 'xx' is the device group; for example, 'cy8c6xx7_cm0plus.ld'.
|
||||||
|
*/
|
||||||
|
ram (rwx) : ORIGIN = 0x08024000, LENGTH = 0x23800
|
||||||
|
flash (rx) : ORIGIN = 0x10080000, LENGTH = 0x80000
|
||||||
|
|
||||||
|
/* This is a 32K flash region used for EEPROM emulation. This region can also be used as the general purpose flash.
|
||||||
|
* You can assign sections to this memory region for only one of the cores.
|
||||||
|
* Note some middleware (e.g. BLE, Emulated EEPROM) can place their data into this memory region.
|
||||||
|
* Therefore, repurposing this memory region will prevent such middleware from operation.
|
||||||
|
*/
|
||||||
|
em_eeprom (rx) : ORIGIN = 0x14000000, LENGTH = 0x8000 /* 32 KB */
|
||||||
|
|
||||||
|
/* The following regions define device specific memory regions and must not be changed. */
|
||||||
|
sflash_user_data (rx) : ORIGIN = 0x16000800, LENGTH = 0x800 /* Supervisory flash: User data */
|
||||||
|
sflash_nar (rx) : ORIGIN = 0x16001A00, LENGTH = 0x200 /* Supervisory flash: Normal Access Restrictions (NAR) */
|
||||||
|
sflash_public_key (rx) : ORIGIN = 0x16005A00, LENGTH = 0xC00 /* Supervisory flash: Public Key */
|
||||||
|
sflash_toc_2 (rx) : ORIGIN = 0x16007C00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 */
|
||||||
|
sflash_rtoc_2 (rx) : ORIGIN = 0x16007E00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 Copy */
|
||||||
|
xip (rx) : ORIGIN = 0x18000000, LENGTH = 0x8000000 /* 128 MB */
|
||||||
|
efuse (r) : ORIGIN = 0x90700000, LENGTH = 0x100000 /* 1 MB */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Library configurations */
|
||||||
|
GROUP(libgcc.a libc.a libm.a libnosys.a)
|
||||||
|
|
||||||
|
/* Linker script to place sections and symbol values. Should be used together
|
||||||
|
* with other linker script that defines memory regions FLASH and RAM.
|
||||||
|
* It references following symbols, which must be defined in code:
|
||||||
|
* Reset_Handler : Entry of reset handler
|
||||||
|
*
|
||||||
|
* It defines following symbols, which code can use without definition:
|
||||||
|
* __exidx_start
|
||||||
|
* __exidx_end
|
||||||
|
* __copy_table_start__
|
||||||
|
* __copy_table_end__
|
||||||
|
* __zero_table_start__
|
||||||
|
* __zero_table_end__
|
||||||
|
* __etext
|
||||||
|
* __data_start__
|
||||||
|
* __preinit_array_start
|
||||||
|
* __preinit_array_end
|
||||||
|
* __init_array_start
|
||||||
|
* __init_array_end
|
||||||
|
* __fini_array_start
|
||||||
|
* __fini_array_end
|
||||||
|
* __data_end__
|
||||||
|
* __bss_start__
|
||||||
|
* __bss_end__
|
||||||
|
* __end__
|
||||||
|
* end
|
||||||
|
* __HeapLimit
|
||||||
|
* __StackLimit
|
||||||
|
* __StackTop
|
||||||
|
* __stack
|
||||||
|
* __Vectors_End
|
||||||
|
* __Vectors_Size
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__Vectors = . ;
|
||||||
|
KEEP(*(.vectors))
|
||||||
|
. = ALIGN(4);
|
||||||
|
__Vectors_End = .;
|
||||||
|
__Vectors_Size = __Vectors_End - __Vectors;
|
||||||
|
__end__ = .;
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(.text*)
|
||||||
|
|
||||||
|
KEEP(*(.init))
|
||||||
|
KEEP(*(.fini))
|
||||||
|
|
||||||
|
/* .ctors */
|
||||||
|
*crtbegin.o(.ctors)
|
||||||
|
*crtbegin?.o(.ctors)
|
||||||
|
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||||
|
*(SORT(.ctors.*))
|
||||||
|
*(.ctors)
|
||||||
|
|
||||||
|
/* .dtors */
|
||||||
|
*crtbegin.o(.dtors)
|
||||||
|
*crtbegin?.o(.dtors)
|
||||||
|
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||||
|
*(SORT(.dtors.*))
|
||||||
|
*(.dtors)
|
||||||
|
|
||||||
|
/* Read-only code (constants). */
|
||||||
|
*(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*)
|
||||||
|
|
||||||
|
KEEP(*(.eh_frame*))
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
|
||||||
|
.ARM.extab :
|
||||||
|
{
|
||||||
|
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
__exidx_start = .;
|
||||||
|
|
||||||
|
.ARM.exidx :
|
||||||
|
{
|
||||||
|
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||||
|
} > flash
|
||||||
|
__exidx_end = .;
|
||||||
|
|
||||||
|
|
||||||
|
/* To copy multiple ROM to RAM sections,
|
||||||
|
* uncomment .copy.table section and,
|
||||||
|
* define __STARTUP_COPY_MULTIPLE in startup_psoc6_01_cm4.S */
|
||||||
|
.copy.table :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__copy_table_start__ = .;
|
||||||
|
|
||||||
|
/* Copy interrupt vectors from flash to RAM */
|
||||||
|
LONG (__Vectors) /* From */
|
||||||
|
LONG (__ram_vectors_start__) /* To */
|
||||||
|
LONG (__Vectors_End - __Vectors) /* Size */
|
||||||
|
|
||||||
|
/* Copy data section to RAM */
|
||||||
|
LONG (__etext) /* From */
|
||||||
|
LONG (__data_start__) /* To */
|
||||||
|
LONG (__data_end__ - __data_start__) /* Size */
|
||||||
|
|
||||||
|
__copy_table_end__ = .;
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
|
||||||
|
/* To clear multiple BSS sections,
|
||||||
|
* uncomment .zero.table section and,
|
||||||
|
* define __STARTUP_CLEAR_BSS_MULTIPLE in startup_psoc6_01_cm4.S */
|
||||||
|
.zero.table :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__zero_table_start__ = .;
|
||||||
|
LONG (__bss_start__)
|
||||||
|
LONG (__bss_end__ - __bss_start__)
|
||||||
|
__zero_table_end__ = .;
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
__etext = . ;
|
||||||
|
|
||||||
|
|
||||||
|
.ramVectors (NOLOAD) : ALIGN(8)
|
||||||
|
{
|
||||||
|
__ram_vectors_start__ = .;
|
||||||
|
KEEP(*(.ram_vectors))
|
||||||
|
__ram_vectors_end__ = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
.data __ram_vectors_end__ : AT (__etext)
|
||||||
|
{
|
||||||
|
__data_start__ = .;
|
||||||
|
|
||||||
|
*(vtable)
|
||||||
|
*(.data*)
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* preinit data */
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||||
|
KEEP(*(.preinit_array))
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* init data */
|
||||||
|
PROVIDE_HIDDEN (__init_array_start = .);
|
||||||
|
KEEP(*(SORT(.init_array.*)))
|
||||||
|
KEEP(*(.init_array))
|
||||||
|
PROVIDE_HIDDEN (__init_array_end = .);
|
||||||
|
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* finit data */
|
||||||
|
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||||
|
KEEP(*(SORT(.fini_array.*)))
|
||||||
|
KEEP(*(.fini_array))
|
||||||
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||||
|
|
||||||
|
KEEP(*(.jcr*))
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
KEEP(*(.cy_ramfunc*))
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
__data_end__ = .;
|
||||||
|
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* Place variables in the section that should not be initialized during the
|
||||||
|
* device startup.
|
||||||
|
*/
|
||||||
|
.noinit (NOLOAD) : ALIGN(8)
|
||||||
|
{
|
||||||
|
KEEP(*(.noinit))
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* The uninitialized global or static variables are placed in this section.
|
||||||
|
*
|
||||||
|
* The NOLOAD attribute tells linker that .bss section does not consume
|
||||||
|
* any space in the image. The NOLOAD attribute changes the .bss type to
|
||||||
|
* NOBITS, and that makes linker to A) not allocate section in memory, and
|
||||||
|
* A) put information to clear the section with all zeros during application
|
||||||
|
* loading.
|
||||||
|
*
|
||||||
|
* Without the NOLOAD attribute, the .bss section might get PROGBITS type.
|
||||||
|
* This makes linker to A) allocate zeroed section in memory, and B) copy
|
||||||
|
* this section to RAM during application loading.
|
||||||
|
*/
|
||||||
|
.bss (NOLOAD):
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__bss_start__ = .;
|
||||||
|
*(.bss*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(4);
|
||||||
|
__bss_end__ = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
.heap (NOLOAD):
|
||||||
|
{
|
||||||
|
__HeapBase = .;
|
||||||
|
__end__ = .;
|
||||||
|
end = __end__;
|
||||||
|
KEEP(*(.heap*))
|
||||||
|
__HeapLimit = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||||
|
* used for linker to calculate size of stack sections, and assign
|
||||||
|
* values to stack symbols later */
|
||||||
|
.stack_dummy (NOLOAD):
|
||||||
|
{
|
||||||
|
KEEP(*(.stack*))
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* Set stack top to end of RAM, and stack limit move down by
|
||||||
|
* size of stack_dummy section */
|
||||||
|
__StackTop = ORIGIN(ram) + LENGTH(ram);
|
||||||
|
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||||
|
PROVIDE(__stack = __StackTop);
|
||||||
|
|
||||||
|
/* Check if data + heap + stack exceeds RAM limit */
|
||||||
|
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||||
|
|
||||||
|
|
||||||
|
/* Used for the digital signature of the secure application and the Bootloader SDK application.
|
||||||
|
* The size of the section depends on the required data size. */
|
||||||
|
.cy_app_signature ORIGIN(flash) + LENGTH(flash) - 256 :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_app_signature))
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
.cy_em_eeprom :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_em_eeprom))
|
||||||
|
} > em_eeprom
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: User data */
|
||||||
|
.cy_sflash_user_data :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_user_data))
|
||||||
|
} > sflash_user_data
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Normal Access Restrictions (NAR) */
|
||||||
|
.cy_sflash_nar :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_nar))
|
||||||
|
} > sflash_nar
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Public Key */
|
||||||
|
.cy_sflash_public_key :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_public_key))
|
||||||
|
} > sflash_public_key
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Table of Content # 2 */
|
||||||
|
.cy_toc_part2 :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_toc_part2))
|
||||||
|
} > sflash_toc_2
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Table of Content # 2 Copy */
|
||||||
|
.cy_rtoc_part2 :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_rtoc_part2))
|
||||||
|
} > sflash_rtoc_2
|
||||||
|
|
||||||
|
|
||||||
|
/* Places the code in the Execute in Place (XIP) section. See the smif driver
|
||||||
|
* documentation for details.
|
||||||
|
*/
|
||||||
|
.cy_xip :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_xip))
|
||||||
|
} > xip
|
||||||
|
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
.cy_efuse :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_efuse))
|
||||||
|
} > efuse
|
||||||
|
|
||||||
|
|
||||||
|
/* These sections are used for additional metadata (silicon revision,
|
||||||
|
* Silicon/JTAG ID, etc.) storage.
|
||||||
|
*/
|
||||||
|
.cymeta 0x90500000 : { KEEP(*(.cymeta)) } :NONE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* The following symbols used by the cymcuelftool. */
|
||||||
|
/* Flash */
|
||||||
|
__cy_memory_0_start = 0x10000000;
|
||||||
|
__cy_memory_0_length = 0x00100000;
|
||||||
|
__cy_memory_0_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
__cy_memory_1_start = 0x14000000;
|
||||||
|
__cy_memory_1_length = 0x8000;
|
||||||
|
__cy_memory_1_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
__cy_memory_2_start = 0x16000000;
|
||||||
|
__cy_memory_2_length = 0x8000;
|
||||||
|
__cy_memory_2_row_size = 0x200;
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
__cy_memory_3_start = 0x18000000;
|
||||||
|
__cy_memory_3_length = 0x08000000;
|
||||||
|
__cy_memory_3_row_size = 0x200;
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
__cy_memory_4_start = 0x90700000;
|
||||||
|
__cy_memory_4_length = 0x100000;
|
||||||
|
__cy_memory_4_row_size = 1;
|
||||||
|
|
||||||
|
/* EOF */
|
213
2020TPCApp0.cydsn/cy8c6xx7_cm4_dual.scat
Normal file
213
2020TPCApp0.cydsn/cy8c6xx7_cm4_dual.scat
Normal file
|
@ -0,0 +1,213 @@
|
||||||
|
#! armcc -E
|
||||||
|
; The first line specifies a preprocessor command that the linker invokes
|
||||||
|
; to pass a scatter file through a C preprocessor.
|
||||||
|
|
||||||
|
;*******************************************************************************
|
||||||
|
;* \file cy8c6xx7_cm4_dual.scat
|
||||||
|
;* \version 2.20
|
||||||
|
;*
|
||||||
|
;* Linker file for the ARMCC.
|
||||||
|
;*
|
||||||
|
;* The main purpose of the linker script is to describe how the sections in the
|
||||||
|
;* input files should be mapped into the output file, and to control the memory
|
||||||
|
;* layout of the output file.
|
||||||
|
;*
|
||||||
|
;* \note The entry point location is fixed and starts at 0x10000000. The valid
|
||||||
|
;* application image should be placed there.
|
||||||
|
;*
|
||||||
|
;* \note The linker files included with the PDL template projects must be
|
||||||
|
;* generic and handle all common use cases. Your project may not use every
|
||||||
|
;* section defined in the linker files. In that case you may see the warnings
|
||||||
|
;* during the build process: L6314W (no section matches pattern) and/or L6329W
|
||||||
|
;* (pattern only matches removed unused sections). In your project, you can
|
||||||
|
;* suppress the warning by passing the "--diag_suppress=L6314W,L6329W" option to
|
||||||
|
;* the linker, simply comment out or remove the relevant code in the linker
|
||||||
|
;* file.
|
||||||
|
;*
|
||||||
|
;*******************************************************************************
|
||||||
|
;* \copyright
|
||||||
|
;* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
;* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
;* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
;* the software package with which this file was provided.
|
||||||
|
;******************************************************************************/
|
||||||
|
|
||||||
|
; The defines below describe the location and size of blocks of memory in the target.
|
||||||
|
; Use these defines to specify the memory regions available for allocation.
|
||||||
|
|
||||||
|
; The following defines control RAM and flash memory allocation for the CM4 core.
|
||||||
|
; You can change the memory allocation by editing RAM and Flash defines.
|
||||||
|
; Note that 2 KB of RAM (at the end of the RAM section) are reserved for system use.
|
||||||
|
; Using this memory region for other purposes will lead to unexpected behavior.
|
||||||
|
; Your changes must be aligned with the corresponding defines for CM0+ core in 'xx_cm0plus.scat',
|
||||||
|
; where 'xx' is the device group; for example, 'cy8c6xx7_cm0plus.scat'.
|
||||||
|
; RAM
|
||||||
|
#define RAM_START 0x08024000
|
||||||
|
#define RAM_SIZE 0x00023800
|
||||||
|
; Flash
|
||||||
|
#define FLASH_START 0x10080000
|
||||||
|
#define FLASH_SIZE 0x00080000
|
||||||
|
|
||||||
|
; The following defines describe a 32K flash region used for EEPROM emulation.
|
||||||
|
; This region can also be used as the general purpose flash.
|
||||||
|
; You can assign sections to this memory region for only one of the cores.
|
||||||
|
; Note some middleware (e.g. BLE, Emulated EEPROM) can place their data into this memory region.
|
||||||
|
; Therefore, repurposing this memory region will prevent such middleware from operation.
|
||||||
|
#define EM_EEPROM_START 0x14000000
|
||||||
|
#define EM_EEPROM_SIZE 0x8000
|
||||||
|
|
||||||
|
; The following defines describe device specific memory regions and must not be changed.
|
||||||
|
; Supervisory flash: User data
|
||||||
|
#define SFLASH_USER_DATA_START 0x16000800
|
||||||
|
#define SFLASH_USER_DATA_SIZE 0x00000800
|
||||||
|
|
||||||
|
; Supervisory flash: Normal Access Restrictions (NAR)
|
||||||
|
#define SFLASH_NAR_START 0x16001A00
|
||||||
|
#define SFLASH_NAR_SIZE 0x00000200
|
||||||
|
|
||||||
|
; Supervisory flash: Public Key
|
||||||
|
#define SFLASH_PUBLIC_KEY_START 0x16005A00
|
||||||
|
#define SFLASH_PUBLIC_KEY_SIZE 0x00000C00
|
||||||
|
|
||||||
|
; Supervisory flash: Table of Content # 2
|
||||||
|
#define SFLASH_TOC_2_START 0x16007C00
|
||||||
|
#define SFLASH_TOC_2_SIZE 0x00000200
|
||||||
|
|
||||||
|
; Supervisory flash: Table of Content # 2 Copy
|
||||||
|
#define SFLASH_RTOC_2_START 0x16007E00
|
||||||
|
#define SFLASH_RTOC_2_SIZE 0x00000200
|
||||||
|
|
||||||
|
; External memory
|
||||||
|
#define XIP_START 0x18000000
|
||||||
|
#define XIP_SIZE 0x08000000
|
||||||
|
|
||||||
|
; eFuse
|
||||||
|
#define EFUSE_START 0x90700000
|
||||||
|
#define EFUSE_SIZE 0x100000
|
||||||
|
|
||||||
|
|
||||||
|
LR_FLASH FLASH_START FLASH_SIZE
|
||||||
|
{
|
||||||
|
ER_FLASH_VECTORS +0
|
||||||
|
{
|
||||||
|
* (RESET, +FIRST)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_FLASH_CODE +0 FIXED
|
||||||
|
{
|
||||||
|
* (InRoot$$Sections)
|
||||||
|
* (+RO)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_RAM_VECTORS RAM_START UNINIT
|
||||||
|
{
|
||||||
|
* (RESET_RAM, +FIRST)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_RAM_DATA +0
|
||||||
|
{
|
||||||
|
* (.cy_ramfunc)
|
||||||
|
.ANY (+RW, +ZI)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Place variables in the section that should not be initialized during the
|
||||||
|
; device startup.
|
||||||
|
ER_RAM_NOINIT_DATA +0 UNINIT
|
||||||
|
{
|
||||||
|
* (.noinit)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; Used for the digital signature of the secure application and the
|
||||||
|
; Bootloader SDK application. The size of the section depends on the required
|
||||||
|
; data size.
|
||||||
|
.cy_app_signature (FLASH_START + FLASH_SIZE - 256) 256
|
||||||
|
{
|
||||||
|
* (.cy_app_signature)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; Emulated EEPROM Flash area
|
||||||
|
LR_EM_EEPROM EM_EEPROM_START EM_EEPROM_SIZE
|
||||||
|
{
|
||||||
|
.cy_em_eeprom +0
|
||||||
|
{
|
||||||
|
* (.cy_em_eeprom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: User data
|
||||||
|
LR_SFLASH_USER_DATA SFLASH_USER_DATA_START SFLASH_USER_DATA_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_user_data +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_user_data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: Normal Access Restrictions (NAR)
|
||||||
|
LR_SFLASH_NAR SFLASH_NAR_START SFLASH_NAR_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_nar +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_nar)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: Public Key
|
||||||
|
LR_SFLASH_PUBLIC_KEY SFLASH_PUBLIC_KEY_START SFLASH_PUBLIC_KEY_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_public_key +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_public_key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: Table of Content # 2
|
||||||
|
LR_SFLASH_TOC_2 SFLASH_TOC_2_START SFLASH_TOC_2_SIZE
|
||||||
|
{
|
||||||
|
.cy_toc_part2 +0
|
||||||
|
{
|
||||||
|
* (.cy_toc_part2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: Table of Content # 2 Copy
|
||||||
|
LR_SFLASH_RTOC_2 SFLASH_RTOC_2_START SFLASH_RTOC_2_SIZE
|
||||||
|
{
|
||||||
|
.cy_rtoc_part2 +0
|
||||||
|
{
|
||||||
|
* (.cy_rtoc_part2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; Places the code in the Execute in Place (XIP) section. See the smif driver documentation for details.
|
||||||
|
LR_EROM XIP_START XIP_SIZE
|
||||||
|
{
|
||||||
|
.cy_xip +0
|
||||||
|
{
|
||||||
|
* (.cy_xip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; eFuse
|
||||||
|
LR_EFUSE EFUSE_START EFUSE_SIZE
|
||||||
|
{
|
||||||
|
.cy_efuse +0
|
||||||
|
{
|
||||||
|
* (.cy_efuse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; The section is used for additional metadata (silicon revision, Silicon/JTAG ID, etc.) storage.
|
||||||
|
CYMETA 0x90500000
|
||||||
|
{
|
||||||
|
.cymeta +0 { * (.cymeta) }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
66
2020TPCApp0.cydsn/cy_ble_config.h
Normal file
66
2020TPCApp0.cydsn/cy_ble_config.h
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file cy_ble_config.h
|
||||||
|
* \version 2.80
|
||||||
|
*
|
||||||
|
* \brief
|
||||||
|
* The user BLE configuration file. Allows redefining the configuration #define(s)
|
||||||
|
* generated by the BLE customizer.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2017-2023, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CY_BLE_CONF_H
|
||||||
|
#define CY_BLE_CONF_H
|
||||||
|
|
||||||
|
#include "ble/cy_ble_defines.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The BLE_config.h file is generated by the BLE customizer and includes all common
|
||||||
|
* configuration defines (CY_BLE_CONFIG_***).
|
||||||
|
*/
|
||||||
|
#include "BLE_config.h"
|
||||||
|
|
||||||
|
#include <cy_device_headers.h>
|
||||||
|
#ifndef CY_IP_MXBLESS
|
||||||
|
#error "The BLE middleware is not supported on this device"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The BLE Interrupt Notification Feature - Exposes BLE interrupt notifications
|
||||||
|
* to an application that indicates a different link layer and radio state
|
||||||
|
* transition to the user from the BLESS interrupt context.
|
||||||
|
* This callback is triggered at the beginning of a received BLESS interrupt
|
||||||
|
* (based on the registered interrupt mask). After this feature is enabled,
|
||||||
|
* the following APIs are available:
|
||||||
|
* Cy_BLE_RegisterInterruptCallback() and Cy_BLE_UnRegisterInterruptCallback().
|
||||||
|
*
|
||||||
|
* The valid value: 1u - enable / 0u - disable.
|
||||||
|
*
|
||||||
|
* BLE Dual mode requires an additional define IPC channel and IPC Interrupt
|
||||||
|
* structure to send notification from the controller core to host core.
|
||||||
|
* Use the following defines:
|
||||||
|
* #define CY_BLE_INTR_NOTIFY_IPC_CHAN (9..15)
|
||||||
|
* #define CY_BLE_INTR_NOTIFY_IPC_INTR (9..15)
|
||||||
|
* #define CY_BLE_INTR_NOTIFY_IPC_INTR_PRIOR (0..7)
|
||||||
|
*/
|
||||||
|
#define CY_BLE_INTR_NOTIFY_FEATURE_ENABLE (0u)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To redefine the config #define(s) generated by the BLE customizer,
|
||||||
|
* use the construction #undef... #define.
|
||||||
|
*
|
||||||
|
* #undef CY_BLE_CONFIG_ENABLE_LL_PRIVACY
|
||||||
|
* #define CY_BLE_CONFIG_ENABLE_LL_PRIVACY (1u)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !defined(CY_BLE_CONF_H)*/
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
131
2020TPCApp0.cydsn/cy_si_config.h
Normal file
131
2020TPCApp0.cydsn/cy_si_config.h
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file cy_si_config.h
|
||||||
|
* \version 1.0.1
|
||||||
|
*
|
||||||
|
* \brief
|
||||||
|
* Definitions for Secure Image.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2017-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _CY_SI_CONFIG_H_
|
||||||
|
#define _CY_SI_CONFIG_H_
|
||||||
|
|
||||||
|
#include "cy_si_keystorage.h"
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Macros
|
||||||
|
***************************************/
|
||||||
|
/*
|
||||||
|
* Macros to define the secure image version and ID.
|
||||||
|
*/
|
||||||
|
#define CY_SI_VERSION_MAJOR 1UL /**< Major version */
|
||||||
|
#define CY_SI_VERSION_MINOR 0UL /**< Minor version */
|
||||||
|
#define CY_SI_APP_VERSION ((CY_SI_VERSION_MAJOR << 24u) | (CY_SI_VERSION_MINOR << 16u)) /**< App Version */
|
||||||
|
#define CY_SI_ID CY_PDL_DRV_ID(0x38u) /**< Secure Image ID */
|
||||||
|
#define CY_SI_ID_INFO (uint32_t)( CY_SI_ID | CY_PDL_STATUS_INFO ) /**< Secure Image INFO ID */
|
||||||
|
#define CY_SI_ID_WARNING (uint32_t)( CY_SI_ID | CY_PDL_STATUS_WARNING) /**< Secure Image WARNING ID */
|
||||||
|
#define CY_SI_ID_ERROR (uint32_t)( CY_SI_ID | CY_PDL_STATUS_ERROR) /**< Secure Image ERROR ID */
|
||||||
|
#define CY_SI_CHECKID(val) ((uint32_t)(val) & (CY_PDL_MODULE_ID_Msk << CY_PDL_MODULE_ID_Pos)) /**< Check ID macro */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clock selection for Flash boot execution.
|
||||||
|
*/
|
||||||
|
#define CY_SI_FLASHBOOT_CLK_25MHZ (0x00UL) /**< 25MHz clock selection for Flashboot */
|
||||||
|
#define CY_SI_FLASHBOOT_CLK_8MHZ (0x01UL) /**< 8MHz clock selection for Flashboot */
|
||||||
|
#define CY_SI_FLASHBOOT_CLK_50MHZ (0x02UL) /**< 50MHz clock selection for Flashboot */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Debugger wait window selection for Flash boot execution.
|
||||||
|
*/
|
||||||
|
#define CY_SI_FLASHBOOT_WAIT_20MS (0x00UL) /**< 20ms debugger wait window for Flashboot */
|
||||||
|
#define CY_SI_FLASHBOOT_WAIT_10MS (0x01UL) /**< 10ms debugger wait window for Flashboot */
|
||||||
|
#define CY_SI_FLASHBOOT_WAIT_1MS (0x02UL) /**< 1ms debugger wait window for Flashboot */
|
||||||
|
#define CY_SI_FLASHBOOT_WAIT_0MS (0x03UL) /**< 0ms debugger wait window for Flashboot */
|
||||||
|
#define CY_SI_FLASHBOOT_WAIT_100MS (0x04UL) /**< 100ms debugger wait window for Flashboot */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Flash boot validation selection in chip NORMAL mode.
|
||||||
|
*/
|
||||||
|
#define CY_SI_FLASHBOOT_VALIDATE_NO (0x00UL) /**< Do not validate app1 in NORMAL mode */
|
||||||
|
#define CY_SI_FLASHBOOT_VALIDATE_YES (0x01UL) /**< Validate app1 in NORMAL mode */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Application format selection for secure boot.
|
||||||
|
*/
|
||||||
|
#define CY_SI_APP_FORMAT_BASIC (0UL) /**< Basic application format (no header) */
|
||||||
|
#define CY_SI_APP_FORMAT_CYPRESS (1UL) /**< Cypress application format (Cypress header) */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Application type selection for secure boot.
|
||||||
|
*/
|
||||||
|
#define CY_SI_APP_ID_FLASHBOOT (0x8001UL) /**< Flash boot ID Type */
|
||||||
|
#define CY_SI_APP_ID_SECUREIMG (0x8002UL) /**< Secure image ID Type */
|
||||||
|
#define CY_SI_APP_ID_BOOTLOADER (0x8003UL) /**< Bootloader ID Type */
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Constants
|
||||||
|
***************************************/
|
||||||
|
#define CY_ARM_CM0P_CPUID (0xC6000000u) /** CM0+ partNo value from ARM CPUID[15:4] register shifted to [31:20] bits */
|
||||||
|
#define CY_ARM_CM4_CPUID (0xC2400000u) /** CM4 partNo value from ARM CPUID[15:4] register shifted to [31:20] bits */
|
||||||
|
|
||||||
|
#define CY_SI_TOC_FLAGS_CLOCKS_MASK (0x00000003UL) /**< Mask for Flashboot clock selection */
|
||||||
|
#define CY_SI_TOC_FLAGS_CLOCKS_POS (0UL) /**< Bit position of Flashboot clock selection */
|
||||||
|
#define CY_SI_TOC_FLAGS_DELAY_MASK (0x0000001CUL) /**< Mask for Flashboot wait window selection */
|
||||||
|
#define CY_SI_TOC_FLAGS_DELAY_POS (2UL) /**< Bit position of Flashboot wait window selection */
|
||||||
|
#define CY_SI_TOC_FLAGS_APP_VERIFY_MASK (0x80000000UL) /**< Mask for Flashboot NORMAL mode app1 validation */
|
||||||
|
#define CY_SI_TOC_FLAGS_APP_VERIFY_POS (31UL) /**< Bit position of Flashboot NORMAL mode app1 validation */
|
||||||
|
|
||||||
|
#define CY_SI_TOC2_MAGICNUMBER (0x01211220UL) /**< TOC2 identifier */
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Structs
|
||||||
|
***************************************/
|
||||||
|
/** Table of Content structure */
|
||||||
|
typedef struct{
|
||||||
|
volatile uint32_t objSize; /**< Object size (Bytes) */
|
||||||
|
volatile uint32_t magicNum; /**< TOC ID (magic number) */
|
||||||
|
volatile uint32_t userKeyAddr; /**< Secure key address in user Flash */
|
||||||
|
volatile uint32_t smifCfgAddr; /**< SMIF configuration structure */
|
||||||
|
volatile uint32_t appAddr1; /**< First user application object address */
|
||||||
|
volatile uint32_t appFormat1; /**< First user application format */
|
||||||
|
volatile uint32_t appAddr2; /**< Second user application object address */
|
||||||
|
volatile uint32_t appFormat2; /**< Second user application format */
|
||||||
|
volatile uint32_t shashObj; /**< Number of additional objects to be verified (S-HASH) */
|
||||||
|
volatile uint32_t sigKeyAddr; /**< Signature verification key address */
|
||||||
|
volatile uint32_t addObj[116]; /**< Additional objects to include in S-HASH */
|
||||||
|
volatile uint32_t tocFlags; /**< Flags in TOC to control Flash boot options */
|
||||||
|
volatile uint32_t crc; /**< CRC16-CCITT */
|
||||||
|
}cy_stc_si_toc_t;
|
||||||
|
|
||||||
|
/** User application header in Cypress format */
|
||||||
|
typedef struct{
|
||||||
|
volatile uint32_t objSize; /**< Object size (Bytes) */
|
||||||
|
volatile uint32_t appId; /**< Application ID/version */
|
||||||
|
volatile uint32_t appAttributes; /**< Attributes (reserved for future use) */
|
||||||
|
volatile uint32_t numCores; /**< Number of cores */
|
||||||
|
volatile uint32_t core0Vt; /**< (CM0+)VT offset - offset to the vector table from that entry */
|
||||||
|
volatile uint32_t core1Vt; /**< (CM4)VT offset - offset to the vector table from that entry */
|
||||||
|
volatile uint32_t core0Id; /**< CM0+ core ID */
|
||||||
|
volatile uint32_t core1Id; /**< CM4 core ID */
|
||||||
|
}cy_stc_user_appheader_t;
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _CY_SI_CONFIG_H_ */
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
198
2020TPCApp0.cydsn/cy_si_keystorage.c
Normal file
198
2020TPCApp0.cydsn/cy_si_keystorage.c
Normal file
|
@ -0,0 +1,198 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file cy_si_keystorage.c
|
||||||
|
* \version 1.00
|
||||||
|
*
|
||||||
|
* \brief
|
||||||
|
* Secure key storage for the secure image.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2017-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "cy_si_keystorage.h"
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Secure Key Storage (Note: Ensure that the alignment matches the Protection unit configuration) */
|
||||||
|
CY_ALIGN(1024) __USED const uint8_t CySecureKeyStorage[CY_SI_SECURE_KEY_ARRAY_SIZE][CY_SI_SECURE_KEY_LENGTH] = {
|
||||||
|
{0x00u}, /* Insert user key #1 values */
|
||||||
|
{0x00u}, /* Insert user key #2 values */
|
||||||
|
{0x00u}, /* Insert user key #3 values */
|
||||||
|
{0x00u} /* Insert user key #4 values */
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Public key in SFlash */
|
||||||
|
CY_SECTION(".cy_sflash_public_key") __USED const cy_si_stc_public_key_t cy_publicKey =
|
||||||
|
{
|
||||||
|
.objSize = sizeof(cy_si_stc_public_key_t),
|
||||||
|
.signatureScheme = CY_SI_PUBLIC_KEY_RSA_2048,
|
||||||
|
.publicKeyStruct =
|
||||||
|
{
|
||||||
|
.moduloAddr = (uint32_t)&(SFLASH->PUBLIC_KEY) + offsetof(cy_si_stc_public_key_t, moduloData),
|
||||||
|
.moduloSize = CY_SI_PUBLIC_KEY_SIZEOF_BYTE * CY_SI_PUBLIC_KEY_MODULOLENGTH,
|
||||||
|
.expAddr = (uint32_t)&(SFLASH->PUBLIC_KEY) + offsetof(cy_si_stc_public_key_t, expData),
|
||||||
|
.expSize = CY_SI_PUBLIC_KEY_SIZEOF_BYTE * CY_SI_PUBLIC_KEY_EXPLENGTH,
|
||||||
|
.barrettAddr = (uint32_t)&(SFLASH->PUBLIC_KEY) + offsetof(cy_si_stc_public_key_t, barrettData),
|
||||||
|
.inverseModuloAddr = (uint32_t)&(SFLASH->PUBLIC_KEY) + offsetof(cy_si_stc_public_key_t, inverseModuloData),
|
||||||
|
.rBarAddr = (uint32_t)&(SFLASH->PUBLIC_KEY) + offsetof(cy_si_stc_public_key_t, rBarData),
|
||||||
|
},
|
||||||
|
/* Replace key data from this point */
|
||||||
|
.moduloData =
|
||||||
|
{
|
||||||
|
0x0Du, 0x10u, 0x58u, 0x3Fu, 0x4Fu, 0x25u, 0x70u, 0x63u,
|
||||||
|
0x6Du, 0x3Bu, 0xE6u, 0x10u, 0x9Eu, 0x7Cu, 0x7Cu, 0x9Cu,
|
||||||
|
0x02u, 0x8Bu, 0x43u, 0x07u, 0x61u, 0x91u, 0xF6u, 0xBFu,
|
||||||
|
0x12u, 0x7Cu, 0x2Bu, 0xDAu, 0x45u, 0xD5u, 0x75u, 0xBEu,
|
||||||
|
0xB5u, 0xF1u, 0xBDu, 0x36u, 0x3Au, 0xC1u, 0xD1u, 0x39u,
|
||||||
|
0x20u, 0x11u, 0x99u, 0x22u, 0x2Fu, 0xE8u, 0xFEu, 0x98u,
|
||||||
|
0xFBu, 0xCDu, 0x34u, 0xD4u, 0xE2u, 0x2Cu, 0xC5u, 0x7Cu,
|
||||||
|
0xC5u, 0x50u, 0x62u, 0xFFu, 0xFDu, 0x61u, 0x14u, 0x90u,
|
||||||
|
0xFAu, 0x43u, 0xBDu, 0xADu, 0xA3u, 0xD5u, 0x86u, 0x85u,
|
||||||
|
0x4Du, 0xF1u, 0x24u, 0x62u, 0x5Au, 0xECu, 0x87u, 0x4Du,
|
||||||
|
0xD0u, 0x18u, 0xB0u, 0xE1u, 0x4Fu, 0x40u, 0xDEu, 0x87u,
|
||||||
|
0xBBu, 0x74u, 0xC5u, 0x5Du, 0x48u, 0x90u, 0x26u, 0x68u,
|
||||||
|
0x5Cu, 0xECu, 0xC3u, 0x5Cu, 0xC7u, 0x03u, 0x8Au, 0x05u,
|
||||||
|
0x2Eu, 0x37u, 0xB8u, 0xA0u, 0x05u, 0xC5u, 0x21u, 0x0Fu,
|
||||||
|
0x76u, 0x9Cu, 0xEEu, 0x19u, 0x4Cu, 0x2Eu, 0x89u, 0xA2u,
|
||||||
|
0x21u, 0x44u, 0x61u, 0x9Fu, 0x7Fu, 0xD2u, 0x51u, 0x72u,
|
||||||
|
0xABu, 0x2Cu, 0xA5u, 0xC6u, 0x7Cu, 0x0Au, 0x9Bu, 0x06u,
|
||||||
|
0x14u, 0xECu, 0x91u, 0x3Du, 0x5Eu, 0x08u, 0x71u, 0x6Au,
|
||||||
|
0xFEu, 0xABu, 0x3Eu, 0x1Bu, 0x99u, 0x3Cu, 0xF0u, 0x12u,
|
||||||
|
0x57u, 0x0Cu, 0xF2u, 0x42u, 0x78u, 0xA5u, 0x3Bu, 0xAAu,
|
||||||
|
0x49u, 0x98u, 0x03u, 0x8Eu, 0x0Fu, 0x5Au, 0xC9u, 0xFCu,
|
||||||
|
0x26u, 0xC9u, 0x93u, 0xB8u, 0xB8u, 0xEBu, 0x6Fu, 0xF1u,
|
||||||
|
0x65u, 0x78u, 0x43u, 0x0Au, 0xE5u, 0xFBu, 0x2Bu, 0xCCu,
|
||||||
|
0x8Bu, 0x2Cu, 0x31u, 0x0Du, 0xE1u, 0x49u, 0x06u, 0x25u,
|
||||||
|
0xE3u, 0xFAu, 0x92u, 0x7Fu, 0xC7u, 0x96u, 0x35u, 0x17u,
|
||||||
|
0x2Cu, 0xEEu, 0xEEu, 0x40u, 0xC1u, 0x18u, 0x1Cu, 0x5Cu,
|
||||||
|
0x45u, 0x4Du, 0xE9u, 0xB5u, 0xFDu, 0x23u, 0x60u, 0x14u,
|
||||||
|
0x5Fu, 0x78u, 0x88u, 0xB9u, 0x17u, 0xAAu, 0xD5u, 0xB4u,
|
||||||
|
0x68u, 0xCCu, 0x5Cu, 0xE2u, 0x3Fu, 0xD7u, 0xD4u, 0x6Eu,
|
||||||
|
0x29u, 0x2Au, 0xD7u, 0x6Fu, 0xE8u, 0x89u, 0xCBu, 0xE3u,
|
||||||
|
0x97u, 0x54u, 0xBCu, 0x4Eu, 0x85u, 0xA7u, 0x63u, 0xAFu,
|
||||||
|
0x8Au, 0xFDu, 0xB8u, 0xF2u, 0x8Bu, 0xA4u, 0x36u, 0xD4u,
|
||||||
|
},
|
||||||
|
.expData =
|
||||||
|
{
|
||||||
|
0x01u, 0x00u, 0x01u, 0x00u,
|
||||||
|
},
|
||||||
|
.barrettData =
|
||||||
|
{
|
||||||
|
0x44u, 0x94u, 0xA5u, 0xF4u, 0x4Fu, 0xCEu, 0x24u, 0xD0u,
|
||||||
|
0x3Bu, 0xDCu, 0x6Eu, 0x1Cu, 0x72u, 0xE8u, 0x6Fu, 0x5Eu,
|
||||||
|
0x32u, 0x38u, 0x0Bu, 0xEDu, 0x73u, 0x8Bu, 0x7Cu, 0x1Cu,
|
||||||
|
0x8Au, 0x03u, 0x36u, 0x88u, 0xB0u, 0x20u, 0x7Au, 0x90u,
|
||||||
|
0x7Bu, 0x0Du, 0x44u, 0xA2u, 0xF2u, 0x21u, 0x4Fu, 0xD9u,
|
||||||
|
0xA3u, 0x31u, 0xD8u, 0x87u, 0xD6u, 0xC8u, 0x36u, 0x94u,
|
||||||
|
0x9Eu, 0x32u, 0x01u, 0xD6u, 0x18u, 0x2Fu, 0x77u, 0x0Cu,
|
||||||
|
0xD6u, 0xAAu, 0x9Bu, 0x15u, 0xD8u, 0x50u, 0x6Eu, 0x88u,
|
||||||
|
0xD7u, 0x28u, 0x11u, 0x84u, 0xE3u, 0x7Au, 0x52u, 0x08u,
|
||||||
|
0x12u, 0xB8u, 0x05u, 0xECu, 0x70u, 0x1Fu, 0xD7u, 0x0Au,
|
||||||
|
0x53u, 0x18u, 0x62u, 0xEBu, 0x37u, 0x16u, 0x04u, 0x6Du,
|
||||||
|
0x86u, 0x4Cu, 0x8Au, 0x1Au, 0x6Eu, 0xCEu, 0x5Au, 0xD4u,
|
||||||
|
0x8Fu, 0x17u, 0xEBu, 0x20u, 0x03u, 0x36u, 0xACu, 0xDDu,
|
||||||
|
0x74u, 0x16u, 0xB4u, 0xE7u, 0x40u, 0x81u, 0x82u, 0x7Bu,
|
||||||
|
0x2Fu, 0x31u, 0x95u, 0x64u, 0xFDu, 0x6Eu, 0x75u, 0xB7u,
|
||||||
|
0x8Bu, 0xC8u, 0x6Au, 0x5Au, 0x48u, 0x28u, 0x5Du, 0xAEu,
|
||||||
|
0x0Au, 0x11u, 0x86u, 0xC0u, 0x5Au, 0x4Du, 0xDBu, 0x3Eu,
|
||||||
|
0x85u, 0xCCu, 0xDFu, 0x0Bu, 0x0Eu, 0xCBu, 0x52u, 0xB7u,
|
||||||
|
0x45u, 0xACu, 0x42u, 0xC2u, 0x39u, 0x1Fu, 0xE1u, 0x18u,
|
||||||
|
0xFDu, 0x7Bu, 0x77u, 0x7Fu, 0xE9u, 0xFCu, 0x25u, 0x8Cu,
|
||||||
|
0xB7u, 0x9Eu, 0x38u, 0x6Fu, 0x22u, 0xE6u, 0x6Du, 0xC5u,
|
||||||
|
0xB8u, 0x79u, 0x15u, 0x0Fu, 0xD1u, 0xAFu, 0x3Du, 0xC2u,
|
||||||
|
0xB1u, 0xD8u, 0x4Fu, 0x81u, 0x09u, 0xB7u, 0x02u, 0xF0u,
|
||||||
|
0xCDu, 0x65u, 0xF9u, 0xDFu, 0x0Bu, 0x74u, 0x14u, 0xDEu,
|
||||||
|
0x17u, 0xDDu, 0xE6u, 0x85u, 0x19u, 0x7Eu, 0x49u, 0x2Fu,
|
||||||
|
0x82u, 0xBAu, 0x73u, 0x1Du, 0x44u, 0x84u, 0x4Du, 0x5Cu,
|
||||||
|
0x5Fu, 0x5Bu, 0x6Du, 0x78u, 0x73u, 0xA3u, 0x6Fu, 0x07u,
|
||||||
|
0x76u, 0xF3u, 0xCDu, 0x52u, 0xE3u, 0xC3u, 0x89u, 0xE8u,
|
||||||
|
0xA6u, 0x8Au, 0xFAu, 0xF5u, 0x21u, 0xC3u, 0x25u, 0x16u,
|
||||||
|
0xD5u, 0x10u, 0xFDu, 0x30u, 0x5Du, 0xC5u, 0xB9u, 0xCAu,
|
||||||
|
0x2Bu, 0x5Au, 0x92u, 0xEDu, 0xE5u, 0xF4u, 0x3Bu, 0xBFu,
|
||||||
|
0x08u, 0x06u, 0x8Au, 0x75u, 0x88u, 0x36u, 0xD2u, 0x34u,
|
||||||
|
0x01u, 0x00u, 0x00u, 0x00u,
|
||||||
|
},
|
||||||
|
.inverseModuloData =
|
||||||
|
{
|
||||||
|
0x3Bu, 0x41u, 0xE5u, 0xABu, 0xC8u, 0x05u, 0x56u, 0xBFu,
|
||||||
|
0xF8u, 0xF5u, 0xE6u, 0x9Au, 0x46u, 0xF3u, 0x01u, 0x17u,
|
||||||
|
0xBEu, 0x0Eu, 0x81u, 0x9Bu, 0x54u, 0x2Fu, 0x2Eu, 0x3Du,
|
||||||
|
0xCBu, 0xA6u, 0xC3u, 0x35u, 0x02u, 0x18u, 0x38u, 0x1Au,
|
||||||
|
0x38u, 0x15u, 0x54u, 0x0Eu, 0xA4u, 0xCDu, 0xD1u, 0xEDu,
|
||||||
|
0x10u, 0x8Eu, 0x6Eu, 0xB9u, 0xCDu, 0x2Fu, 0x8Cu, 0xD6u,
|
||||||
|
0x56u, 0x95u, 0xE8u, 0x14u, 0x79u, 0xC6u, 0x32u, 0x02u,
|
||||||
|
0xA6u, 0x03u, 0xA1u, 0x8Du, 0x26u, 0x47u, 0xA1u, 0x99u,
|
||||||
|
0x96u, 0xECu, 0xA3u, 0x77u, 0x22u, 0xEAu, 0x25u, 0x72u,
|
||||||
|
0xBCu, 0xB8u, 0x77u, 0xE9u, 0x11u, 0x78u, 0x8Cu, 0x55u,
|
||||||
|
0xB9u, 0x8Eu, 0x90u, 0x19u, 0x3Cu, 0xFFu, 0x9Fu, 0x40u,
|
||||||
|
0x46u, 0x6Du, 0x51u, 0x22u, 0x21u, 0x15u, 0x5Cu, 0x4Fu,
|
||||||
|
0xCAu, 0x15u, 0xB0u, 0xE8u, 0x67u, 0x0Au, 0x2Cu, 0x4Au,
|
||||||
|
0xB1u, 0x77u, 0xFAu, 0xE6u, 0x3Cu, 0xA6u, 0x02u, 0x2Fu,
|
||||||
|
0x16u, 0x96u, 0xE3u, 0xADu, 0x29u, 0x83u, 0x4Au, 0x88u,
|
||||||
|
0xB1u, 0x6Bu, 0x13u, 0x38u, 0xA4u, 0xB0u, 0xE8u, 0xA6u,
|
||||||
|
0xDBu, 0xA5u, 0xFBu, 0x36u, 0x7Au, 0x10u, 0xB1u, 0x75u,
|
||||||
|
0x93u, 0x00u, 0xECu, 0x2Bu, 0x1Du, 0x86u, 0xE0u, 0x4Fu,
|
||||||
|
0x85u, 0xC8u, 0x70u, 0x23u, 0xEBu, 0x96u, 0x87u, 0x70u,
|
||||||
|
0x39u, 0x58u, 0x2Du, 0xAEu, 0xC3u, 0xC9u, 0xB6u, 0xFDu,
|
||||||
|
0x27u, 0xEEu, 0x5Fu, 0x14u, 0x4Du, 0xB6u, 0xFAu, 0x55u,
|
||||||
|
0xC3u, 0x2Cu, 0xFAu, 0x2Au, 0x60u, 0x67u, 0x37u, 0xBAu,
|
||||||
|
0xB3u, 0xA0u, 0x17u, 0x9Du, 0x5Cu, 0xDCu, 0x0Au, 0x82u,
|
||||||
|
0xFEu, 0x0Eu, 0xC9u, 0xE7u, 0x36u, 0x09u, 0x38u, 0xF3u,
|
||||||
|
0xA7u, 0x83u, 0x9Au, 0x71u, 0xD2u, 0x07u, 0x2Bu, 0x4Fu,
|
||||||
|
0x4Eu, 0xABu, 0x49u, 0xE8u, 0x0Eu, 0xE0u, 0x1Cu, 0x48u,
|
||||||
|
0x73u, 0x87u, 0x62u, 0xC9u, 0x95u, 0x17u, 0xCCu, 0xE6u,
|
||||||
|
0xECu, 0x34u, 0x18u, 0xE0u, 0xF0u, 0xCFu, 0x64u, 0x48u,
|
||||||
|
0xD9u, 0x92u, 0x1Au, 0x82u, 0x21u, 0x68u, 0xBCu, 0x70u,
|
||||||
|
0x31u, 0xA3u, 0xE0u, 0xC9u, 0xAEu, 0xC8u, 0x94u, 0x83u,
|
||||||
|
0x4Du, 0x95u, 0x3Bu, 0x4Cu, 0x65u, 0x8Eu, 0xC7u, 0x46u,
|
||||||
|
0x91u, 0x3Cu, 0xF4u, 0xD1u, 0x0Bu, 0xA5u, 0x64u, 0x13u,
|
||||||
|
},
|
||||||
|
.rBarData =
|
||||||
|
{
|
||||||
|
0xF3u, 0xEFu, 0xA7u, 0xC0u, 0xB0u, 0xDAu, 0x8Fu, 0x9Cu,
|
||||||
|
0x92u, 0xC4u, 0x19u, 0xEFu, 0x61u, 0x83u, 0x83u, 0x63u,
|
||||||
|
0xFDu, 0x74u, 0xBCu, 0xF8u, 0x9Eu, 0x6Eu, 0x09u, 0x40u,
|
||||||
|
0xEDu, 0x83u, 0xD4u, 0x25u, 0xBAu, 0x2Au, 0x8Au, 0x41u,
|
||||||
|
0x4Au, 0x0Eu, 0x42u, 0xC9u, 0xC5u, 0x3Eu, 0x2Eu, 0xC6u,
|
||||||
|
0xDFu, 0xEEu, 0x66u, 0xDDu, 0xD0u, 0x17u, 0x01u, 0x67u,
|
||||||
|
0x04u, 0x32u, 0xCBu, 0x2Bu, 0x1Du, 0xD3u, 0x3Au, 0x83u,
|
||||||
|
0x3Au, 0xAFu, 0x9Du, 0x00u, 0x02u, 0x9Eu, 0xEBu, 0x6Fu,
|
||||||
|
0x05u, 0xBCu, 0x42u, 0x52u, 0x5Cu, 0x2Au, 0x79u, 0x7Au,
|
||||||
|
0xB2u, 0x0Eu, 0xDBu, 0x9Du, 0xA5u, 0x13u, 0x78u, 0xB2u,
|
||||||
|
0x2Fu, 0xE7u, 0x4Fu, 0x1Eu, 0xB0u, 0xBFu, 0x21u, 0x78u,
|
||||||
|
0x44u, 0x8Bu, 0x3Au, 0xA2u, 0xB7u, 0x6Fu, 0xD9u, 0x97u,
|
||||||
|
0xA3u, 0x13u, 0x3Cu, 0xA3u, 0x38u, 0xFCu, 0x75u, 0xFAu,
|
||||||
|
0xD1u, 0xC8u, 0x47u, 0x5Fu, 0xFAu, 0x3Au, 0xDEu, 0xF0u,
|
||||||
|
0x89u, 0x63u, 0x11u, 0xE6u, 0xB3u, 0xD1u, 0x76u, 0x5Du,
|
||||||
|
0xDEu, 0xBBu, 0x9Eu, 0x60u, 0x80u, 0x2Du, 0xAEu, 0x8Du,
|
||||||
|
0x54u, 0xD3u, 0x5Au, 0x39u, 0x83u, 0xF5u, 0x64u, 0xF9u,
|
||||||
|
0xEBu, 0x13u, 0x6Eu, 0xC2u, 0xA1u, 0xF7u, 0x8Eu, 0x95u,
|
||||||
|
0x01u, 0x54u, 0xC1u, 0xE4u, 0x66u, 0xC3u, 0x0Fu, 0xEDu,
|
||||||
|
0xA8u, 0xF3u, 0x0Du, 0xBDu, 0x87u, 0x5Au, 0xC4u, 0x55u,
|
||||||
|
0xB6u, 0x67u, 0xFCu, 0x71u, 0xF0u, 0xA5u, 0x36u, 0x03u,
|
||||||
|
0xD9u, 0x36u, 0x6Cu, 0x47u, 0x47u, 0x14u, 0x90u, 0x0Eu,
|
||||||
|
0x9Au, 0x87u, 0xBCu, 0xF5u, 0x1Au, 0x04u, 0xD4u, 0x33u,
|
||||||
|
0x74u, 0xD3u, 0xCEu, 0xF2u, 0x1Eu, 0xB6u, 0xF9u, 0xDAu,
|
||||||
|
0x1Cu, 0x05u, 0x6Du, 0x80u, 0x38u, 0x69u, 0xCAu, 0xE8u,
|
||||||
|
0xD3u, 0x11u, 0x11u, 0xBFu, 0x3Eu, 0xE7u, 0xE3u, 0xA3u,
|
||||||
|
0xBAu, 0xB2u, 0x16u, 0x4Au, 0x02u, 0xDCu, 0x9Fu, 0xEBu,
|
||||||
|
0xA0u, 0x87u, 0x77u, 0x46u, 0xE8u, 0x55u, 0x2Au, 0x4Bu,
|
||||||
|
0x97u, 0x33u, 0xA3u, 0x1Du, 0xC0u, 0x28u, 0x2Bu, 0x91u,
|
||||||
|
0xD6u, 0xD5u, 0x28u, 0x90u, 0x17u, 0x76u, 0x34u, 0x1Cu,
|
||||||
|
0x68u, 0xABu, 0x43u, 0xB1u, 0x7Au, 0x58u, 0x9Cu, 0x50u,
|
||||||
|
0x75u, 0x02u, 0x47u, 0x0Du, 0x74u, 0x5Bu, 0xC9u, 0x2Bu,
|
||||||
|
},
|
||||||
|
/* End of key data */
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
110
2020TPCApp0.cydsn/cy_si_keystorage.h
Normal file
110
2020TPCApp0.cydsn/cy_si_keystorage.h
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file cy_si_keystorage.h
|
||||||
|
* \version 1.00
|
||||||
|
*
|
||||||
|
* \brief
|
||||||
|
* Secure key storage header for the secure image.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2017-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _CY_KEY_STORAGE_H_
|
||||||
|
#define _CY_KEY_STORAGE_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "syslib/cy_syslib.h"
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Macros
|
||||||
|
***************************************/
|
||||||
|
|
||||||
|
/** \addtogroup group_secure_image_macro
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \defgroup group_secure_image_userkey_macros User Key Macros
|
||||||
|
* Macros used to define the user-defined key array.
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
#define CY_SI_SECURE_KEY_LENGTH (256u) /**< Key length (Bytes) */
|
||||||
|
#define CY_SI_SECURE_KEY_ARRAY_SIZE (4u) /**< Number of Keys */
|
||||||
|
/** \} group_secure_image_userkey_macros */
|
||||||
|
|
||||||
|
/** \defgroup group_secure_image_pubkey_macros Public Key Macros
|
||||||
|
* Macros used to define the Public key.
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
#define CY_SI_PUBLIC_KEY_RSA_2048 (0UL) /**< RSASSA-PKCS1-v1_5-2048 signature scheme */
|
||||||
|
#define CY_SI_PUBLIC_KEY_RSA_1024 (1UL) /**< RSASSA-PKCS1-v1_5-1024 signature scheme */
|
||||||
|
#define CY_SI_PUBLIC_KEY_STRUCT_OFFSET (8UL) /**< Offset to public key struct in number of bytes */
|
||||||
|
#define CY_SI_PUBLIC_KEY_MODULOLENGTH (256UL) /**< Modulus length of the RSA key */
|
||||||
|
#define CY_SI_PUBLIC_KEY_EXPLENGTH (32UL) /**< Exponent length of the RSA key */
|
||||||
|
#define CY_SI_PUBLIC_KEY_SIZEOF_BYTE (8UL) /**< Size of Byte in number of bits */
|
||||||
|
/** \} group_secure_image_pubkey_macros */
|
||||||
|
|
||||||
|
/** \} group_secure_image_macro */
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Structs
|
||||||
|
***************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup group_secure_image_data_structures
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Public key definition structure as expected by the Crypto driver */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t moduloAddr; /**< Address of the public key modulus */
|
||||||
|
uint32_t moduloSize; /**< Size (bits) of the modulus part of the public key */
|
||||||
|
uint32_t expAddr; /**< Address of the public key exponent */
|
||||||
|
uint32_t expSize; /**< Size (bits) of the exponent part of the public key */
|
||||||
|
uint32_t barrettAddr; /**< Address of the Barret coefficient */
|
||||||
|
uint32_t inverseModuloAddr; /**< Address of the binary inverse modulo */
|
||||||
|
uint32_t rBarAddr; /**< Address of the (2^moduloLength mod modulo) */
|
||||||
|
} cy_si_stc_crypto_public_key_t;
|
||||||
|
|
||||||
|
/** Public key structure */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t objSize; /**< Public key Object size */
|
||||||
|
uint32_t signatureScheme; /**< Signature scheme */
|
||||||
|
cy_si_stc_crypto_public_key_t publicKeyStruct; /**< Public key definition struct */
|
||||||
|
uint8_t moduloData[CY_SI_PUBLIC_KEY_MODULOLENGTH]; /**< Modulo data */
|
||||||
|
uint8_t expData[CY_SI_PUBLIC_KEY_EXPLENGTH]; /**< Exponent data */
|
||||||
|
uint8_t barrettData[CY_SI_PUBLIC_KEY_MODULOLENGTH + 4UL]; /**< Barret coefficient data */
|
||||||
|
uint8_t inverseModuloData[CY_SI_PUBLIC_KEY_MODULOLENGTH]; /**< Binary inverse modulo data */
|
||||||
|
uint8_t rBarData[CY_SI_PUBLIC_KEY_MODULOLENGTH]; /**< 2^moduloLength mod modulo data */
|
||||||
|
} cy_si_stc_public_key_t;
|
||||||
|
|
||||||
|
/** \} group_secure_image_data_structures */
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Globals
|
||||||
|
***************************************/
|
||||||
|
/** Secure Key Storage (Note: Ensure that the alignment matches the Protection unit configuration) */
|
||||||
|
extern const uint8_t CySecureKeyStorage[CY_SI_SECURE_KEY_ARRAY_SIZE][CY_SI_SECURE_KEY_LENGTH];
|
||||||
|
|
||||||
|
/** Public key in SFlash */
|
||||||
|
extern const cy_si_stc_public_key_t cy_publicKey;
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
162
2020TPCApp0.cydsn/debug.c
Normal file
162
2020TPCApp0.cydsn/debug.c
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* File Name: debug.c
|
||||||
|
*
|
||||||
|
* Version: 1.0
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This file contains functions for printf functionality
|
||||||
|
* and LED status notification.
|
||||||
|
*
|
||||||
|
* Hardware Dependency:
|
||||||
|
* CY8CKIT-062 PSoC6 BLE Pioneer Kit
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* Copyright 2017, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "project.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if (DEBUG_UART_ENABLED == ENABLED)
|
||||||
|
|
||||||
|
#if defined(__ARMCC_VERSION)
|
||||||
|
|
||||||
|
/* For MDK/RVDS compiler revise fputc function for printf functionality */
|
||||||
|
struct __FILE
|
||||||
|
{
|
||||||
|
int handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
STDIN_HANDLE,
|
||||||
|
STDOUT_HANDLE,
|
||||||
|
STDERR_HANDLE
|
||||||
|
};
|
||||||
|
|
||||||
|
FILE __stdin = {STDIN_HANDLE};
|
||||||
|
FILE __stdout = {STDOUT_HANDLE};
|
||||||
|
FILE __stderr = {STDERR_HANDLE};
|
||||||
|
|
||||||
|
int fputc(int ch, FILE *file)
|
||||||
|
{
|
||||||
|
int ret = EOF;
|
||||||
|
|
||||||
|
switch( file->handle )
|
||||||
|
{
|
||||||
|
case STDOUT_HANDLE:
|
||||||
|
UART_DEB_PUT_CHAR(ch);
|
||||||
|
ret = ch ;
|
||||||
|
break ;
|
||||||
|
|
||||||
|
case STDERR_HANDLE:
|
||||||
|
ret = ch ;
|
||||||
|
break ;
|
||||||
|
|
||||||
|
default:
|
||||||
|
file = file;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
return ret ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined (__ICCARM__) /* IAR */
|
||||||
|
|
||||||
|
/* For IAR compiler revise __write() function for printf functionality */
|
||||||
|
size_t __write(int handle, const unsigned char * buffer, size_t size)
|
||||||
|
{
|
||||||
|
size_t nChars = 0;
|
||||||
|
(void) handle;
|
||||||
|
|
||||||
|
if (buffer == 0)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* This means that we should flush internal buffers. Since we
|
||||||
|
* don't we just return. (Remember, "handle" == -1 means that all
|
||||||
|
* handles should be flushed.)
|
||||||
|
*/
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (/* Empty */; size != 0; --size)
|
||||||
|
{
|
||||||
|
UART_DEB_PUT_CHAR(*buffer);
|
||||||
|
++buffer;
|
||||||
|
++nChars;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (nChars);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* (__GNUC__) GCC */
|
||||||
|
|
||||||
|
/* For GCC compiler revise _write() function for printf functionality */
|
||||||
|
int _write(int file, char *ptr, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
file = file;
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
UART_DEB_PUT_CHAR(*ptr);
|
||||||
|
++ptr;
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* (__ARMCC_VERSION) */
|
||||||
|
|
||||||
|
#endif /* DEBUG_UART_ENABLED == ENABLED */
|
||||||
|
|
||||||
|
#if (DEBUG_LED_ENABLED == ENABLED)
|
||||||
|
|
||||||
|
void InitLED(void)
|
||||||
|
{
|
||||||
|
#if CYDEV_VDD_MV >= RGB_LED_MIN_VOLTAGE_MV
|
||||||
|
Cy_GPIO_SetDrivemode(PIN_LED_RED_0_PORT, PIN_LED_RED_0_NUM, CY_GPIO_DM_STRONG_IN_OFF);
|
||||||
|
Cy_GPIO_Write(PIN_LED_RED_0_PORT, PIN_LED_RED_0_NUM, LED_OFF);
|
||||||
|
Cy_GPIO_SetDrivemode(PIN_LED_GREEN_0_PORT, PIN_LED_GREEN_0_NUM, CY_GPIO_DM_STRONG_IN_OFF);
|
||||||
|
Cy_GPIO_Write(PIN_LED_GREEN_0_PORT, PIN_LED_GREEN_0_NUM, LED_OFF);
|
||||||
|
#else
|
||||||
|
Cy_GPIO_SetDrivemode(PIN_LED_RED_0_PORT, PIN_LED_RED_0_NUM, CY_GPIO_DM_STRONG_IN_OFF);
|
||||||
|
Cy_GPIO_Write(PIN_LED_RED_0_PORT, PIN_LED_RED_0_NUM, LED_OFF);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void HibernateLED(void)
|
||||||
|
{
|
||||||
|
#if CYDEV_VDD_MV >= RGB_LED_MIN_VOLTAGE_MV
|
||||||
|
Cy_GPIO_Write(PIN_LED_RED_0_PORT, PIN_LED_RED_0_NUM, LED_ON);
|
||||||
|
Cy_GPIO_Write(PIN_LED_GREEN_0_PORT, PIN_LED_GREEN_0_NUM, LED_OFF);
|
||||||
|
#else
|
||||||
|
Cy_GPIO_Write(PIN_LED_RED_0_PORT, PIN_LED_RED_0_NUM, LED_ON);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlinkLED(void)
|
||||||
|
{
|
||||||
|
#if CYDEV_VDD_MV >= RGB_LED_MIN_VOLTAGE_MV
|
||||||
|
Cy_GPIO_Inv(PIN_LED_RED_0_PORT, PIN_LED_RED_0_NUM);
|
||||||
|
Cy_GPIO_Inv(PIN_LED_GREEN_0_PORT, PIN_LED_GREEN_0_NUM);
|
||||||
|
#else
|
||||||
|
Cy_GPIO_Inv(PIN_LED_RED_0_PORT, PIN_LED_RED_0_NUM);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectedLED(void)
|
||||||
|
{
|
||||||
|
#if CYDEV_VDD_MV >= RGB_LED_MIN_VOLTAGE_MV
|
||||||
|
Cy_GPIO_Write(PIN_LED_RED_0_PORT, PIN_LED_RED_0_NUM, LED_OFF);
|
||||||
|
Cy_GPIO_Write(PIN_LED_GREEN_0_PORT, PIN_LED_GREEN_0_NUM, LED_OFF);
|
||||||
|
#else
|
||||||
|
Cy_GPIO_Write(PIN_LED_RED_0_PORT, PIN_LED_RED_0_NUM, LED_OFF);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* DEBUG_LED == ENABLED */
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
82
2020TPCApp0.cydsn/debug.h
Normal file
82
2020TPCApp0.cydsn/debug.h
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file debug.h
|
||||||
|
*
|
||||||
|
* \version 1.0
|
||||||
|
*
|
||||||
|
* Contains the function prototypes and constants for the UART debugging
|
||||||
|
* and LED status notification.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* Copyright 2017, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "project.h"
|
||||||
|
|
||||||
|
#define ENABLED (1u)
|
||||||
|
#define DISABLED (0u)
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Conditional Compilation Parameters
|
||||||
|
***************************************/
|
||||||
|
#define DEBUG_UART_ENABLED ENABLED
|
||||||
|
#define DEBUG_LED_ENABLED ENABLED
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* API Constants
|
||||||
|
***************************************/
|
||||||
|
#define LED_ON (0u)
|
||||||
|
#define LED_OFF (1u)
|
||||||
|
#define RGB_LED_MIN_VOLTAGE_MV (2700u)
|
||||||
|
#define ADV_TIMER_TIMEOUT (1u)
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* External Function Prototypes
|
||||||
|
***************************************/
|
||||||
|
#if (DEBUG_LED_ENABLED)
|
||||||
|
|
||||||
|
void InitLED(void);
|
||||||
|
void HibernateLED(void);
|
||||||
|
void BlinkLED(void);
|
||||||
|
void ConnectedLED(void);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define InitLED()
|
||||||
|
#define HibernateLED()
|
||||||
|
#define BlinkLED()
|
||||||
|
#define ConnectedLED()
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/***************************************
|
||||||
|
* Macros
|
||||||
|
***************************************/
|
||||||
|
#if (DEBUG_UART_ENABLED == ENABLED)
|
||||||
|
#define DBG_PRINTF(...) (printf(__VA_ARGS__))
|
||||||
|
#define UART_DEB_PUT_CHAR(ch) while(0UL == UART_DEB_Put(ch))
|
||||||
|
|
||||||
|
__STATIC_INLINE char8 UART_DEB_GET_CHAR(void)
|
||||||
|
{
|
||||||
|
uint32 rec;
|
||||||
|
rec = UART_DEB_Get();
|
||||||
|
return((rec == CY_SCB_UART_RX_NO_DATA) ? 0u : (char8)(rec & 0xff));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define UART_DEB_GET_TX_BUFF_SIZE() ( UART_DEB_GetNumInTxFifo() )
|
||||||
|
#define UART_START() ( UART_DEB_Start() )
|
||||||
|
#else
|
||||||
|
#define DBG_PRINTF(...)
|
||||||
|
#define UART_DEB_PUT_CHAR(ch)
|
||||||
|
#define UART_DEB_GET_CHAR(ch) (0u)
|
||||||
|
#ifndef UART_DEB_GET_TX_FIFO_SR_VALID
|
||||||
|
#define UART_DEB_GET_TX_FIFO_SR_VALID (0u)
|
||||||
|
#endif
|
||||||
|
#define UART_DEB_GET_TX_BUFF_SIZE(...) (0u)
|
||||||
|
#define UART_START()
|
||||||
|
#endif /* (DEBUG_UART_ENABLED == ENABLED) */
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
251
2020TPCApp0.cydsn/dfu_cm0p.icf
Normal file
251
2020TPCApp0.cydsn/dfu_cm0p.icf
Normal file
|
@ -0,0 +1,251 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file dfu_cm0p.icf
|
||||||
|
* \version 3.0
|
||||||
|
*
|
||||||
|
* The linker file for the the IAR compiler.
|
||||||
|
*
|
||||||
|
* \note The entry point is fixed and starts at 0x10000000. The valid application
|
||||||
|
* image should be placed there.
|
||||||
|
*
|
||||||
|
* \note The linker files included with the PDL template projects must be generic
|
||||||
|
* and handle all common use cases. Your project may not use every section
|
||||||
|
* defined in the linker files. In that case, you may see warnings during the
|
||||||
|
* build process. In your project, you can simply comment out or remove the
|
||||||
|
* relevant code in the linker file.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/*-Editor annotation file-*/
|
||||||
|
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_4.xml" */
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Start of CM4 and CM0+ linker script common region
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/*-Memory Regions-*/
|
||||||
|
/* Flash */
|
||||||
|
define exported symbol __cy_memory_0_start = 0x10000000;
|
||||||
|
define exported symbol __cy_memory_0_length = 0x00100000;
|
||||||
|
define exported symbol __cy_memory_0_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
define exported symbol __cy_memory_1_start = 0x14000000;
|
||||||
|
define exported symbol __cy_memory_1_length = 0x8000;
|
||||||
|
define exported symbol __cy_memory_1_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
define exported symbol __cy_memory_2_start = 0x16000000;
|
||||||
|
define exported symbol __cy_memory_2_length = 0x8000;
|
||||||
|
define exported symbol __cy_memory_2_row_size = 0x200;
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
define exported symbol __cy_memory_3_start = 0x18000000;
|
||||||
|
define exported symbol __cy_memory_3_length = 0x08000000;
|
||||||
|
define exported symbol __cy_memory_3_row_size = 0x200;
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
define exported symbol __cy_memory_4_start = 0x90700000;
|
||||||
|
define exported symbol __cy_memory_4_length = 0x100000;
|
||||||
|
define exported symbol __cy_memory_4_row_size = 1;
|
||||||
|
|
||||||
|
|
||||||
|
define memory mem with size = 4G;
|
||||||
|
|
||||||
|
/* Memory regions for all applications are defined here */
|
||||||
|
define region FLASH_app0_core0 = mem:[from 0x10000000 size 0x10000];
|
||||||
|
define region FLASH_app0_core1 = mem:[from 0x10010000 size 0x10000];
|
||||||
|
define region FLASH_app1_core0 = mem:[from 0x10040000 size 0x10000];
|
||||||
|
define region FLASH_app1_core1 = mem:[from 0x10050000 size 0x10000];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The region for DFU SDK metadata
|
||||||
|
* when it is outside of any application
|
||||||
|
*/
|
||||||
|
define region FLASH_boot_meta = mem:[from 0x100FFA00 size 0x200];
|
||||||
|
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
define region ROM_EFUSE = mem:[from 0x90700000 size 0x100000];
|
||||||
|
|
||||||
|
/* SFlash NAR */
|
||||||
|
define region SFLASH_NAR = mem:[from 0x16001A00 size 0x200];
|
||||||
|
|
||||||
|
/* SFlash User Data */
|
||||||
|
define region SFLASH_USER_DATA = mem:[from 0x16000800 size 0x800];
|
||||||
|
|
||||||
|
/* SFlash Public Key, 6 SFlash rows */
|
||||||
|
define region SFLASH_PUBLIC_KEY = mem:[from 0x16005A00 size 0xC00];
|
||||||
|
|
||||||
|
/* Table of Content part 2, two SFlash rows */
|
||||||
|
define region SFLASH_TOC = mem:[from 0x16007C00 size 0x400];
|
||||||
|
|
||||||
|
|
||||||
|
/* Emulated EEPROM app regions */
|
||||||
|
define region EM_EEPROM_app0_core0 = mem:[from 0x14000000 size 0x8000];
|
||||||
|
define region EM_EEPROM_app0_core1 = mem:[from 0x14000000 size 0x8000];
|
||||||
|
define region EM_EEPROM_app1_core0 = mem:[from 0x14000000 size 0x8000];
|
||||||
|
define region EM_EEPROM_app1_core1 = mem:[from 0x14000000 size 0x8000];
|
||||||
|
|
||||||
|
/* XIP/SMIF app regions */
|
||||||
|
define region EROM_app0_core0 = mem:[from 0x18000000 size 0x1000];
|
||||||
|
define region EROM_app0_core1 = mem:[from 0x18000000 size 0x1000];
|
||||||
|
define region EROM_app1_core0 = mem:[from 0x18000000 size 0x1000];
|
||||||
|
define region EROM_app1_core1 = mem:[from 0x18000000 size 0x1000];
|
||||||
|
|
||||||
|
/* used for RAM sharing across applications */
|
||||||
|
define region IRAM_common = mem:[from 0x08000000 size 0x0100];
|
||||||
|
|
||||||
|
/* note: all the IRAM_appX_core0 regions has to be 0x100 aligned */
|
||||||
|
/* and the IRAM_appX_core1 regions has to be 0x400 aligned */
|
||||||
|
/* as they contain Interrupt Vector Table Remapped at the start */
|
||||||
|
define region IRAM_app0_core0 = mem:[from 0x08000100 size 0x1F00];
|
||||||
|
define region IRAM_app0_core1 = mem:[from 0x08002000 size 0x8000];
|
||||||
|
define region IRAM_app1_core0 = mem:[from 0x08000100 size 0x1F00];
|
||||||
|
define region IRAM_app1_core1 = mem:[from 0x08002000 size 0x8000];
|
||||||
|
|
||||||
|
|
||||||
|
/* Used by all DFU SDK and CyMCUElfTool */
|
||||||
|
define exported symbol __cy_boot_metadata_addr = 0x100FFA00;
|
||||||
|
define exported symbol __cy_boot_metadata_length = __cy_memory_0_row_size;
|
||||||
|
|
||||||
|
/* Used by CyMCUElfTool to generate ProductID for DFU SDK apps */
|
||||||
|
define exported symbol __cy_product_id = 0x01020304;
|
||||||
|
|
||||||
|
/* Used by CyMCUElfTool to generate ChecksumType for DFU SDK apps */
|
||||||
|
define exported symbol __cy_checksum_type = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The size of the application signature.
|
||||||
|
* E.g. 4 for CRC-32,
|
||||||
|
* 32 for SHA256,
|
||||||
|
* 256 for RSA 2048.
|
||||||
|
*/
|
||||||
|
define exported symbol __cy_boot_signature_size = 4;
|
||||||
|
|
||||||
|
/* Used by DFU SDK projects, in dfu_user.c to fill in the metadata table */
|
||||||
|
define exported symbol __cy_app0_verify_start = start(FLASH_app0_core0);
|
||||||
|
define exported symbol __cy_app0_verify_length = size (FLASH_app0_core0) + size (FLASH_app0_core1)
|
||||||
|
- __cy_boot_signature_size;
|
||||||
|
|
||||||
|
define exported symbol __cy_app1_verify_start = start(FLASH_app1_core0);
|
||||||
|
define exported symbol __cy_app1_verify_length = size (FLASH_app1_core0) + size (FLASH_app1_core1)
|
||||||
|
- __cy_boot_signature_size;
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* End of CM4 and CM0+ linker script common region
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Used by CM0+ to start the CM4 core in DFU SDK applications.
|
||||||
|
* Make sure the correct app no. is entered here.
|
||||||
|
*/
|
||||||
|
define exported symbol __cy_app_core1_start_addr = start(FLASH_app0_core1);
|
||||||
|
|
||||||
|
/* CyMCUElfTool uses this symbol to set a proper app number */
|
||||||
|
define exported symbol __cy_app_id = 0;
|
||||||
|
|
||||||
|
/* CyMCUElfTool uses these to generate an application signature */
|
||||||
|
/* The size of the default signature (CRC-32C) is 4 bytes */
|
||||||
|
define exported symbol __cy_app_verify_start = start(FLASH_app0_core0);
|
||||||
|
define exported symbol __cy_app_verify_length = size(FLASH_app0_core0) + size(FLASH_app0_core1)
|
||||||
|
- __cy_boot_signature_size;
|
||||||
|
|
||||||
|
|
||||||
|
/*-Sizes-*/
|
||||||
|
if (!isdefinedsymbol(__STACK_SIZE)) {
|
||||||
|
define symbol __ICFEDIT_size_cstack__ = 0x1000;
|
||||||
|
} else {
|
||||||
|
define symbol __ICFEDIT_size_cstack__ = __STACK_SIZE;
|
||||||
|
}
|
||||||
|
define symbol __ICFEDIT_size_proc_stack__ = 0x0;
|
||||||
|
if (!isdefinedsymbol(__HEAP_SIZE)) {
|
||||||
|
define symbol __ICFEDIT_size_heap__ = 0x0400;
|
||||||
|
} else {
|
||||||
|
define symbol __ICFEDIT_size_heap__ = __HEAP_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
define region IROM1_region = FLASH_app0_core0; /* Flash, user app */
|
||||||
|
define region IROM2_region = EM_EEPROM_app0_core0; /* Emulated EEPROM */
|
||||||
|
define region IROM3_region = SFLASH_USER_DATA; /* SFlash User Data */
|
||||||
|
define region IROM4_region = SFLASH_NAR; /* SFlash NAR */
|
||||||
|
define region IROM5_region = SFLASH_PUBLIC_KEY; /* SFlash Public Key */
|
||||||
|
define region IROM6_region = SFLASH_TOC; /* SFlash TOC part 2 */
|
||||||
|
define region IROM7_region = ROM_EFUSE; /* eFuse */
|
||||||
|
define region EROM1_region = EROM_app0_core0; /* XIP / SMIF */
|
||||||
|
define region IRAM1_region = IRAM_app0_core0; /* RAM */
|
||||||
|
|
||||||
|
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||||
|
define block PROC_STACK with alignment = 8, size = __ICFEDIT_size_proc_stack__ { };
|
||||||
|
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||||
|
define block HSTACK {block HEAP, block PROC_STACK, last block CSTACK};
|
||||||
|
define block RO {first section .intvec, readonly};
|
||||||
|
|
||||||
|
/*-Initializations-*/
|
||||||
|
initialize by copy { readwrite };
|
||||||
|
do not initialize { section .noinit, section .intvec_ram,
|
||||||
|
section .cy_boot_noinit.appId, section .cy_boot_noinit };
|
||||||
|
|
||||||
|
|
||||||
|
/*-Placement-*/
|
||||||
|
|
||||||
|
/* Flash */
|
||||||
|
".cy_app_header" : place at start of IROM1_region { section .cy_app_header };
|
||||||
|
place in IROM1_region { block RO };
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
".cy_em_eeprom" : place at start of IROM2_region { section .cy_em_eeprom };
|
||||||
|
|
||||||
|
/* Supervisory Flash - User Data */
|
||||||
|
".cy_sflash_user_data" : place at start of IROM3_region { section .cy_sflash_user_data };
|
||||||
|
|
||||||
|
/* Supervisory Flash - NAR */
|
||||||
|
".cy_sflash_nar" : place at start of IROM4_region { section .cy_sflash_nar };
|
||||||
|
|
||||||
|
/* Supervisory Flash - Public Key */
|
||||||
|
".cy_sflash_public_key" : place at start of IROM5_region { section .cy_sflash_public_key };
|
||||||
|
|
||||||
|
/* Supervisory Flash - TOC2 */
|
||||||
|
".cy_toc_part2" : place at start of IROM6_region { section .cy_toc_part2 };
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
".cy_efuse" : place at start of IROM7_region { section .cy_efuse };
|
||||||
|
|
||||||
|
/* Execute in Place (XIP). See the smif driver documentation for details. */
|
||||||
|
".cy_xip" : place at start of EROM1_region { section .cy_xip };
|
||||||
|
|
||||||
|
/* RAM */
|
||||||
|
place at start of IRAM_common { readwrite section .cy_boot_noinit.appId };
|
||||||
|
place in IRAM_common { readwrite section .cy_boot_noinit };
|
||||||
|
place at start of IRAM1_region { readwrite section .intvec_ram};
|
||||||
|
place in IRAM1_region { readwrite };
|
||||||
|
place at end of IRAM1_region { block HSTACK };
|
||||||
|
|
||||||
|
/* These sections are used for additional metadata (silicon revision, Silicon/JTAG ID, etc.) storage. */
|
||||||
|
".cymeta" : place at address mem : 0x90500000 { readonly section .cymeta };
|
||||||
|
|
||||||
|
|
||||||
|
keep { section .cy_app_header,
|
||||||
|
section .cy_em_eeprom,
|
||||||
|
section .cy_sflash_user_data,
|
||||||
|
section .cy_sflash_nar,
|
||||||
|
section .cy_sflash_public_key,
|
||||||
|
section .cy_sflash_toc_2,
|
||||||
|
section .cy_efuse,
|
||||||
|
section .cy_xip,
|
||||||
|
section .cymeta,
|
||||||
|
section .cy_boot_noinit,
|
||||||
|
section .cy_boot_noinit.appId,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* EOF */
|
479
2020TPCApp0.cydsn/dfu_cm0p.ld
Normal file
479
2020TPCApp0.cydsn/dfu_cm0p.ld
Normal file
|
@ -0,0 +1,479 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file dfu_cm0p.ld
|
||||||
|
* \version 3.0
|
||||||
|
*
|
||||||
|
* The linker file for the GNU C compiler.
|
||||||
|
* Used for DFU SDK core0 firmware projects.
|
||||||
|
*
|
||||||
|
* \note The linker files included with the PDL template projects must be generic
|
||||||
|
* and handle all common use cases. Your project may not use every section
|
||||||
|
* defined in the linker files. In that case, you may see warnings during the
|
||||||
|
* build process. In your project, simply comment out or remove the
|
||||||
|
* relevant code in the linker file.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||||
|
SEARCH_DIR(.)
|
||||||
|
GROUP(-lgcc -lc -lnosys)
|
||||||
|
ENTRY(Reset_Handler)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Forces symbol to be added to the output file.
|
||||||
|
* Otherwise linker may remove it if founds that it is not used in the project.
|
||||||
|
* This command has the same effect as the -u command-line option.
|
||||||
|
*/
|
||||||
|
EXTERN(Reset_Handler)
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Start of CM4 and CM0+ linker script common region
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Memory regions, for each application and MCU core.
|
||||||
|
*/
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
flash_app0_core0 (rx) : ORIGIN = 0x10000000, LENGTH = 0x10000
|
||||||
|
flash_app0_core1 (rx) : ORIGIN = 0x10010000, LENGTH = 0x30000
|
||||||
|
flash_app1_core0 (rx) : ORIGIN = 0x10040000, LENGTH = 0x30000
|
||||||
|
flash_app1_core1 (rx) : ORIGIN = 0x10070000, LENGTH = 0x50000
|
||||||
|
|
||||||
|
flash_storage (rw) : ORIGIN = 0x100D0000, LENGTH = 0x1000
|
||||||
|
flash_boot_meta (rw) : ORIGIN = 0x100FFA00, LENGTH = 0x400
|
||||||
|
|
||||||
|
sflash_user_data (rx) : ORIGIN = 0x16000800, LENGTH = 0x800
|
||||||
|
sflash_nar (rx) : ORIGIN = 0x16001A00, LENGTH = 0x200
|
||||||
|
sflash_public_key (rx) : ORIGIN = 0x16005A00, LENGTH = 0xC00
|
||||||
|
sflash_toc_2 (rx) : ORIGIN = 0x16007C00, LENGTH = 0x400
|
||||||
|
|
||||||
|
efuse (r) : ORIGIN = 0x90700000, LENGTH = 0x100000
|
||||||
|
|
||||||
|
ram_common (rwx) : ORIGIN = 0x08000000, LENGTH = 0x0100
|
||||||
|
|
||||||
|
/* note: all the ram_appX_core0 regions has to be 0x100 aligned */
|
||||||
|
/* and the ram_appX_core1 regions has to be 0x400 aligned */
|
||||||
|
/* as they contain Interrupt Vector Table Remapped at the start */
|
||||||
|
ram_app0_core0 (rwx) : ORIGIN = 0x08000100, LENGTH = 0x7F00
|
||||||
|
ram_app0_core1 (rwx) : ORIGIN = 0x08008000, LENGTH = 0x8000
|
||||||
|
|
||||||
|
ram_app1_core0 (rwx) : ORIGIN = 0x08000100, LENGTH = 0x7F00
|
||||||
|
ram_app1_core1 (rwx) : ORIGIN = 0x08008000, LENGTH = 0x30000
|
||||||
|
|
||||||
|
em_eeprom (rx) : ORIGIN = 0x14000000, LENGTH = 0x8000
|
||||||
|
xip (rx) : ORIGIN = 0x18000000, LENGTH = 0x08000000
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Regions parameters */
|
||||||
|
/* Flash */
|
||||||
|
__cy_memory_0_start = 0x10000000;
|
||||||
|
__cy_memory_0_length = 0x00100000;
|
||||||
|
__cy_memory_0_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
__cy_memory_1_start = 0x14000000;
|
||||||
|
__cy_memory_1_length = 0x8000;
|
||||||
|
__cy_memory_1_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
__cy_memory_2_start = 0x16000000;
|
||||||
|
__cy_memory_2_length = 0x8000;
|
||||||
|
__cy_memory_2_row_size = 0x200;
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
__cy_memory_3_start = 0x18000000;
|
||||||
|
__cy_memory_3_length = 0x08000000;
|
||||||
|
__cy_memory_3_row_size = 0x200;
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
__cy_memory_4_start = 0x90700000;
|
||||||
|
__cy_memory_4_length = 0x100000;
|
||||||
|
__cy_memory_4_row_size = 1;
|
||||||
|
|
||||||
|
/* The DFU SDK metadata limits */
|
||||||
|
__cy_boot_metadata_addr = ORIGIN(flash_boot_meta);
|
||||||
|
__cy_boot_metadata_length = __cy_memory_0_row_size;
|
||||||
|
|
||||||
|
/* The Product ID, used by CyMCUElfTool to generate a updating file */
|
||||||
|
__cy_product_id = 0x01020304;
|
||||||
|
|
||||||
|
/* The checksum type used by CyMCUElfTool to generate a updating file */
|
||||||
|
__cy_checksum_type = 0x00;
|
||||||
|
|
||||||
|
/* Used by the DFU SDK application to set the metadata */
|
||||||
|
__cy_app0_verify_start = ORIGIN(flash_app0_core0);
|
||||||
|
__cy_app0_verify_length = LENGTH(flash_app0_core0) + LENGTH(flash_app0_core1) - __cy_boot_signature_size;
|
||||||
|
__cy_app1_verify_start = ORIGIN(flash_app1_core0);
|
||||||
|
__cy_app1_verify_length = LENGTH(flash_app1_core0) + LENGTH(flash_app1_core1) - __cy_boot_signature_size;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The size of the application signature.
|
||||||
|
* E.g. 4 for CRC-32,
|
||||||
|
* 32 for SHA256,
|
||||||
|
* 256 for RSA 2048.
|
||||||
|
*/
|
||||||
|
__cy_boot_signature_size = 256;
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* End of CM4 and CM0+ linker script common region
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DFU SDK specific: aliases regions, so the rest of code does not use
|
||||||
|
* application specific memory region names
|
||||||
|
*/
|
||||||
|
REGION_ALIAS("flash", flash_app0_core0);
|
||||||
|
REGION_ALIAS("flash_core1", flash_app0_core1);
|
||||||
|
REGION_ALIAS("ram", ram_app0_core0);
|
||||||
|
|
||||||
|
/* DFU SDK specific: sets an app Id */
|
||||||
|
__cy_app_id = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DFU SDK specific: sets a start address of the Core1 application image,
|
||||||
|
* more specifically an address of the Core1 interrupt vector table.
|
||||||
|
* CM0+ uses this information to launch Core1.
|
||||||
|
*/
|
||||||
|
__cy_app_core1_start_addr = ORIGIN(flash_core1); /* used to start Core1 from Core0 */
|
||||||
|
|
||||||
|
/* DFU SDK specific */
|
||||||
|
/* CyMCUElfTool uses these ELF symbols to generate an application signature */
|
||||||
|
__cy_app_verify_start = ORIGIN(flash);
|
||||||
|
__cy_app_verify_length = LENGTH(flash) + LENGTH(flash_core1) - __cy_boot_signature_size;
|
||||||
|
|
||||||
|
|
||||||
|
/* Library configurations */
|
||||||
|
GROUP(libgcc.a libc.a libm.a libnosys.a)
|
||||||
|
|
||||||
|
/* The linker script defines how to place sections and symbol values. Should be used together
|
||||||
|
* with other linker script that defines memory regions FLASH and RAM.
|
||||||
|
* It references following symbols, which must be defined in code:
|
||||||
|
* Reset_Handler : Entry of reset handler
|
||||||
|
*
|
||||||
|
* This linker script defines the symbols, which can be used by code without a definition:
|
||||||
|
* __exidx_start
|
||||||
|
* __exidx_end
|
||||||
|
* __copy_table_start__
|
||||||
|
* __copy_table_end__
|
||||||
|
* __zero_table_start__
|
||||||
|
* __zero_table_end__
|
||||||
|
* __etext
|
||||||
|
* __data_start__
|
||||||
|
* __preinit_array_start
|
||||||
|
* __preinit_array_end
|
||||||
|
* __init_array_start
|
||||||
|
* __init_array_end
|
||||||
|
* __fini_array_start
|
||||||
|
* __fini_array_end
|
||||||
|
* __data_end__
|
||||||
|
* __bss_start__
|
||||||
|
* __bss_end__
|
||||||
|
* __end__
|
||||||
|
* end
|
||||||
|
* __HeapLimit
|
||||||
|
* __StackLimit
|
||||||
|
* __StackTop
|
||||||
|
* __stack
|
||||||
|
* __Vectors_End
|
||||||
|
* __Vectors_Size
|
||||||
|
*
|
||||||
|
* For the DFU SDK, these additional symbols are defined:
|
||||||
|
* __cy_app_id
|
||||||
|
* __cy_product_id
|
||||||
|
* __cy_checksum_type
|
||||||
|
* __cy_app_core1_start_addr
|
||||||
|
* __cy_boot_metadata_addr
|
||||||
|
* __cy_boot_metadata_length
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
/* DFU SDK specific */
|
||||||
|
/* The noinit section, used across all the applications */
|
||||||
|
.cy_boot_noinit (NOLOAD) :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_boot_noinit));
|
||||||
|
} > ram_common
|
||||||
|
|
||||||
|
/* The last byte of the section is used for AppId to be shared between all the applications */
|
||||||
|
.cy_boot_noinit.appId ORIGIN(ram_common) + LENGTH(ram_common) - 1 (NOLOAD) :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_boot_noinit.appId));
|
||||||
|
} > ram_common
|
||||||
|
|
||||||
|
/* App0 uses it to initialize DFU SDK metadata, in the dfu_user.c file */
|
||||||
|
.cy_boot_metadata :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_boot_metadata))
|
||||||
|
} > flash_boot_meta
|
||||||
|
|
||||||
|
.cy_app_header :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_app_header))
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__Vectors = . ;
|
||||||
|
KEEP(*(.vectors))
|
||||||
|
. = ALIGN(4);
|
||||||
|
__Vectors_End = .;
|
||||||
|
__Vectors_Size = __Vectors_End - __Vectors;
|
||||||
|
__end__ = .;
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(.text*)
|
||||||
|
|
||||||
|
KEEP(*(.init))
|
||||||
|
KEEP(*(.fini))
|
||||||
|
|
||||||
|
/* .ctors */
|
||||||
|
*crtbegin.o(.ctors)
|
||||||
|
*crtbegin?.o(.ctors)
|
||||||
|
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||||
|
*(SORT(.ctors.*))
|
||||||
|
*(.ctors)
|
||||||
|
|
||||||
|
/* .dtors */
|
||||||
|
*crtbegin.o(.dtors)
|
||||||
|
*crtbegin?.o(.dtors)
|
||||||
|
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||||
|
*(SORT(.dtors.*))
|
||||||
|
*(.dtors)
|
||||||
|
|
||||||
|
/* Read-only code (constants). */
|
||||||
|
*(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*)
|
||||||
|
|
||||||
|
KEEP(*(.eh_frame*))
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
|
||||||
|
.ARM.extab :
|
||||||
|
{
|
||||||
|
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
__exidx_start = .;
|
||||||
|
|
||||||
|
.ARM.exidx :
|
||||||
|
{
|
||||||
|
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||||
|
} > flash
|
||||||
|
__exidx_end = .;
|
||||||
|
|
||||||
|
|
||||||
|
/* To copy multiple ROM to the RAM sections,
|
||||||
|
* uncomment .copy.table section and,
|
||||||
|
* define __STARTUP_COPY_MULTIPLE in startup_{device}_cm0plus.S */
|
||||||
|
.copy.table :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__copy_table_start__ = .;
|
||||||
|
|
||||||
|
/* Copy interrupt vectors from Flash to RAM */
|
||||||
|
LONG (__Vectors) /* From */
|
||||||
|
LONG (__ram_vectors_start__) /* To */
|
||||||
|
LONG (__Vectors_End - __Vectors) /* Size */
|
||||||
|
|
||||||
|
/* Copy data section to RAM */
|
||||||
|
LONG (__etext) /* From */
|
||||||
|
LONG (__data_start__) /* To */
|
||||||
|
LONG (__data_end__ - __data_start__) /* Size */
|
||||||
|
|
||||||
|
__copy_table_end__ = .;
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
|
||||||
|
/* To clear multiple BSS sections,
|
||||||
|
* uncomment .zero.table section and,
|
||||||
|
* define __STARTUP_CLEAR_BSS_MULTIPLE in startup_{device}_cm0plus.S */
|
||||||
|
.zero.table :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__zero_table_start__ = .;
|
||||||
|
LONG (__bss_start__)
|
||||||
|
LONG (__bss_end__ - __bss_start__)
|
||||||
|
__zero_table_end__ = .;
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
__etext = . ;
|
||||||
|
|
||||||
|
|
||||||
|
.ramVectors (NOLOAD) : ALIGN(8)
|
||||||
|
{
|
||||||
|
__ram_vectors_start__ = .;
|
||||||
|
KEEP(*(.ram_vectors))
|
||||||
|
__ram_vectors_end__ = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
.data __ram_vectors_end__ : AT (__etext)
|
||||||
|
{
|
||||||
|
__data_start__ = .;
|
||||||
|
|
||||||
|
*(vtable)
|
||||||
|
*(.data*)
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* preinit data */
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||||
|
KEEP(*(.preinit_array))
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* init data */
|
||||||
|
PROVIDE_HIDDEN (__init_array_start = .);
|
||||||
|
KEEP(*(SORT(.init_array.*)))
|
||||||
|
KEEP(*(.init_array))
|
||||||
|
PROVIDE_HIDDEN (__init_array_end = .);
|
||||||
|
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* finit data */
|
||||||
|
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||||
|
KEEP(*(SORT(.fini_array.*)))
|
||||||
|
KEEP(*(.fini_array))
|
||||||
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||||
|
|
||||||
|
KEEP(*(.jcr*))
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
KEEP(*(.cy_ramfunc*))
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
__data_end__ = .;
|
||||||
|
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* Place variables in the section that should not be initialized during the
|
||||||
|
* device startup.
|
||||||
|
*/
|
||||||
|
.noinit (NOLOAD) : ALIGN(8)
|
||||||
|
{
|
||||||
|
KEEP(*(.noinit))
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* The uninitialized global or static variables are placed in this section.
|
||||||
|
*
|
||||||
|
* The NOLOAD attribute tells the linker that the .bss section does not consume
|
||||||
|
* any space in the image. The NOLOAD attribute changes the .bss type to
|
||||||
|
* NOBITS, and that makes the linker: A) not allocate the section in memory;
|
||||||
|
* B) put information to clear the section with all zeros during application
|
||||||
|
* loading.
|
||||||
|
*
|
||||||
|
* Without the NOLOAD attribute, the .bss section might get the PROGBITS type.
|
||||||
|
* This makes the linker: A) allocate the zeroed section in memory; B) copy
|
||||||
|
* this section to RAM during application loading.
|
||||||
|
*/
|
||||||
|
.bss (NOLOAD):
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__bss_start__ = .;
|
||||||
|
*(.bss*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(4);
|
||||||
|
__bss_end__ = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
.heap (NOLOAD):
|
||||||
|
{
|
||||||
|
__HeapBase = .;
|
||||||
|
__end__ = .;
|
||||||
|
end = __end__;
|
||||||
|
KEEP(*(.heap*))
|
||||||
|
__HeapLimit = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* The .stack_dummy section doesn't contain any symbols. It is only
|
||||||
|
* used for the linker to calculate the size of the stack sections, and assign
|
||||||
|
* values to the stack symbols later */
|
||||||
|
.stack_dummy (NOLOAD):
|
||||||
|
{
|
||||||
|
KEEP(*(.stack*))
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* Set the stack top to the end of RAM, and the stack limit move down by
|
||||||
|
* the size of the stack_dummy section */
|
||||||
|
__StackTop = ORIGIN(ram) + LENGTH(ram);
|
||||||
|
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||||
|
PROVIDE(__stack = __StackTop);
|
||||||
|
|
||||||
|
/* Check if data + heap + stack exceeds RAM limit */
|
||||||
|
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||||
|
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
.cy_em_eeprom :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_em_eeprom))
|
||||||
|
} > em_eeprom
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: User data */
|
||||||
|
.cy_sflash_user_data :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_user_data))
|
||||||
|
} > sflash_user_data
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Normal Access Restrictions (NAR) */
|
||||||
|
.cy_sflash_nar :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_nar))
|
||||||
|
} > sflash_nar
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Public Key */
|
||||||
|
.cy_sflash_public_key :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_public_key))
|
||||||
|
} > sflash_public_key
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Table of Content # 2 */
|
||||||
|
.cy_toc_part2 :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_toc_part2))
|
||||||
|
} > sflash_toc_2
|
||||||
|
|
||||||
|
|
||||||
|
/* Places the code in the Execute in the Place (XIP) section. See the smif driver
|
||||||
|
* documentation for details.
|
||||||
|
*/
|
||||||
|
.cy_xip :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_xip))
|
||||||
|
} > xip
|
||||||
|
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
.cy_efuse :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_efuse))
|
||||||
|
} > efuse
|
||||||
|
|
||||||
|
|
||||||
|
/* These sections are used for additional metadata (silicon revision,
|
||||||
|
* Silicon/JTAG ID, etc.) storage.
|
||||||
|
*/
|
||||||
|
.cymeta 0x90500000 : { KEEP(*(.cymeta)) } :NONE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* EOF */
|
189
2020TPCApp0.cydsn/dfu_cm0p.scat
Normal file
189
2020TPCApp0.cydsn/dfu_cm0p.scat
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
#! armcc -E
|
||||||
|
; The first line specifies a preprocessor command that the linker invokes
|
||||||
|
; to pass a scatter file through a C preprocessor.
|
||||||
|
|
||||||
|
;*******************************************************************************
|
||||||
|
;* \file dfu_cm0p.scat
|
||||||
|
;* \version 3.0
|
||||||
|
;*
|
||||||
|
;* The linker file for the ARMCC.
|
||||||
|
;*
|
||||||
|
;* \note The entry point location is fixed and starts at 0x10000000. The valid
|
||||||
|
;* application image should be placed there.
|
||||||
|
;*
|
||||||
|
;* \note The linker files included with the PDL template projects must be
|
||||||
|
;* generic and handle all common use cases. Your project may not use every
|
||||||
|
;* section defined in the linker files. In that case, you may see the warnings
|
||||||
|
;* during the build process: L6314W (no section matches pattern) and/or L6329W
|
||||||
|
;* (pattern only matches removed unused sections). In your project, you can
|
||||||
|
;* suppress the warning by passing the "--diag_suppress=L6314W,L6329W" option to
|
||||||
|
;* the linker, simply comment out or remove the relevant code in the linker
|
||||||
|
;* file.
|
||||||
|
;*
|
||||||
|
;*******************************************************************************
|
||||||
|
;* \copyright
|
||||||
|
;* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
;* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
;* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
;* the software package with which this file was provided.
|
||||||
|
;******************************************************************************/
|
||||||
|
|
||||||
|
;* DFU SDK specific: includes defines common across all the applications
|
||||||
|
#include "dfu_mdk_common.h"
|
||||||
|
|
||||||
|
;* DFU SDK specific: defines the memory regions
|
||||||
|
;* Make sure the correct app no. is entered here.
|
||||||
|
|
||||||
|
; Flash
|
||||||
|
#define FLASH_START CY_APP0_CORE0_FLASH_ADDR
|
||||||
|
#define FLASH_SIZE CY_APP0_CORE0_FLASH_LENGTH
|
||||||
|
|
||||||
|
; Emulated EEPROM Flash area
|
||||||
|
#define EM_EEPROM_START CY_APP0_CORE0_EM_EEPROM_ADDR
|
||||||
|
#define EM_EEPROM_SIZE CY_APP0_CORE0_EM_EEPROM_LENGTH
|
||||||
|
|
||||||
|
; Supervisory flash: User data
|
||||||
|
#define SFLASH_USER_DATA_START 0x16000800
|
||||||
|
#define SFLASH_USER_DATA_SIZE 0x00000800
|
||||||
|
|
||||||
|
; Supervisory flash: Normal Access Restrictions (NAR)
|
||||||
|
#define SFLASH_NAR_START 0x16001A00
|
||||||
|
#define SFLASH_NAR_SIZE 0x00000200
|
||||||
|
|
||||||
|
; Supervisory flash: Public Key
|
||||||
|
#define SFLASH_PUBLIC_KEY_START 0x16005A00
|
||||||
|
#define SFLASH_PUBLIC_KEY_SIZE 0x00000C00
|
||||||
|
|
||||||
|
; Supervisory flash: Table of Content # 2
|
||||||
|
#define SFLASH_TOC_2_START 0x16007C00
|
||||||
|
#define SFLASH_TOC_2_SIZE 0x00000400
|
||||||
|
|
||||||
|
; External memory
|
||||||
|
#define XIP_START CY_APP0_CORE0_SMIF_ADDR
|
||||||
|
#define XIP_SIZE CY_APP0_CORE0_SMIF_LENGTH
|
||||||
|
|
||||||
|
; eFuse
|
||||||
|
#define EFUSE_START 0x90700000
|
||||||
|
#define EFUSE_SIZE 0x100000
|
||||||
|
|
||||||
|
; RAM
|
||||||
|
#define RAM_START CY_APP0_CORE0_RAM_ADDR
|
||||||
|
#define RAM_SIZE CY_APP0_CORE0_RAM_LENGTH
|
||||||
|
|
||||||
|
|
||||||
|
LR_FLASH FLASH_START FLASH_SIZE
|
||||||
|
{
|
||||||
|
.cy_app_header +0
|
||||||
|
{
|
||||||
|
* (.cy_app_header)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_FLASH_VECTORS +0
|
||||||
|
{
|
||||||
|
* (RESET, +FIRST)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_FLASH_CODE +0 FIXED
|
||||||
|
{
|
||||||
|
* (InRoot$$Sections)
|
||||||
|
* (+RO)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_RAM_COMMON CY_APP_RAM_COMMON_ADDR UNINIT
|
||||||
|
{
|
||||||
|
* (.cy_boot_noinit.appId)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_RAM_VECTORS RAM_START UNINIT
|
||||||
|
{
|
||||||
|
* (RESET_RAM, +FIRST)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_RAM_DATA +0
|
||||||
|
{
|
||||||
|
* (.cy_ramfunc)
|
||||||
|
.ANY (+RW, +ZI)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Place variables in the section that should not be initialized during the
|
||||||
|
; device startup.
|
||||||
|
ER_RAM_NOINIT_DATA +0 UNINIT
|
||||||
|
{
|
||||||
|
* (.noinit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; Emulated EEPROM Flash area
|
||||||
|
LR_EM_EEPROM EM_EEPROM_START EM_EEPROM_SIZE
|
||||||
|
{
|
||||||
|
.cy_em_eeprom +0
|
||||||
|
{
|
||||||
|
* (.cy_em_eeprom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: User data
|
||||||
|
LR_SFLASH_USER_DATA SFLASH_USER_DATA_START SFLASH_USER_DATA_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_user_data +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_user_data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: Normal Access Restrictions (NAR)
|
||||||
|
LR_SFLASH_NAR SFLASH_NAR_START SFLASH_NAR_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_nar +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_nar)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: Public Key
|
||||||
|
LR_SFLASH_PUBLIC_KEY SFLASH_PUBLIC_KEY_START SFLASH_PUBLIC_KEY_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_public_key +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_public_key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory flash: Table of Content # 2
|
||||||
|
LR_SFLASH_TOC_2 SFLASH_TOC_2_START SFLASH_TOC_2_SIZE
|
||||||
|
{
|
||||||
|
.cy_toc_part2 +0
|
||||||
|
{
|
||||||
|
* (.cy_toc_part2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Places the code in the Execute in the Place (XIP) section. See the smif driver documentation for details.
|
||||||
|
LR_EROM XIP_START XIP_SIZE
|
||||||
|
{
|
||||||
|
.cy_xip +0
|
||||||
|
{
|
||||||
|
* (.cy_xip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; eFuse
|
||||||
|
LR_EFUSE EFUSE_START EFUSE_SIZE
|
||||||
|
{
|
||||||
|
.cy_efuse +0
|
||||||
|
{
|
||||||
|
* (.cy_efuse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; The section is used for additional metadata (silicon revision, Silicon/JTAG ID, etc.) storage.
|
||||||
|
CYMETA 0x90500000
|
||||||
|
{
|
||||||
|
.cymeta +0 { * (.cymeta) }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
248
2020TPCApp0.cydsn/dfu_cm4.icf
Normal file
248
2020TPCApp0.cydsn/dfu_cm4.icf
Normal file
|
@ -0,0 +1,248 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file dfu_cm4.icf
|
||||||
|
* \version 3.0
|
||||||
|
*
|
||||||
|
* The linker file for the the IAR compiler.
|
||||||
|
*
|
||||||
|
* \note The entry point is fixed and starts at 0x10000000. The valid application
|
||||||
|
* image should be placed there.
|
||||||
|
*
|
||||||
|
* \note The linker files included with the PDL template projects must be generic
|
||||||
|
* and handle all common use cases. Your project may not use every section
|
||||||
|
* defined in the linker files. In that case, you may see warnings during the
|
||||||
|
* build process. In your project, you can simply comment out or remove the
|
||||||
|
* relevant code in the linker file.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/*-Editor annotation file-*/
|
||||||
|
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_4.xml" */
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Start of CM4 and CM0+ linker script common region
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/*-Memory Regions-*/
|
||||||
|
/* Flash */
|
||||||
|
define exported symbol __cy_memory_0_start = 0x10000000;
|
||||||
|
define exported symbol __cy_memory_0_length = 0x00100000;
|
||||||
|
define exported symbol __cy_memory_0_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
define exported symbol __cy_memory_1_start = 0x14000000;
|
||||||
|
define exported symbol __cy_memory_1_length = 0x8000;
|
||||||
|
define exported symbol __cy_memory_1_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
define exported symbol __cy_memory_2_start = 0x16000000;
|
||||||
|
define exported symbol __cy_memory_2_length = 0x8000;
|
||||||
|
define exported symbol __cy_memory_2_row_size = 0x200;
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
define exported symbol __cy_memory_3_start = 0x18000000;
|
||||||
|
define exported symbol __cy_memory_3_length = 0x08000000;
|
||||||
|
define exported symbol __cy_memory_3_row_size = 0x200;
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
define exported symbol __cy_memory_4_start = 0x90700000;
|
||||||
|
define exported symbol __cy_memory_4_length = 0x100000;
|
||||||
|
define exported symbol __cy_memory_4_row_size = 1;
|
||||||
|
|
||||||
|
|
||||||
|
define memory mem with size = 4G;
|
||||||
|
|
||||||
|
/* Memory regions for all applications are defined here */
|
||||||
|
define region FLASH_app0_core0 = mem:[from 0x10000000 size 0x10000];
|
||||||
|
define region FLASH_app0_core1 = mem:[from 0x10010000 size 0x10000];
|
||||||
|
define region FLASH_app1_core0 = mem:[from 0x10040000 size 0x10000];
|
||||||
|
define region FLASH_app1_core1 = mem:[from 0x10050000 size 0x10000];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The region for DFU SDK metadata
|
||||||
|
* when it is outside of any application
|
||||||
|
*/
|
||||||
|
define region FLASH_boot_meta = mem:[from 0x100FFA00 size 0x200];
|
||||||
|
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
define region ROM_EFUSE = mem:[from 0x90700000 size 0x100000];
|
||||||
|
|
||||||
|
/* SFlash NAR */
|
||||||
|
define region SFLASH_NAR = mem:[from 0x16001A00 size 0x200];
|
||||||
|
|
||||||
|
/* SFlash User Data */
|
||||||
|
define region SFLASH_USER_DATA = mem:[from 0x16000800 size 0x800];
|
||||||
|
|
||||||
|
/* SFlash Public Key, 6 SFlash rows */
|
||||||
|
define region SFLASH_PUBLIC_KEY = mem:[from 0x16005A00 size 0xC00];
|
||||||
|
|
||||||
|
/* Table of Content part 2, two SFlash rows */
|
||||||
|
define region SFLASH_TOC = mem:[from 0x16007C00 size 0x400];
|
||||||
|
|
||||||
|
|
||||||
|
/* Emulated EEPROM app regions */
|
||||||
|
define region EM_EEPROM_app0_core0 = mem:[from 0x14000000 size 0x8000];
|
||||||
|
define region EM_EEPROM_app0_core1 = mem:[from 0x14000000 size 0x8000];
|
||||||
|
define region EM_EEPROM_app1_core0 = mem:[from 0x14000000 size 0x8000];
|
||||||
|
define region EM_EEPROM_app1_core1 = mem:[from 0x14000000 size 0x8000];
|
||||||
|
|
||||||
|
/* XIP/SMIF app regions */
|
||||||
|
define region EROM_app0_core0 = mem:[from 0x18000000 size 0x1000];
|
||||||
|
define region EROM_app0_core1 = mem:[from 0x18000000 size 0x1000];
|
||||||
|
define region EROM_app1_core0 = mem:[from 0x18000000 size 0x1000];
|
||||||
|
define region EROM_app1_core1 = mem:[from 0x18000000 size 0x1000];
|
||||||
|
|
||||||
|
/* used for RAM sharing across applications */
|
||||||
|
define region IRAM_common = mem:[from 0x08000000 size 0x0100];
|
||||||
|
|
||||||
|
/* note: all the IRAM_appX_core0 regions has to be 0x100 aligned */
|
||||||
|
/* and the IRAM_appX_core1 regions has to be 0x400 aligned */
|
||||||
|
/* as they contain Interrupt Vector Table Remapped at the start */
|
||||||
|
define region IRAM_app0_core0 = mem:[from 0x08000100 size 0x1F00];
|
||||||
|
define region IRAM_app0_core1 = mem:[from 0x08002000 size 0x8000];
|
||||||
|
define region IRAM_app1_core0 = mem:[from 0x08000100 size 0x1F00];
|
||||||
|
define region IRAM_app1_core1 = mem:[from 0x08002000 size 0x8000];
|
||||||
|
|
||||||
|
|
||||||
|
/* Used by all DFU SDK and CyMCUElfTool */
|
||||||
|
define exported symbol __cy_boot_metadata_addr = 0x100FFA00;
|
||||||
|
define exported symbol __cy_boot_metadata_length = __cy_memory_0_row_size;
|
||||||
|
|
||||||
|
/* Used by CyMCUElfTool to generate ProductID for DFU SDK apps */
|
||||||
|
define exported symbol __cy_product_id = 0x01020304;
|
||||||
|
|
||||||
|
/* Used by CyMCUElfTool to generate ChecksumType for DFU SDK apps */
|
||||||
|
define exported symbol __cy_checksum_type = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The size of the application signature.
|
||||||
|
* E.g. 4 for CRC-32,
|
||||||
|
* 32 for SHA256,
|
||||||
|
* 256 for RSA 2048.
|
||||||
|
*/
|
||||||
|
define exported symbol __cy_boot_signature_size = 4;
|
||||||
|
|
||||||
|
/* Used by DFU SDK projects, in dfu_user.c to fill in the metadata table */
|
||||||
|
define exported symbol __cy_app0_verify_start = start(FLASH_app0_core0);
|
||||||
|
define exported symbol __cy_app0_verify_length = size (FLASH_app0_core0) + size (FLASH_app0_core1)
|
||||||
|
- __cy_boot_signature_size;
|
||||||
|
|
||||||
|
define exported symbol __cy_app1_verify_start = start(FLASH_app1_core0);
|
||||||
|
define exported symbol __cy_app1_verify_length = size (FLASH_app1_core0) + size (FLASH_app1_core1)
|
||||||
|
- __cy_boot_signature_size;
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* End of CM4 and CM0+ linker script common region
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/* CyMCUElfTool uses this symbol to set a proper app number */
|
||||||
|
define exported symbol __cy_app_id = 0;
|
||||||
|
|
||||||
|
/* CyMCUElfTool uses these to generate an application signature */
|
||||||
|
/* The size of the default signature (CRC-32C) is 4 bytes */
|
||||||
|
define exported symbol __cy_app_verify_start = start(FLASH_app0_core0);
|
||||||
|
define exported symbol __cy_app_verify_length = size(FLASH_app0_core0) + size(FLASH_app0_core1)
|
||||||
|
- __cy_boot_signature_size;
|
||||||
|
|
||||||
|
|
||||||
|
/*-Sizes-*/
|
||||||
|
if (!isdefinedsymbol(__STACK_SIZE)) {
|
||||||
|
define symbol __ICFEDIT_size_cstack__ = 0x1000;
|
||||||
|
} else {
|
||||||
|
define symbol __ICFEDIT_size_cstack__ = __STACK_SIZE;
|
||||||
|
}
|
||||||
|
define symbol __ICFEDIT_size_proc_stack__ = 0x0;
|
||||||
|
if (!isdefinedsymbol(__HEAP_SIZE)) {
|
||||||
|
define symbol __ICFEDIT_size_heap__ = 0x0400;
|
||||||
|
} else {
|
||||||
|
define symbol __ICFEDIT_size_heap__ = __HEAP_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
define region IROM1_region = FLASH_app0_core1; /* Flash, user app */
|
||||||
|
define region IROM2_region = EM_EEPROM_app0_core1; /* Emulated EEPROM */
|
||||||
|
define region IROM3_region = SFLASH_USER_DATA; /* SFlash User Data */
|
||||||
|
define region IROM4_region = SFLASH_NAR; /* SFlash NAR */
|
||||||
|
define region IROM5_region = SFLASH_PUBLIC_KEY; /* SFlash Public Key */
|
||||||
|
define region IROM6_region = SFLASH_TOC; /* SFlash TOC part 2 */
|
||||||
|
define region IROM7_region = ROM_EFUSE; /* eFuse */
|
||||||
|
define region EROM1_region = EROM_app0_core1; /* XIP / SMIF */
|
||||||
|
define region IRAM1_region = IRAM_app0_core1; /* RAM */
|
||||||
|
|
||||||
|
|
||||||
|
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||||
|
define block PROC_STACK with alignment = 8, size = __ICFEDIT_size_proc_stack__ { };
|
||||||
|
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||||
|
define block HSTACK {block HEAP, block PROC_STACK, last block CSTACK};
|
||||||
|
define block RO {first section .intvec, readonly};
|
||||||
|
|
||||||
|
/*-Initializations-*/
|
||||||
|
initialize by copy { readwrite };
|
||||||
|
do not initialize { section .noinit, section .intvec_ram,
|
||||||
|
section .cy_boot_noinit.appId, section .cy_boot_noinit };
|
||||||
|
|
||||||
|
|
||||||
|
/*-Placement-*/
|
||||||
|
|
||||||
|
/* Flash */
|
||||||
|
place at start of IROM1_region { block RO };
|
||||||
|
".cy_app_signature": place at end of IROM1_region { section .cy_app_signature };
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
".cy_em_eeprom" : place at start of IROM2_region { section .cy_em_eeprom };
|
||||||
|
|
||||||
|
/* Supervisory Flash - User Data */
|
||||||
|
".cy_sflash_user_data" : place at start of IROM3_region { section .cy_sflash_user_data };
|
||||||
|
|
||||||
|
/* Supervisory Flash - NAR */
|
||||||
|
".cy_sflash_nar" : place at start of IROM4_region { section .cy_sflash_nar };
|
||||||
|
|
||||||
|
/* Supervisory Flash - Public Key */
|
||||||
|
".cy_sflash_public_key" : place at start of IROM5_region { section .cy_sflash_public_key };
|
||||||
|
|
||||||
|
/* Supervisory Flash - TOC2 */
|
||||||
|
".cy_toc_part2" : place at start of IROM6_region { section .cy_toc_part2 };
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
".cy_efuse" : place at start of IROM7_region { section .cy_efuse };
|
||||||
|
|
||||||
|
/* Execute in Place (XIP). See the smif driver documentation for details. */
|
||||||
|
".cy_xip" : place at start of EROM1_region { section .cy_xip };
|
||||||
|
|
||||||
|
/* RAM */
|
||||||
|
place at start of IRAM_common { readwrite section .cy_boot_noinit.appId };
|
||||||
|
place in IRAM_common { readwrite section .cy_boot_noinit };
|
||||||
|
place at start of IRAM1_region { readwrite section .intvec_ram};
|
||||||
|
place in IRAM1_region { readwrite };
|
||||||
|
place at end of IRAM1_region { block HSTACK };
|
||||||
|
|
||||||
|
/* These sections are used for additional metadata (silicon revision, Silicon/JTAG ID, etc.) storage. */
|
||||||
|
".cymeta" : place at address mem : 0x90500000 { readonly section .cymeta };
|
||||||
|
|
||||||
|
/* App0 uses it to initialize DFU SDK metadata, in the dfu_user.c file */
|
||||||
|
".cy_boot_metadata" : place at start of FLASH_boot_meta { section .cy_boot_metadata };
|
||||||
|
|
||||||
|
keep { section .cy_app_signature,
|
||||||
|
section .cy_em_eeprom,
|
||||||
|
section .cy_sflash_user_data,
|
||||||
|
section .cy_sflash_nar,
|
||||||
|
section .cy_sflash_public_key,
|
||||||
|
section .cy_sflash_toc_2,
|
||||||
|
section .cy_efuse,
|
||||||
|
section .cy_xip,
|
||||||
|
section .cymeta,
|
||||||
|
section .cy_boot_metadata,
|
||||||
|
section .cy_boot_noinit,
|
||||||
|
section .cy_boot_noinit.appId,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* EOF */
|
478
2020TPCApp0.cydsn/dfu_cm4.ld
Normal file
478
2020TPCApp0.cydsn/dfu_cm4.ld
Normal file
|
@ -0,0 +1,478 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file dfu_cm4.ld
|
||||||
|
* \version 3.0
|
||||||
|
*
|
||||||
|
* The linker file for the GNU C compiler.
|
||||||
|
* Used for DFU SDK core1 firmware projects.
|
||||||
|
*
|
||||||
|
* \note The linker files included with the PDL template projects must be generic
|
||||||
|
* and handle all common use cases. Your project may not use every section
|
||||||
|
* defined in the linker files. In that case, you may see warnings during the
|
||||||
|
* build process. In your project, simply comment out or remove the
|
||||||
|
* relevant code in the linker file.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||||
|
SEARCH_DIR(.)
|
||||||
|
GROUP(-lgcc -lc -lnosys)
|
||||||
|
ENTRY(Reset_Handler)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Forces symbol to be added to the output file.
|
||||||
|
* Otherwise linker may remove it if founds that it is not used in the project.
|
||||||
|
* This command has the same effect as the -u command-line option.
|
||||||
|
*/
|
||||||
|
EXTERN(Reset_Handler)
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Start of CM4 and CM0+ linker script common region
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Memory regions, for each application and MCU core.
|
||||||
|
*/
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
flash_app0_core0 (rx) : ORIGIN = 0x10000000, LENGTH = 0x10000
|
||||||
|
flash_app0_core1 (rx) : ORIGIN = 0x10010000, LENGTH = 0x30000
|
||||||
|
flash_app1_core0 (rx) : ORIGIN = 0x10040000, LENGTH = 0x30000
|
||||||
|
flash_app1_core1 (rx) : ORIGIN = 0x10070000, LENGTH = 0x50000
|
||||||
|
|
||||||
|
flash_storage (rw) : ORIGIN = 0x100D0000, LENGTH = 0x1000
|
||||||
|
flash_boot_meta (rw) : ORIGIN = 0x100FFA00, LENGTH = 0x400
|
||||||
|
|
||||||
|
sflash_user_data (rx) : ORIGIN = 0x16000800, LENGTH = 0x800
|
||||||
|
sflash_nar (rx) : ORIGIN = 0x16001A00, LENGTH = 0x200
|
||||||
|
sflash_public_key (rx) : ORIGIN = 0x16005A00, LENGTH = 0xC00
|
||||||
|
sflash_toc_2 (rx) : ORIGIN = 0x16007C00, LENGTH = 0x400
|
||||||
|
|
||||||
|
efuse (r) : ORIGIN = 0x90700000, LENGTH = 0x100000
|
||||||
|
|
||||||
|
ram_common (rwx) : ORIGIN = 0x08000000, LENGTH = 0x0100
|
||||||
|
|
||||||
|
/* note: all the ram_appX_core0 regions has to be 0x100 aligned */
|
||||||
|
/* and the ram_appX_core1 regions has to be 0x400 aligned */
|
||||||
|
/* as they contain Interrupt Vector Table Remapped at the start */
|
||||||
|
ram_app0_core0 (rwx) : ORIGIN = 0x08000100, LENGTH = 0x7F00
|
||||||
|
ram_app0_core1 (rwx) : ORIGIN = 0x08008000, LENGTH = 0x8000
|
||||||
|
|
||||||
|
ram_app1_core0 (rwx) : ORIGIN = 0x08000100, LENGTH = 0x7F00
|
||||||
|
ram_app1_core1 (rwx) : ORIGIN = 0x08008000, LENGTH = 0x30000
|
||||||
|
|
||||||
|
em_eeprom (rx) : ORIGIN = 0x14000000, LENGTH = 0x8000
|
||||||
|
xip (rx) : ORIGIN = 0x18000000, LENGTH = 0x08000000
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Regions parameters */
|
||||||
|
/* Flash */
|
||||||
|
__cy_memory_0_start = 0x10000000;
|
||||||
|
__cy_memory_0_length = 0x00100000;
|
||||||
|
__cy_memory_0_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
__cy_memory_1_start = 0x14000000;
|
||||||
|
__cy_memory_1_length = 0x8000;
|
||||||
|
__cy_memory_1_row_size = 0x200;
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
__cy_memory_2_start = 0x16000000;
|
||||||
|
__cy_memory_2_length = 0x8000;
|
||||||
|
__cy_memory_2_row_size = 0x200;
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
__cy_memory_3_start = 0x18000000;
|
||||||
|
__cy_memory_3_length = 0x08000000;
|
||||||
|
__cy_memory_3_row_size = 0x200;
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
__cy_memory_4_start = 0x90700000;
|
||||||
|
__cy_memory_4_length = 0x100000;
|
||||||
|
__cy_memory_4_row_size = 1;
|
||||||
|
|
||||||
|
/* The DFU SDK metadata limits */
|
||||||
|
__cy_boot_metadata_addr = ORIGIN(flash_boot_meta);
|
||||||
|
__cy_boot_metadata_length = __cy_memory_0_row_size;
|
||||||
|
|
||||||
|
/* The Product ID, used by CyMCUElfTool to generate a updating file */
|
||||||
|
__cy_product_id = 0x01020304;
|
||||||
|
|
||||||
|
/* The checksum type used by CyMCUElfTool to generate a updating file */
|
||||||
|
__cy_checksum_type = 0x00;
|
||||||
|
|
||||||
|
/* Used by the DFU SDK application to set the metadata */
|
||||||
|
__cy_app0_verify_start = ORIGIN(flash_app0_core0);
|
||||||
|
__cy_app0_verify_length = LENGTH(flash_app0_core0) + LENGTH(flash_app0_core1) - __cy_boot_signature_size;
|
||||||
|
__cy_app1_verify_start = ORIGIN(flash_app1_core0);
|
||||||
|
__cy_app1_verify_length = LENGTH(flash_app1_core0) + LENGTH(flash_app1_core1) - __cy_boot_signature_size;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The size of the application signature.
|
||||||
|
* E.g. 4 for CRC-32,
|
||||||
|
* 32 for SHA256,
|
||||||
|
* 256 for RSA 2048.
|
||||||
|
*/
|
||||||
|
__cy_boot_signature_size = 256;
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* End of CM4 and CM0+ linker script common region
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DFU SDK specific: aliases regions, so the rest of code does not use
|
||||||
|
* application specific memory region names
|
||||||
|
*/
|
||||||
|
REGION_ALIAS("flash_core0", flash_app0_core0);
|
||||||
|
REGION_ALIAS("flash", flash_app0_core1);
|
||||||
|
REGION_ALIAS("ram", ram_app0_core1);
|
||||||
|
|
||||||
|
/* DFU SDK specific: sets an app Id */
|
||||||
|
__cy_app_id = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* DFU SDK specific */
|
||||||
|
/* CyMCUElfTool uses these ELF symbols to generate an application signature */
|
||||||
|
__cy_app_verify_start = ORIGIN(flash_core0);
|
||||||
|
__cy_app_verify_length = LENGTH(flash_core0) + LENGTH(flash) - __cy_boot_signature_size;
|
||||||
|
|
||||||
|
|
||||||
|
/* Library configurations */
|
||||||
|
GROUP(libgcc.a libc.a libm.a libnosys.a)
|
||||||
|
|
||||||
|
/* The linker script defines how to place sections and symbol values. Should be used together
|
||||||
|
* with other linker script that defines memory regions FLASH and RAM.
|
||||||
|
* It references following symbols, which must be defined in code:
|
||||||
|
* Reset_Handler : Entry of reset handler
|
||||||
|
*
|
||||||
|
* This linker script defines the symbols, which can be used by code without a definition:
|
||||||
|
* __exidx_start
|
||||||
|
* __exidx_end
|
||||||
|
* __copy_table_start__
|
||||||
|
* __copy_table_end__
|
||||||
|
* __zero_table_start__
|
||||||
|
* __zero_table_end__
|
||||||
|
* __etext
|
||||||
|
* __data_start__
|
||||||
|
* __preinit_array_start
|
||||||
|
* __preinit_array_end
|
||||||
|
* __init_array_start
|
||||||
|
* __init_array_end
|
||||||
|
* __fini_array_start
|
||||||
|
* __fini_array_end
|
||||||
|
* __data_end__
|
||||||
|
* __bss_start__
|
||||||
|
* __bss_end__
|
||||||
|
* __end__
|
||||||
|
* end
|
||||||
|
* __HeapLimit
|
||||||
|
* __StackLimit
|
||||||
|
* __StackTop
|
||||||
|
* __stack
|
||||||
|
* __Vectors_End
|
||||||
|
* __Vectors_Size
|
||||||
|
*
|
||||||
|
* For the DFU SDK, these additional symbols are defined:
|
||||||
|
* __cy_app_id
|
||||||
|
* __cy_product_id
|
||||||
|
* __cy_checksum_type
|
||||||
|
* __cy_app_core1_start_addr
|
||||||
|
* __cy_boot_metadata_addr
|
||||||
|
* __cy_boot_metadata_length
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
/* DFU SDK specific */
|
||||||
|
/* The noinit section, used across all the applications */
|
||||||
|
.cy_boot_noinit (NOLOAD) :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_boot_noinit));
|
||||||
|
} > ram_common
|
||||||
|
|
||||||
|
/* The last byte of the section is used for AppId to be shared between all the applications */
|
||||||
|
.cy_boot_noinit.appId ORIGIN(ram_common) + LENGTH(ram_common) - 1 (NOLOAD) :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_boot_noinit.appId));
|
||||||
|
} > ram_common
|
||||||
|
|
||||||
|
/* App0 uses it to initialize DFU SDK metadata, in the dfu_user.c file */
|
||||||
|
.cy_boot_metadata :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_boot_metadata))
|
||||||
|
} > flash_boot_meta
|
||||||
|
|
||||||
|
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__Vectors = . ;
|
||||||
|
KEEP(*(.vectors))
|
||||||
|
. = ALIGN(4);
|
||||||
|
__Vectors_End = .;
|
||||||
|
__Vectors_Size = __Vectors_End - __Vectors;
|
||||||
|
__end__ = .;
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(.text*)
|
||||||
|
|
||||||
|
KEEP(*(.init))
|
||||||
|
KEEP(*(.fini))
|
||||||
|
|
||||||
|
/* .ctors */
|
||||||
|
*crtbegin.o(.ctors)
|
||||||
|
*crtbegin?.o(.ctors)
|
||||||
|
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||||
|
*(SORT(.ctors.*))
|
||||||
|
*(.ctors)
|
||||||
|
|
||||||
|
/* .dtors */
|
||||||
|
*crtbegin.o(.dtors)
|
||||||
|
*crtbegin?.o(.dtors)
|
||||||
|
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||||
|
*(SORT(.dtors.*))
|
||||||
|
*(.dtors)
|
||||||
|
|
||||||
|
/* Read-only code (constants). */
|
||||||
|
*(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*)
|
||||||
|
|
||||||
|
KEEP(*(.eh_frame*))
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
|
||||||
|
.ARM.extab :
|
||||||
|
{
|
||||||
|
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
__exidx_start = .;
|
||||||
|
|
||||||
|
.ARM.exidx :
|
||||||
|
{
|
||||||
|
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||||
|
} > flash
|
||||||
|
__exidx_end = .;
|
||||||
|
|
||||||
|
|
||||||
|
/* To copy multiple ROM to the RAM sections,
|
||||||
|
* uncomment .copy.table section and,
|
||||||
|
* define __STARTUP_COPY_MULTIPLE in startup_{device}_cm4.S */
|
||||||
|
.copy.table :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__copy_table_start__ = .;
|
||||||
|
|
||||||
|
/* Copy interrupt vectors from flash to RAM */
|
||||||
|
LONG (__Vectors) /* From */
|
||||||
|
LONG (__ram_vectors_start__) /* To */
|
||||||
|
LONG (__Vectors_End - __Vectors) /* Size */
|
||||||
|
|
||||||
|
/* Copy data section to RAM */
|
||||||
|
LONG (__etext) /* From */
|
||||||
|
LONG (__data_start__) /* To */
|
||||||
|
LONG (__data_end__ - __data_start__) /* Size */
|
||||||
|
|
||||||
|
__copy_table_end__ = .;
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
|
||||||
|
/* To clear multiple BSS sections,
|
||||||
|
* uncomment .zero.table section and,
|
||||||
|
* define __STARTUP_CLEAR_BSS_MULTIPLE in startup_{device}_cm4.S */
|
||||||
|
.zero.table :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__zero_table_start__ = .;
|
||||||
|
LONG (__bss_start__)
|
||||||
|
LONG (__bss_end__ - __bss_start__)
|
||||||
|
__zero_table_end__ = .;
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
__etext = . ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The DFU SDK section for an app verification signature.
|
||||||
|
* Must be placed at the end of the application.
|
||||||
|
* In this case, last N bytes of the last Flash row inside the application.
|
||||||
|
*/
|
||||||
|
.cy_app_signature ABSOLUTE(ORIGIN(flash) + LENGTH(flash) - __cy_boot_signature_size) :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_app_signature))
|
||||||
|
} > flash = 0
|
||||||
|
|
||||||
|
.ramVectors (NOLOAD) : ALIGN(8)
|
||||||
|
{
|
||||||
|
__ram_vectors_start__ = .;
|
||||||
|
KEEP(*(.ram_vectors))
|
||||||
|
__ram_vectors_end__ = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
.data __ram_vectors_end__ : AT (__etext)
|
||||||
|
{
|
||||||
|
__data_start__ = .;
|
||||||
|
|
||||||
|
*(vtable)
|
||||||
|
*(.data*)
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* preinit data */
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||||
|
KEEP(*(.preinit_array))
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* init data */
|
||||||
|
PROVIDE_HIDDEN (__init_array_start = .);
|
||||||
|
KEEP(*(SORT(.init_array.*)))
|
||||||
|
KEEP(*(.init_array))
|
||||||
|
PROVIDE_HIDDEN (__init_array_end = .);
|
||||||
|
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* finit data */
|
||||||
|
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||||
|
KEEP(*(SORT(.fini_array.*)))
|
||||||
|
KEEP(*(.fini_array))
|
||||||
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||||
|
|
||||||
|
KEEP(*(.jcr*))
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
KEEP(*(.cy_ramfunc*))
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
__data_end__ = .;
|
||||||
|
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* Place variables in the section that should not be initialized during the
|
||||||
|
* device startup.
|
||||||
|
*/
|
||||||
|
.noinit (NOLOAD) : ALIGN(8)
|
||||||
|
{
|
||||||
|
KEEP(*(.noinit))
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* The uninitialized global or static variables are placed in this section.
|
||||||
|
*
|
||||||
|
* The NOLOAD attribute tells the linker that the .bss section does not consume
|
||||||
|
* any space in the image. The NOLOAD attribute changes the .bss type to
|
||||||
|
* NOBITS, and that makes the linker: A) not allocate the section in memory;
|
||||||
|
* B) put information to clear the section with all zeros during application
|
||||||
|
* loading.
|
||||||
|
*
|
||||||
|
* Without the NOLOAD attribute, the .bss section might get the PROGBITS type.
|
||||||
|
* This makes the linker: A) allocate the zeroed section in memory; B) copy
|
||||||
|
* this section to RAM during application loading.
|
||||||
|
*/
|
||||||
|
.bss (NOLOAD):
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
__bss_start__ = .;
|
||||||
|
*(.bss*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(4);
|
||||||
|
__bss_end__ = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
.heap (NOLOAD):
|
||||||
|
{
|
||||||
|
__HeapBase = .;
|
||||||
|
__end__ = .;
|
||||||
|
end = __end__;
|
||||||
|
KEEP(*(.heap*))
|
||||||
|
__HeapLimit = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* The .stack_dummy section doesn't contain any symbols. It is only
|
||||||
|
* used for the linker to calculate the size of the stack sections, and assign
|
||||||
|
* values to the stack symbols later */
|
||||||
|
.stack_dummy (NOLOAD):
|
||||||
|
{
|
||||||
|
KEEP(*(.stack*))
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
|
||||||
|
/* Set the stack top to the end of RAM, and the stack limit move down by
|
||||||
|
* the size of the stack_dummy section */
|
||||||
|
__StackTop = ORIGIN(ram) + LENGTH(ram);
|
||||||
|
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||||
|
PROVIDE(__stack = __StackTop);
|
||||||
|
|
||||||
|
/* Check if data + heap + stack exceeds RAM limit */
|
||||||
|
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||||
|
|
||||||
|
|
||||||
|
/* Emulated EEPROM Flash area */
|
||||||
|
.cy_em_eeprom :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_em_eeprom))
|
||||||
|
} > em_eeprom
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: User data */
|
||||||
|
.cy_sflash_user_data :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_user_data))
|
||||||
|
} > sflash_user_data
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Normal Access Restrictions (NAR) */
|
||||||
|
.cy_sflash_nar :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_nar))
|
||||||
|
} > sflash_nar
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Public Key */
|
||||||
|
.cy_sflash_public_key :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_sflash_public_key))
|
||||||
|
} > sflash_public_key
|
||||||
|
|
||||||
|
|
||||||
|
/* Supervisory Flash: Table of Content # 2 */
|
||||||
|
.cy_toc_part2 :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_toc_part2))
|
||||||
|
} > sflash_toc_2
|
||||||
|
|
||||||
|
|
||||||
|
/* Places the code in the Execute in the Place (XIP) section. See the smif driver
|
||||||
|
* documentation for details.
|
||||||
|
*/
|
||||||
|
.cy_xip :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_xip))
|
||||||
|
} > xip
|
||||||
|
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
.cy_efuse :
|
||||||
|
{
|
||||||
|
KEEP(*(.cy_efuse))
|
||||||
|
} > efuse
|
||||||
|
|
||||||
|
|
||||||
|
/* These sections are used for additional metadata (silicon revision,
|
||||||
|
* Silicon/JTAG ID, etc.) storage.
|
||||||
|
*/
|
||||||
|
.cymeta 0x90500000 : { KEEP(*(.cymeta)) } :NONE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* EOF */
|
206
2020TPCApp0.cydsn/dfu_cm4.scat
Normal file
206
2020TPCApp0.cydsn/dfu_cm4.scat
Normal file
|
@ -0,0 +1,206 @@
|
||||||
|
#! armcc -E
|
||||||
|
; The first line specifies a preprocessor command that the linker invokes
|
||||||
|
; to pass a scatter file through a C preprocessor.
|
||||||
|
|
||||||
|
;*******************************************************************************
|
||||||
|
;* \file dfu_cm4.scat
|
||||||
|
;* \version 3.0
|
||||||
|
;*
|
||||||
|
;* The linker file for the ARMCC.
|
||||||
|
;*
|
||||||
|
;* \note The entry point location is fixed and starts at 0x10000000. The valid
|
||||||
|
;* application image should be placed there.
|
||||||
|
;*
|
||||||
|
;* \note The linker files included with the PDL template projects must be
|
||||||
|
;* generic and handle all common use cases. Your project may not use every
|
||||||
|
;* section defined in the linker files. In that case, you may see the warnings
|
||||||
|
;* during the build process: L6314W (no section matches pattern) and/or L6329W
|
||||||
|
;* (pattern only matches removed unused sections). In your project, you can
|
||||||
|
;* suppress the warning by passing the "--diag_suppress=L6314W,L6329W" option to
|
||||||
|
;* the linker, simply comment out or remove the relevant code in the linker
|
||||||
|
;* file.
|
||||||
|
;*
|
||||||
|
;*******************************************************************************
|
||||||
|
;* \copyright
|
||||||
|
;* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
;* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
;* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
;* the software package with which this file was provided.
|
||||||
|
;******************************************************************************/
|
||||||
|
|
||||||
|
;* DFU SDK specific: includes defines common across all the applications
|
||||||
|
#include "dfu_mdk_common.h"
|
||||||
|
|
||||||
|
;* DFU SDK specific: defines the memory regions
|
||||||
|
;* Make sure the correct app no. is entered here
|
||||||
|
|
||||||
|
; Flash
|
||||||
|
#define FLASH_START CY_APP0_CORE1_FLASH_ADDR
|
||||||
|
#define FLASH_SIZE CY_APP0_CORE1_FLASH_LENGTH
|
||||||
|
|
||||||
|
; Flash Toc
|
||||||
|
#define FLASH_TOC_START CY_TOC_START
|
||||||
|
#define FLASH_TOC_SIZE CY_TOC_SIZE
|
||||||
|
|
||||||
|
; Emulated EEPROM Flash area
|
||||||
|
#define EM_EEPROM_START CY_APP0_CORE1_EM_EEPROM_ADDR
|
||||||
|
#define EM_EEPROM_SIZE CY_APP0_CORE1_EM_EEPROM_LENGTH
|
||||||
|
|
||||||
|
; Supervisory flash: User data
|
||||||
|
#define SFLASH_USER_DATA_START 0x16000800
|
||||||
|
#define SFLASH_USER_DATA_SIZE 0x00000800
|
||||||
|
|
||||||
|
; Supervisory flash: Normal Access Restrictions (NAR)
|
||||||
|
#define SFLASH_NAR_START 0x16001A00
|
||||||
|
#define SFLASH_NAR_SIZE 0x00000200
|
||||||
|
|
||||||
|
; Supervisory flash: Public Key
|
||||||
|
#define SFLASH_PUBLIC_KEY_START 0x16005A00
|
||||||
|
#define SFLASH_PUBLIC_KEY_SIZE 0x00000C00
|
||||||
|
|
||||||
|
; Supervisory flash: Table of Content # 2
|
||||||
|
#define SFLASH_TOC_2_START 0x16007C00
|
||||||
|
#define SFLASH_TOC_2_SIZE 0x00000400
|
||||||
|
|
||||||
|
; External memory
|
||||||
|
#define XIP_START CY_APP0_CORE1_SMIF_ADDR
|
||||||
|
#define XIP_SIZE CY_APP0_CORE1_SMIF_LENGTH
|
||||||
|
|
||||||
|
; eFuse
|
||||||
|
#define EFUSE_START 0x90700000
|
||||||
|
#define EFUSE_SIZE 0x100000
|
||||||
|
|
||||||
|
; RAM
|
||||||
|
#define RAM_START CY_APP0_CORE1_RAM_ADDR
|
||||||
|
#define RAM_SIZE CY_APP0_CORE1_RAM_LENGTH
|
||||||
|
|
||||||
|
|
||||||
|
LR_FLASH FLASH_START FLASH_SIZE
|
||||||
|
{
|
||||||
|
ER_FLASH_VECTORS +0
|
||||||
|
{
|
||||||
|
* (RESET, +FIRST)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_FLASH_CODE +0 FIXED
|
||||||
|
{
|
||||||
|
* (InRoot$$Sections)
|
||||||
|
* (+RO)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_RAM_COMMON CY_APP_RAM_COMMON_ADDR UNINIT
|
||||||
|
{
|
||||||
|
* (.cy_boot_noinit.appId)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_RAM_VECTORS RAM_START UNINIT
|
||||||
|
{
|
||||||
|
* (RESET_RAM, +FIRST)
|
||||||
|
}
|
||||||
|
|
||||||
|
ER_RAM_DATA +0
|
||||||
|
{
|
||||||
|
* (.cy_ramfunc)
|
||||||
|
.ANY (+RW, +ZI)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Place variables in the section that should not be initialized during
|
||||||
|
; a device startup.
|
||||||
|
ER_RAM_NOINIT_DATA +0 UNINIT
|
||||||
|
{
|
||||||
|
* (.noinit)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; Used for the digital signature of the secure application and the
|
||||||
|
; DFU SDK application. The size of the section depends on the required
|
||||||
|
; data size.
|
||||||
|
.cy_app_signature (FLASH_START + FLASH_SIZE - CY_BOOT_SIGNATURE_SIZE) FIXED
|
||||||
|
{
|
||||||
|
* (.cy_app_signature)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; App0 uses it to initialize DFU SDK metadata, in dfu_user.c file
|
||||||
|
LR_CY_BOOT_METADATA CY_BOOT_META_FLASH_ADDR CY_BOOT_META_FLASH_LENGTH
|
||||||
|
{
|
||||||
|
.cy_boot_metadata + 0
|
||||||
|
{
|
||||||
|
* (.cy_boot_metadata)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Emulated EEPROM Flash area
|
||||||
|
LR_EM_EEPROM EM_EEPROM_START EM_EEPROM_SIZE
|
||||||
|
{
|
||||||
|
.cy_em_eeprom +0
|
||||||
|
{
|
||||||
|
* (.cy_em_eeprom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory Flash: User data
|
||||||
|
LR_SFLASH_USER_DATA SFLASH_USER_DATA_START SFLASH_USER_DATA_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_user_data +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_user_data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory Flash: Normal Access Restrictions (NAR)
|
||||||
|
LR_SFLASH_NAR SFLASH_NAR_START SFLASH_NAR_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_nar +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_nar)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory Flash: Public Key
|
||||||
|
LR_SFLASH_PUBLIC_KEY SFLASH_PUBLIC_KEY_START SFLASH_PUBLIC_KEY_SIZE
|
||||||
|
{
|
||||||
|
.cy_sflash_public_key +0
|
||||||
|
{
|
||||||
|
* (.cy_sflash_public_key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Supervisory Flash: Table of Content # 2
|
||||||
|
LR_SFLASH_TOC_2 SFLASH_TOC_2_START SFLASH_TOC_2_SIZE
|
||||||
|
{
|
||||||
|
.cy_toc_part2 +0
|
||||||
|
{
|
||||||
|
* (.cy_toc_part2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; Places the code in the Execute in Place (XIP) section. See the smif driver documentation for details.
|
||||||
|
LR_EROM XIP_START XIP_SIZE
|
||||||
|
{
|
||||||
|
.cy_xip +0
|
||||||
|
{
|
||||||
|
* (.cy_xip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; eFuse
|
||||||
|
LR_EFUSE EFUSE_START EFUSE_SIZE
|
||||||
|
{
|
||||||
|
.cy_efuse +0
|
||||||
|
{
|
||||||
|
* (.cy_efuse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; The section is used for additional metadata (silicon revision, Silicon/JTAG ID, etc.) storage.
|
||||||
|
CYMETA 0x90500000
|
||||||
|
{
|
||||||
|
.cymeta +0 { * (.cymeta) }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
114
2020TPCApp0.cydsn/dfu_mdk_common.h
Normal file
114
2020TPCApp0.cydsn/dfu_mdk_common.h
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* \file dfu_mdk_common.h
|
||||||
|
* \version 3.0
|
||||||
|
*
|
||||||
|
* This file provides only macro definitions to use for
|
||||||
|
* project configuration.
|
||||||
|
* They may be used in both scatter files and source code files.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DFU_MDK_COMMON_H_
|
||||||
|
#define DFU_MDK_COMMON_H_
|
||||||
|
|
||||||
|
/* DFU SDK parameters */
|
||||||
|
/* The user application may either update them or leave the defaults if they fit */
|
||||||
|
#define CY_BOOT_METADATA_ADDR 0x100FFA00
|
||||||
|
#define CY_BOOT_METADATA_LENGTH 0x200
|
||||||
|
#define CY_PRODUCT_ID 0x01020304
|
||||||
|
#define CY_CHECKSUM_TYPE 0x00
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The size of the section .cy_app_signature.
|
||||||
|
* 1,2, or 4 for a checksum
|
||||||
|
* 4 for CRC-32
|
||||||
|
* 20 for SHA1
|
||||||
|
* 32 for SHA256
|
||||||
|
* 256 for RSASSA-PKCS1-v1.5 with the 2048 bit RSA key.
|
||||||
|
*
|
||||||
|
* SHA1 must be used.
|
||||||
|
*/
|
||||||
|
#define CY_BOOT_SIGNATURE_SIZE 4
|
||||||
|
|
||||||
|
/* For the MDK linker script, defines TOC parameters */
|
||||||
|
/* Update per device series to be in the last Flash row */
|
||||||
|
#define CY_TOC_START 0x16007C00
|
||||||
|
#define CY_TOC_SIZE 0x400
|
||||||
|
|
||||||
|
|
||||||
|
/* Memory region ranges per core and app */
|
||||||
|
#define CY_APP0_CORE0_FLASH_ADDR 0x10000000
|
||||||
|
#define CY_APP0_CORE0_FLASH_LENGTH 0x10000
|
||||||
|
|
||||||
|
#define CY_APP0_CORE1_FLASH_ADDR 0x10010000
|
||||||
|
#define CY_APP0_CORE1_FLASH_LENGTH 0x10000
|
||||||
|
|
||||||
|
#define CY_APP1_CORE0_FLASH_ADDR 0x10040000
|
||||||
|
#define CY_APP1_CORE0_FLASH_LENGTH 0x10000
|
||||||
|
|
||||||
|
#define CY_APP1_CORE1_FLASH_ADDR 0x10050000
|
||||||
|
#define CY_APP1_CORE1_FLASH_LENGTH 0x10000
|
||||||
|
|
||||||
|
/* DFU SDK metadata address range in Flash */
|
||||||
|
#define CY_BOOT_META_FLASH_ADDR 0x100FFA00
|
||||||
|
#define CY_BOOT_META_FLASH_LENGTH 0x200
|
||||||
|
|
||||||
|
/* Application ranges in emulated EEPROM */
|
||||||
|
#define CY_APP0_CORE0_EM_EEPROM_ADDR 0x14000000
|
||||||
|
#define CY_APP0_CORE0_EM_EEPROM_LENGTH 0x00000000
|
||||||
|
|
||||||
|
#define CY_APP0_CORE1_EM_EEPROM_ADDR (CY_APP0_CORE0_EM_EEPROM_ADDR + CY_APP0_CORE0_EM_EEPROM_LENGTH)
|
||||||
|
#define CY_APP0_CORE1_EM_EEPROM_LENGTH 0x0000
|
||||||
|
|
||||||
|
#define CY_APP1_CORE0_EM_EEPROM_ADDR 0x14000000
|
||||||
|
#define CY_APP1_CORE0_EM_EEPROM_LENGTH 0x00000000
|
||||||
|
|
||||||
|
#define CY_APP1_CORE1_EM_EEPROM_ADDR (CY_APP1_CORE0_EM_EEPROM_ADDR + CY_APP1_CORE0_EM_EEPROM_LENGTH)
|
||||||
|
#define CY_APP1_CORE1_EM_EEPROM_LENGTH 0x00000000
|
||||||
|
|
||||||
|
/* Application ranges in SMIF XIP */
|
||||||
|
#define CY_APP0_CORE0_SMIF_ADDR 0x18000000
|
||||||
|
#define CY_APP0_CORE0_SMIF_LENGTH 0x00000000
|
||||||
|
|
||||||
|
#define CY_APP0_CORE1_SMIF_ADDR (CY_APP0_CORE0_SMIF_ADDR + CY_APP0_CORE0_SMIF_LENGTH)
|
||||||
|
#define CY_APP0_CORE1_SMIF_LENGTH 0x00000000
|
||||||
|
|
||||||
|
#define CY_APP1_CORE0_SMIF_ADDR 0x14000200
|
||||||
|
#define CY_APP1_CORE0_SMIF_LENGTH 0x00000000
|
||||||
|
|
||||||
|
#define CY_APP1_CORE1_SMIF_ADDR (CY_APP1_CORE0_SMIF_ADDR + CY_APP1_CORE0_SMIF_LENGTH)
|
||||||
|
#define CY_APP1_CORE1_SMIF_LENGTH 0x00000000
|
||||||
|
|
||||||
|
/* Application ranges in RAM */
|
||||||
|
#define CY_APP_RAM_COMMON_ADDR 0x08000000
|
||||||
|
#define CY_APP_RAM_COMMON_LENGTH 0x00000100
|
||||||
|
|
||||||
|
/* note: all the CY_APPX_CORE0_RAM regions has to be 0x100 aligned */
|
||||||
|
/* and the CY_APPX_CORE1_RAM regions has to be 0x400 aligned */
|
||||||
|
/* as they contain Interrupt Vector Table Remapped at the start */
|
||||||
|
|
||||||
|
#define CY_APP0_CORE0_RAM_ADDR 0x08000100
|
||||||
|
#define CY_APP0_CORE0_RAM_LENGTH 0x00001F00
|
||||||
|
|
||||||
|
#define CY_APP0_CORE1_RAM_ADDR (CY_APP0_CORE0_RAM_ADDR + CY_APP0_CORE0_RAM_LENGTH)
|
||||||
|
#define CY_APP0_CORE1_RAM_LENGTH 0x00008000
|
||||||
|
|
||||||
|
#define CY_APP1_CORE0_RAM_ADDR CY_APP0_CORE0_RAM_ADDR
|
||||||
|
#define CY_APP1_CORE0_RAM_LENGTH 0x00001F00
|
||||||
|
|
||||||
|
#define CY_APP1_CORE1_RAM_ADDR (CY_APP1_CORE0_RAM_ADDR + CY_APP1_CORE0_RAM_LENGTH)
|
||||||
|
#define CY_APP1_CORE1_RAM_LENGTH 0x00008000
|
||||||
|
|
||||||
|
|
||||||
|
__asm void cy_DFU_mdkAsmDummy(void);
|
||||||
|
|
||||||
|
#endif /* DFU_MDK_COMMON_H_ */
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
66
2020TPCApp0.cydsn/dfu_mdk_symbols.c
Normal file
66
2020TPCApp0.cydsn/dfu_mdk_symbols.c
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* \file dfu_mdk_symbols.c
|
||||||
|
* \version 3.0
|
||||||
|
*
|
||||||
|
* This file provides symbols to add to an ELF file required by
|
||||||
|
* CyMCUElfTool to generate correct HEX and CYACD2 files.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "dfu_mdk_common.h"
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: cy_DFU_mdkAsmDummy
|
||||||
|
********************************************************************************
|
||||||
|
* This function provides ELF file symbols through
|
||||||
|
* the inline assembly.
|
||||||
|
* The inline assembly in the *.c file is chosen, because it allows using
|
||||||
|
* #include <mdk_linker_common.h> where the user configuration is updated.
|
||||||
|
*
|
||||||
|
* Note that this function does not have code, so no additional memory
|
||||||
|
* is allocated for it.
|
||||||
|
*******************************************************************************/
|
||||||
|
__asm void cy_DFU_mdkAsmDummy(void)
|
||||||
|
{
|
||||||
|
EXPORT __cy_boot_metadata_addr
|
||||||
|
EXPORT __cy_boot_metadata_length
|
||||||
|
|
||||||
|
EXPORT __cy_app_core1_start_addr
|
||||||
|
|
||||||
|
EXPORT __cy_product_id
|
||||||
|
EXPORT __cy_checksum_type
|
||||||
|
EXPORT __cy_app_id
|
||||||
|
|
||||||
|
EXPORT __cy_app_verify_start
|
||||||
|
EXPORT __cy_app_verify_length
|
||||||
|
|
||||||
|
/* Used by all DFU SDK applications to switch to another app */
|
||||||
|
__cy_boot_metadata_addr EQU __cpp(CY_BOOT_METADATA_ADDR)
|
||||||
|
/* Used by CyMCUElfTool to update DFU SDK metadata with CRC-32C */
|
||||||
|
__cy_boot_metadata_length EQU __cpp(CY_BOOT_METADATA_LENGTH)
|
||||||
|
|
||||||
|
/* Used by CM0+ to start CM4 core in the DFU SDK applications. */
|
||||||
|
/* Make sure the correct app no. is entered here */
|
||||||
|
__cy_app_core1_start_addr EQU __cpp(CY_APP0_CORE1_FLASH_ADDR)
|
||||||
|
|
||||||
|
/* Used by CyMCUElfTool to generate ProductID */
|
||||||
|
__cy_product_id EQU __cpp(CY_PRODUCT_ID)
|
||||||
|
/* Used by CyMCUElfTool to generate ChecksumType */
|
||||||
|
__cy_checksum_type EQU __cpp(CY_CHECKSUM_TYPE)
|
||||||
|
/* Application number (ID) */
|
||||||
|
__cy_app_id EQU 0
|
||||||
|
|
||||||
|
/* CyMCUElfTool uses these to generate an application signature */
|
||||||
|
/* The size of the default signature (CRC-32C) is 4 bytes */
|
||||||
|
__cy_app_verify_start EQU __cpp(CY_APP0_CORE0_FLASH_ADDR)
|
||||||
|
__cy_app_verify_length EQU __cpp(CY_APP0_CORE0_FLASH_LENGTH + CY_APP0_CORE1_FLASH_LENGTH - CY_BOOT_SIGNATURE_SIZE)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
303
2020TPCApp0.cydsn/dfu_user.c
Normal file
303
2020TPCApp0.cydsn/dfu_user.c
Normal file
|
@ -0,0 +1,303 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file dfu_user.c
|
||||||
|
* \version 3.0
|
||||||
|
*
|
||||||
|
* This file provides the custom API for a firmware application with
|
||||||
|
* DFU SDK.
|
||||||
|
* - Cy_DFU_ReadData (address, length, ctl, params) - to read the NVM block
|
||||||
|
* - Cy_DFU_WriteData(address, length, ctl, params) - to write the NVM block
|
||||||
|
*
|
||||||
|
* - Cy_DFU_TransportStart() to start a communication interface
|
||||||
|
* - Cy_DFU_TransportStop () to stop a communication interface
|
||||||
|
* - Cy_DFU_TransportReset() to reset a communication interface
|
||||||
|
* - Cy_DFU_TransportRead (buffer, size, count, timeout)
|
||||||
|
* - Cy_DFU_TransportWrite(buffer, size, count, timeout)
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2019, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "transport_ble.h"
|
||||||
|
#include "cy_syslib.h"
|
||||||
|
#include "cy_flash.h"
|
||||||
|
#include "cy_dfu.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The DFU SDK metadata initial value is placed here
|
||||||
|
* Note: the number of elements equal to the number of the app multiplies by 2
|
||||||
|
* because of the two fields per app plus one element for the CRC-32C field.
|
||||||
|
*/
|
||||||
|
CY_SECTION(".cy_boot_metadata") __USED
|
||||||
|
static const uint32_t cy_dfu_metadata[CY_FLASH_SIZEOF_ROW / sizeof(uint32_t)] =
|
||||||
|
{
|
||||||
|
CY_DFU_APP0_VERIFY_START, CY_DFU_APP0_VERIFY_LENGTH, /* The App0 base address and length */
|
||||||
|
CY_DFU_APP1_VERIFY_START, CY_DFU_APP1_VERIFY_LENGTH, /* The App1 base address and length */
|
||||||
|
0u /* The rest does not matter */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t IsMultipleOf(uint32_t value, uint32_t multiple);
|
||||||
|
static void GetStartEndAddress(uint32_t appId, uint32_t *startAddress, uint32_t *endAddress);
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: IsMultipleOf
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* This internal function check if value parameter is a multiple of parameter
|
||||||
|
* multiple
|
||||||
|
*
|
||||||
|
* \param value value that will be checked
|
||||||
|
* \param multiple value with which value is checked
|
||||||
|
*
|
||||||
|
* \return 1 - value is multiple of parameter multiple, else 0
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
static uint32_t IsMultipleOf(uint32_t value, uint32_t multiple)
|
||||||
|
{
|
||||||
|
return ( ((value % multiple) == 0u)? 1ul : 0ul);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: GetStartEndAddress
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* This internal function returns start and end address of application
|
||||||
|
*
|
||||||
|
* \param appId The application number
|
||||||
|
* \param startAddress The pointer to a variable where an application start
|
||||||
|
* address is stored
|
||||||
|
* \param endAddress The pointer to a variable where a size of application
|
||||||
|
* area is stored.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
static void GetStartEndAddress(uint32_t appId, uint32_t *startAddress, uint32_t *endAddress)
|
||||||
|
{
|
||||||
|
uint32_t verifyStart;
|
||||||
|
uint32_t verifySize;
|
||||||
|
|
||||||
|
(void)Cy_DFU_GetAppMetadata(appId, &verifyStart, &verifySize);
|
||||||
|
|
||||||
|
#if (CY_DFU_APP_FORMAT == CY_DFU_SIMPLIFIED_APP)
|
||||||
|
*startAddress = verifyStart - CY_DFU_SIGNATURE_SIZE;
|
||||||
|
*endAddress = verifyStart + verifySize;
|
||||||
|
#else
|
||||||
|
*startAddress = verifyStart;
|
||||||
|
*endAddress = verifyStart + verifySize + CY_DFU_SIGNATURE_SIZE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_DFU_WriteData
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* This function documentation is part of the DFU SDK API, see the
|
||||||
|
* cy_dfu.h file or DFU SDK API Reference Manual for details.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
cy_en_dfu_status_t Cy_DFU_WriteData (uint32_t address, uint32_t length, uint32_t ctl,
|
||||||
|
cy_stc_dfu_params_t *params)
|
||||||
|
{
|
||||||
|
/* User Flash Limits */
|
||||||
|
/* Note that App0 is out of range */
|
||||||
|
const uint32_t minUFlashAddress = CY_FLASH_BASE + CY_DFU_APP0_VERIFY_LENGTH;
|
||||||
|
const uint32_t maxUFlashAddress = CY_FLASH_BASE + CY_FLASH_SIZE;
|
||||||
|
/* EM_EEPROM Limits*/
|
||||||
|
const uint32_t minEmEepromAddress = CY_EM_EEPROM_BASE;
|
||||||
|
const uint32_t maxEmEepromAddress = CY_EM_EEPROM_BASE + CY_EM_EEPROM_SIZE;
|
||||||
|
|
||||||
|
cy_en_dfu_status_t status = CY_DFU_SUCCESS;
|
||||||
|
|
||||||
|
uint32_t app = Cy_DFU_GetRunningApp();
|
||||||
|
uint32_t startAddress;
|
||||||
|
uint32_t endAddress;
|
||||||
|
|
||||||
|
GetStartEndAddress(app, &startAddress, &endAddress);
|
||||||
|
|
||||||
|
/* Check if the address and length are valid
|
||||||
|
* Note Length = 0 is valid for erase command */
|
||||||
|
if ( (IsMultipleOf(address, CY_FLASH_SIZEOF_ROW) == 0u) ||
|
||||||
|
( (length != CY_FLASH_SIZEOF_ROW) && ( (ctl & CY_DFU_IOCTL_ERASE) == 0u) ) )
|
||||||
|
{
|
||||||
|
status = CY_DFU_ERROR_LENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Refuse to write to a row within a range of the current application */
|
||||||
|
if ( (startAddress <= address) && (address < endAddress) )
|
||||||
|
{ /* It is forbidden to overwrite the currently running application */
|
||||||
|
status = CY_DFU_ERROR_ADDRESS;
|
||||||
|
}
|
||||||
|
#if CY_DFU_OPT_GOLDEN_IMAGE
|
||||||
|
if (status == CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
uint8_t goldenImages[] = { CY_DFU_GOLDEN_IMAGE_IDS() };
|
||||||
|
uint32_t count = sizeof(goldenImages) / sizeof(goldenImages[0]);
|
||||||
|
uint32_t idx;
|
||||||
|
for (idx = 0u; idx < count; ++idx)
|
||||||
|
{
|
||||||
|
app = goldenImages[idx];
|
||||||
|
GetStartEndAddress(app, &startAddress, &endAddress);
|
||||||
|
|
||||||
|
if ( (startAddress <= address) && (address < endAddress) )
|
||||||
|
{
|
||||||
|
status = Cy_DFU_ValidateApp(app, params);
|
||||||
|
status = (status == CY_DFU_SUCCESS) ? CY_DFU_ERROR_ADDRESS : CY_DFU_SUCCESS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* #if CY_DFU_OPT_GOLDEN_IMAGE != 0 */
|
||||||
|
|
||||||
|
/* Check if the address is inside the valid range */
|
||||||
|
if ( ( (minUFlashAddress <= address) && (address < maxUFlashAddress) )
|
||||||
|
|| ( (minEmEepromAddress <= address) && (address < maxEmEepromAddress) ) )
|
||||||
|
{ /* Do nothing, this is an allowed memory range to update to */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = CY_DFU_ERROR_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
if ((ctl & CY_DFU_IOCTL_ERASE) != 0u)
|
||||||
|
{
|
||||||
|
(void) memset(params->dataBuffer, 0, CY_FLASH_SIZEOF_ROW);
|
||||||
|
}
|
||||||
|
cy_en_flashdrv_status_t fstatus = Cy_Flash_WriteRow(address, (uint32_t*)params->dataBuffer);
|
||||||
|
status = (fstatus == CY_FLASH_DRV_SUCCESS) ? CY_DFU_SUCCESS : CY_DFU_ERROR_DATA;
|
||||||
|
}
|
||||||
|
return (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_DFU_ReadData
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* This function documentation is part of the DFU SDK API, see the
|
||||||
|
* cy_dfu.h file or DFU SDK API Reference Manual for details.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
cy_en_dfu_status_t Cy_DFU_ReadData (uint32_t address, uint32_t length, uint32_t ctl,
|
||||||
|
cy_stc_dfu_params_t *params)
|
||||||
|
{
|
||||||
|
/* User Flash Limits */
|
||||||
|
/* Note that App0 is out of range */
|
||||||
|
const uint32_t minUFlashAddress = CY_FLASH_BASE + CY_DFU_APP0_VERIFY_LENGTH;
|
||||||
|
const uint32_t maxUFlashAddress = CY_FLASH_BASE + CY_FLASH_SIZE;
|
||||||
|
/* EM_EEPROM Limits*/
|
||||||
|
const uint32_t minEmEepromAddress = CY_EM_EEPROM_BASE;
|
||||||
|
const uint32_t maxEmEepromAddress = CY_EM_EEPROM_BASE + CY_EM_EEPROM_SIZE;
|
||||||
|
|
||||||
|
cy_en_dfu_status_t status = CY_DFU_SUCCESS;
|
||||||
|
|
||||||
|
/* Check if the length is valid */
|
||||||
|
if (IsMultipleOf(length, CY_FLASH_SIZEOF_ROW) == 0u)
|
||||||
|
{
|
||||||
|
status = CY_DFU_ERROR_LENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if the address is inside the valid range */
|
||||||
|
if ( ( (minUFlashAddress <= address) && (address < maxUFlashAddress) )
|
||||||
|
|| ( (minEmEepromAddress <= address) && (address < maxEmEepromAddress) ) )
|
||||||
|
{ /* Do nothing, this is an allowed memory range to update to */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = CY_DFU_ERROR_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read or Compare */
|
||||||
|
if (status == CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
if ((ctl & CY_DFU_IOCTL_COMPARE) == 0u)
|
||||||
|
{
|
||||||
|
(void) memcpy(params->dataBuffer, (const void *)address, length);
|
||||||
|
status = CY_DFU_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = ( memcmp(params->dataBuffer, (const void *)address, length) == 0 )
|
||||||
|
? CY_DFU_SUCCESS : CY_DFU_ERROR_VERIFY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_DFU_TransportRead
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* This function documentation is part of the DFU SDK API, see the
|
||||||
|
* cy_dfu.h file or DFU SDK API Reference Manual for details.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
cy_en_dfu_status_t Cy_DFU_TransportRead (uint8_t *buffer, uint32_t size, uint32_t *count, uint32_t timeout)
|
||||||
|
{
|
||||||
|
return (CyBLE_CyBtldrCommRead(buffer, size, count, timeout));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_DFU_TransportWrite
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* This function documentation is part of the DFU SDK API, see the
|
||||||
|
* cy_dfu.h file or DFU SDK API Reference Manual for details.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
cy_en_dfu_status_t Cy_DFU_TransportWrite(uint8_t *buffer, uint32_t size, uint32_t *count, uint32_t timeout)
|
||||||
|
{
|
||||||
|
return (CyBLE_CyBtldrCommWrite(buffer, size, count, timeout));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_DFU_TransportReset
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* This function documentation is part of the DFU SDK API, see the
|
||||||
|
* cy_dfu.h file or DFU SDK API Reference Manual for details.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void Cy_DFU_TransportReset(void)
|
||||||
|
{
|
||||||
|
CyBLE_CyBtldrCommReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_DFU_TransportStart
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* This function documentation is part of the DFU SDK API, see the
|
||||||
|
* cy_dfu.h file or DFU SDK API Reference Manual for details.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void Cy_DFU_TransportStart(void)
|
||||||
|
{
|
||||||
|
CyBLE_CyBtldrCommStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_DFU_TransportStop
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* This function documentation is part of the DFU SDK API, see the
|
||||||
|
* cy_dfu.h file or DFU SDK API Reference Manual for details.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void Cy_DFU_TransportStop(void)
|
||||||
|
{
|
||||||
|
CyBLE_CyBtldrCommStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
151
2020TPCApp0.cydsn/dfu_user.h
Normal file
151
2020TPCApp0.cydsn/dfu_user.h
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file dfu_user.h
|
||||||
|
* \version 3.0
|
||||||
|
*
|
||||||
|
* This file provides declarations that can be modified by the user but
|
||||||
|
* are used by the DFU SDK.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2019, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(DFU_USER_H)
|
||||||
|
#define DFU_USER_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "cy_flash.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup group_dfu_macro_config
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** The size of a buffer to hold DFU commands */
|
||||||
|
/* 16 bytes is a maximum overhead of a DFU packet and additional data for the Program Data command */
|
||||||
|
#define CY_DFU_SIZEOF_CMD_BUFFER (CY_FLASH_SIZEOF_ROW + 16u)
|
||||||
|
|
||||||
|
/** The size of a buffer to hold an NVM row of data to write or verify */
|
||||||
|
#define CY_DFU_SIZEOF_DATA_BUFFER (CY_FLASH_SIZEOF_ROW + 16u)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to non-zero for the DFU SDK Program Data command to check
|
||||||
|
* if the Golden image is going to be overwritten while updating.
|
||||||
|
*/
|
||||||
|
#define CY_DFU_OPT_GOLDEN_IMAGE (0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of Golden Image Application IDs.
|
||||||
|
* Here "Golden Image Application" means an application that cannot be changed with
|
||||||
|
* CommandProgramData()
|
||||||
|
*
|
||||||
|
* Usage. Define the list of Golden Image Application IDs without enclosing
|
||||||
|
* parenthesis, e.g.
|
||||||
|
* \code #define CY_DFU_GOLDEN_IMAGE_IDS() 0u, 1u, 3u \endcode
|
||||||
|
* later it is used in cy_dfu.c file:
|
||||||
|
* \code uint8_t goldenImages[] = { CY_DFU_GOLDEN_IMAGE_IDS() }; \endcode
|
||||||
|
*/
|
||||||
|
#define CY_DFU_GOLDEN_IMAGE_IDS() 0u
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of applications in the metadata,
|
||||||
|
* for 512 bytes in a Flash row - 63 is the maximum possible value,
|
||||||
|
* because 4 bytes are reserved for the entire metadata CRC.
|
||||||
|
*
|
||||||
|
* The smallest metadata size if CY_DFU_MAX_APPS * 8 (bytes per one app) + 4 (bytes for CRC-32C)
|
||||||
|
*/
|
||||||
|
#define CY_DFU_MAX_APPS (2u)
|
||||||
|
|
||||||
|
|
||||||
|
/** A non-zero value enables the Verify Data DFU command */
|
||||||
|
#define CY_DFU_OPT_VERIFY_DATA (1)
|
||||||
|
|
||||||
|
/** A non-zero value enables the Erase Data DFU command */
|
||||||
|
#define CY_DFU_OPT_ERASE_DATA (1)
|
||||||
|
|
||||||
|
/** A non-zero value enables the Verify App DFU command */
|
||||||
|
#define CY_DFU_OPT_VERIFY_APP (1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A non-zero value enables the Send Data DFU command.
|
||||||
|
* If the "Send Data" DFU command is enabled, \c packetBuffer and \c dataBuffer
|
||||||
|
* must be non-overlapping.
|
||||||
|
*
|
||||||
|
* Else, \c dataBuffer must be inside \c packetBuffer with an offset of
|
||||||
|
* \c CY_DFU_PACKET_DATA_IDX, typically 4 bytes. \n
|
||||||
|
* <code>params->dataBuffer = &packetBuffer[4];</code> \n
|
||||||
|
* \note that \c packetBuffer in this case must be 4 bytes aligned, as
|
||||||
|
* \c dataBuffer is required to be 4 bytes aligned.
|
||||||
|
*/
|
||||||
|
#define CY_DFU_OPT_SEND_DATA (1)
|
||||||
|
|
||||||
|
/** A non-zero value enables the Get Metadata DFU command */
|
||||||
|
#define CY_DFU_OPT_GET_METADATA (1)
|
||||||
|
|
||||||
|
/** A non-zero value enables the Set EI Vector DFU command */
|
||||||
|
#define CY_DFU_OPT_SET_EIVECTOR (0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A non-zero value allows writing metadata
|
||||||
|
* with the Set App Metadata DFU command.
|
||||||
|
*/
|
||||||
|
#define CY_DFU_METADATA_WRITABLE (1)
|
||||||
|
|
||||||
|
/** Non-zero value enables the usage of hardware Crypto API */
|
||||||
|
#define CY_DFU_OPT_CRYPTO_HW (1)
|
||||||
|
|
||||||
|
/** A non-zero value enables the usage of CRC-16 for DFU packet verification */
|
||||||
|
#define CY_DFU_OPT_PACKET_CRC (0)
|
||||||
|
|
||||||
|
/** Set the default application-format-possible values defined in \ref group_dfu_macro_app_type */
|
||||||
|
#define CY_DFU_APP_FORMAT (CY_DFU_CYPRESS_APP)
|
||||||
|
|
||||||
|
/** Set the default secure application-verification-type possible values
|
||||||
|
* defined in \ref group_dfu_macro_ver_type */
|
||||||
|
#define CY_DFU_SEC_APP_VERIFY_TYPE (CY_DFU_VERIFY_FAST)
|
||||||
|
|
||||||
|
/** \} group_dfu_macro_config */
|
||||||
|
|
||||||
|
#if !defined(CY_DOXYGEN)
|
||||||
|
#if defined(__GNUC__) || defined(__ICCARM__)
|
||||||
|
/*
|
||||||
|
* These variables are defined in the linker scripts, the values of their addresses define
|
||||||
|
* corresponding applications start address and length.
|
||||||
|
*/
|
||||||
|
extern uint8_t __cy_app0_verify_start;
|
||||||
|
extern uint8_t __cy_app0_verify_length;
|
||||||
|
extern uint8_t __cy_app1_verify_start;
|
||||||
|
extern uint8_t __cy_app1_verify_length;
|
||||||
|
extern uint8_t __cy_boot_signature_size;
|
||||||
|
|
||||||
|
#define CY_DFU_APP0_VERIFY_START ( (uint32_t)&__cy_app0_verify_start )
|
||||||
|
#define CY_DFU_APP0_VERIFY_LENGTH ( (uint32_t)&__cy_app0_verify_length )
|
||||||
|
#define CY_DFU_APP1_VERIFY_START ( (uint32_t)&__cy_app1_verify_start )
|
||||||
|
#define CY_DFU_APP1_VERIFY_LENGTH ( (uint32_t)&__cy_app1_verify_length )
|
||||||
|
#define CY_DFU_SIGNATURE_SIZE ( (uint32_t)&__cy_boot_signature_size )
|
||||||
|
|
||||||
|
#elif defined(__ARMCC_VERSION)
|
||||||
|
#include "dfu_mdk_common.h"
|
||||||
|
|
||||||
|
#define CY_DFU_APP0_VERIFY_START ( CY_APP0_CORE0_FLASH_ADDR )
|
||||||
|
#define CY_DFU_APP0_VERIFY_LENGTH ( CY_APP0_CORE0_FLASH_LENGTH + CY_APP0_CORE1_FLASH_LENGTH \
|
||||||
|
- CY_BOOT_SIGNATURE_SIZE)
|
||||||
|
#define CY_DFU_APP1_VERIFY_START ( CY_APP1_CORE0_FLASH_ADDR )
|
||||||
|
#define CY_DFU_APP1_VERIFY_LENGTH ( CY_APP1_CORE0_FLASH_LENGTH + CY_APP1_CORE1_FLASH_LENGTH \
|
||||||
|
- CY_BOOT_SIGNATURE_SIZE)
|
||||||
|
#define CY_DFU_SIGNATURE_SIZE CY_BOOT_SIGNATURE_SIZE
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Not implemented for this compiler"
|
||||||
|
#endif /* defined(__GNUC__) || defined(__ICCARM__) */
|
||||||
|
#endif /* !defined(CY_DOXYGEN) */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !defined(DFU_USER_H) */
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
404
2020TPCApp0.cydsn/gcc/startup_psoc6_01_cm0plus.S
Normal file
404
2020TPCApp0.cydsn/gcc/startup_psoc6_01_cm0plus.S
Normal file
|
@ -0,0 +1,404 @@
|
||||||
|
/**************************************************************************//**
|
||||||
|
* @file startup_psoc6_01_cm0plus.S
|
||||||
|
* @brief CMSIS Core Device Startup File for
|
||||||
|
* ARMCM0plus Device Series
|
||||||
|
* @version V5.00
|
||||||
|
* @date 02. March 2016
|
||||||
|
******************************************************************************/
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Address of the NMI handler */
|
||||||
|
#define CY_NMI_HANLDER_ADDR 0x0000000D
|
||||||
|
|
||||||
|
/* The CPU VTOR register */
|
||||||
|
#define CY_CPU_VTOR_ADDR 0xE000ED08
|
||||||
|
|
||||||
|
/* Copy flash vectors and data section to RAM */
|
||||||
|
#define __STARTUP_COPY_MULTIPLE
|
||||||
|
|
||||||
|
/* Clear single BSS section */
|
||||||
|
#define __STARTUP_CLEAR_BSS
|
||||||
|
|
||||||
|
.syntax unified
|
||||||
|
.arch armv6-m
|
||||||
|
|
||||||
|
.section .stack
|
||||||
|
.align 3
|
||||||
|
#ifdef __STACK_SIZE
|
||||||
|
.equ Stack_Size, __STACK_SIZE
|
||||||
|
#else
|
||||||
|
.equ Stack_Size, 0x00001000
|
||||||
|
#endif
|
||||||
|
.globl __StackTop
|
||||||
|
.globl __StackLimit
|
||||||
|
__StackLimit:
|
||||||
|
.space Stack_Size
|
||||||
|
.size __StackLimit, . - __StackLimit
|
||||||
|
__StackTop:
|
||||||
|
.size __StackTop, . - __StackTop
|
||||||
|
|
||||||
|
.section .heap
|
||||||
|
.align 3
|
||||||
|
#ifdef __HEAP_SIZE
|
||||||
|
.equ Heap_Size, __HEAP_SIZE
|
||||||
|
#else
|
||||||
|
.equ Heap_Size, 0x00000400
|
||||||
|
#endif
|
||||||
|
.globl __HeapBase
|
||||||
|
.globl __HeapLimit
|
||||||
|
__HeapBase:
|
||||||
|
.if Heap_Size
|
||||||
|
.space Heap_Size
|
||||||
|
.endif
|
||||||
|
.size __HeapBase, . - __HeapBase
|
||||||
|
__HeapLimit:
|
||||||
|
.size __HeapLimit, . - __HeapLimit
|
||||||
|
|
||||||
|
.section .vectors
|
||||||
|
.align 2
|
||||||
|
.globl __Vectors
|
||||||
|
__Vectors:
|
||||||
|
.long __StackTop /* Top of Stack */
|
||||||
|
.long Reset_Handler /* Reset Handler */
|
||||||
|
.long CY_NMI_HANLDER_ADDR /* NMI Handler */
|
||||||
|
.long HardFault_Handler /* Hard Fault Handler */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long SVC_Handler /* SVCall Handler */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long PendSV_Handler /* PendSV Handler */
|
||||||
|
.long SysTick_Handler /* SysTick Handler */
|
||||||
|
|
||||||
|
/* External interrupts Description */
|
||||||
|
.long NvicMux0_IRQHandler /* CM0+ NVIC Mux input 0 */
|
||||||
|
.long NvicMux1_IRQHandler /* CM0+ NVIC Mux input 1 */
|
||||||
|
.long NvicMux2_IRQHandler /* CM0+ NVIC Mux input 2 */
|
||||||
|
.long NvicMux3_IRQHandler /* CM0+ NVIC Mux input 3 */
|
||||||
|
.long NvicMux4_IRQHandler /* CM0+ NVIC Mux input 4 */
|
||||||
|
.long NvicMux5_IRQHandler /* CM0+ NVIC Mux input 5 */
|
||||||
|
.long NvicMux6_IRQHandler /* CM0+ NVIC Mux input 6 */
|
||||||
|
.long NvicMux7_IRQHandler /* CM0+ NVIC Mux input 7 */
|
||||||
|
.long NvicMux8_IRQHandler /* CM0+ NVIC Mux input 8 */
|
||||||
|
.long NvicMux9_IRQHandler /* CM0+ NVIC Mux input 9 */
|
||||||
|
.long NvicMux10_IRQHandler /* CM0+ NVIC Mux input 10 */
|
||||||
|
.long NvicMux11_IRQHandler /* CM0+ NVIC Mux input 11 */
|
||||||
|
.long NvicMux12_IRQHandler /* CM0+ NVIC Mux input 12 */
|
||||||
|
.long NvicMux13_IRQHandler /* CM0+ NVIC Mux input 13 */
|
||||||
|
.long NvicMux14_IRQHandler /* CM0+ NVIC Mux input 14 */
|
||||||
|
.long NvicMux15_IRQHandler /* CM0+ NVIC Mux input 15 */
|
||||||
|
.long NvicMux16_IRQHandler /* CM0+ NVIC Mux input 16 */
|
||||||
|
.long NvicMux17_IRQHandler /* CM0+ NVIC Mux input 17 */
|
||||||
|
.long NvicMux18_IRQHandler /* CM0+ NVIC Mux input 18 */
|
||||||
|
.long NvicMux19_IRQHandler /* CM0+ NVIC Mux input 19 */
|
||||||
|
.long NvicMux20_IRQHandler /* CM0+ NVIC Mux input 20 */
|
||||||
|
.long NvicMux21_IRQHandler /* CM0+ NVIC Mux input 21 */
|
||||||
|
.long NvicMux22_IRQHandler /* CM0+ NVIC Mux input 22 */
|
||||||
|
.long NvicMux23_IRQHandler /* CM0+ NVIC Mux input 23 */
|
||||||
|
.long NvicMux24_IRQHandler /* CM0+ NVIC Mux input 24 */
|
||||||
|
.long NvicMux25_IRQHandler /* CM0+ NVIC Mux input 25 */
|
||||||
|
.long NvicMux26_IRQHandler /* CM0+ NVIC Mux input 26 */
|
||||||
|
.long NvicMux27_IRQHandler /* CM0+ NVIC Mux input 27 */
|
||||||
|
.long NvicMux28_IRQHandler /* CM0+ NVIC Mux input 28 */
|
||||||
|
.long NvicMux29_IRQHandler /* CM0+ NVIC Mux input 29 */
|
||||||
|
.long NvicMux30_IRQHandler /* CM0+ NVIC Mux input 30 */
|
||||||
|
.long NvicMux31_IRQHandler /* CM0+ NVIC Mux input 31 */
|
||||||
|
|
||||||
|
.size __Vectors, . - __Vectors
|
||||||
|
.equ __VectorsSize, . - __Vectors
|
||||||
|
|
||||||
|
.section .ram_vectors
|
||||||
|
.align 2
|
||||||
|
.globl __ramVectors
|
||||||
|
__ramVectors:
|
||||||
|
.space __VectorsSize
|
||||||
|
.size __ramVectors, . - __ramVectors
|
||||||
|
|
||||||
|
|
||||||
|
.text
|
||||||
|
.thumb
|
||||||
|
.thumb_func
|
||||||
|
.align 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Device startup customization
|
||||||
|
*
|
||||||
|
* Note. The global resources are not yet initialized (for example global variables, peripherals, clocks)
|
||||||
|
* because this function is executed as the first instruction in the ResetHandler.
|
||||||
|
* The PDL is also not initialized to use the proper register offsets.
|
||||||
|
* The user of this function is responsible for initializing the PDL and resources before using them.
|
||||||
|
*/
|
||||||
|
.weak Cy_OnResetUser
|
||||||
|
.func Cy_OnResetUser, Cy_OnResetUser
|
||||||
|
.type Cy_OnResetUser, %function
|
||||||
|
|
||||||
|
Cy_OnResetUser:
|
||||||
|
bx lr
|
||||||
|
.size Cy_OnResetUser, . - Cy_OnResetUser
|
||||||
|
.endfunc
|
||||||
|
|
||||||
|
/* Reset handler */
|
||||||
|
.weak Reset_Handler
|
||||||
|
.type Reset_Handler, %function
|
||||||
|
|
||||||
|
Reset_Handler:
|
||||||
|
bl Cy_OnResetUser
|
||||||
|
cpsid i
|
||||||
|
|
||||||
|
/* Firstly it copies data from read only memory to RAM. There are two schemes
|
||||||
|
* to copy. One can copy more than one sections. Another can only copy
|
||||||
|
* one section. The former scheme needs more instructions and read-only
|
||||||
|
* data to implement than the latter.
|
||||||
|
* Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes. */
|
||||||
|
|
||||||
|
#ifdef __STARTUP_COPY_MULTIPLE
|
||||||
|
/* Multiple sections scheme.
|
||||||
|
*
|
||||||
|
* Between symbol address __copy_table_start__ and __copy_table_end__,
|
||||||
|
* there are array of triplets, each of which specify:
|
||||||
|
* offset 0: LMA of start of a section to copy from
|
||||||
|
* offset 4: VMA of start of a section to copy to
|
||||||
|
* offset 8: size of the section to copy. Must be multiply of 4
|
||||||
|
*
|
||||||
|
* All addresses must be aligned to 4 bytes boundary.
|
||||||
|
*/
|
||||||
|
ldr r4, =__copy_table_start__
|
||||||
|
ldr r5, =__copy_table_end__
|
||||||
|
|
||||||
|
.L_loop0:
|
||||||
|
cmp r4, r5
|
||||||
|
bge .L_loop0_done
|
||||||
|
ldr r1, [r4]
|
||||||
|
ldr r2, [r4, #4]
|
||||||
|
ldr r3, [r4, #8]
|
||||||
|
|
||||||
|
.L_loop0_0:
|
||||||
|
subs r3, #4
|
||||||
|
blt .L_loop0_0_done
|
||||||
|
ldr r0, [r1, r3]
|
||||||
|
str r0, [r2, r3]
|
||||||
|
b .L_loop0_0
|
||||||
|
|
||||||
|
.L_loop0_0_done:
|
||||||
|
adds r4, #12
|
||||||
|
b .L_loop0
|
||||||
|
|
||||||
|
.L_loop0_done:
|
||||||
|
#else
|
||||||
|
/* Single section scheme.
|
||||||
|
*
|
||||||
|
* The ranges of copy from/to are specified by following symbols
|
||||||
|
* __etext: LMA of start of the section to copy from. Usually end of text
|
||||||
|
* __data_start__: VMA of start of the section to copy to
|
||||||
|
* __data_end__: VMA of end of the section to copy to
|
||||||
|
*
|
||||||
|
* All addresses must be aligned to 4 bytes boundary.
|
||||||
|
*/
|
||||||
|
ldr r1, =__etext
|
||||||
|
ldr r2, =__data_start__
|
||||||
|
ldr r3, =__data_end__
|
||||||
|
|
||||||
|
subs r3, r2
|
||||||
|
ble .L_loop1_done
|
||||||
|
|
||||||
|
.L_loop1:
|
||||||
|
subs r3, #4
|
||||||
|
ldr r0, [r1,r3]
|
||||||
|
str r0, [r2,r3]
|
||||||
|
bgt .L_loop1
|
||||||
|
|
||||||
|
.L_loop1_done:
|
||||||
|
#endif /*__STARTUP_COPY_MULTIPLE */
|
||||||
|
|
||||||
|
/* This part of work usually is done in C library startup code. Otherwise,
|
||||||
|
* define this macro to enable it in this startup.
|
||||||
|
*
|
||||||
|
* There are two schemes too. One can clear multiple BSS sections. Another
|
||||||
|
* can only clear one section. The former is more size expensive than the
|
||||||
|
* latter.
|
||||||
|
*
|
||||||
|
* Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former.
|
||||||
|
* Otherwise define macro __STARTUP_CLEAR_BSS to choose the later.
|
||||||
|
*/
|
||||||
|
#ifdef __STARTUP_CLEAR_BSS_MULTIPLE
|
||||||
|
/* Multiple sections scheme.
|
||||||
|
*
|
||||||
|
* Between symbol address __copy_table_start__ and __copy_table_end__,
|
||||||
|
* there are array of tuples specifying:
|
||||||
|
* offset 0: Start of a BSS section
|
||||||
|
* offset 4: Size of this BSS section. Must be multiply of 4
|
||||||
|
*/
|
||||||
|
ldr r3, =__zero_table_start__
|
||||||
|
ldr r4, =__zero_table_end__
|
||||||
|
|
||||||
|
.L_loop2:
|
||||||
|
cmp r3, r4
|
||||||
|
bge .L_loop2_done
|
||||||
|
ldr r1, [r3]
|
||||||
|
ldr r2, [r3, #4]
|
||||||
|
movs r0, 0
|
||||||
|
|
||||||
|
.L_loop2_0:
|
||||||
|
subs r2, #4
|
||||||
|
blt .L_loop2_0_done
|
||||||
|
str r0, [r1, r2]
|
||||||
|
b .L_loop2_0
|
||||||
|
.L_loop2_0_done:
|
||||||
|
|
||||||
|
adds r3, #8
|
||||||
|
b .L_loop2
|
||||||
|
.L_loop2_done:
|
||||||
|
#elif defined (__STARTUP_CLEAR_BSS)
|
||||||
|
/* Single BSS section scheme.
|
||||||
|
*
|
||||||
|
* The BSS section is specified by following symbols
|
||||||
|
* __bss_start__: start of the BSS section.
|
||||||
|
* __bss_end__: end of the BSS section.
|
||||||
|
*
|
||||||
|
* Both addresses must be aligned to 4 bytes boundary.
|
||||||
|
*/
|
||||||
|
ldr r1, =__bss_start__
|
||||||
|
ldr r2, =__bss_end__
|
||||||
|
|
||||||
|
movs r0, 0
|
||||||
|
|
||||||
|
subs r2, r1
|
||||||
|
ble .L_loop3_done
|
||||||
|
|
||||||
|
.L_loop3:
|
||||||
|
subs r2, #4
|
||||||
|
str r0, [r1, r2]
|
||||||
|
bgt .L_loop3
|
||||||
|
.L_loop3_done:
|
||||||
|
#endif /* __STARTUP_CLEAR_BSS_MULTIPLE || __STARTUP_CLEAR_BSS */
|
||||||
|
|
||||||
|
/* Update Vector Table Offset Register. */
|
||||||
|
ldr r0, =__ramVectors
|
||||||
|
ldr r1, =CY_CPU_VTOR_ADDR
|
||||||
|
str r0, [r1]
|
||||||
|
dsb 0xF
|
||||||
|
|
||||||
|
#ifndef __NO_SYSTEM_INIT
|
||||||
|
bl SystemInit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bl main
|
||||||
|
|
||||||
|
/* Should never get here */
|
||||||
|
b .
|
||||||
|
|
||||||
|
.pool
|
||||||
|
.size Reset_Handler, . - Reset_Handler
|
||||||
|
|
||||||
|
.align 1
|
||||||
|
.thumb_func
|
||||||
|
.weak Default_Handler
|
||||||
|
.type Default_Handler, %function
|
||||||
|
Default_Handler:
|
||||||
|
b .
|
||||||
|
.size Default_Handler, . - Default_Handler
|
||||||
|
.weak Cy_SysLib_FaultHandler
|
||||||
|
.type Cy_SysLib_FaultHandler, %function
|
||||||
|
|
||||||
|
Cy_SysLib_FaultHandler:
|
||||||
|
b .
|
||||||
|
.size Cy_SysLib_FaultHandler, . - Cy_SysLib_FaultHandler
|
||||||
|
.type Fault_Handler, %function
|
||||||
|
|
||||||
|
Fault_Handler:
|
||||||
|
/* Storing LR content for Creator call stack trace */
|
||||||
|
push {LR}
|
||||||
|
movs r0, #4
|
||||||
|
mov r1, LR
|
||||||
|
tst r0, r1
|
||||||
|
beq .L_MSP
|
||||||
|
mrs r0, PSP
|
||||||
|
b .L_API_call
|
||||||
|
.L_MSP:
|
||||||
|
mrs r0, MSP
|
||||||
|
.L_API_call:
|
||||||
|
/* Compensation of stack pointer address due to pushing 4 bytes of LR */
|
||||||
|
adds r0, r0, #4
|
||||||
|
bl Cy_SysLib_FaultHandler
|
||||||
|
b .
|
||||||
|
.size Fault_Handler, . - Fault_Handler
|
||||||
|
|
||||||
|
.macro def_fault_Handler fault_handler_name
|
||||||
|
.weak \fault_handler_name
|
||||||
|
.set \fault_handler_name, Fault_Handler
|
||||||
|
.endm
|
||||||
|
|
||||||
|
/* Macro to define default handlers. Default handler
|
||||||
|
* will be weak symbol and just dead loops. They can be
|
||||||
|
* overwritten by other handlers */
|
||||||
|
.macro def_irq_handler handler_name
|
||||||
|
.weak \handler_name
|
||||||
|
.set \handler_name, Default_Handler
|
||||||
|
.endm
|
||||||
|
|
||||||
|
def_irq_handler NMI_Handler
|
||||||
|
|
||||||
|
def_fault_Handler HardFault_Handler
|
||||||
|
|
||||||
|
def_irq_handler SVC_Handler
|
||||||
|
def_irq_handler PendSV_Handler
|
||||||
|
def_irq_handler SysTick_Handler
|
||||||
|
|
||||||
|
def_irq_handler NvicMux0_IRQHandler /* CM0+ NVIC Mux input 0 */
|
||||||
|
def_irq_handler NvicMux1_IRQHandler /* CM0+ NVIC Mux input 1 */
|
||||||
|
def_irq_handler NvicMux2_IRQHandler /* CM0+ NVIC Mux input 2 */
|
||||||
|
def_irq_handler NvicMux3_IRQHandler /* CM0+ NVIC Mux input 3 */
|
||||||
|
def_irq_handler NvicMux4_IRQHandler /* CM0+ NVIC Mux input 4 */
|
||||||
|
def_irq_handler NvicMux5_IRQHandler /* CM0+ NVIC Mux input 5 */
|
||||||
|
def_irq_handler NvicMux6_IRQHandler /* CM0+ NVIC Mux input 6 */
|
||||||
|
def_irq_handler NvicMux7_IRQHandler /* CM0+ NVIC Mux input 7 */
|
||||||
|
def_irq_handler NvicMux8_IRQHandler /* CM0+ NVIC Mux input 8 */
|
||||||
|
def_irq_handler NvicMux9_IRQHandler /* CM0+ NVIC Mux input 9 */
|
||||||
|
def_irq_handler NvicMux10_IRQHandler /* CM0+ NVIC Mux input 10 */
|
||||||
|
def_irq_handler NvicMux11_IRQHandler /* CM0+ NVIC Mux input 11 */
|
||||||
|
def_irq_handler NvicMux12_IRQHandler /* CM0+ NVIC Mux input 12 */
|
||||||
|
def_irq_handler NvicMux13_IRQHandler /* CM0+ NVIC Mux input 13 */
|
||||||
|
def_irq_handler NvicMux14_IRQHandler /* CM0+ NVIC Mux input 14 */
|
||||||
|
def_irq_handler NvicMux15_IRQHandler /* CM0+ NVIC Mux input 15 */
|
||||||
|
def_irq_handler NvicMux16_IRQHandler /* CM0+ NVIC Mux input 16 */
|
||||||
|
def_irq_handler NvicMux17_IRQHandler /* CM0+ NVIC Mux input 17 */
|
||||||
|
def_irq_handler NvicMux18_IRQHandler /* CM0+ NVIC Mux input 18 */
|
||||||
|
def_irq_handler NvicMux19_IRQHandler /* CM0+ NVIC Mux input 19 */
|
||||||
|
def_irq_handler NvicMux20_IRQHandler /* CM0+ NVIC Mux input 20 */
|
||||||
|
def_irq_handler NvicMux21_IRQHandler /* CM0+ NVIC Mux input 21 */
|
||||||
|
def_irq_handler NvicMux22_IRQHandler /* CM0+ NVIC Mux input 22 */
|
||||||
|
def_irq_handler NvicMux23_IRQHandler /* CM0+ NVIC Mux input 23 */
|
||||||
|
def_irq_handler NvicMux24_IRQHandler /* CM0+ NVIC Mux input 24 */
|
||||||
|
def_irq_handler NvicMux25_IRQHandler /* CM0+ NVIC Mux input 25 */
|
||||||
|
def_irq_handler NvicMux26_IRQHandler /* CM0+ NVIC Mux input 26 */
|
||||||
|
def_irq_handler NvicMux27_IRQHandler /* CM0+ NVIC Mux input 27 */
|
||||||
|
def_irq_handler NvicMux28_IRQHandler /* CM0+ NVIC Mux input 28 */
|
||||||
|
def_irq_handler NvicMux29_IRQHandler /* CM0+ NVIC Mux input 29 */
|
||||||
|
def_irq_handler NvicMux30_IRQHandler /* CM0+ NVIC Mux input 30 */
|
||||||
|
def_irq_handler NvicMux31_IRQHandler /* CM0+ NVIC Mux input 31 */
|
||||||
|
|
||||||
|
.end
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
635
2020TPCApp0.cydsn/gcc/startup_psoc6_01_cm4.S
Normal file
635
2020TPCApp0.cydsn/gcc/startup_psoc6_01_cm4.S
Normal file
|
@ -0,0 +1,635 @@
|
||||||
|
/**************************************************************************//**
|
||||||
|
* @file startup_psoc6_01_cm4.S
|
||||||
|
* @brief CMSIS Core Device Startup File for
|
||||||
|
* ARMCM4 Device Series
|
||||||
|
* @version V5.00
|
||||||
|
* @date 02. March 2016
|
||||||
|
******************************************************************************/
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Address of the NMI handler */
|
||||||
|
#define CY_NMI_HANLDER_ADDR 0x0000000D
|
||||||
|
|
||||||
|
/* The CPU VTOR register */
|
||||||
|
#define CY_CPU_VTOR_ADDR 0xE000ED08
|
||||||
|
|
||||||
|
/* Copy flash vectors and data section to RAM */
|
||||||
|
#define __STARTUP_COPY_MULTIPLE
|
||||||
|
|
||||||
|
/* Clear single BSS section */
|
||||||
|
#define __STARTUP_CLEAR_BSS
|
||||||
|
|
||||||
|
.syntax unified
|
||||||
|
.arch armv7-m
|
||||||
|
|
||||||
|
.section .stack
|
||||||
|
.align 3
|
||||||
|
#ifdef __STACK_SIZE
|
||||||
|
.equ Stack_Size, __STACK_SIZE
|
||||||
|
#else
|
||||||
|
.equ Stack_Size, 0x00001000
|
||||||
|
#endif
|
||||||
|
.globl __StackTop
|
||||||
|
.globl __StackLimit
|
||||||
|
__StackLimit:
|
||||||
|
.space Stack_Size
|
||||||
|
.size __StackLimit, . - __StackLimit
|
||||||
|
__StackTop:
|
||||||
|
.size __StackTop, . - __StackTop
|
||||||
|
|
||||||
|
.section .heap
|
||||||
|
.align 3
|
||||||
|
#ifdef __HEAP_SIZE
|
||||||
|
.equ Heap_Size, __HEAP_SIZE
|
||||||
|
#else
|
||||||
|
.equ Heap_Size, 0x00000400
|
||||||
|
#endif
|
||||||
|
.globl __HeapBase
|
||||||
|
.globl __HeapLimit
|
||||||
|
__HeapBase:
|
||||||
|
.if Heap_Size
|
||||||
|
.space Heap_Size
|
||||||
|
.endif
|
||||||
|
.size __HeapBase, . - __HeapBase
|
||||||
|
__HeapLimit:
|
||||||
|
.size __HeapLimit, . - __HeapLimit
|
||||||
|
|
||||||
|
.section .vectors
|
||||||
|
.align 2
|
||||||
|
.globl __Vectors
|
||||||
|
__Vectors:
|
||||||
|
.long __StackTop /* Top of Stack */
|
||||||
|
.long Reset_Handler /* Reset Handler */
|
||||||
|
.long CY_NMI_HANLDER_ADDR /* NMI Handler */
|
||||||
|
.long HardFault_Handler /* Hard Fault Handler */
|
||||||
|
.long MemManage_Handler /* MPU Fault Handler */
|
||||||
|
.long BusFault_Handler /* Bus Fault Handler */
|
||||||
|
.long UsageFault_Handler /* Usage Fault Handler */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long SVC_Handler /* SVCall Handler */
|
||||||
|
.long DebugMon_Handler /* Debug Monitor Handler */
|
||||||
|
.long 0 /* Reserved */
|
||||||
|
.long PendSV_Handler /* PendSV Handler */
|
||||||
|
.long SysTick_Handler /* SysTick Handler */
|
||||||
|
|
||||||
|
/* External interrupts Description */
|
||||||
|
.long ioss_interrupts_gpio_0_IRQHandler /* GPIO Port Interrupt #0 */
|
||||||
|
.long ioss_interrupts_gpio_1_IRQHandler /* GPIO Port Interrupt #1 */
|
||||||
|
.long ioss_interrupts_gpio_2_IRQHandler /* GPIO Port Interrupt #2 */
|
||||||
|
.long ioss_interrupts_gpio_3_IRQHandler /* GPIO Port Interrupt #3 */
|
||||||
|
.long ioss_interrupts_gpio_4_IRQHandler /* GPIO Port Interrupt #4 */
|
||||||
|
.long ioss_interrupts_gpio_5_IRQHandler /* GPIO Port Interrupt #5 */
|
||||||
|
.long ioss_interrupts_gpio_6_IRQHandler /* GPIO Port Interrupt #6 */
|
||||||
|
.long ioss_interrupts_gpio_7_IRQHandler /* GPIO Port Interrupt #7 */
|
||||||
|
.long ioss_interrupts_gpio_8_IRQHandler /* GPIO Port Interrupt #8 */
|
||||||
|
.long ioss_interrupts_gpio_9_IRQHandler /* GPIO Port Interrupt #9 */
|
||||||
|
.long ioss_interrupts_gpio_10_IRQHandler /* GPIO Port Interrupt #10 */
|
||||||
|
.long ioss_interrupts_gpio_11_IRQHandler /* GPIO Port Interrupt #11 */
|
||||||
|
.long ioss_interrupts_gpio_12_IRQHandler /* GPIO Port Interrupt #12 */
|
||||||
|
.long ioss_interrupts_gpio_13_IRQHandler /* GPIO Port Interrupt #13 */
|
||||||
|
.long ioss_interrupts_gpio_14_IRQHandler /* GPIO Port Interrupt #14 */
|
||||||
|
.long ioss_interrupt_gpio_IRQHandler /* GPIO All Ports */
|
||||||
|
.long ioss_interrupt_vdd_IRQHandler /* GPIO Supply Detect Interrupt */
|
||||||
|
.long lpcomp_interrupt_IRQHandler /* Low Power Comparator Interrupt */
|
||||||
|
.long scb_8_interrupt_IRQHandler /* Serial Communication Block #8 (DeepSleep capable) */
|
||||||
|
.long srss_interrupt_mcwdt_0_IRQHandler /* Multi Counter Watchdog Timer interrupt */
|
||||||
|
.long srss_interrupt_mcwdt_1_IRQHandler /* Multi Counter Watchdog Timer interrupt */
|
||||||
|
.long srss_interrupt_backup_IRQHandler /* Backup domain interrupt */
|
||||||
|
.long srss_interrupt_IRQHandler /* Other combined Interrupts for SRSS (LVD, WDT, CLKCAL) */
|
||||||
|
.long pass_interrupt_ctbs_IRQHandler /* CTBm Interrupt (all CTBms) */
|
||||||
|
.long bless_interrupt_IRQHandler /* Bluetooth Radio interrupt */
|
||||||
|
.long cpuss_interrupts_ipc_0_IRQHandler /* CPUSS Inter Process Communication Interrupt #0 */
|
||||||
|
.long cpuss_interrupts_ipc_1_IRQHandler /* CPUSS Inter Process Communication Interrupt #1 */
|
||||||
|
.long cpuss_interrupts_ipc_2_IRQHandler /* CPUSS Inter Process Communication Interrupt #2 */
|
||||||
|
.long cpuss_interrupts_ipc_3_IRQHandler /* CPUSS Inter Process Communication Interrupt #3 */
|
||||||
|
.long cpuss_interrupts_ipc_4_IRQHandler /* CPUSS Inter Process Communication Interrupt #4 */
|
||||||
|
.long cpuss_interrupts_ipc_5_IRQHandler /* CPUSS Inter Process Communication Interrupt #5 */
|
||||||
|
.long cpuss_interrupts_ipc_6_IRQHandler /* CPUSS Inter Process Communication Interrupt #6 */
|
||||||
|
.long cpuss_interrupts_ipc_7_IRQHandler /* CPUSS Inter Process Communication Interrupt #7 */
|
||||||
|
.long cpuss_interrupts_ipc_8_IRQHandler /* CPUSS Inter Process Communication Interrupt #8 */
|
||||||
|
.long cpuss_interrupts_ipc_9_IRQHandler /* CPUSS Inter Process Communication Interrupt #9 */
|
||||||
|
.long cpuss_interrupts_ipc_10_IRQHandler /* CPUSS Inter Process Communication Interrupt #10 */
|
||||||
|
.long cpuss_interrupts_ipc_11_IRQHandler /* CPUSS Inter Process Communication Interrupt #11 */
|
||||||
|
.long cpuss_interrupts_ipc_12_IRQHandler /* CPUSS Inter Process Communication Interrupt #12 */
|
||||||
|
.long cpuss_interrupts_ipc_13_IRQHandler /* CPUSS Inter Process Communication Interrupt #13 */
|
||||||
|
.long cpuss_interrupts_ipc_14_IRQHandler /* CPUSS Inter Process Communication Interrupt #14 */
|
||||||
|
.long cpuss_interrupts_ipc_15_IRQHandler /* CPUSS Inter Process Communication Interrupt #15 */
|
||||||
|
.long scb_0_interrupt_IRQHandler /* Serial Communication Block #0 */
|
||||||
|
.long scb_1_interrupt_IRQHandler /* Serial Communication Block #1 */
|
||||||
|
.long scb_2_interrupt_IRQHandler /* Serial Communication Block #2 */
|
||||||
|
.long scb_3_interrupt_IRQHandler /* Serial Communication Block #3 */
|
||||||
|
.long scb_4_interrupt_IRQHandler /* Serial Communication Block #4 */
|
||||||
|
.long scb_5_interrupt_IRQHandler /* Serial Communication Block #5 */
|
||||||
|
.long scb_6_interrupt_IRQHandler /* Serial Communication Block #6 */
|
||||||
|
.long scb_7_interrupt_IRQHandler /* Serial Communication Block #7 */
|
||||||
|
.long csd_interrupt_IRQHandler /* CSD (Capsense) interrupt */
|
||||||
|
.long cpuss_interrupts_dw0_0_IRQHandler /* CPUSS DataWire #0, Channel #0 */
|
||||||
|
.long cpuss_interrupts_dw0_1_IRQHandler /* CPUSS DataWire #0, Channel #1 */
|
||||||
|
.long cpuss_interrupts_dw0_2_IRQHandler /* CPUSS DataWire #0, Channel #2 */
|
||||||
|
.long cpuss_interrupts_dw0_3_IRQHandler /* CPUSS DataWire #0, Channel #3 */
|
||||||
|
.long cpuss_interrupts_dw0_4_IRQHandler /* CPUSS DataWire #0, Channel #4 */
|
||||||
|
.long cpuss_interrupts_dw0_5_IRQHandler /* CPUSS DataWire #0, Channel #5 */
|
||||||
|
.long cpuss_interrupts_dw0_6_IRQHandler /* CPUSS DataWire #0, Channel #6 */
|
||||||
|
.long cpuss_interrupts_dw0_7_IRQHandler /* CPUSS DataWire #0, Channel #7 */
|
||||||
|
.long cpuss_interrupts_dw0_8_IRQHandler /* CPUSS DataWire #0, Channel #8 */
|
||||||
|
.long cpuss_interrupts_dw0_9_IRQHandler /* CPUSS DataWire #0, Channel #9 */
|
||||||
|
.long cpuss_interrupts_dw0_10_IRQHandler /* CPUSS DataWire #0, Channel #10 */
|
||||||
|
.long cpuss_interrupts_dw0_11_IRQHandler /* CPUSS DataWire #0, Channel #11 */
|
||||||
|
.long cpuss_interrupts_dw0_12_IRQHandler /* CPUSS DataWire #0, Channel #12 */
|
||||||
|
.long cpuss_interrupts_dw0_13_IRQHandler /* CPUSS DataWire #0, Channel #13 */
|
||||||
|
.long cpuss_interrupts_dw0_14_IRQHandler /* CPUSS DataWire #0, Channel #14 */
|
||||||
|
.long cpuss_interrupts_dw0_15_IRQHandler /* CPUSS DataWire #0, Channel #15 */
|
||||||
|
.long cpuss_interrupts_dw1_0_IRQHandler /* CPUSS DataWire #1, Channel #0 */
|
||||||
|
.long cpuss_interrupts_dw1_1_IRQHandler /* CPUSS DataWire #1, Channel #1 */
|
||||||
|
.long cpuss_interrupts_dw1_2_IRQHandler /* CPUSS DataWire #1, Channel #2 */
|
||||||
|
.long cpuss_interrupts_dw1_3_IRQHandler /* CPUSS DataWire #1, Channel #3 */
|
||||||
|
.long cpuss_interrupts_dw1_4_IRQHandler /* CPUSS DataWire #1, Channel #4 */
|
||||||
|
.long cpuss_interrupts_dw1_5_IRQHandler /* CPUSS DataWire #1, Channel #5 */
|
||||||
|
.long cpuss_interrupts_dw1_6_IRQHandler /* CPUSS DataWire #1, Channel #6 */
|
||||||
|
.long cpuss_interrupts_dw1_7_IRQHandler /* CPUSS DataWire #1, Channel #7 */
|
||||||
|
.long cpuss_interrupts_dw1_8_IRQHandler /* CPUSS DataWire #1, Channel #8 */
|
||||||
|
.long cpuss_interrupts_dw1_9_IRQHandler /* CPUSS DataWire #1, Channel #9 */
|
||||||
|
.long cpuss_interrupts_dw1_10_IRQHandler /* CPUSS DataWire #1, Channel #10 */
|
||||||
|
.long cpuss_interrupts_dw1_11_IRQHandler /* CPUSS DataWire #1, Channel #11 */
|
||||||
|
.long cpuss_interrupts_dw1_12_IRQHandler /* CPUSS DataWire #1, Channel #12 */
|
||||||
|
.long cpuss_interrupts_dw1_13_IRQHandler /* CPUSS DataWire #1, Channel #13 */
|
||||||
|
.long cpuss_interrupts_dw1_14_IRQHandler /* CPUSS DataWire #1, Channel #14 */
|
||||||
|
.long cpuss_interrupts_dw1_15_IRQHandler /* CPUSS DataWire #1, Channel #15 */
|
||||||
|
.long cpuss_interrupts_fault_0_IRQHandler /* CPUSS Fault Structure Interrupt #0 */
|
||||||
|
.long cpuss_interrupts_fault_1_IRQHandler /* CPUSS Fault Structure Interrupt #1 */
|
||||||
|
.long cpuss_interrupt_crypto_IRQHandler /* CRYPTO Accelerator Interrupt */
|
||||||
|
.long cpuss_interrupt_fm_IRQHandler /* FLASH Macro Interrupt */
|
||||||
|
.long cpuss_interrupts_cm0_cti_0_IRQHandler /* CM0+ CTI #0 */
|
||||||
|
.long cpuss_interrupts_cm0_cti_1_IRQHandler /* CM0+ CTI #1 */
|
||||||
|
.long cpuss_interrupts_cm4_cti_0_IRQHandler /* CM4 CTI #0 */
|
||||||
|
.long cpuss_interrupts_cm4_cti_1_IRQHandler /* CM4 CTI #1 */
|
||||||
|
.long tcpwm_0_interrupts_0_IRQHandler /* TCPWM #0, Counter #0 */
|
||||||
|
.long tcpwm_0_interrupts_1_IRQHandler /* TCPWM #0, Counter #1 */
|
||||||
|
.long tcpwm_0_interrupts_2_IRQHandler /* TCPWM #0, Counter #2 */
|
||||||
|
.long tcpwm_0_interrupts_3_IRQHandler /* TCPWM #0, Counter #3 */
|
||||||
|
.long tcpwm_0_interrupts_4_IRQHandler /* TCPWM #0, Counter #4 */
|
||||||
|
.long tcpwm_0_interrupts_5_IRQHandler /* TCPWM #0, Counter #5 */
|
||||||
|
.long tcpwm_0_interrupts_6_IRQHandler /* TCPWM #0, Counter #6 */
|
||||||
|
.long tcpwm_0_interrupts_7_IRQHandler /* TCPWM #0, Counter #7 */
|
||||||
|
.long tcpwm_1_interrupts_0_IRQHandler /* TCPWM #1, Counter #0 */
|
||||||
|
.long tcpwm_1_interrupts_1_IRQHandler /* TCPWM #1, Counter #1 */
|
||||||
|
.long tcpwm_1_interrupts_2_IRQHandler /* TCPWM #1, Counter #2 */
|
||||||
|
.long tcpwm_1_interrupts_3_IRQHandler /* TCPWM #1, Counter #3 */
|
||||||
|
.long tcpwm_1_interrupts_4_IRQHandler /* TCPWM #1, Counter #4 */
|
||||||
|
.long tcpwm_1_interrupts_5_IRQHandler /* TCPWM #1, Counter #5 */
|
||||||
|
.long tcpwm_1_interrupts_6_IRQHandler /* TCPWM #1, Counter #6 */
|
||||||
|
.long tcpwm_1_interrupts_7_IRQHandler /* TCPWM #1, Counter #7 */
|
||||||
|
.long tcpwm_1_interrupts_8_IRQHandler /* TCPWM #1, Counter #8 */
|
||||||
|
.long tcpwm_1_interrupts_9_IRQHandler /* TCPWM #1, Counter #9 */
|
||||||
|
.long tcpwm_1_interrupts_10_IRQHandler /* TCPWM #1, Counter #10 */
|
||||||
|
.long tcpwm_1_interrupts_11_IRQHandler /* TCPWM #1, Counter #11 */
|
||||||
|
.long tcpwm_1_interrupts_12_IRQHandler /* TCPWM #1, Counter #12 */
|
||||||
|
.long tcpwm_1_interrupts_13_IRQHandler /* TCPWM #1, Counter #13 */
|
||||||
|
.long tcpwm_1_interrupts_14_IRQHandler /* TCPWM #1, Counter #14 */
|
||||||
|
.long tcpwm_1_interrupts_15_IRQHandler /* TCPWM #1, Counter #15 */
|
||||||
|
.long tcpwm_1_interrupts_16_IRQHandler /* TCPWM #1, Counter #16 */
|
||||||
|
.long tcpwm_1_interrupts_17_IRQHandler /* TCPWM #1, Counter #17 */
|
||||||
|
.long tcpwm_1_interrupts_18_IRQHandler /* TCPWM #1, Counter #18 */
|
||||||
|
.long tcpwm_1_interrupts_19_IRQHandler /* TCPWM #1, Counter #19 */
|
||||||
|
.long tcpwm_1_interrupts_20_IRQHandler /* TCPWM #1, Counter #20 */
|
||||||
|
.long tcpwm_1_interrupts_21_IRQHandler /* TCPWM #1, Counter #21 */
|
||||||
|
.long tcpwm_1_interrupts_22_IRQHandler /* TCPWM #1, Counter #22 */
|
||||||
|
.long tcpwm_1_interrupts_23_IRQHandler /* TCPWM #1, Counter #23 */
|
||||||
|
.long udb_interrupts_0_IRQHandler /* UDB Interrupt #0 */
|
||||||
|
.long udb_interrupts_1_IRQHandler /* UDB Interrupt #1 */
|
||||||
|
.long udb_interrupts_2_IRQHandler /* UDB Interrupt #2 */
|
||||||
|
.long udb_interrupts_3_IRQHandler /* UDB Interrupt #3 */
|
||||||
|
.long udb_interrupts_4_IRQHandler /* UDB Interrupt #4 */
|
||||||
|
.long udb_interrupts_5_IRQHandler /* UDB Interrupt #5 */
|
||||||
|
.long udb_interrupts_6_IRQHandler /* UDB Interrupt #6 */
|
||||||
|
.long udb_interrupts_7_IRQHandler /* UDB Interrupt #7 */
|
||||||
|
.long udb_interrupts_8_IRQHandler /* UDB Interrupt #8 */
|
||||||
|
.long udb_interrupts_9_IRQHandler /* UDB Interrupt #9 */
|
||||||
|
.long udb_interrupts_10_IRQHandler /* UDB Interrupt #10 */
|
||||||
|
.long udb_interrupts_11_IRQHandler /* UDB Interrupt #11 */
|
||||||
|
.long udb_interrupts_12_IRQHandler /* UDB Interrupt #12 */
|
||||||
|
.long udb_interrupts_13_IRQHandler /* UDB Interrupt #13 */
|
||||||
|
.long udb_interrupts_14_IRQHandler /* UDB Interrupt #14 */
|
||||||
|
.long udb_interrupts_15_IRQHandler /* UDB Interrupt #15 */
|
||||||
|
.long pass_interrupt_sar_IRQHandler /* SAR ADC interrupt */
|
||||||
|
.long audioss_interrupt_i2s_IRQHandler /* I2S Audio interrupt */
|
||||||
|
.long audioss_interrupt_pdm_IRQHandler /* PDM/PCM Audio interrupt */
|
||||||
|
.long profile_interrupt_IRQHandler /* Energy Profiler interrupt */
|
||||||
|
.long smif_interrupt_IRQHandler /* Serial Memory Interface interrupt */
|
||||||
|
.long usb_interrupt_hi_IRQHandler /* USB Interrupt */
|
||||||
|
.long usb_interrupt_med_IRQHandler /* USB Interrupt */
|
||||||
|
.long usb_interrupt_lo_IRQHandler /* USB Interrupt */
|
||||||
|
.long pass_interrupt_dacs_IRQHandler /* Consolidated interrrupt for all DACs */
|
||||||
|
|
||||||
|
|
||||||
|
.size __Vectors, . - __Vectors
|
||||||
|
.equ __VectorsSize, . - __Vectors
|
||||||
|
|
||||||
|
.section .ram_vectors
|
||||||
|
.align 2
|
||||||
|
.globl __ramVectors
|
||||||
|
__ramVectors:
|
||||||
|
.space __VectorsSize
|
||||||
|
.size __ramVectors, . - __ramVectors
|
||||||
|
|
||||||
|
|
||||||
|
.text
|
||||||
|
.thumb
|
||||||
|
.thumb_func
|
||||||
|
.align 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Device startup customization
|
||||||
|
*
|
||||||
|
* Note. The global resources are not yet initialized (for example global variables, peripherals, clocks)
|
||||||
|
* because this function is executed as the first instruction in the ResetHandler.
|
||||||
|
* The PDL is also not initialized to use the proper register offsets.
|
||||||
|
* The user of this function is responsible for initializing the PDL and resources before using them.
|
||||||
|
*/
|
||||||
|
.weak Cy_OnResetUser
|
||||||
|
.func Cy_OnResetUser, Cy_OnResetUser
|
||||||
|
.type Cy_OnResetUser, %function
|
||||||
|
|
||||||
|
Cy_OnResetUser:
|
||||||
|
bx lr
|
||||||
|
.size Cy_OnResetUser, . - Cy_OnResetUser
|
||||||
|
.endfunc
|
||||||
|
|
||||||
|
/* Reset handler */
|
||||||
|
.weak Reset_Handler
|
||||||
|
.type Reset_Handler, %function
|
||||||
|
|
||||||
|
Reset_Handler:
|
||||||
|
bl Cy_OnResetUser
|
||||||
|
cpsid i
|
||||||
|
|
||||||
|
/* Firstly it copies data from read only memory to RAM. There are two schemes
|
||||||
|
* to copy. One can copy more than one sections. Another can only copy
|
||||||
|
* one section. The former scheme needs more instructions and read-only
|
||||||
|
* data to implement than the latter.
|
||||||
|
* Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes. */
|
||||||
|
|
||||||
|
#ifdef __STARTUP_COPY_MULTIPLE
|
||||||
|
/* Multiple sections scheme.
|
||||||
|
*
|
||||||
|
* Between symbol address __copy_table_start__ and __copy_table_end__,
|
||||||
|
* there are array of triplets, each of which specify:
|
||||||
|
* offset 0: LMA of start of a section to copy from
|
||||||
|
* offset 4: VMA of start of a section to copy to
|
||||||
|
* offset 8: size of the section to copy. Must be multiply of 4
|
||||||
|
*
|
||||||
|
* All addresses must be aligned to 4 bytes boundary.
|
||||||
|
*/
|
||||||
|
ldr r4, =__copy_table_start__
|
||||||
|
ldr r5, =__copy_table_end__
|
||||||
|
|
||||||
|
.L_loop0:
|
||||||
|
cmp r4, r5
|
||||||
|
bge .L_loop0_done
|
||||||
|
ldr r1, [r4]
|
||||||
|
ldr r2, [r4, #4]
|
||||||
|
ldr r3, [r4, #8]
|
||||||
|
|
||||||
|
.L_loop0_0:
|
||||||
|
subs r3, #4
|
||||||
|
ittt ge
|
||||||
|
ldrge r0, [r1, r3]
|
||||||
|
strge r0, [r2, r3]
|
||||||
|
bge .L_loop0_0
|
||||||
|
|
||||||
|
adds r4, #12
|
||||||
|
b .L_loop0
|
||||||
|
|
||||||
|
.L_loop0_done:
|
||||||
|
#else
|
||||||
|
/* Single section scheme.
|
||||||
|
*
|
||||||
|
* The ranges of copy from/to are specified by following symbols
|
||||||
|
* __etext: LMA of start of the section to copy from. Usually end of text
|
||||||
|
* __data_start__: VMA of start of the section to copy to
|
||||||
|
* __data_end__: VMA of end of the section to copy to
|
||||||
|
*
|
||||||
|
* All addresses must be aligned to 4 bytes boundary.
|
||||||
|
*/
|
||||||
|
ldr r1, =__etext
|
||||||
|
ldr r2, =__data_start__
|
||||||
|
ldr r3, =__data_end__
|
||||||
|
|
||||||
|
.L_loop1:
|
||||||
|
cmp r2, r3
|
||||||
|
ittt lt
|
||||||
|
ldrlt r0, [r1], #4
|
||||||
|
strlt r0, [r2], #4
|
||||||
|
blt .L_loop1
|
||||||
|
#endif /*__STARTUP_COPY_MULTIPLE */
|
||||||
|
|
||||||
|
/* This part of work usually is done in C library startup code. Otherwise,
|
||||||
|
* define this macro to enable it in this startup.
|
||||||
|
*
|
||||||
|
* There are two schemes too. One can clear multiple BSS sections. Another
|
||||||
|
* can only clear one section. The former is more size expensive than the
|
||||||
|
* latter.
|
||||||
|
*
|
||||||
|
* Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former.
|
||||||
|
* Otherwise define macro __STARTUP_CLEAR_BSS to choose the later.
|
||||||
|
*/
|
||||||
|
#ifdef __STARTUP_CLEAR_BSS_MULTIPLE
|
||||||
|
/* Multiple sections scheme.
|
||||||
|
*
|
||||||
|
* Between symbol address __copy_table_start__ and __copy_table_end__,
|
||||||
|
* there are array of tuples specifying:
|
||||||
|
* offset 0: Start of a BSS section
|
||||||
|
* offset 4: Size of this BSS section. Must be multiply of 4
|
||||||
|
*/
|
||||||
|
ldr r3, =__zero_table_start__
|
||||||
|
ldr r4, =__zero_table_end__
|
||||||
|
|
||||||
|
.L_loop2:
|
||||||
|
cmp r3, r4
|
||||||
|
bge .L_loop2_done
|
||||||
|
ldr r1, [r3]
|
||||||
|
ldr r2, [r3, #4]
|
||||||
|
movs r0, 0
|
||||||
|
|
||||||
|
.L_loop2_0:
|
||||||
|
subs r2, #4
|
||||||
|
itt ge
|
||||||
|
strge r0, [r1, r2]
|
||||||
|
bge .L_loop2_0
|
||||||
|
|
||||||
|
adds r3, #8
|
||||||
|
b .L_loop2
|
||||||
|
.L_loop2_done:
|
||||||
|
#elif defined (__STARTUP_CLEAR_BSS)
|
||||||
|
/* Single BSS section scheme.
|
||||||
|
*
|
||||||
|
* The BSS section is specified by following symbols
|
||||||
|
* __bss_start__: start of the BSS section.
|
||||||
|
* __bss_end__: end of the BSS section.
|
||||||
|
*
|
||||||
|
* Both addresses must be aligned to 4 bytes boundary.
|
||||||
|
*/
|
||||||
|
ldr r1, =__bss_start__
|
||||||
|
ldr r2, =__bss_end__
|
||||||
|
|
||||||
|
movs r0, 0
|
||||||
|
.L_loop3:
|
||||||
|
cmp r1, r2
|
||||||
|
itt lt
|
||||||
|
strlt r0, [r1], #4
|
||||||
|
blt .L_loop3
|
||||||
|
#endif /* __STARTUP_CLEAR_BSS_MULTIPLE || __STARTUP_CLEAR_BSS */
|
||||||
|
|
||||||
|
/* Update Vector Table Offset Register. */
|
||||||
|
ldr r0, =__ramVectors
|
||||||
|
ldr r1, =CY_CPU_VTOR_ADDR
|
||||||
|
str r0, [r1]
|
||||||
|
dsb 0xF
|
||||||
|
|
||||||
|
/* Enable the FPU if used */
|
||||||
|
bl Cy_SystemInitFpuEnable
|
||||||
|
|
||||||
|
#ifndef __NO_SYSTEM_INIT
|
||||||
|
bl SystemInit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bl main
|
||||||
|
|
||||||
|
/* Should never get here */
|
||||||
|
b .
|
||||||
|
|
||||||
|
.pool
|
||||||
|
.size Reset_Handler, . - Reset_Handler
|
||||||
|
|
||||||
|
.align 1
|
||||||
|
.thumb_func
|
||||||
|
.weak Default_Handler
|
||||||
|
.type Default_Handler, %function
|
||||||
|
|
||||||
|
Default_Handler:
|
||||||
|
b .
|
||||||
|
.size Default_Handler, . - Default_Handler
|
||||||
|
|
||||||
|
|
||||||
|
.weak Cy_SysLib_FaultHandler
|
||||||
|
.type Cy_SysLib_FaultHandler, %function
|
||||||
|
|
||||||
|
Cy_SysLib_FaultHandler:
|
||||||
|
b .
|
||||||
|
.size Cy_SysLib_FaultHandler, . - Cy_SysLib_FaultHandler
|
||||||
|
.type Fault_Handler, %function
|
||||||
|
|
||||||
|
Fault_Handler:
|
||||||
|
/* Storing LR content for Creator call stack trace */
|
||||||
|
push {LR}
|
||||||
|
movs r0, #4
|
||||||
|
mov r1, LR
|
||||||
|
tst r0, r1
|
||||||
|
beq .L_MSP
|
||||||
|
mrs r0, PSP
|
||||||
|
b .L_API_call
|
||||||
|
.L_MSP:
|
||||||
|
mrs r0, MSP
|
||||||
|
.L_API_call:
|
||||||
|
/* Compensation of stack pointer address due to pushing 4 bytes of LR */
|
||||||
|
adds r0, r0, #4
|
||||||
|
bl Cy_SysLib_FaultHandler
|
||||||
|
b .
|
||||||
|
.size Fault_Handler, . - Fault_Handler
|
||||||
|
|
||||||
|
.macro def_fault_Handler fault_handler_name
|
||||||
|
.weak \fault_handler_name
|
||||||
|
.set \fault_handler_name, Fault_Handler
|
||||||
|
.endm
|
||||||
|
|
||||||
|
/* Macro to define default handlers. Default handler
|
||||||
|
* will be weak symbol and just dead loops. They can be
|
||||||
|
* overwritten by other handlers */
|
||||||
|
.macro def_irq_handler handler_name
|
||||||
|
.weak \handler_name
|
||||||
|
.set \handler_name, Default_Handler
|
||||||
|
.endm
|
||||||
|
|
||||||
|
def_irq_handler NMI_Handler
|
||||||
|
|
||||||
|
def_fault_Handler HardFault_Handler
|
||||||
|
def_fault_Handler MemManage_Handler
|
||||||
|
def_fault_Handler BusFault_Handler
|
||||||
|
def_fault_Handler UsageFault_Handler
|
||||||
|
|
||||||
|
def_irq_handler SVC_Handler
|
||||||
|
def_irq_handler DebugMon_Handler
|
||||||
|
def_irq_handler PendSV_Handler
|
||||||
|
def_irq_handler SysTick_Handler
|
||||||
|
|
||||||
|
def_irq_handler ioss_interrupts_gpio_0_IRQHandler /* GPIO Port Interrupt #0 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_1_IRQHandler /* GPIO Port Interrupt #1 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_2_IRQHandler /* GPIO Port Interrupt #2 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_3_IRQHandler /* GPIO Port Interrupt #3 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_4_IRQHandler /* GPIO Port Interrupt #4 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_5_IRQHandler /* GPIO Port Interrupt #5 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_6_IRQHandler /* GPIO Port Interrupt #6 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_7_IRQHandler /* GPIO Port Interrupt #7 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_8_IRQHandler /* GPIO Port Interrupt #8 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_9_IRQHandler /* GPIO Port Interrupt #9 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_10_IRQHandler /* GPIO Port Interrupt #10 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_11_IRQHandler /* GPIO Port Interrupt #11 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_12_IRQHandler /* GPIO Port Interrupt #12 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_13_IRQHandler /* GPIO Port Interrupt #13 */
|
||||||
|
def_irq_handler ioss_interrupts_gpio_14_IRQHandler /* GPIO Port Interrupt #14 */
|
||||||
|
def_irq_handler ioss_interrupt_gpio_IRQHandler /* GPIO All Ports */
|
||||||
|
def_irq_handler ioss_interrupt_vdd_IRQHandler /* GPIO Supply Detect Interrupt */
|
||||||
|
def_irq_handler lpcomp_interrupt_IRQHandler /* Low Power Comparator Interrupt */
|
||||||
|
def_irq_handler scb_8_interrupt_IRQHandler /* Serial Communication Block #8 (DeepSleep capable) */
|
||||||
|
def_irq_handler srss_interrupt_mcwdt_0_IRQHandler /* Multi Counter Watchdog Timer interrupt */
|
||||||
|
def_irq_handler srss_interrupt_mcwdt_1_IRQHandler /* Multi Counter Watchdog Timer interrupt */
|
||||||
|
def_irq_handler srss_interrupt_backup_IRQHandler /* Backup domain interrupt */
|
||||||
|
def_irq_handler srss_interrupt_IRQHandler /* Other combined Interrupts for SRSS (LVD, WDT, CLKCAL) */
|
||||||
|
def_irq_handler pass_interrupt_ctbs_IRQHandler /* CTBm Interrupt (all CTBms) */
|
||||||
|
def_irq_handler bless_interrupt_IRQHandler /* Bluetooth Radio interrupt */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_0_IRQHandler /* CPUSS Inter Process Communication Interrupt #0 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_1_IRQHandler /* CPUSS Inter Process Communication Interrupt #1 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_2_IRQHandler /* CPUSS Inter Process Communication Interrupt #2 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_3_IRQHandler /* CPUSS Inter Process Communication Interrupt #3 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_4_IRQHandler /* CPUSS Inter Process Communication Interrupt #4 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_5_IRQHandler /* CPUSS Inter Process Communication Interrupt #5 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_6_IRQHandler /* CPUSS Inter Process Communication Interrupt #6 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_7_IRQHandler /* CPUSS Inter Process Communication Interrupt #7 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_8_IRQHandler /* CPUSS Inter Process Communication Interrupt #8 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_9_IRQHandler /* CPUSS Inter Process Communication Interrupt #9 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_10_IRQHandler /* CPUSS Inter Process Communication Interrupt #10 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_11_IRQHandler /* CPUSS Inter Process Communication Interrupt #11 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_12_IRQHandler /* CPUSS Inter Process Communication Interrupt #12 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_13_IRQHandler /* CPUSS Inter Process Communication Interrupt #13 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_14_IRQHandler /* CPUSS Inter Process Communication Interrupt #14 */
|
||||||
|
def_irq_handler cpuss_interrupts_ipc_15_IRQHandler /* CPUSS Inter Process Communication Interrupt #15 */
|
||||||
|
def_irq_handler scb_0_interrupt_IRQHandler /* Serial Communication Block #0 */
|
||||||
|
def_irq_handler scb_1_interrupt_IRQHandler /* Serial Communication Block #1 */
|
||||||
|
def_irq_handler scb_2_interrupt_IRQHandler /* Serial Communication Block #2 */
|
||||||
|
def_irq_handler scb_3_interrupt_IRQHandler /* Serial Communication Block #3 */
|
||||||
|
def_irq_handler scb_4_interrupt_IRQHandler /* Serial Communication Block #4 */
|
||||||
|
def_irq_handler scb_5_interrupt_IRQHandler /* Serial Communication Block #5 */
|
||||||
|
def_irq_handler scb_6_interrupt_IRQHandler /* Serial Communication Block #6 */
|
||||||
|
def_irq_handler scb_7_interrupt_IRQHandler /* Serial Communication Block #7 */
|
||||||
|
def_irq_handler csd_interrupt_IRQHandler /* CSD (Capsense) interrupt */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_0_IRQHandler /* CPUSS DataWire #0, Channel #0 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_1_IRQHandler /* CPUSS DataWire #0, Channel #1 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_2_IRQHandler /* CPUSS DataWire #0, Channel #2 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_3_IRQHandler /* CPUSS DataWire #0, Channel #3 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_4_IRQHandler /* CPUSS DataWire #0, Channel #4 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_5_IRQHandler /* CPUSS DataWire #0, Channel #5 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_6_IRQHandler /* CPUSS DataWire #0, Channel #6 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_7_IRQHandler /* CPUSS DataWire #0, Channel #7 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_8_IRQHandler /* CPUSS DataWire #0, Channel #8 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_9_IRQHandler /* CPUSS DataWire #0, Channel #9 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_10_IRQHandler /* CPUSS DataWire #0, Channel #10 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_11_IRQHandler /* CPUSS DataWire #0, Channel #11 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_12_IRQHandler /* CPUSS DataWire #0, Channel #12 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_13_IRQHandler /* CPUSS DataWire #0, Channel #13 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_14_IRQHandler /* CPUSS DataWire #0, Channel #14 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw0_15_IRQHandler /* CPUSS DataWire #0, Channel #15 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_0_IRQHandler /* CPUSS DataWire #1, Channel #0 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_1_IRQHandler /* CPUSS DataWire #1, Channel #1 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_2_IRQHandler /* CPUSS DataWire #1, Channel #2 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_3_IRQHandler /* CPUSS DataWire #1, Channel #3 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_4_IRQHandler /* CPUSS DataWire #1, Channel #4 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_5_IRQHandler /* CPUSS DataWire #1, Channel #5 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_6_IRQHandler /* CPUSS DataWire #1, Channel #6 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_7_IRQHandler /* CPUSS DataWire #1, Channel #7 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_8_IRQHandler /* CPUSS DataWire #1, Channel #8 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_9_IRQHandler /* CPUSS DataWire #1, Channel #9 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_10_IRQHandler /* CPUSS DataWire #1, Channel #10 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_11_IRQHandler /* CPUSS DataWire #1, Channel #11 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_12_IRQHandler /* CPUSS DataWire #1, Channel #12 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_13_IRQHandler /* CPUSS DataWire #1, Channel #13 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_14_IRQHandler /* CPUSS DataWire #1, Channel #14 */
|
||||||
|
def_irq_handler cpuss_interrupts_dw1_15_IRQHandler /* CPUSS DataWire #1, Channel #15 */
|
||||||
|
def_irq_handler cpuss_interrupts_fault_0_IRQHandler /* CPUSS Fault Structure Interrupt #0 */
|
||||||
|
def_irq_handler cpuss_interrupts_fault_1_IRQHandler /* CPUSS Fault Structure Interrupt #1 */
|
||||||
|
def_irq_handler cpuss_interrupt_crypto_IRQHandler /* CRYPTO Accelerator Interrupt */
|
||||||
|
def_irq_handler cpuss_interrupt_fm_IRQHandler /* FLASH Macro Interrupt */
|
||||||
|
def_irq_handler cpuss_interrupts_cm0_cti_0_IRQHandler /* CM0+ CTI #0 */
|
||||||
|
def_irq_handler cpuss_interrupts_cm0_cti_1_IRQHandler /* CM0+ CTI #1 */
|
||||||
|
def_irq_handler cpuss_interrupts_cm4_cti_0_IRQHandler /* CM4 CTI #0 */
|
||||||
|
def_irq_handler cpuss_interrupts_cm4_cti_1_IRQHandler /* CM4 CTI #1 */
|
||||||
|
def_irq_handler tcpwm_0_interrupts_0_IRQHandler /* TCPWM #0, Counter #0 */
|
||||||
|
def_irq_handler tcpwm_0_interrupts_1_IRQHandler /* TCPWM #0, Counter #1 */
|
||||||
|
def_irq_handler tcpwm_0_interrupts_2_IRQHandler /* TCPWM #0, Counter #2 */
|
||||||
|
def_irq_handler tcpwm_0_interrupts_3_IRQHandler /* TCPWM #0, Counter #3 */
|
||||||
|
def_irq_handler tcpwm_0_interrupts_4_IRQHandler /* TCPWM #0, Counter #4 */
|
||||||
|
def_irq_handler tcpwm_0_interrupts_5_IRQHandler /* TCPWM #0, Counter #5 */
|
||||||
|
def_irq_handler tcpwm_0_interrupts_6_IRQHandler /* TCPWM #0, Counter #6 */
|
||||||
|
def_irq_handler tcpwm_0_interrupts_7_IRQHandler /* TCPWM #0, Counter #7 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_0_IRQHandler /* TCPWM #1, Counter #0 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_1_IRQHandler /* TCPWM #1, Counter #1 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_2_IRQHandler /* TCPWM #1, Counter #2 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_3_IRQHandler /* TCPWM #1, Counter #3 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_4_IRQHandler /* TCPWM #1, Counter #4 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_5_IRQHandler /* TCPWM #1, Counter #5 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_6_IRQHandler /* TCPWM #1, Counter #6 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_7_IRQHandler /* TCPWM #1, Counter #7 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_8_IRQHandler /* TCPWM #1, Counter #8 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_9_IRQHandler /* TCPWM #1, Counter #9 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_10_IRQHandler /* TCPWM #1, Counter #10 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_11_IRQHandler /* TCPWM #1, Counter #11 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_12_IRQHandler /* TCPWM #1, Counter #12 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_13_IRQHandler /* TCPWM #1, Counter #13 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_14_IRQHandler /* TCPWM #1, Counter #14 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_15_IRQHandler /* TCPWM #1, Counter #15 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_16_IRQHandler /* TCPWM #1, Counter #16 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_17_IRQHandler /* TCPWM #1, Counter #17 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_18_IRQHandler /* TCPWM #1, Counter #18 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_19_IRQHandler /* TCPWM #1, Counter #19 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_20_IRQHandler /* TCPWM #1, Counter #20 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_21_IRQHandler /* TCPWM #1, Counter #21 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_22_IRQHandler /* TCPWM #1, Counter #22 */
|
||||||
|
def_irq_handler tcpwm_1_interrupts_23_IRQHandler /* TCPWM #1, Counter #23 */
|
||||||
|
def_irq_handler udb_interrupts_0_IRQHandler /* UDB Interrupt #0 */
|
||||||
|
def_irq_handler udb_interrupts_1_IRQHandler /* UDB Interrupt #1 */
|
||||||
|
def_irq_handler udb_interrupts_2_IRQHandler /* UDB Interrupt #2 */
|
||||||
|
def_irq_handler udb_interrupts_3_IRQHandler /* UDB Interrupt #3 */
|
||||||
|
def_irq_handler udb_interrupts_4_IRQHandler /* UDB Interrupt #4 */
|
||||||
|
def_irq_handler udb_interrupts_5_IRQHandler /* UDB Interrupt #5 */
|
||||||
|
def_irq_handler udb_interrupts_6_IRQHandler /* UDB Interrupt #6 */
|
||||||
|
def_irq_handler udb_interrupts_7_IRQHandler /* UDB Interrupt #7 */
|
||||||
|
def_irq_handler udb_interrupts_8_IRQHandler /* UDB Interrupt #8 */
|
||||||
|
def_irq_handler udb_interrupts_9_IRQHandler /* UDB Interrupt #9 */
|
||||||
|
def_irq_handler udb_interrupts_10_IRQHandler /* UDB Interrupt #10 */
|
||||||
|
def_irq_handler udb_interrupts_11_IRQHandler /* UDB Interrupt #11 */
|
||||||
|
def_irq_handler udb_interrupts_12_IRQHandler /* UDB Interrupt #12 */
|
||||||
|
def_irq_handler udb_interrupts_13_IRQHandler /* UDB Interrupt #13 */
|
||||||
|
def_irq_handler udb_interrupts_14_IRQHandler /* UDB Interrupt #14 */
|
||||||
|
def_irq_handler udb_interrupts_15_IRQHandler /* UDB Interrupt #15 */
|
||||||
|
def_irq_handler pass_interrupt_sar_IRQHandler /* SAR ADC interrupt */
|
||||||
|
def_irq_handler audioss_interrupt_i2s_IRQHandler /* I2S Audio interrupt */
|
||||||
|
def_irq_handler audioss_interrupt_pdm_IRQHandler /* PDM/PCM Audio interrupt */
|
||||||
|
def_irq_handler profile_interrupt_IRQHandler /* Energy Profiler interrupt */
|
||||||
|
def_irq_handler smif_interrupt_IRQHandler /* Serial Memory Interface interrupt */
|
||||||
|
def_irq_handler usb_interrupt_hi_IRQHandler /* USB Interrupt */
|
||||||
|
def_irq_handler usb_interrupt_med_IRQHandler /* USB Interrupt */
|
||||||
|
def_irq_handler usb_interrupt_lo_IRQHandler /* USB Interrupt */
|
||||||
|
def_irq_handler pass_interrupt_dacs_IRQHandler /* Consolidated interrrupt for all DACs */
|
||||||
|
|
||||||
|
.end
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
423
2020TPCApp0.cydsn/iar/startup_psoc6_01_cm0plus.s
Normal file
423
2020TPCApp0.cydsn/iar/startup_psoc6_01_cm0plus.s
Normal file
|
@ -0,0 +1,423 @@
|
||||||
|
;/**************************************************************************//**
|
||||||
|
; * @file startup_psoc6_01_cm0plus.s
|
||||||
|
; * @brief CMSIS Core Device Startup File for
|
||||||
|
; * ARMCM0plus Device Series
|
||||||
|
; * @version V5.00
|
||||||
|
; * @date 08. March 2016
|
||||||
|
; ******************************************************************************/
|
||||||
|
;/*
|
||||||
|
; * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
|
||||||
|
; *
|
||||||
|
; * SPDX-License-Identifier: Apache-2.0
|
||||||
|
; *
|
||||||
|
; * Licensed under the Apache License, Version 2.0 (the License); you may
|
||||||
|
; * not use this file except in compliance with the License.
|
||||||
|
; * You may obtain a copy of the License at
|
||||||
|
; *
|
||||||
|
; * www.apache.org/licenses/LICENSE-2.0
|
||||||
|
; *
|
||||||
|
; * Unless required by applicable law or agreed to in writing, software
|
||||||
|
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||||
|
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
; * See the License for the specific language governing permissions and
|
||||||
|
; * limitations under the License.
|
||||||
|
; */
|
||||||
|
|
||||||
|
;
|
||||||
|
; The modules in this file are included in the libraries, and may be replaced
|
||||||
|
; by any user-defined modules that define the PUBLIC symbol _program_start or
|
||||||
|
; a user defined start symbol.
|
||||||
|
; To override the cstartup defined in the library, simply add your modified
|
||||||
|
; version to the workbench project.
|
||||||
|
;
|
||||||
|
; The vector table is normally located at address 0.
|
||||||
|
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
|
||||||
|
; 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.
|
||||||
|
;
|
||||||
|
; Cortex-M version
|
||||||
|
;
|
||||||
|
|
||||||
|
MODULE ?cstartup
|
||||||
|
|
||||||
|
;; Forward declaration of sections.
|
||||||
|
SECTION CSTACK:DATA:NOROOT(3)
|
||||||
|
SECTION .intvec_ram:DATA:NOROOT(2)
|
||||||
|
SECTION .intvec:CODE:NOROOT(2)
|
||||||
|
|
||||||
|
EXTERN __iar_program_start
|
||||||
|
EXTERN SystemInit
|
||||||
|
EXTERN __iar_data_init3
|
||||||
|
PUBLIC __vector_table
|
||||||
|
PUBLIC __vector_table_0x1c
|
||||||
|
PUBLIC __Vectors
|
||||||
|
PUBLIC __Vectors_End
|
||||||
|
PUBLIC __Vectors_Size
|
||||||
|
PUBLIC __ramVectors
|
||||||
|
|
||||||
|
DATA
|
||||||
|
|
||||||
|
__vector_table
|
||||||
|
DCD sfe(CSTACK)
|
||||||
|
DCD Reset_Handler
|
||||||
|
|
||||||
|
DCD 0x0000000D ; NMI_Handler is defined in ROM code
|
||||||
|
DCD HardFault_Handler
|
||||||
|
DCD 0
|
||||||
|
DCD 0
|
||||||
|
DCD 0
|
||||||
|
__vector_table_0x1c
|
||||||
|
DCD 0
|
||||||
|
DCD 0
|
||||||
|
DCD 0
|
||||||
|
DCD 0
|
||||||
|
DCD SVC_Handler
|
||||||
|
DCD 0
|
||||||
|
DCD 0
|
||||||
|
DCD PendSV_Handler
|
||||||
|
DCD SysTick_Handler
|
||||||
|
|
||||||
|
; External interrupts Power Mode Description
|
||||||
|
DCD NvicMux0_IRQHandler ; CM0+ NVIC Mux input 0
|
||||||
|
DCD NvicMux1_IRQHandler ; CM0+ NVIC Mux input 1
|
||||||
|
DCD NvicMux2_IRQHandler ; CM0+ NVIC Mux input 2
|
||||||
|
DCD NvicMux3_IRQHandler ; CM0+ NVIC Mux input 3
|
||||||
|
DCD NvicMux4_IRQHandler ; CM0+ NVIC Mux input 4
|
||||||
|
DCD NvicMux5_IRQHandler ; CM0+ NVIC Mux input 5
|
||||||
|
DCD NvicMux6_IRQHandler ; CM0+ NVIC Mux input 6
|
||||||
|
DCD NvicMux7_IRQHandler ; CM0+ NVIC Mux input 7
|
||||||
|
DCD NvicMux8_IRQHandler ; CM0+ NVIC Mux input 8
|
||||||
|
DCD NvicMux9_IRQHandler ; CM0+ NVIC Mux input 9
|
||||||
|
DCD NvicMux10_IRQHandler ; CM0+ NVIC Mux input 10
|
||||||
|
DCD NvicMux11_IRQHandler ; CM0+ NVIC Mux input 11
|
||||||
|
DCD NvicMux12_IRQHandler ; CM0+ NVIC Mux input 12
|
||||||
|
DCD NvicMux13_IRQHandler ; CM0+ NVIC Mux input 13
|
||||||
|
DCD NvicMux14_IRQHandler ; CM0+ NVIC Mux input 14
|
||||||
|
DCD NvicMux15_IRQHandler ; CM0+ NVIC Mux input 15
|
||||||
|
DCD NvicMux16_IRQHandler ; CM0+ NVIC Mux input 16
|
||||||
|
DCD NvicMux17_IRQHandler ; CM0+ NVIC Mux input 17
|
||||||
|
DCD NvicMux18_IRQHandler ; CM0+ NVIC Mux input 18
|
||||||
|
DCD NvicMux19_IRQHandler ; CM0+ NVIC Mux input 19
|
||||||
|
DCD NvicMux20_IRQHandler ; CM0+ NVIC Mux input 20
|
||||||
|
DCD NvicMux21_IRQHandler ; CM0+ NVIC Mux input 21
|
||||||
|
DCD NvicMux22_IRQHandler ; CM0+ NVIC Mux input 22
|
||||||
|
DCD NvicMux23_IRQHandler ; CM0+ NVIC Mux input 23
|
||||||
|
DCD NvicMux24_IRQHandler ; CM0+ NVIC Mux input 24
|
||||||
|
DCD NvicMux25_IRQHandler ; CM0+ NVIC Mux input 25
|
||||||
|
DCD NvicMux26_IRQHandler ; CM0+ NVIC Mux input 26
|
||||||
|
DCD NvicMux27_IRQHandler ; CM0+ NVIC Mux input 27
|
||||||
|
DCD NvicMux28_IRQHandler ; CM0+ NVIC Mux input 28
|
||||||
|
DCD NvicMux29_IRQHandler ; CM0+ NVIC Mux input 29
|
||||||
|
DCD NvicMux30_IRQHandler ; CM0+ NVIC Mux input 30
|
||||||
|
DCD NvicMux31_IRQHandler ; CM0+ NVIC Mux input 31
|
||||||
|
|
||||||
|
__Vectors_End
|
||||||
|
|
||||||
|
__Vectors EQU __vector_table
|
||||||
|
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||||
|
|
||||||
|
SECTION .intvec_ram:DATA:REORDER:NOROOT(2)
|
||||||
|
__ramVectors
|
||||||
|
DS32 __Vectors_Size
|
||||||
|
|
||||||
|
|
||||||
|
THUMB
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;
|
||||||
|
;; Default handlers
|
||||||
|
;;
|
||||||
|
PUBWEAK Default_Handler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(2)
|
||||||
|
Default_Handler
|
||||||
|
B Default_Handler
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;
|
||||||
|
;; Weak function for startup customization
|
||||||
|
;;
|
||||||
|
;; Note. The global resources are not yet initialized (for example global variables, peripherals, clocks)
|
||||||
|
;; because this function is executed as the first instruction in the ResetHandler.
|
||||||
|
;; The PDL is also not initialized to use the proper register offsets.
|
||||||
|
;; The user of this function is responsible for initializing the PDL and resources before using them.
|
||||||
|
;;
|
||||||
|
PUBWEAK Cy_OnResetUser
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(2)
|
||||||
|
Cy_OnResetUser
|
||||||
|
BX LR
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;
|
||||||
|
;; Define strong version to return zero for
|
||||||
|
;; __iar_program_start to skip data sections
|
||||||
|
;; initialization.
|
||||||
|
;;
|
||||||
|
PUBLIC __low_level_init
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(2)
|
||||||
|
__low_level_init
|
||||||
|
MOVS R0, #0
|
||||||
|
BX LR
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;
|
||||||
|
;; Default interrupt handlers.
|
||||||
|
;;
|
||||||
|
THUMB
|
||||||
|
PUBWEAK Reset_Handler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(2)
|
||||||
|
Reset_Handler
|
||||||
|
|
||||||
|
; Define strong function for startup customization
|
||||||
|
LDR R0, =Cy_OnResetUser
|
||||||
|
BLX R0
|
||||||
|
|
||||||
|
; Disable global interrupts
|
||||||
|
CPSID I
|
||||||
|
|
||||||
|
; Copy vectors from ROM to RAM
|
||||||
|
LDR r1, =__vector_table
|
||||||
|
LDR r0, =__ramVectors
|
||||||
|
LDR r2, =__Vectors_Size
|
||||||
|
intvec_copy
|
||||||
|
LDR r3, [r1]
|
||||||
|
STR r3, [r0]
|
||||||
|
ADDS r0, r0, #4
|
||||||
|
ADDS r1, r1, #4
|
||||||
|
SUBS r2, r2, #1
|
||||||
|
CMP r2, #0
|
||||||
|
BNE intvec_copy
|
||||||
|
|
||||||
|
; Update Vector Table Offset Register
|
||||||
|
LDR r0, =__ramVectors
|
||||||
|
LDR r1, =0xE000ED08
|
||||||
|
STR r0, [r1]
|
||||||
|
dsb
|
||||||
|
|
||||||
|
; Initialize data sections
|
||||||
|
LDR R0, =__iar_data_init3
|
||||||
|
BLX R0
|
||||||
|
|
||||||
|
LDR R0, =SystemInit
|
||||||
|
BLX R0
|
||||||
|
|
||||||
|
LDR R0, =__iar_program_start
|
||||||
|
BLX R0
|
||||||
|
|
||||||
|
; Should never get here
|
||||||
|
Cy_Main_Exited
|
||||||
|
B Cy_Main_Exited
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK NMI_Handler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NMI_Handler
|
||||||
|
B NMI_Handler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK Cy_SysLib_FaultHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
Cy_SysLib_FaultHandler
|
||||||
|
B Cy_SysLib_FaultHandler
|
||||||
|
|
||||||
|
PUBWEAK HardFault_Handler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
HardFault_Handler
|
||||||
|
IMPORT Cy_SysLib_FaultHandler
|
||||||
|
movs r0, #4
|
||||||
|
mov r1, LR
|
||||||
|
tst r0, r1
|
||||||
|
beq L_MSP
|
||||||
|
mrs r0, PSP
|
||||||
|
b L_API_call
|
||||||
|
L_MSP
|
||||||
|
mrs r0, MSP
|
||||||
|
L_API_call
|
||||||
|
; Storing LR content for Creator call stack trace
|
||||||
|
push {LR}
|
||||||
|
bl Cy_SysLib_FaultHandler
|
||||||
|
|
||||||
|
|
||||||
|
PUBWEAK SVC_Handler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
SVC_Handler
|
||||||
|
B SVC_Handler
|
||||||
|
|
||||||
|
PUBWEAK PendSV_Handler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
PendSV_Handler
|
||||||
|
B PendSV_Handler
|
||||||
|
|
||||||
|
PUBWEAK SysTick_Handler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
SysTick_Handler
|
||||||
|
B SysTick_Handler
|
||||||
|
|
||||||
|
|
||||||
|
; External interrupts
|
||||||
|
PUBWEAK NvicMux0_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux0_IRQHandler
|
||||||
|
B NvicMux0_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux1_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux1_IRQHandler
|
||||||
|
B NvicMux1_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux2_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux2_IRQHandler
|
||||||
|
B NvicMux2_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux3_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux3_IRQHandler
|
||||||
|
B NvicMux3_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux4_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux4_IRQHandler
|
||||||
|
B NvicMux4_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux5_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux5_IRQHandler
|
||||||
|
B NvicMux5_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux6_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux6_IRQHandler
|
||||||
|
B NvicMux6_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux7_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux7_IRQHandler
|
||||||
|
B NvicMux7_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux8_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux8_IRQHandler
|
||||||
|
B NvicMux8_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux9_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux9_IRQHandler
|
||||||
|
B NvicMux9_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux10_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux10_IRQHandler
|
||||||
|
B NvicMux10_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux11_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux11_IRQHandler
|
||||||
|
B NvicMux11_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux12_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux12_IRQHandler
|
||||||
|
B NvicMux12_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux13_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux13_IRQHandler
|
||||||
|
B NvicMux13_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux14_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux14_IRQHandler
|
||||||
|
B NvicMux14_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux15_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux15_IRQHandler
|
||||||
|
B NvicMux15_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux16_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux16_IRQHandler
|
||||||
|
B NvicMux16_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux17_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux17_IRQHandler
|
||||||
|
B NvicMux17_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux18_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux18_IRQHandler
|
||||||
|
B NvicMux18_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux19_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux19_IRQHandler
|
||||||
|
B NvicMux19_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux20_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux20_IRQHandler
|
||||||
|
B NvicMux20_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux21_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux21_IRQHandler
|
||||||
|
B NvicMux21_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux22_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux22_IRQHandler
|
||||||
|
B NvicMux22_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux23_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux23_IRQHandler
|
||||||
|
B NvicMux23_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux24_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux24_IRQHandler
|
||||||
|
B NvicMux24_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux25_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux25_IRQHandler
|
||||||
|
B NvicMux25_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux26_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux26_IRQHandler
|
||||||
|
B NvicMux26_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux27_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux27_IRQHandler
|
||||||
|
B NvicMux27_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux28_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux28_IRQHandler
|
||||||
|
B NvicMux28_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux29_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux29_IRQHandler
|
||||||
|
B NvicMux29_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux30_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux30_IRQHandler
|
||||||
|
B NvicMux30_IRQHandler
|
||||||
|
|
||||||
|
PUBWEAK NvicMux31_IRQHandler
|
||||||
|
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||||
|
NvicMux31_IRQHandler
|
||||||
|
B NvicMux31_IRQHandler
|
||||||
|
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
; [] END OF FILE
|
1142
2020TPCApp0.cydsn/iar/startup_psoc6_01_cm4.s
Normal file
1142
2020TPCApp0.cydsn/iar/startup_psoc6_01_cm4.s
Normal file
File diff suppressed because it is too large
Load diff
62
2020TPCApp0.cydsn/ias.c
Normal file
62
2020TPCApp0.cydsn/ias.c
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* File Name: ias.c
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This file contains Immediate Alert Service callback handler function.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* Copyright 2017, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "ias.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* IAS alert level value */
|
||||||
|
volatile uint8_t alertLevel = 0;
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Function Name: IasInit
|
||||||
|
*******************************************************************************
|
||||||
|
*
|
||||||
|
* Summary:
|
||||||
|
* Registers the IAS CallBack.
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
void IasInit(void)
|
||||||
|
{
|
||||||
|
Cy_BLE_IAS_RegisterAttrCallback(IasEventHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: IasEventHandler
|
||||||
|
********************************************************************************
|
||||||
|
*
|
||||||
|
* Summary:
|
||||||
|
* This is an event callback function to receive events from the BLE Component,
|
||||||
|
* which are specific to Immediate Alert Service.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* event: Write Command event from the BLE component.
|
||||||
|
* eventParams: A structure instance of CY_BLE_GATT_HANDLE_VALUE_PAIR_T type.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void IasEventHandler(uint32 event, void *eventParam)
|
||||||
|
{
|
||||||
|
(void) eventParam;
|
||||||
|
uint8_t alert;
|
||||||
|
|
||||||
|
/* Alert Level Characteristic write event */
|
||||||
|
if(event == CY_BLE_EVT_IASS_WRITE_CHAR_CMD)
|
||||||
|
{
|
||||||
|
/* Read the updated Alert Level value from the GATT database */
|
||||||
|
Cy_BLE_IASS_GetCharacteristicValue(CY_BLE_IAS_ALERT_LEVEL, sizeof(alert), &alert);
|
||||||
|
alertLevel = alert;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
31
2020TPCApp0.cydsn/ias.h
Normal file
31
2020TPCApp0.cydsn/ias.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* File Name: ias.h
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Contains the function prototypes and references for the Immediate Alert
|
||||||
|
* Service of the Bluetooth Component.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* Copyright 2017, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "project.h"
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Function Prototypes
|
||||||
|
***************************************/
|
||||||
|
void IasInit(void);
|
||||||
|
void IasEventHandler(uint32_t event, void *eventParam);
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* External data references
|
||||||
|
***************************************/
|
||||||
|
extern volatile uint8_t alertLevel;
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
78
2020TPCApp0.cydsn/key_copy.bat
Normal file
78
2020TPCApp0.cydsn/key_copy.bat
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::
|
||||||
|
:: File Name: key_copy.bat
|
||||||
|
::
|
||||||
|
:: Version: 1.01
|
||||||
|
::
|
||||||
|
:: Description:
|
||||||
|
:: Simple script to copy generated key files to a persistent location
|
||||||
|
::
|
||||||
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
:: Copyright 2017-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
:: This software is owned by Cypress Semiconductor Corporation and is protected
|
||||||
|
:: by and subject to worldwide patent and copyright laws and treaties.
|
||||||
|
:: Therefore, you may use this software only as provided in the license agreement
|
||||||
|
:: accompanying the software package from which you obtained this software.
|
||||||
|
:: CYPRESS AND ITS SUPPLIERS MAKE NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
:: WITH REGARD TO THIS SOFTWARE, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT,
|
||||||
|
:: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
|
||||||
|
@echo off
|
||||||
|
set OUT_DIR="..\Keys"
|
||||||
|
set LOCAL_DIR=keys_generated
|
||||||
|
|
||||||
|
set SRC_PRIV_NAME=rsa_private_generated.txt
|
||||||
|
set SRC_PUB_NAME=rsa_public_generated.txt
|
||||||
|
set SRC_AES_NAME=aes_private_generated.txt
|
||||||
|
set SRC_EIV_NAME=aes_eiv_generated.txt
|
||||||
|
|
||||||
|
set PRIV_NAME=rsa_private.txt
|
||||||
|
set PUB_NAME=rsa_public.txt
|
||||||
|
set AES_NAME=aes_private.txt
|
||||||
|
set EIV_NAME=aes_eiv.txt
|
||||||
|
|
||||||
|
|
||||||
|
:: File Check
|
||||||
|
set ALLOK=1
|
||||||
|
IF NOT EXIST %LOCAL_DIR%\%SRC_PRIV_NAME% (
|
||||||
|
echo File %SRC_PRIV_NAME% does not exist.
|
||||||
|
set ALLOK=0
|
||||||
|
)
|
||||||
|
IF NOT EXIST %LOCAL_DIR%\%SRC_PUB_NAME% (
|
||||||
|
echo File %SRC_PUB_NAME% does not exist.
|
||||||
|
set ALLOK=0
|
||||||
|
)
|
||||||
|
IF NOT EXIST %LOCAL_DIR%\%SRC_AES_NAME% (
|
||||||
|
echo File %SRC_AES_NAME% does not exist.
|
||||||
|
set ALLOK=0
|
||||||
|
)
|
||||||
|
IF NOT EXIST %LOCAL_DIR%\%SRC_EIV_NAME% (
|
||||||
|
echo File %SRC_EIV_NAME% does not exist.
|
||||||
|
set ALLOK=0
|
||||||
|
)
|
||||||
|
IF %ALLOK% == 0 (
|
||||||
|
echo Please run the keygen batch file to generate the keys.
|
||||||
|
echo.
|
||||||
|
goto :end
|
||||||
|
)
|
||||||
|
|
||||||
|
IF NOT EXIST %OUT_DIR% mkdir %OUT_DIR%
|
||||||
|
|
||||||
|
:choice
|
||||||
|
cls
|
||||||
|
echo Warning: The keys used in the application will be overwritten.
|
||||||
|
set /P c=Are you sure you want to continue [Y/N]?
|
||||||
|
if /I "%c%" EQU "Y" goto :cont
|
||||||
|
if /I "%c%" EQU "N" goto :end
|
||||||
|
goto :choice
|
||||||
|
|
||||||
|
:: Copy files to persistent location, renaming them in the process
|
||||||
|
:cont
|
||||||
|
COPY /y %LOCAL_DIR%\%SRC_PRIV_NAME% %OUT_DIR%\%PRIV_NAME%
|
||||||
|
COPY /y %LOCAL_DIR%\%SRC_PUB_NAME% %OUT_DIR%\%PUB_NAME%
|
||||||
|
COPY /y %LOCAL_DIR%\%SRC_AES_NAME% %OUT_DIR%\%AES_NAME%
|
||||||
|
COPY /y %LOCAL_DIR%\%SRC_EIV_NAME% %OUT_DIR%\%EIV_NAME%
|
||||||
|
|
||||||
|
:end
|
||||||
|
pause
|
143
2020TPCApp0.cydsn/keygen.bat
Normal file
143
2020TPCApp0.cydsn/keygen.bat
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::
|
||||||
|
:: File Name: keygen.bat
|
||||||
|
::
|
||||||
|
:: Version: 1.0
|
||||||
|
::
|
||||||
|
:: Description:
|
||||||
|
:: Simple script to generate the RSA-2048 public and private keys using OpenSSL.
|
||||||
|
:: Once created, the script calls a python script to print out the public key
|
||||||
|
:: modulus that is ready to be inserted into cy_publicKey struct in
|
||||||
|
:: cy_si_keyStorage.c.
|
||||||
|
:: The script also generates a 128 bit random number to be used for the AES
|
||||||
|
:: private key and EIV.
|
||||||
|
::
|
||||||
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
:: Copyright 2017-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
:: This software is owned by Cypress Semiconductor Corporation and is protected
|
||||||
|
:: by and subject to worldwide patent and copyright laws and treaties.
|
||||||
|
:: Therefore, you may use this software only as provided in the license agreement
|
||||||
|
:: accompanying the software package from which you obtained this software.
|
||||||
|
:: CYPRESS AND ITS SUPPLIERS MAKE NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
:: WITH REGARD TO THIS SOFTWARE, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT,
|
||||||
|
:: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
|
||||||
|
@echo off
|
||||||
|
set OUT_DIR="%~dp0\keys_generated"
|
||||||
|
set LOCAL_DIR=keys_generated
|
||||||
|
set PRIV_NAME=rsa_private_generated.txt
|
||||||
|
set PUB_NAME=rsa_public_generated.txt
|
||||||
|
set MOD_NAME=rsa_to_c_generated.txt
|
||||||
|
|
||||||
|
set AES_TEMP=aes_private_generated_temp.txt
|
||||||
|
set EIV_TEMP=aes_eiv_generated_temp.txt
|
||||||
|
set AES_NAME=aes_private_generated.txt
|
||||||
|
set EIV_NAME=aes_eiv_generated.txt
|
||||||
|
set AES_ARRAY=aes_private_array_generated.txt
|
||||||
|
|
||||||
|
:: Check if OpenSSL and Python are correctly installed
|
||||||
|
set ALLOK=1
|
||||||
|
CALL :testOpenSSL
|
||||||
|
CALL :testPython
|
||||||
|
IF %ALLOK% == 0 (
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
goto :end
|
||||||
|
)
|
||||||
|
IF NOT EXIST %OUT_DIR% mkdir %OUT_DIR%
|
||||||
|
|
||||||
|
:: Delete temp files
|
||||||
|
IF EXIST %OUT_DIR%\%AES_TEMP% DEL /F %OUT_DIR%\%AES_TEMP%
|
||||||
|
IF EXIST %OUT_DIR%\%EIV_TEMP% DEL /F %OUT_DIR%\%EIV_TEMP%
|
||||||
|
|
||||||
|
:: Generate the RSA-2048 public and private keys
|
||||||
|
openssl genrsa -out %OUT_DIR%\%PRIV_NAME% 2048
|
||||||
|
openssl rsa -in %OUT_DIR%\%PRIV_NAME% -outform PEM -pubout -out %OUT_DIR%\%PUB_NAME%
|
||||||
|
|
||||||
|
:: Generate a 128bit random number
|
||||||
|
openssl rand -hex -out %OUT_DIR%\%AES_TEMP% 16
|
||||||
|
openssl rand -hex -out %OUT_DIR%\%EIV_TEMP% 16
|
||||||
|
|
||||||
|
:: Check if files exist before processing
|
||||||
|
IF NOT EXIST %LOCAL_DIR%\%AES_TEMP% (
|
||||||
|
echo Could not find OpenSSL generated files. If the error persists, check OpenSSL installation and permissions.
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
goto :end
|
||||||
|
)
|
||||||
|
IF NOT EXIST %LOCAL_DIR%\%AES_TEMP% (
|
||||||
|
echo Could not find OpenSSL generated files. If the error persists, check OpenSSL installation and permissions.
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
goto :end
|
||||||
|
)
|
||||||
|
|
||||||
|
IF EXIST %OUT_DIR%\%AES_NAME% DEL /F %OUT_DIR%\%AES_NAME%
|
||||||
|
IF EXIST %OUT_DIR%\%EIV_NAME% DEL /F %OUT_DIR%\%EIV_NAME%
|
||||||
|
IF EXIST %OUT_DIR%\%AES_ARRAY% DEL /F %OUT_DIR%\%AES_ARRAY%
|
||||||
|
|
||||||
|
:: Remove new line characters from AES and EIV files
|
||||||
|
FOR /F "Usebackq Tokens=*" %%@ IN ("%LOCAL_DIR%\%AES_TEMP%") DO (
|
||||||
|
<NUL Set /P "=%%@"
|
||||||
|
) >> %LOCAL_DIR%\%AES_NAME%
|
||||||
|
|
||||||
|
FOR /F "Usebackq Tokens=*" %%@ IN ("%LOCAL_DIR%\%EIV_TEMP%") DO (
|
||||||
|
<NUL Set /P "=%%@"
|
||||||
|
) >> %LOCAL_DIR%\%EIV_NAME%
|
||||||
|
|
||||||
|
:: Delete temp files
|
||||||
|
IF EXIST %OUT_DIR%\%AES_TEMP% DEL /F %OUT_DIR%\%AES_TEMP%
|
||||||
|
IF EXIST %OUT_DIR%\%EIV_TEMP% DEL /F %OUT_DIR%\%EIV_TEMP%
|
||||||
|
|
||||||
|
:: Generate a C array with the AES private key
|
||||||
|
setlocal enableDelayedExpansion
|
||||||
|
set /p str=<%LOCAL_DIR%\%AES_NAME%
|
||||||
|
set counter=1
|
||||||
|
set "out="
|
||||||
|
for /f delims^=^ eol^= %%A in ('cmd /u /v:on /c echo(^^!str^^!^|more') do (
|
||||||
|
IF "!counter!" == "1" (
|
||||||
|
set "out=!out!, 0x^%%A"
|
||||||
|
set "counter=0"
|
||||||
|
) ELSE (
|
||||||
|
set "out=!out!%%A"
|
||||||
|
set "counter=1"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
set "out=!out:~2!"
|
||||||
|
|
||||||
|
echo static const uint8_t AES128_Key[16] = {!out!}; >> %OUT_DIR%\%AES_ARRAY%
|
||||||
|
|
||||||
|
:: Create C-code ready public key
|
||||||
|
%~dp0\rsa_to_c.py %OUT_DIR%\%PUB_NAME% > %OUT_DIR%\%MOD_NAME%
|
||||||
|
|
||||||
|
goto :end
|
||||||
|
|
||||||
|
:testOpenSSL
|
||||||
|
openssl version >nul 2>nul
|
||||||
|
IF ERRORLEVEL 1 CALL :errOpenSSL
|
||||||
|
EXIT /B
|
||||||
|
|
||||||
|
:testPython
|
||||||
|
python --version >nul 2>nul
|
||||||
|
IF ERRORLEVEL 1 CALL :errPython
|
||||||
|
EXIT /B
|
||||||
|
|
||||||
|
:errOpenSSL
|
||||||
|
echo.
|
||||||
|
echo OpenSSL could not be found.
|
||||||
|
echo If OpenSSL is installed, add the OpenSSL binaries directory to the system Path variable.
|
||||||
|
echo A restart may be required.
|
||||||
|
set ALLOK=0
|
||||||
|
EXIT /B
|
||||||
|
|
||||||
|
:errPython
|
||||||
|
echo.
|
||||||
|
echo Python could not be found.
|
||||||
|
echo Python is required to generate the RSA public key C array.
|
||||||
|
echo Please install Python or check that it is included in the system Path variable.
|
||||||
|
set ALLOK=0
|
||||||
|
EXIT /B
|
||||||
|
|
||||||
|
:end
|
||||||
|
pause
|
237
2020TPCApp0.cydsn/main_cm0p.c
Normal file
237
2020TPCApp0.cydsn/main_cm0p.c
Normal file
|
@ -0,0 +1,237 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* File Name: main_cm0p.c
|
||||||
|
*
|
||||||
|
* Version: 1.30
|
||||||
|
*
|
||||||
|
* Description: This file provides the source code for the DFU (App0)
|
||||||
|
* running on the core CM0+ (core0).
|
||||||
|
* App0 core0 firmware does the following:
|
||||||
|
* - Switches to the App1 on reset if it was scheduled.
|
||||||
|
* - Else starts App0 core1 firmware.
|
||||||
|
*
|
||||||
|
* Related Document: Code example CE216767.pdf
|
||||||
|
*
|
||||||
|
* Hardware Dependency: CY8CKIT-062-BLE PSoC 6 BLE Pioneer Kit
|
||||||
|
* CY5677 CySmart USB Dongle
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright (2019), Cypress Semiconductor Corporation.
|
||||||
|
******************************************************************************
|
||||||
|
* This software is owned by Cypress Semiconductor Corporation (Cypress) and is
|
||||||
|
* protected by and subject to worldwide patent protection (United States and
|
||||||
|
* foreign), United States copyright laws and international treaty provisions.
|
||||||
|
* Cypress hereby grants to licensee a personal, non-exclusive, non-transferable
|
||||||
|
* license to copy, use, modify, create derivative works of, and compile the
|
||||||
|
* Cypress Source Code and derivative works for the sole purpose of creating
|
||||||
|
* custom software in support of licensee product to be used only in conjunction
|
||||||
|
* with a Cypress integrated circuit as specified in the applicable agreement.
|
||||||
|
* Any reproduction, modification, translation, compilation, or representation of
|
||||||
|
* this software except as specified above is prohibited without the express
|
||||||
|
* written permission of Cypress.
|
||||||
|
*
|
||||||
|
* Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH
|
||||||
|
* REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* Cypress reserves the right to make changes without further notice to the
|
||||||
|
* materials described herein. Cypress does not assume any liability arising out
|
||||||
|
* of the application or use of any product or circuit described herein. Cypress
|
||||||
|
* does not authorize its products for use as critical components in life-support
|
||||||
|
* systems where a malfunction or failure may reasonably be expected to result in
|
||||||
|
* significant injury to the user. The inclusion of Cypress' product in a life-
|
||||||
|
* support systems application implies that the manufacturer assumes all risk of
|
||||||
|
* such use and in doing so indemnifies Cypress against all charges. Use may be
|
||||||
|
* limited by and subject to the applicable Cypress software license agreement.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "dfu/cy_dfu.h"
|
||||||
|
#include "project.h"
|
||||||
|
#include "cy_si_config.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set this define to any value different than 0, to use a standard TOC2,
|
||||||
|
* erase the public key, and enable the device to run code generated by other projects.
|
||||||
|
*/
|
||||||
|
#define UNLOCK_SYSTEM (1u)
|
||||||
|
|
||||||
|
#if CY_DFU_OPT_CRYPTO_HW != 0
|
||||||
|
#define MY_CHAN_CRYPTO (uint32_t)(3u) /* IPC data channel for the Crypto */
|
||||||
|
#define MY_INTR_CRYPTO_SRV (uint32_t)(1u) /* IPC interrupt structure for the Crypto server */
|
||||||
|
#define MY_INTR_CRYPTO_CLI (uint32_t)(2u) /* IPC interrupt structure for the Crypto client */
|
||||||
|
#define MY_INTR_CRYPTO_SRV_MUX (IRQn_Type)(2u) /* CM0+ IPC interrupt mux number the Crypto server */
|
||||||
|
#define MY_INTR_CRYPTO_CLI_MUX (IRQn_Type)(3u) /* CM0+ IPC interrupt mux number the Crypto client */
|
||||||
|
#define MY_INTR_CRYPTO_ERR_MUX (IRQn_Type)(4u) /* CM0+ ERROR interrupt mux number the Crypto server */
|
||||||
|
|
||||||
|
const cy_stc_crypto_config_t cryptoConfig =
|
||||||
|
{
|
||||||
|
/* .ipcChannel */ MY_CHAN_CRYPTO,
|
||||||
|
/* .acquireNotifierChannel */ MY_INTR_CRYPTO_SRV,
|
||||||
|
/* .releaseNotifierChannel */ MY_INTR_CRYPTO_CLI,
|
||||||
|
/* .releaseNotifierConfig */ {
|
||||||
|
#if (CY_CPU_CORTEX_M0P)
|
||||||
|
/* .intrSrc */ MY_INTR_CRYPTO_CLI_MUX,
|
||||||
|
/* .cm0pSrc */ cpuss_interrupts_ipc_2_IRQn, /* depends on selected releaseNotifierChannel value */
|
||||||
|
#else
|
||||||
|
/* .intrSrc */ cpuss_interrupts_ipc_2_IRQn, /* depends on selected releaseNotifierChannel value */
|
||||||
|
#endif
|
||||||
|
/* .intrPriority */ 2u,
|
||||||
|
},
|
||||||
|
/* .userCompleteCallback */ NULL,
|
||||||
|
/* .userGetDataHandler */ NULL,
|
||||||
|
/* .userErrorHandler */ NULL,
|
||||||
|
/* .acquireNotifierConfig */ {
|
||||||
|
#if (CY_CPU_CORTEX_M0P)
|
||||||
|
/* .intrSrc */ MY_INTR_CRYPTO_SRV_MUX, /* to use with DeepSleep mode should be in DeepSleep capable muxer's range */
|
||||||
|
/* .cm0pSrc */ cpuss_interrupts_ipc_1_IRQn, /* depends on selected acquireNotifierChannel value */
|
||||||
|
#else
|
||||||
|
/* .intrSrc */ cpuss_interrupts_ipc_1_IRQn, /* depends on selected acquireNotifierChannel value */
|
||||||
|
#endif
|
||||||
|
/* .intrPriority */ 2u,
|
||||||
|
},
|
||||||
|
/* .cryptoErrorIntrConfig */ {
|
||||||
|
#if (CY_CPU_CORTEX_M0P)
|
||||||
|
/* .intrSrc */ MY_INTR_CRYPTO_ERR_MUX,
|
||||||
|
/* .cm0pSrc */ cpuss_interrupt_crypto_IRQn,
|
||||||
|
#else
|
||||||
|
/* .intrSrc */ cpuss_interrupt_crypto_IRQn,
|
||||||
|
#endif
|
||||||
|
/* .intrPriority */ 2u,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
cy_stc_crypto_server_context_t cryptoServerContext;
|
||||||
|
cy_en_crypto_status_t cryptoStatus;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNLOCK_SYSTEM == (0u)
|
||||||
|
/* Flashboot parameters */
|
||||||
|
#define CY_SI_FLASHBOOT_FLAGS ((CY_SI_FLASHBOOT_VALIDATE_YES << CY_SI_TOC_FLAGS_APP_VERIFY_POS) \
|
||||||
|
| (CY_SI_FLASHBOOT_WAIT_20MS << CY_SI_TOC_FLAGS_DELAY_POS) \
|
||||||
|
| (CY_SI_FLASHBOOT_CLK_25MHZ << CY_SI_TOC_FLAGS_CLOCKS_POS))
|
||||||
|
|
||||||
|
/* TOC Part 2 Definition */
|
||||||
|
CY_SECTION(".cy_toc_part2") __USED
|
||||||
|
const cy_stc_si_toc_t cy_toc2 =
|
||||||
|
{
|
||||||
|
.objSize = sizeof(cy_stc_si_toc_t) - sizeof(uint32_t), /**< Object Size (Bytes) excluding CRC */
|
||||||
|
.magicNum = CY_SI_TOC2_MAGICNUMBER, /**< TOC2 ID (magic number) */
|
||||||
|
.userKeyAddr = (uint32_t) &CySecureKeyStorage, /**< User key storage address */
|
||||||
|
.smifCfgAddr = 0UL, /**< SMIF config list pointer */
|
||||||
|
.appAddr1 = CY_DFU_APP0_VERIFY_START, /**< App0 start address */
|
||||||
|
.appFormat1 = CY_DFU_CYPRESS_APP, /**< App0 Format */
|
||||||
|
.shashObj = 1UL, /**< Include public key in the SECURE HASH */
|
||||||
|
.sigKeyAddr = (uint32_t)&SFLASH->PUBLIC_KEY, /**< Address of signature verification key */
|
||||||
|
.tocFlags = CY_SI_FLASHBOOT_FLAGS, /**< Flashboot flags stored in TOC2 */
|
||||||
|
.crc = 0UL, /**< CRC populated by cymcuelftool */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Assuming App0 is located at start of flash, change define if different */
|
||||||
|
#define APP0_START_ADDRESS CY_FLASH_BASE
|
||||||
|
|
||||||
|
/* Cypress Standard Application Format Header */
|
||||||
|
CY_SECTION(".cy_app_header") __USED
|
||||||
|
const cy_stc_user_appheader_t applicationHeader =
|
||||||
|
{
|
||||||
|
.objSize = CY_DFU_APP0_VERIFY_LENGTH, /* Application Size (Bytes) excluding hash */
|
||||||
|
.appId = CY_SI_APP_VERSION, /* App ID */
|
||||||
|
.appAttributes = 0UL, /* Reserved */
|
||||||
|
.numCores = 2UL, /* CM0+ and CM4 */
|
||||||
|
.core0Vt = (uint32_t)(&__Vectors[0]) - APP0_START_ADDRESS - offsetof(cy_stc_user_appheader_t, core0Vt), /* Offset to CM0+ Vector Table in flash */
|
||||||
|
.core1Vt = (uint32_t)(&__cy_app_core1_start_addr) - APP0_START_ADDRESS - offsetof(cy_stc_user_appheader_t, core1Vt), /* Offset to CM4 Vector Table in flash */
|
||||||
|
.core0Id = CY_ARM_CM0P_CPUID, /* ARM CM0+ CPU ID */
|
||||||
|
.core1Id = CY_ARM_CM4_CPUID, /* ARM CM4 CPU ID */
|
||||||
|
};
|
||||||
|
#endif /* UNLOCK_SYSTEM == (0u) */
|
||||||
|
|
||||||
|
#if UNLOCK_SYSTEM != (0u)
|
||||||
|
/* Flashboot parameters */
|
||||||
|
#define CY_SI_FLASHBOOT_FLAGS ((CY_SI_FLASHBOOT_VALIDATE_NO << CY_SI_TOC_FLAGS_APP_VERIFY_POS) \
|
||||||
|
| (CY_SI_FLASHBOOT_WAIT_20MS << CY_SI_TOC_FLAGS_DELAY_POS) \
|
||||||
|
| (CY_SI_FLASHBOOT_CLK_25MHZ << CY_SI_TOC_FLAGS_CLOCKS_POS))
|
||||||
|
|
||||||
|
/* Standard TOC Part 2 Definition */
|
||||||
|
CY_SECTION(".cy_toc_part2") __USED
|
||||||
|
const cy_stc_si_toc_t cy_toc2 =
|
||||||
|
{
|
||||||
|
.objSize = sizeof(cy_stc_si_toc_t) - sizeof(uint32_t), /**< Object Size (Bytes) excluding CRC */
|
||||||
|
.magicNum = CY_SI_TOC2_MAGICNUMBER, /**< TOC2 ID (magic number) */
|
||||||
|
.userKeyAddr = 0UL, /**< User key storage address */
|
||||||
|
.smifCfgAddr = 0UL, /**< SMIF config list pointer */
|
||||||
|
.appAddr1 = CY_FLASH_BASE, /**< Main Flash base address */
|
||||||
|
.appFormat1 = CY_DFU_BASIC_APP, /**< Basic format */
|
||||||
|
.shashObj = 0UL,
|
||||||
|
.sigKeyAddr = 0UL, /**< Address of signature verification key */
|
||||||
|
.tocFlags = CY_SI_FLASHBOOT_FLAGS, /**< Flashboot flags stored in TOC2 */
|
||||||
|
.crc = 0UL, /**< CRC populated by cymcuelftool */
|
||||||
|
};
|
||||||
|
#endif /* UNLOCK_SYSTEM != 0UL */
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: main
|
||||||
|
********************************************************************************
|
||||||
|
*
|
||||||
|
* Summary:
|
||||||
|
* Main function of App0 core0. Unfreezes IO and sets up the user button (SW2)
|
||||||
|
* as the hibernate wakeup source. Afterwards initializes core1 (CM4) and goes
|
||||||
|
* into deep sleep.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
/* Unfreeze IO after Hibernate */
|
||||||
|
if(Cy_SysPm_GetIoFreezeStatus())
|
||||||
|
{
|
||||||
|
Cy_SysPm_IoUnfreeze();
|
||||||
|
}
|
||||||
|
/* Set SW2 as hibernate wakeup pin */
|
||||||
|
Cy_SysPm_SetHibWakeupSource(CY_SYSPM_HIBPIN1_LOW);
|
||||||
|
|
||||||
|
/* enable global interrupts */
|
||||||
|
__enable_irq();
|
||||||
|
|
||||||
|
#if CY_DFU_OPT_CRYPTO_HW != 0
|
||||||
|
/* Start the Crypto Server */
|
||||||
|
Cy_Crypto_Server_Start(&cryptoConfig, &cryptoServerContext);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Enable CM4 with the CM4 start address defined in the
|
||||||
|
DFU SDK linker script */
|
||||||
|
Cy_SysEnableCM4( (uint32_t)(&__cy_app_core1_start_addr) );
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
/* Process crypto server requests */
|
||||||
|
Cy_Crypto_Server_Process();
|
||||||
|
//Go into Deep Sleep
|
||||||
|
Cy_SysPm_DeepSleep(CY_SYSPM_WAIT_FOR_INTERRUPT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_OnResetUser
|
||||||
|
********************************************************************************
|
||||||
|
*
|
||||||
|
* Summary:
|
||||||
|
* This function is called at the start of Reset_Handler(). It is a weak function
|
||||||
|
* that may be redefined by user code.
|
||||||
|
* DFU SDK requires it to call Cy_DFU_OnResetApp0().
|
||||||
|
* Checks if an App switch has been scheduled and transfers control to it.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void Cy_OnResetUser(void)
|
||||||
|
{
|
||||||
|
Cy_DFU_OnResetApp0();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
812
2020TPCApp0.cydsn/main_cm4.c
Normal file
812
2020TPCApp0.cydsn/main_cm4.c
Normal file
|
@ -0,0 +1,812 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* File Name: main_cm4.c
|
||||||
|
*
|
||||||
|
* Version: 1.30
|
||||||
|
*
|
||||||
|
* Description: This file provides the source code for the DFU (App0)
|
||||||
|
* running on the core CM4 (core1).
|
||||||
|
* App0 core1 firmware does the following:
|
||||||
|
* - Downloads App1 firmware image
|
||||||
|
* - Switches to App1 if App1 image has successfully downloaded
|
||||||
|
* and is valid
|
||||||
|
* - Switches to existing App1 if button is pressed
|
||||||
|
* - Turn on an LED depending on status
|
||||||
|
* - Hibernates on timeout
|
||||||
|
*******************************************************************************
|
||||||
|
* Related Document: CE216767.pdf
|
||||||
|
*
|
||||||
|
* Hardware Dependency: CY8CKIT-062-BLE PSoC 6 BLE Pioneer Kit
|
||||||
|
* CY5677 CySmart USB Dongle
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright (2019), Cypress Semiconductor Corporation.
|
||||||
|
******************************************************************************
|
||||||
|
* This software is owned by Cypress Semiconductor Corporation (Cypress) and is
|
||||||
|
* protected by and subject to worldwide patent protection (United States and
|
||||||
|
* foreign), United States copyright laws and international treaty provisions.
|
||||||
|
* Cypress hereby grants to licensee a personal, non-exclusive, non-transferable
|
||||||
|
* license to copy, use, modify, create derivative works of, and compile the
|
||||||
|
* Cypress Source Code and derivative works for the sole purpose of creating
|
||||||
|
* custom software in support of licensee product to be used only in conjunction
|
||||||
|
* with a Cypress integrated circuit as specified in the applicable agreement.
|
||||||
|
* Any reproduction, modification, translation, compilation, or representation of
|
||||||
|
* this software except as specified above is prohibited without the express
|
||||||
|
* written permission of Cypress.
|
||||||
|
*
|
||||||
|
* Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH
|
||||||
|
* REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* Cypress reserves the right to make changes without further notice to the
|
||||||
|
* materials described herein. Cypress does not assume any liability arising out
|
||||||
|
* of the application or use of any product or circuit described herein. Cypress
|
||||||
|
* does not authorize its products for use as critical components in life-support
|
||||||
|
* systems where a malfunction or failure may reasonably be expected to result in
|
||||||
|
* significant injury to the user. The inclusion of Cypress' product in a life-
|
||||||
|
* support systems application implies that the manufacturer assumes all risk of
|
||||||
|
* such use and in doing so indemnifies Cypress against all charges. Use may be
|
||||||
|
* limited by and subject to the applicable Cypress software license agreement.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "project.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "ias.h"
|
||||||
|
#include "transport_ble.h"
|
||||||
|
|
||||||
|
#if CY_DFU_OPT_CRYPTO_HW != 0
|
||||||
|
#define MY_CHAN_CRYPTO (uint32_t)(3u) /* IPC data channel for the Crypto */
|
||||||
|
#define MY_INTR_CRYPTO_SRV (uint32_t)(1u) /* IPC interrupt structure for the Crypto server */
|
||||||
|
#define MY_INTR_CRYPTO_CLI (uint32_t)(2u) /* IPC interrupt structure for the Crypto client */
|
||||||
|
#define MY_INTR_CRYPTO_SRV_MUX (IRQn_Type)(2u) /* CM0+ IPC interrupt mux number the Crypto server */
|
||||||
|
#define MY_INTR_CRYPTO_CLI_MUX (IRQn_Type)(3u) /* CM0+ IPC interrupt mux number the Crypto client */
|
||||||
|
#define MY_INTR_CRYPTO_ERR_MUX (IRQn_Type)(4u) /* CM0+ ERROR interrupt mux number the Crypto server */
|
||||||
|
|
||||||
|
const cy_stc_crypto_config_t cryptoConfig =
|
||||||
|
{
|
||||||
|
/* .ipcChannel */ MY_CHAN_CRYPTO,
|
||||||
|
/* .acquireNotifierChannel */ MY_INTR_CRYPTO_SRV,
|
||||||
|
/* .releaseNotifierChannel */ MY_INTR_CRYPTO_CLI,
|
||||||
|
/* .releaseNotifierConfig */ {
|
||||||
|
#if (CY_CPU_CORTEX_M0P)
|
||||||
|
/* .intrSrc */ MY_INTR_CRYPTO_CLI_MUX,
|
||||||
|
/* .cm0pSrc */ cpuss_interrupts_ipc_2_IRQn, /* depends on selected releaseNotifierChannel value */
|
||||||
|
#else
|
||||||
|
/* .intrSrc */ cpuss_interrupts_ipc_2_IRQn, /* depends on selected releaseNotifierChannel value */
|
||||||
|
#endif
|
||||||
|
/* .intrPriority */ 2u,
|
||||||
|
},
|
||||||
|
/* .userCompleteCallback */ NULL,
|
||||||
|
/* .userGetDataHandler */ NULL,
|
||||||
|
/* .userErrorHandler */ NULL,
|
||||||
|
/* .acquireNotifierConfig */ {
|
||||||
|
#if (CY_CPU_CORTEX_M0P)
|
||||||
|
/* .intrSrc */ MY_INTR_CRYPTO_SRV_MUX, /* to use with DeepSleep mode should be in DeepSleep capable muxer's range */
|
||||||
|
/* .cm0pSrc */ cpuss_interrupts_ipc_1_IRQn, /* depends on selected acquireNotifierChannel value */
|
||||||
|
#else
|
||||||
|
/* .intrSrc */ cpuss_interrupts_ipc_1_IRQn, /* depends on selected acquireNotifierChannel value */
|
||||||
|
#endif
|
||||||
|
/* .intrPriority */ 2u,
|
||||||
|
},
|
||||||
|
/* .cryptoErrorIntrConfig */ {
|
||||||
|
#if (CY_CPU_CORTEX_M0P)
|
||||||
|
/* .intrSrc */ MY_INTR_CRYPTO_ERR_MUX,
|
||||||
|
/* .cm0pSrc */ cpuss_interrupt_crypto_IRQn,
|
||||||
|
#else
|
||||||
|
/* .intrSrc */ cpuss_interrupt_crypto_IRQn,
|
||||||
|
#endif
|
||||||
|
/* .intrPriority */ 2u,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
cy_stc_crypto_context_t cryptoContext;
|
||||||
|
cy_en_crypto_status_t cryptoStatus;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* BLE GAPP Connection Settings */
|
||||||
|
#define CYBLE_GAPP_CONNECTION_INTERVAL_MIN (0x000Cu) /* 15 ms - (N * 1,25)*/
|
||||||
|
#define CYBLE_GAPP_CONNECTION_INTERVAL_MAX (0x000Cu) /* 15 ms */
|
||||||
|
#define CYBLE_GAPP_CONNECTION_SLAVE_LATENCY (0x0000u)
|
||||||
|
#define CYBLE_GAPP_CONNECTION_TIME_OUT (0x00C8u) /* 2000 ms */
|
||||||
|
|
||||||
|
/* BLE Callback function, defined in this file */
|
||||||
|
void AppCallBack(uint32 event, void* eventParam);
|
||||||
|
|
||||||
|
/* Local functions */
|
||||||
|
static cy_en_dfu_status_t CopyRow(uint32_t dest, uint32_t src, uint32_t rowSize, cy_stc_dfu_params_t * params);
|
||||||
|
static cy_en_dfu_status_t HandleMetadata(cy_stc_dfu_params_t *params);
|
||||||
|
static bool IsButtonPressed(uint16_t timeoutInMilis);
|
||||||
|
static uint32_t counterTimeoutSeconds(uint32_t seconds, uint32_t timeout);
|
||||||
|
|
||||||
|
/* This section is used to verify an application signature
|
||||||
|
For sha256 verification, set the number of elements in the array to 64, and
|
||||||
|
in bootload_common.ld set __cy_boot_signature_size = 256.
|
||||||
|
*/
|
||||||
|
CY_SECTION(".cy_app_signature") __USED static const uint32_t cy_bootload_appSignature[64];
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: main
|
||||||
|
********************************************************************************
|
||||||
|
*
|
||||||
|
* Summary:
|
||||||
|
* Main function of the DFU application (App0).
|
||||||
|
* 1. If application started from non-software reset it validates App1
|
||||||
|
* 1.1. If App1 is valid it switches to App1, else goto #2.
|
||||||
|
* 2. Start DFU communication.
|
||||||
|
* 3. If updated application has been received it validates this app.
|
||||||
|
* 4. If App1 is valid it switches to it, else wait for new application.
|
||||||
|
* 5. If 300 seconds have passed and no new application has been received
|
||||||
|
* then validate App1, if it is valid then switch to it, else hibernate
|
||||||
|
* (Happens in the BLE AppCallBack).
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
/* timeout for Cy_DFU_Continue(), in milliseconds */
|
||||||
|
const uint32_t paramsTimeout = 20u;
|
||||||
|
|
||||||
|
/* used to configure DFU */
|
||||||
|
static cy_stc_dfu_params_t dfuParams;
|
||||||
|
|
||||||
|
/* Status codes from DFU SDK API */
|
||||||
|
cy_en_dfu_status_t status;
|
||||||
|
|
||||||
|
/* SW2 released after deciding to stay in App0 */
|
||||||
|
bool buttonReleased = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DFU state, one of
|
||||||
|
* - CY_DFU_STATE_NONE
|
||||||
|
* - CY_DFU_STATE_UPDATING
|
||||||
|
* - CY_DFU_STATE_FINISHED
|
||||||
|
* - CY_DFU_STATE_FAILED
|
||||||
|
*/
|
||||||
|
uint32_t state = CY_DFU_STATE_NONE;
|
||||||
|
|
||||||
|
cy_en_ble_api_result_t apiResult;
|
||||||
|
cy_stc_ble_stack_lib_version_t stackVersion;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Used to count seconds, to convert counts to seconds use
|
||||||
|
* counterTimeoutSeconds(SECONDS, paramsTimeout)
|
||||||
|
*/
|
||||||
|
uint32_t count = 0;
|
||||||
|
|
||||||
|
uint32_t ledTimer = 0;
|
||||||
|
|
||||||
|
#if CY_DFU_OPT_CRYPTO_HW != 0
|
||||||
|
cy_en_crypto_status_t cryptoStatus;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Buffer to store DFU commands */
|
||||||
|
CY_ALIGN(4) static uint8_t buffer[CY_DFU_SIZEOF_DATA_BUFFER];
|
||||||
|
|
||||||
|
/* Buffer for DFU packets for Transport API */
|
||||||
|
CY_ALIGN(4) static uint8_t packet[CY_DFU_SIZEOF_CMD_BUFFER];
|
||||||
|
|
||||||
|
/* Enable global interrupts */
|
||||||
|
__enable_irq();
|
||||||
|
|
||||||
|
/* Start UART Services */
|
||||||
|
UART_START();
|
||||||
|
|
||||||
|
/* Initializes LEDs */
|
||||||
|
InitLED();
|
||||||
|
|
||||||
|
#if CY_DFU_OPT_CRYPTO_HW != 0
|
||||||
|
/* Initialize the Crypto Client code */
|
||||||
|
cryptoStatus = Cy_Crypto_Init(&cryptoConfig, &cryptoContext);
|
||||||
|
if (cryptoStatus != CY_CRYPTO_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Crypto not initialized; debug what is the problem */
|
||||||
|
Cy_SysLib_Halt(0x00u);
|
||||||
|
}
|
||||||
|
cryptoStatus = Cy_Crypto_Enable();
|
||||||
|
if (cryptoStatus != CY_CRYPTO_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Crypto not enabled; debug what is the problem */
|
||||||
|
Cy_SysLib_Halt(0x00u);
|
||||||
|
}
|
||||||
|
#endif /* CY_DFU_OPT_CRYPTO_HW != 0 */
|
||||||
|
|
||||||
|
/* Initialize dfuParams structure and DFU SDK state */
|
||||||
|
dfuParams.timeout = paramsTimeout;
|
||||||
|
dfuParams.dataBuffer = &buffer[0];
|
||||||
|
dfuParams.packetBuffer = &packet[0];
|
||||||
|
|
||||||
|
status = Cy_DFU_Init(&state, &dfuParams);
|
||||||
|
|
||||||
|
/* Ensure DFU Metadata is valid */
|
||||||
|
status = HandleMetadata(&dfuParams);
|
||||||
|
if (status != CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
Cy_SysLib_Halt(0x00u);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In the case of non-software reset and user does not
|
||||||
|
* want to stay in App0, check if there is a valid app image.
|
||||||
|
* If there is - switch to it.
|
||||||
|
*/
|
||||||
|
if ((Cy_SysLib_GetResetReason() != CY_SYSLIB_RESET_SOFT) && (IsButtonPressed(2000u) == false))
|
||||||
|
{
|
||||||
|
status = Cy_DFU_ValidateApp(1u, &dfuParams);
|
||||||
|
if (status == CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Clear reset reason because Cy_DFU_ExecuteApp() performs
|
||||||
|
* a software reset.
|
||||||
|
* Without clearing two reset reasons would be present.
|
||||||
|
*/
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Cy_SysLib_ClearResetReason();
|
||||||
|
}while(Cy_SysLib_GetResetReason() != 0);
|
||||||
|
/* Never returns */
|
||||||
|
Cy_DFU_ExecuteApp(1u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize DFU communication */
|
||||||
|
Cy_DFU_TransportStart();
|
||||||
|
/* Initializes the Immediate Alert Service */
|
||||||
|
IasInit();
|
||||||
|
|
||||||
|
/* Output current stack version to UART */
|
||||||
|
apiResult = Cy_BLE_GetStackLibraryVersion(&stackVersion);
|
||||||
|
if(apiResult != CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
DBG_PRINTF("CyBle_GetStackLibraryVersion API Error: 0x%2.2x \r\n", apiResult);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBG_PRINTF("Stack Version: %d.%d.%d.%d \r\n", stackVersion.majorVersion,
|
||||||
|
stackVersion.minorVersion, stackVersion.patch, stackVersion.buildNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
/* CyBle_ProcessEvents() allows BLE stack to process pending events */
|
||||||
|
Cy_BLE_ProcessEvents();
|
||||||
|
|
||||||
|
/* Process DFU commands */
|
||||||
|
status = Cy_DFU_Continue(&state, &dfuParams);
|
||||||
|
++count;
|
||||||
|
|
||||||
|
switch(state)
|
||||||
|
{
|
||||||
|
case CY_DFU_STATE_FINISHED:
|
||||||
|
/* Finished downloading the application image */
|
||||||
|
|
||||||
|
/* Validate downloaded application, if it is valid then switch to it */
|
||||||
|
status = Cy_DFU_ValidateApp(1u, &dfuParams);
|
||||||
|
if (status == CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
Cy_DFU_TransportStop();
|
||||||
|
/*
|
||||||
|
* Clear reset reason because Cy_DFU_ExecuteApp() performs
|
||||||
|
* a software reset.
|
||||||
|
* Without clearing two reset reasons would be present.
|
||||||
|
*/
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Cy_SysLib_ClearResetReason();
|
||||||
|
}while(Cy_SysLib_GetResetReason() != 0);
|
||||||
|
/* Never returns */
|
||||||
|
Cy_DFU_ExecuteApp(1u);
|
||||||
|
}
|
||||||
|
else if (status == CY_DFU_ERROR_VERIFY)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Restarts DFU, alternatives are to Halt MCU here
|
||||||
|
* or switch to the other app if it is valid.
|
||||||
|
* Error code may be handled here, i.e. print to debug UART.
|
||||||
|
*/
|
||||||
|
status = Cy_DFU_Init(&state, &dfuParams);
|
||||||
|
/* Reset LED */
|
||||||
|
ConnectedLED();
|
||||||
|
ledTimer = 0;
|
||||||
|
Cy_DFU_TransportReset();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CY_DFU_STATE_FAILED:
|
||||||
|
/* Handle error here */
|
||||||
|
DBG_PRINTF("Downloading has failed with error code 0x%x, try again\r\n", status);
|
||||||
|
|
||||||
|
/* In this Code Example just restart DFU process */
|
||||||
|
status = Cy_DFU_Init(&state, &dfuParams);
|
||||||
|
/* Reset LED */
|
||||||
|
ConnectedLED();
|
||||||
|
ledTimer = 0;
|
||||||
|
Cy_DFU_TransportReset();
|
||||||
|
break;
|
||||||
|
case CY_DFU_STATE_UPDATING:
|
||||||
|
/* Reset timeout counter, if a command was correctly received */
|
||||||
|
if (status == CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
count = 0u;
|
||||||
|
}
|
||||||
|
else if (status == CY_DFU_ERROR_TIMEOUT)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* if no command has been received during 5 seconds when DFU
|
||||||
|
* has started then restart DFU.
|
||||||
|
*/
|
||||||
|
if (count >= counterTimeoutSeconds(5u, paramsTimeout))
|
||||||
|
{
|
||||||
|
count = 0u;
|
||||||
|
Cy_DFU_Init(&state, &dfuParams);
|
||||||
|
/* Reset LED */
|
||||||
|
ConnectedLED();
|
||||||
|
ledTimer = 0;
|
||||||
|
Cy_DFU_TransportReset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
count = 0u;
|
||||||
|
/* Delay because Transport still may be sending error response to a host */
|
||||||
|
Cy_SysLib_Delay(paramsTimeout);
|
||||||
|
Cy_DFU_Init(&state, &dfuParams);
|
||||||
|
Cy_DFU_TransportReset();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* LED logic, constant values are optimized out. */
|
||||||
|
/* Reset timer after 2 seconds */
|
||||||
|
if(ledTimer == (2000u / paramsTimeout)) ledTimer = 0;
|
||||||
|
/* Every 100 miliseconds */
|
||||||
|
if(!(ledTimer % (100u / paramsTimeout)))
|
||||||
|
{
|
||||||
|
/* Generates two 100 miliseconds pulses, every 2 seconds */
|
||||||
|
if((state == CY_DFU_STATE_UPDATING) && (ledTimer < (400u / paramsTimeout)))
|
||||||
|
{
|
||||||
|
BlinkLED();
|
||||||
|
}
|
||||||
|
/* Generates one 100 miliseconds pulse, every 2 seconds */
|
||||||
|
else if ((Cy_BLE_GetAdvertisementState() == CY_BLE_ADV_STATE_ADVERTISING)
|
||||||
|
&& (ledTimer < (200u / paramsTimeout)))
|
||||||
|
{
|
||||||
|
BlinkLED();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Remain OFF */
|
||||||
|
ConnectedLED();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++ledTimer;
|
||||||
|
|
||||||
|
/* Check if a switch to the other app is requested and perform the switch if it is */
|
||||||
|
if((buttonReleased == true) && (state == CY_DFU_STATE_NONE))
|
||||||
|
{
|
||||||
|
bool switchRequested = false;
|
||||||
|
if (alertLevel != 0)
|
||||||
|
{
|
||||||
|
switchRequested = true;
|
||||||
|
}
|
||||||
|
else if(IsButtonPressed(500u) == true)
|
||||||
|
{
|
||||||
|
switchRequested = true;
|
||||||
|
buttonReleased = false;
|
||||||
|
}
|
||||||
|
if (switchRequested)
|
||||||
|
{
|
||||||
|
/* Validate and switch to App1 */
|
||||||
|
cy_en_dfu_status_t status = Cy_DFU_ValidateApp(1u, &dfuParams);
|
||||||
|
|
||||||
|
if (status == CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
Cy_DFU_TransportStop();
|
||||||
|
/*
|
||||||
|
* Clear reset reason because Cy_DFU_ExecuteApp() performs
|
||||||
|
* a software reset.
|
||||||
|
* Without clearing two reset reasons would be present.
|
||||||
|
*/
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Cy_SysLib_ClearResetReason();
|
||||||
|
}while(Cy_SysLib_GetResetReason() != 0);
|
||||||
|
/* Never returns */
|
||||||
|
Cy_DFU_ExecuteApp(1u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buttonReleased = Cy_GPIO_Read(PIN_SW2_PORT, PIN_SW2_NUM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: IsButtonPressed
|
||||||
|
********************************************************************************
|
||||||
|
* Checks if button is pressed for a 'timeoutInMilis' time.
|
||||||
|
*
|
||||||
|
* Params:
|
||||||
|
* timeout: Amount of time to check if button was pressed. Broken into
|
||||||
|
* 20 miliseconds steps.
|
||||||
|
* Returns:
|
||||||
|
* true if button is pressed for specified amount.
|
||||||
|
* false otherwise.
|
||||||
|
*******************************************************************************/
|
||||||
|
static bool IsButtonPressed(uint16_t timeoutInMilis)
|
||||||
|
{
|
||||||
|
uint16_t buttonTime = 0;
|
||||||
|
bool buttonPressed = false;
|
||||||
|
timeoutInMilis /= 20;
|
||||||
|
while(Cy_GPIO_Read(PIN_SW2_PORT, PIN_SW2_NUM) == 0u)
|
||||||
|
{
|
||||||
|
Cy_SysLib_Delay(20u);
|
||||||
|
if(++buttonTime == timeoutInMilis)
|
||||||
|
{
|
||||||
|
/* time has passed */
|
||||||
|
buttonPressed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buttonPressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: counterTimeoutSeconds
|
||||||
|
********************************************************************************
|
||||||
|
* Returns number of counts that correspond to number of seconds passed as
|
||||||
|
* a parameter.
|
||||||
|
* E.g. comparing counter with 300 seconds is like this.
|
||||||
|
* ---
|
||||||
|
* uint32_t counter = 0u;
|
||||||
|
* for (;;)
|
||||||
|
* {
|
||||||
|
* Cy_SysLib_Delay(UART_TIMEOUT);
|
||||||
|
* ++count;
|
||||||
|
* if (count >= counterTimeoutSeconds(seconds: 300u, timeout: UART_TIMEOUT))
|
||||||
|
* {
|
||||||
|
* count = 0u;
|
||||||
|
* DoSomething();
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ---
|
||||||
|
*
|
||||||
|
* Both parameters are required to be compile time constants,
|
||||||
|
* so this function gets optimized out to single constant value.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* seconds Number of seconds to pass. Must be less that 4_294_967 seconds.
|
||||||
|
* timeout Timeout for Cy_DFU_Continue() function, in milliseconds.
|
||||||
|
* Must be greater than zero.
|
||||||
|
* It is recommended to be a value that produces no reminder
|
||||||
|
* for this function to be precise.
|
||||||
|
* Return:
|
||||||
|
* See description.
|
||||||
|
*******************************************************************************/
|
||||||
|
static uint32_t counterTimeoutSeconds(uint32_t seconds, uint32_t timeout)
|
||||||
|
{
|
||||||
|
return (seconds * 1000ul) / timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: CopyRow
|
||||||
|
********************************************************************************
|
||||||
|
* Copies data from a "src" address to a flash row with the address "dest".
|
||||||
|
* If "src" data is the same as "dest" data then no copy is needed.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* dest Destination address. Has to be an address of the start of flash row.
|
||||||
|
* src Source address. Has to be properly aligned.
|
||||||
|
* rowSize Size of flash row.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* CY_DFU_SUCCESS if operation is successful.
|
||||||
|
* Error code in a case of failure.
|
||||||
|
*******************************************************************************/
|
||||||
|
static cy_en_dfu_status_t CopyRow(uint32_t dest, uint32_t src, uint32_t rowSize, cy_stc_dfu_params_t * params)
|
||||||
|
{
|
||||||
|
cy_en_dfu_status_t status;
|
||||||
|
|
||||||
|
/* Save params->dataBuffer value */
|
||||||
|
uint8_t *buffer = params->dataBuffer;
|
||||||
|
|
||||||
|
/* Compare "dest" and "src" content */
|
||||||
|
params->dataBuffer = (uint8_t *)src;
|
||||||
|
status = Cy_DFU_ReadData(dest, rowSize, CY_DFU_IOCTL_COMPARE, params);
|
||||||
|
|
||||||
|
/* Restore params->dataBuffer */
|
||||||
|
params->dataBuffer = buffer;
|
||||||
|
|
||||||
|
/* If "dest" differs from "src" then copy "src" to "dest" */
|
||||||
|
if (status != CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
(void) memcpy((void *) params->dataBuffer, (const void*)src, rowSize);
|
||||||
|
status = Cy_DFU_WriteData(dest, rowSize, CY_DFU_IOCTL_WRITE, params);
|
||||||
|
}
|
||||||
|
/* Restore params->dataBuffer */
|
||||||
|
params->dataBuffer = buffer;
|
||||||
|
|
||||||
|
return (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: HandleMetadata
|
||||||
|
********************************************************************************
|
||||||
|
* The goal of this function is to make DFU SDK metadata (MD) valid.
|
||||||
|
* The following algorithm is used (in C-like pseudocode):
|
||||||
|
* ---
|
||||||
|
* if (isValid(MD) == true)
|
||||||
|
* { if (MDC != MD)
|
||||||
|
* MDC = MD;
|
||||||
|
* } else
|
||||||
|
* { if(isValid(MDC) )
|
||||||
|
* MD = MDC;
|
||||||
|
* #if MD Writeable
|
||||||
|
* else
|
||||||
|
* MD = INITIAL_VALUE;
|
||||||
|
* #endif
|
||||||
|
* }
|
||||||
|
* ---
|
||||||
|
* Here MD is metadata flash row, MDC is flash row with metadata copy,
|
||||||
|
* INITIAL_VALUE is known initial value.
|
||||||
|
*
|
||||||
|
* In this code example MDC is placed in the next flash row after the MD, and
|
||||||
|
* INITIAL_VALUE is MD with only CRC, App0 start and size initialized,
|
||||||
|
* all the other fields are not touched. This is only done if metadata is
|
||||||
|
* writeable when downloading.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* params A pointer to a DFU SDK parameters structure.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* - CY_DFU_SUCCESS when finished normally.
|
||||||
|
* - Any other status code on error.
|
||||||
|
*******************************************************************************/
|
||||||
|
static cy_en_dfu_status_t HandleMetadata(cy_stc_dfu_params_t *params)
|
||||||
|
{
|
||||||
|
const uint32_t MD = (uint32_t)(&__cy_boot_metadata_addr ); /* MD address */
|
||||||
|
const uint32_t mdSize = (uint32_t)(&__cy_boot_metadata_length ); /* MD size, assumed to be one flash row */
|
||||||
|
const uint32_t MDC = MD + mdSize; /* MDC address */
|
||||||
|
|
||||||
|
cy_en_dfu_status_t status = CY_DFU_SUCCESS;
|
||||||
|
|
||||||
|
status = Cy_DFU_ValidateMetadata(MD, params);
|
||||||
|
if (status == CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Checks if MDC equals to DC, if no then copies MD to MDC */
|
||||||
|
status = CopyRow(MDC, MD, mdSize, params);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = Cy_DFU_ValidateMetadata(MDC, params);
|
||||||
|
if (status == CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Copy MDC to MD */
|
||||||
|
status = CopyRow(MD, MDC, mdSize, params);
|
||||||
|
}
|
||||||
|
#if CY_DFU_METADATA_WRITABLE != 0
|
||||||
|
if (status != CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
const uint32_t elfStartAddress = 0x10000000;
|
||||||
|
const uint32_t elfAppSize = 0x40000;
|
||||||
|
/* Set MD to INITIAL_VALUE */
|
||||||
|
status = Cy_DFU_SetAppMetadata(0u, elfStartAddress, elfAppSize, params);
|
||||||
|
}
|
||||||
|
#endif /* CY_DFU_METADATA_WRITABLE != 0 */
|
||||||
|
}
|
||||||
|
return (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: AppCallBack()
|
||||||
|
********************************************************************************
|
||||||
|
*
|
||||||
|
* Summary:
|
||||||
|
* This is an event callback function to receive events from the BLE Component.
|
||||||
|
* Used in Cy_DFU_TransportStart()
|
||||||
|
*
|
||||||
|
* event - the event code
|
||||||
|
* *eventParam - the event parameters
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void AppCallBack(uint32 event, void* eventParam)
|
||||||
|
{
|
||||||
|
cy_en_ble_api_result_t apiResult;
|
||||||
|
|
||||||
|
static cy_stc_ble_gap_sec_key_info_t keyInfo =
|
||||||
|
{
|
||||||
|
.localKeysFlag = CY_BLE_GAP_SMP_INIT_ENC_KEY_DIST |
|
||||||
|
CY_BLE_GAP_SMP_INIT_IRK_KEY_DIST |
|
||||||
|
CY_BLE_GAP_SMP_INIT_CSRK_KEY_DIST,
|
||||||
|
.exchangeKeysFlag = CY_BLE_GAP_SMP_INIT_ENC_KEY_DIST |
|
||||||
|
CY_BLE_GAP_SMP_INIT_IRK_KEY_DIST |
|
||||||
|
CY_BLE_GAP_SMP_INIT_CSRK_KEY_DIST |
|
||||||
|
CY_BLE_GAP_SMP_RESP_ENC_KEY_DIST |
|
||||||
|
CY_BLE_GAP_SMP_RESP_IRK_KEY_DIST |
|
||||||
|
CY_BLE_GAP_SMP_RESP_CSRK_KEY_DIST,
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (event)
|
||||||
|
{
|
||||||
|
/**********************************************************
|
||||||
|
* General Events
|
||||||
|
***********************************************************/
|
||||||
|
|
||||||
|
/* This event received when BLE communication starts */
|
||||||
|
case CY_BLE_EVT_STACK_ON:
|
||||||
|
/* Enter into discoverable mode so that remote can search it. */
|
||||||
|
apiResult = Cy_BLE_GAPP_StartAdvertisement(CY_BLE_ADVERTISING_FAST, 0u);
|
||||||
|
if(apiResult != CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResult = Cy_BLE_GAP_GenerateKeys(&keyInfo);
|
||||||
|
if(apiResult != CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
DBG_PRINTF("CyBle_GapGenerateKeys API Error: %d \r\n", apiResult);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* This event indicates that some internal HW error has occurred. */
|
||||||
|
case CY_BLE_EVT_HARDWARE_ERROR:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_HARDWARE_ERROR\r\n");
|
||||||
|
break;
|
||||||
|
/**********************************************************
|
||||||
|
* GAP Events
|
||||||
|
***********************************************************/
|
||||||
|
case CY_BLE_EVT_GAP_AUTH_REQ:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_AUTH_REQ: security=%x, bonding=%x, ekeySize=%x, err=%x \r\n",
|
||||||
|
(*(cy_stc_ble_gap_auth_info_t *)eventParam).security,
|
||||||
|
(*(cy_stc_ble_gap_auth_info_t *)eventParam).bonding,
|
||||||
|
(*(cy_stc_ble_gap_auth_info_t*)eventParam).ekeySize,
|
||||||
|
(*(cy_stc_ble_gap_auth_info_t *)eventParam).authErr );
|
||||||
|
if ( cy_ble_configPtr->authInfo[CY_BLE_SECURITY_CONFIGURATION_0_INDEX].security
|
||||||
|
== (CY_BLE_GAP_SEC_MODE_1 | CY_BLE_GAP_SEC_LEVEL_1) )
|
||||||
|
{
|
||||||
|
cy_ble_configPtr->authInfo[CY_BLE_SECURITY_CONFIGURATION_0_INDEX].authErr =
|
||||||
|
CY_BLE_GAP_AUTH_ERROR_PAIRING_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
cy_ble_configPtr->authInfo[CY_BLE_SECURITY_CONFIGURATION_0_INDEX].bdHandle =
|
||||||
|
((cy_stc_ble_gap_auth_info_t *)eventParam)->bdHandle;
|
||||||
|
|
||||||
|
apiResult = Cy_BLE_GAPP_AuthReqReply(&cy_ble_configPtr->authInfo[CY_BLE_SECURITY_CONFIGURATION_0_INDEX]);
|
||||||
|
if(apiResult != CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
Cy_BLE_GAP_RemoveOldestDeviceFromBondedList();
|
||||||
|
apiResult = Cy_BLE_GAPP_AuthReqReply(&cy_ble_configPtr->authInfo[CY_BLE_SECURITY_CONFIGURATION_0_INDEX]);
|
||||||
|
if(apiResult != CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
DBG_PRINTF("CyBle_GappAuthReqReply API Error: %d \r\n", apiResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GAP_PASSKEY_ENTRY_REQUEST:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_PASSKEY_ENTRY_REQUEST press 'p' to enter passkey \r\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GAP_PASSKEY_DISPLAY_REQUEST:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_PASSKEY_DISPLAY_REQUEST %6.6d \r\n", *(int *)eventParam);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GAP_KEYINFO_EXCHNGE_CMPLT:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_GAP_KEYINFO_EXCHNGE_CMPLT \r\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GAP_AUTH_COMPLETE:
|
||||||
|
DBG_PRINTF("AUTH_COMPLETE \r\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GAP_AUTH_FAILED:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_AUTH_FAILED: %x \r\n", *(uint8 *)eventParam);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GAP_DEVICE_CONNECTED:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_GAP_DEVICE_CONNECTED: %d \r\n", appConnHandle.bdHandle);
|
||||||
|
|
||||||
|
if ( ((*(cy_stc_ble_gap_connected_param_t *)eventParam).connIntv
|
||||||
|
< CYBLE_GAPP_CONNECTION_INTERVAL_MIN ) || (
|
||||||
|
(*(cy_stc_ble_gap_connected_param_t *)eventParam).connIntv
|
||||||
|
> CYBLE_GAPP_CONNECTION_INTERVAL_MAX ) )
|
||||||
|
{
|
||||||
|
cy_stc_ble_gap_conn_update_param_info_t connUpdateParam;
|
||||||
|
/* If connection settings do not match expected ones - request parameter update */
|
||||||
|
connUpdateParam.connIntvMin = CYBLE_GAPP_CONNECTION_INTERVAL_MIN;
|
||||||
|
connUpdateParam.connIntvMax = CYBLE_GAPP_CONNECTION_INTERVAL_MAX;
|
||||||
|
connUpdateParam.connLatency = CYBLE_GAPP_CONNECTION_SLAVE_LATENCY;
|
||||||
|
connUpdateParam.supervisionTO = CYBLE_GAPP_CONNECTION_TIME_OUT;
|
||||||
|
connUpdateParam.bdHandle = appConnHandle.bdHandle;
|
||||||
|
apiResult = Cy_BLE_L2CAP_LeConnectionParamUpdateRequest(&connUpdateParam);
|
||||||
|
DBG_PRINTF("Cy_BLE_L2CAP_LeConnectionParamUpdateRequest API: 0x%2.2x \r\n", apiResult);
|
||||||
|
}
|
||||||
|
keyInfo.SecKeyParam.bdHandle = (*(cy_stc_ble_gap_connected_param_t *)eventParam).bdHandle;
|
||||||
|
apiResult = Cy_BLE_GAP_SetSecurityKeys(&keyInfo);
|
||||||
|
if(apiResult != CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
DBG_PRINTF("CyBle_GapSetSecurityKeys API Error: %d \r\n", apiResult);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_L2CAP_CONN_PARAM_UPDATE_RSP:
|
||||||
|
DBG_PRINTF("CY_BLE_EVT_L2CAP_CONN_PARAM_UPDATE_RSP, result = %d\r\n",
|
||||||
|
(*(cy_stc_ble_l2cap_conn_update_rsp_param_t *)eventParam).result);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GAP_KEYS_GEN_COMPLETE:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_GAP_KEYS_GEN_COMPLETE \r\n");
|
||||||
|
keyInfo.SecKeyParam = (*(cy_stc_ble_gap_sec_key_param_t *)eventParam);
|
||||||
|
Cy_BLE_GAP_SetIdAddress(&cy_ble_deviceAddress);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GAP_DEVICE_DISCONNECTED:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_GAP_DEVICE_DISCONNECTED\r\n");
|
||||||
|
/* Put the device into discoverable mode so that a remote can search it. */
|
||||||
|
apiResult = Cy_BLE_GAPP_StartAdvertisement(CY_BLE_ADVERTISING_FAST, CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX);
|
||||||
|
if(apiResult != CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
DBG_PRINTF("StartAdvertisement API Error: %d \r\n", apiResult);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GAP_ENCRYPT_CHANGE:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_GAP_ENCRYPT_CHANGE: %x \r\n", *(uint8 *)eventParam);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_CONNECTION_UPDATE_COMPLETE: %x \r\n", *(uint8 *)eventParam);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GAPP_ADVERTISEMENT_START_STOP:
|
||||||
|
if(Cy_BLE_GetAdvertisementState() == CY_BLE_ADV_STATE_STOPPED)
|
||||||
|
{
|
||||||
|
/* Fast and slow advertising period complete, go to low power
|
||||||
|
* mode (Hibernate mode) and wait for an external
|
||||||
|
* user event to wake up the device again */
|
||||||
|
|
||||||
|
/* Stop DFU communication */
|
||||||
|
Cy_DFU_TransportStop();
|
||||||
|
/* Check if app is valid, if it is then switch to it */
|
||||||
|
uint32_t status = Cy_DFU_ValidateApp(1u, NULL);
|
||||||
|
if (status == CY_DFU_SUCCESS)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Clear reset reason because Cy_DFU_ExecuteApp() performs
|
||||||
|
* a software reset.
|
||||||
|
* Without clearing two reset reasons would be present.
|
||||||
|
*/
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Cy_SysLib_ClearResetReason();
|
||||||
|
}while(Cy_SysLib_GetResetReason() != 0);
|
||||||
|
/* Never returns */
|
||||||
|
Cy_DFU_ExecuteApp(1u);
|
||||||
|
}
|
||||||
|
/* 300 seconds has passed and App is invalid. Hibernate */
|
||||||
|
HibernateLED();
|
||||||
|
Cy_SysPm_Hibernate();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/**********************************************************
|
||||||
|
* GATT Events
|
||||||
|
***********************************************************/
|
||||||
|
case CY_BLE_EVT_GATT_CONNECT_IND:
|
||||||
|
appConnHandle = *(cy_stc_ble_conn_handle_t *)eventParam;
|
||||||
|
DBG_PRINTF("CYBLE_EVT_GATT_CONNECT_IND: %d \r\n", appConnHandle.bdHandle);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GATT_DISCONNECT_IND:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_GATT_DISCONNECT_IND: %d \r\n", ((cy_stc_ble_conn_handle_t *)eventParam)->bdHandle);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_GATTS_WRITE_CMD_REQ:
|
||||||
|
DBG_PRINTF("CYBLE_EVT_GATTS_WRITE_CMD_REQ\r\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
321
2020TPCApp0.cydsn/mdk/startup_psoc6_01_cm0plus.s
Normal file
321
2020TPCApp0.cydsn/mdk/startup_psoc6_01_cm0plus.s
Normal file
|
@ -0,0 +1,321 @@
|
||||||
|
;/**************************************************************************//**
|
||||||
|
; * @file startup_psoc6_01_cm0plus.s
|
||||||
|
; * @brief CMSIS Core Device Startup File for
|
||||||
|
; * ARMCM0plus Device Series
|
||||||
|
; * @version V5.00
|
||||||
|
; * @date 02. March 2016
|
||||||
|
; ******************************************************************************/
|
||||||
|
;/*
|
||||||
|
; * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
|
||||||
|
; *
|
||||||
|
; * SPDX-License-Identifier: Apache-2.0
|
||||||
|
; *
|
||||||
|
; * Licensed under the Apache License, Version 2.0 (the License); you may
|
||||||
|
; * not use this file except in compliance with the License.
|
||||||
|
; * You may obtain a copy of the License at
|
||||||
|
; *
|
||||||
|
; * www.apache.org/licenses/LICENSE-2.0
|
||||||
|
; *
|
||||||
|
; * Unless required by applicable law or agreed to in writing, software
|
||||||
|
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||||
|
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
; * See the License for the specific language governing permissions and
|
||||||
|
; * limitations under the License.
|
||||||
|
; */
|
||||||
|
|
||||||
|
;/*
|
||||||
|
;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
|
||||||
|
;*/
|
||||||
|
|
||||||
|
; <h> Stack Configuration
|
||||||
|
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||||
|
; </h>
|
||||||
|
IF :DEF:__STACK_SIZE
|
||||||
|
Stack_Size EQU __STACK_SIZE
|
||||||
|
ELSE
|
||||||
|
Stack_Size EQU 0x00001000
|
||||||
|
ENDIF
|
||||||
|
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>
|
||||||
|
IF :DEF:__HEAP_SIZE
|
||||||
|
Heap_Size EQU __HEAP_SIZE
|
||||||
|
ELSE
|
||||||
|
Heap_Size EQU 0x00000400
|
||||||
|
ENDIF
|
||||||
|
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 0x0000000D ; NMI Handler located at ROM code
|
||||||
|
DCD HardFault_Handler ; Hard Fault Handler
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD SVC_Handler ; SVCall Handler
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD 0 ; Reserved
|
||||||
|
DCD PendSV_Handler ; PendSV Handler
|
||||||
|
DCD SysTick_Handler ; SysTick Handler
|
||||||
|
|
||||||
|
|
||||||
|
; External interrupts Description
|
||||||
|
DCD NvicMux0_IRQHandler ; CM0+ NVIC Mux input 0
|
||||||
|
DCD NvicMux1_IRQHandler ; CM0+ NVIC Mux input 1
|
||||||
|
DCD NvicMux2_IRQHandler ; CM0+ NVIC Mux input 2
|
||||||
|
DCD NvicMux3_IRQHandler ; CM0+ NVIC Mux input 3
|
||||||
|
DCD NvicMux4_IRQHandler ; CM0+ NVIC Mux input 4
|
||||||
|
DCD NvicMux5_IRQHandler ; CM0+ NVIC Mux input 5
|
||||||
|
DCD NvicMux6_IRQHandler ; CM0+ NVIC Mux input 6
|
||||||
|
DCD NvicMux7_IRQHandler ; CM0+ NVIC Mux input 7
|
||||||
|
DCD NvicMux8_IRQHandler ; CM0+ NVIC Mux input 8
|
||||||
|
DCD NvicMux9_IRQHandler ; CM0+ NVIC Mux input 9
|
||||||
|
DCD NvicMux10_IRQHandler ; CM0+ NVIC Mux input 10
|
||||||
|
DCD NvicMux11_IRQHandler ; CM0+ NVIC Mux input 11
|
||||||
|
DCD NvicMux12_IRQHandler ; CM0+ NVIC Mux input 12
|
||||||
|
DCD NvicMux13_IRQHandler ; CM0+ NVIC Mux input 13
|
||||||
|
DCD NvicMux14_IRQHandler ; CM0+ NVIC Mux input 14
|
||||||
|
DCD NvicMux15_IRQHandler ; CM0+ NVIC Mux input 15
|
||||||
|
DCD NvicMux16_IRQHandler ; CM0+ NVIC Mux input 16
|
||||||
|
DCD NvicMux17_IRQHandler ; CM0+ NVIC Mux input 17
|
||||||
|
DCD NvicMux18_IRQHandler ; CM0+ NVIC Mux input 18
|
||||||
|
DCD NvicMux19_IRQHandler ; CM0+ NVIC Mux input 19
|
||||||
|
DCD NvicMux20_IRQHandler ; CM0+ NVIC Mux input 20
|
||||||
|
DCD NvicMux21_IRQHandler ; CM0+ NVIC Mux input 21
|
||||||
|
DCD NvicMux22_IRQHandler ; CM0+ NVIC Mux input 22
|
||||||
|
DCD NvicMux23_IRQHandler ; CM0+ NVIC Mux input 23
|
||||||
|
DCD NvicMux24_IRQHandler ; CM0+ NVIC Mux input 24
|
||||||
|
DCD NvicMux25_IRQHandler ; CM0+ NVIC Mux input 25
|
||||||
|
DCD NvicMux26_IRQHandler ; CM0+ NVIC Mux input 26
|
||||||
|
DCD NvicMux27_IRQHandler ; CM0+ NVIC Mux input 27
|
||||||
|
DCD NvicMux28_IRQHandler ; CM0+ NVIC Mux input 28
|
||||||
|
DCD NvicMux29_IRQHandler ; CM0+ NVIC Mux input 29
|
||||||
|
DCD NvicMux30_IRQHandler ; CM0+ NVIC Mux input 30
|
||||||
|
DCD NvicMux31_IRQHandler ; CM0+ NVIC Mux input 31
|
||||||
|
|
||||||
|
__Vectors_End
|
||||||
|
|
||||||
|
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||||
|
EXPORT __ramVectors
|
||||||
|
AREA RESET_RAM, READWRITE, NOINIT
|
||||||
|
__ramVectors SPACE __Vectors_Size
|
||||||
|
|
||||||
|
|
||||||
|
AREA |.text|, CODE, READONLY
|
||||||
|
|
||||||
|
|
||||||
|
; Weak function for startup customization
|
||||||
|
;
|
||||||
|
; Note. The global resources are not yet initialized (for example global variables, peripherals, clocks)
|
||||||
|
; because this function is executed as the first instruction in the ResetHandler.
|
||||||
|
; The PDL is also not initialized to use the proper register offsets.
|
||||||
|
; The user of this function is responsible for initializing the PDL and resources before using them.
|
||||||
|
;
|
||||||
|
Cy_OnResetUser PROC
|
||||||
|
EXPORT Cy_OnResetUser [WEAK]
|
||||||
|
BX LR
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
; Reset Handler
|
||||||
|
Reset_Handler PROC
|
||||||
|
EXPORT Reset_Handler [WEAK]
|
||||||
|
IMPORT __main
|
||||||
|
|
||||||
|
; Define strong function for startup customization
|
||||||
|
BL Cy_OnResetUser
|
||||||
|
|
||||||
|
; Disable global interrupts
|
||||||
|
CPSID I
|
||||||
|
|
||||||
|
; Copy vectors from ROM to RAM
|
||||||
|
LDR r1, =__Vectors
|
||||||
|
LDR r0, =__ramVectors
|
||||||
|
LDR r2, =__Vectors_Size
|
||||||
|
Vectors_Copy
|
||||||
|
LDR r3, [r1]
|
||||||
|
STR r3, [r0]
|
||||||
|
ADDS r0, r0, #4
|
||||||
|
ADDS r1, r1, #4
|
||||||
|
SUBS r2, r2, #1
|
||||||
|
CMP r2, #0
|
||||||
|
BNE Vectors_Copy
|
||||||
|
|
||||||
|
; Update Vector Table Offset Register. */
|
||||||
|
LDR r0, =__ramVectors
|
||||||
|
LDR r1, =0xE000ED08
|
||||||
|
STR r0, [r1]
|
||||||
|
dsb 0xF
|
||||||
|
|
||||||
|
LDR R0, =__main
|
||||||
|
BLX R0
|
||||||
|
|
||||||
|
; Should never get here
|
||||||
|
B .
|
||||||
|
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||||
|
NMI_Handler PROC
|
||||||
|
EXPORT NMI_Handler [WEAK]
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
Cy_SysLib_FaultHandler PROC
|
||||||
|
EXPORT Cy_SysLib_FaultHandler [WEAK]
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
HardFault_Handler PROC
|
||||||
|
EXPORT HardFault_Handler [WEAK]
|
||||||
|
movs r0, #4
|
||||||
|
mov r1, LR
|
||||||
|
tst r0, r1
|
||||||
|
beq L_MSP
|
||||||
|
mrs r0, PSP
|
||||||
|
bl L_API_call
|
||||||
|
L_MSP
|
||||||
|
mrs r0, MSP
|
||||||
|
L_API_call
|
||||||
|
bl Cy_SysLib_FaultHandler
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
SVC_Handler PROC
|
||||||
|
EXPORT SVC_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 Default_Handler [WEAK]
|
||||||
|
EXPORT NvicMux0_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux1_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux2_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux3_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux4_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux5_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux6_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux7_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux8_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux9_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux10_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux11_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux12_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux13_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux14_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux15_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux16_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux17_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux18_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux19_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux20_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux21_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux22_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux23_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux24_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux25_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux26_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux27_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux28_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux29_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux30_IRQHandler [WEAK]
|
||||||
|
EXPORT NvicMux31_IRQHandler [WEAK]
|
||||||
|
|
||||||
|
NvicMux0_IRQHandler
|
||||||
|
NvicMux1_IRQHandler
|
||||||
|
NvicMux2_IRQHandler
|
||||||
|
NvicMux3_IRQHandler
|
||||||
|
NvicMux4_IRQHandler
|
||||||
|
NvicMux5_IRQHandler
|
||||||
|
NvicMux6_IRQHandler
|
||||||
|
NvicMux7_IRQHandler
|
||||||
|
NvicMux8_IRQHandler
|
||||||
|
NvicMux9_IRQHandler
|
||||||
|
NvicMux10_IRQHandler
|
||||||
|
NvicMux11_IRQHandler
|
||||||
|
NvicMux12_IRQHandler
|
||||||
|
NvicMux13_IRQHandler
|
||||||
|
NvicMux14_IRQHandler
|
||||||
|
NvicMux15_IRQHandler
|
||||||
|
NvicMux16_IRQHandler
|
||||||
|
NvicMux17_IRQHandler
|
||||||
|
NvicMux18_IRQHandler
|
||||||
|
NvicMux19_IRQHandler
|
||||||
|
NvicMux20_IRQHandler
|
||||||
|
NvicMux21_IRQHandler
|
||||||
|
NvicMux22_IRQHandler
|
||||||
|
NvicMux23_IRQHandler
|
||||||
|
NvicMux24_IRQHandler
|
||||||
|
NvicMux25_IRQHandler
|
||||||
|
NvicMux26_IRQHandler
|
||||||
|
NvicMux27_IRQHandler
|
||||||
|
NvicMux28_IRQHandler
|
||||||
|
NvicMux29_IRQHandler
|
||||||
|
NvicMux30_IRQHandler
|
||||||
|
NvicMux31_IRQHandler
|
||||||
|
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
ALIGN
|
||||||
|
|
||||||
|
|
||||||
|
; User Initial Stack & Heap
|
||||||
|
|
||||||
|
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 PROC
|
||||||
|
LDR R0, =Heap_Mem
|
||||||
|
LDR R1, =(Stack_Mem + Stack_Size)
|
||||||
|
LDR R2, =(Heap_Mem + Heap_Size)
|
||||||
|
LDR R3, =Stack_Mem
|
||||||
|
BX LR
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
ALIGN
|
||||||
|
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
; [] END OF FILE
|
696
2020TPCApp0.cydsn/mdk/startup_psoc6_01_cm4.s
Normal file
696
2020TPCApp0.cydsn/mdk/startup_psoc6_01_cm4.s
Normal file
|
@ -0,0 +1,696 @@
|
||||||
|
;/**************************************************************************//**
|
||||||
|
; * @file startup_psoc6_01_cm4.s
|
||||||
|
; * @brief CMSIS Core Device Startup File for
|
||||||
|
; * ARMCM4 Device Series
|
||||||
|
; * @version V5.00
|
||||||
|
; * @date 02. March 2016
|
||||||
|
; ******************************************************************************/
|
||||||
|
;/*
|
||||||
|
; * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
|
||||||
|
; *
|
||||||
|
; * SPDX-License-Identifier: Apache-2.0
|
||||||
|
; *
|
||||||
|
; * Licensed under the Apache License, Version 2.0 (the License); you may
|
||||||
|
; * not use this file except in compliance with the License.
|
||||||
|
; * You may obtain a copy of the License at
|
||||||
|
; *
|
||||||
|
; * www.apache.org/licenses/LICENSE-2.0
|
||||||
|
; *
|
||||||
|
; * Unless required by applicable law or agreed to in writing, software
|
||||||
|
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||||
|
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
; * See the License for the specific language governing permissions and
|
||||||
|
; * limitations under the License.
|
||||||
|
; */
|
||||||
|
|
||||||
|
;/*
|
||||||
|
;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
|
||||||
|
;*/
|
||||||
|
|
||||||
|
; <h> Stack Configuration
|
||||||
|
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||||
|
; </h>
|
||||||
|
IF :DEF:__STACK_SIZE
|
||||||
|
Stack_Size EQU __STACK_SIZE
|
||||||
|
ELSE
|
||||||
|
Stack_Size EQU 0x00001000
|
||||||
|
ENDIF
|
||||||
|
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>
|
||||||
|
IF :DEF:__HEAP_SIZE
|
||||||
|
Heap_Size EQU __HEAP_SIZE
|
||||||
|
ELSE
|
||||||
|
Heap_Size EQU 0x00000400
|
||||||
|
ENDIF
|
||||||
|
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 0x0000000D ; NMI Handler located at ROM code
|
||||||
|
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 Power Mode Description
|
||||||
|
DCD ioss_interrupts_gpio_0_IRQHandler ; GPIO Port Interrupt #0
|
||||||
|
DCD ioss_interrupts_gpio_1_IRQHandler ; GPIO Port Interrupt #1
|
||||||
|
DCD ioss_interrupts_gpio_2_IRQHandler ; GPIO Port Interrupt #2
|
||||||
|
DCD ioss_interrupts_gpio_3_IRQHandler ; GPIO Port Interrupt #3
|
||||||
|
DCD ioss_interrupts_gpio_4_IRQHandler ; GPIO Port Interrupt #4
|
||||||
|
DCD ioss_interrupts_gpio_5_IRQHandler ; GPIO Port Interrupt #5
|
||||||
|
DCD ioss_interrupts_gpio_6_IRQHandler ; GPIO Port Interrupt #6
|
||||||
|
DCD ioss_interrupts_gpio_7_IRQHandler ; GPIO Port Interrupt #7
|
||||||
|
DCD ioss_interrupts_gpio_8_IRQHandler ; GPIO Port Interrupt #8
|
||||||
|
DCD ioss_interrupts_gpio_9_IRQHandler ; GPIO Port Interrupt #9
|
||||||
|
DCD ioss_interrupts_gpio_10_IRQHandler ; GPIO Port Interrupt #10
|
||||||
|
DCD ioss_interrupts_gpio_11_IRQHandler ; GPIO Port Interrupt #11
|
||||||
|
DCD ioss_interrupts_gpio_12_IRQHandler ; GPIO Port Interrupt #12
|
||||||
|
DCD ioss_interrupts_gpio_13_IRQHandler ; GPIO Port Interrupt #13
|
||||||
|
DCD ioss_interrupts_gpio_14_IRQHandler ; GPIO Port Interrupt #14
|
||||||
|
DCD ioss_interrupt_gpio_IRQHandler ; GPIO All Ports
|
||||||
|
DCD ioss_interrupt_vdd_IRQHandler ; GPIO Supply Detect Interrupt
|
||||||
|
DCD lpcomp_interrupt_IRQHandler ; Low Power Comparator Interrupt
|
||||||
|
DCD scb_8_interrupt_IRQHandler ; Serial Communication Block #8 (DeepSleep capable)
|
||||||
|
DCD srss_interrupt_mcwdt_0_IRQHandler ; Multi Counter Watchdog Timer interrupt
|
||||||
|
DCD srss_interrupt_mcwdt_1_IRQHandler ; Multi Counter Watchdog Timer interrupt
|
||||||
|
DCD srss_interrupt_backup_IRQHandler ; Backup domain interrupt
|
||||||
|
DCD srss_interrupt_IRQHandler ; Other combined Interrupts for SRSS (LVD, WDT, CLKCAL)
|
||||||
|
DCD pass_interrupt_ctbs_IRQHandler ; CTBm Interrupt (all CTBms)
|
||||||
|
DCD bless_interrupt_IRQHandler ; Bluetooth Radio interrupt
|
||||||
|
DCD cpuss_interrupts_ipc_0_IRQHandler ; CPUSS Inter Process Communication Interrupt #0
|
||||||
|
DCD cpuss_interrupts_ipc_1_IRQHandler ; CPUSS Inter Process Communication Interrupt #1
|
||||||
|
DCD cpuss_interrupts_ipc_2_IRQHandler ; CPUSS Inter Process Communication Interrupt #2
|
||||||
|
DCD cpuss_interrupts_ipc_3_IRQHandler ; CPUSS Inter Process Communication Interrupt #3
|
||||||
|
DCD cpuss_interrupts_ipc_4_IRQHandler ; CPUSS Inter Process Communication Interrupt #4
|
||||||
|
DCD cpuss_interrupts_ipc_5_IRQHandler ; CPUSS Inter Process Communication Interrupt #5
|
||||||
|
DCD cpuss_interrupts_ipc_6_IRQHandler ; CPUSS Inter Process Communication Interrupt #6
|
||||||
|
DCD cpuss_interrupts_ipc_7_IRQHandler ; CPUSS Inter Process Communication Interrupt #7
|
||||||
|
DCD cpuss_interrupts_ipc_8_IRQHandler ; CPUSS Inter Process Communication Interrupt #8
|
||||||
|
DCD cpuss_interrupts_ipc_9_IRQHandler ; CPUSS Inter Process Communication Interrupt #9
|
||||||
|
DCD cpuss_interrupts_ipc_10_IRQHandler ; CPUSS Inter Process Communication Interrupt #10
|
||||||
|
DCD cpuss_interrupts_ipc_11_IRQHandler ; CPUSS Inter Process Communication Interrupt #11
|
||||||
|
DCD cpuss_interrupts_ipc_12_IRQHandler ; CPUSS Inter Process Communication Interrupt #12
|
||||||
|
DCD cpuss_interrupts_ipc_13_IRQHandler ; CPUSS Inter Process Communication Interrupt #13
|
||||||
|
DCD cpuss_interrupts_ipc_14_IRQHandler ; CPUSS Inter Process Communication Interrupt #14
|
||||||
|
DCD cpuss_interrupts_ipc_15_IRQHandler ; CPUSS Inter Process Communication Interrupt #15
|
||||||
|
DCD scb_0_interrupt_IRQHandler ; Serial Communication Block #0
|
||||||
|
DCD scb_1_interrupt_IRQHandler ; Serial Communication Block #1
|
||||||
|
DCD scb_2_interrupt_IRQHandler ; Serial Communication Block #2
|
||||||
|
DCD scb_3_interrupt_IRQHandler ; Serial Communication Block #3
|
||||||
|
DCD scb_4_interrupt_IRQHandler ; Serial Communication Block #4
|
||||||
|
DCD scb_5_interrupt_IRQHandler ; Serial Communication Block #5
|
||||||
|
DCD scb_6_interrupt_IRQHandler ; Serial Communication Block #6
|
||||||
|
DCD scb_7_interrupt_IRQHandler ; Serial Communication Block #7
|
||||||
|
DCD csd_interrupt_IRQHandler ; CSD (Capsense) interrupt
|
||||||
|
DCD cpuss_interrupts_dw0_0_IRQHandler ; CPUSS DataWire #0, Channel #0
|
||||||
|
DCD cpuss_interrupts_dw0_1_IRQHandler ; CPUSS DataWire #0, Channel #1
|
||||||
|
DCD cpuss_interrupts_dw0_2_IRQHandler ; CPUSS DataWire #0, Channel #2
|
||||||
|
DCD cpuss_interrupts_dw0_3_IRQHandler ; CPUSS DataWire #0, Channel #3
|
||||||
|
DCD cpuss_interrupts_dw0_4_IRQHandler ; CPUSS DataWire #0, Channel #4
|
||||||
|
DCD cpuss_interrupts_dw0_5_IRQHandler ; CPUSS DataWire #0, Channel #5
|
||||||
|
DCD cpuss_interrupts_dw0_6_IRQHandler ; CPUSS DataWire #0, Channel #6
|
||||||
|
DCD cpuss_interrupts_dw0_7_IRQHandler ; CPUSS DataWire #0, Channel #7
|
||||||
|
DCD cpuss_interrupts_dw0_8_IRQHandler ; CPUSS DataWire #0, Channel #8
|
||||||
|
DCD cpuss_interrupts_dw0_9_IRQHandler ; CPUSS DataWire #0, Channel #9
|
||||||
|
DCD cpuss_interrupts_dw0_10_IRQHandler ; CPUSS DataWire #0, Channel #10
|
||||||
|
DCD cpuss_interrupts_dw0_11_IRQHandler ; CPUSS DataWire #0, Channel #11
|
||||||
|
DCD cpuss_interrupts_dw0_12_IRQHandler ; CPUSS DataWire #0, Channel #12
|
||||||
|
DCD cpuss_interrupts_dw0_13_IRQHandler ; CPUSS DataWire #0, Channel #13
|
||||||
|
DCD cpuss_interrupts_dw0_14_IRQHandler ; CPUSS DataWire #0, Channel #14
|
||||||
|
DCD cpuss_interrupts_dw0_15_IRQHandler ; CPUSS DataWire #0, Channel #15
|
||||||
|
DCD cpuss_interrupts_dw1_0_IRQHandler ; CPUSS DataWire #1, Channel #0
|
||||||
|
DCD cpuss_interrupts_dw1_1_IRQHandler ; CPUSS DataWire #1, Channel #1
|
||||||
|
DCD cpuss_interrupts_dw1_2_IRQHandler ; CPUSS DataWire #1, Channel #2
|
||||||
|
DCD cpuss_interrupts_dw1_3_IRQHandler ; CPUSS DataWire #1, Channel #3
|
||||||
|
DCD cpuss_interrupts_dw1_4_IRQHandler ; CPUSS DataWire #1, Channel #4
|
||||||
|
DCD cpuss_interrupts_dw1_5_IRQHandler ; CPUSS DataWire #1, Channel #5
|
||||||
|
DCD cpuss_interrupts_dw1_6_IRQHandler ; CPUSS DataWire #1, Channel #6
|
||||||
|
DCD cpuss_interrupts_dw1_7_IRQHandler ; CPUSS DataWire #1, Channel #7
|
||||||
|
DCD cpuss_interrupts_dw1_8_IRQHandler ; CPUSS DataWire #1, Channel #8
|
||||||
|
DCD cpuss_interrupts_dw1_9_IRQHandler ; CPUSS DataWire #1, Channel #9
|
||||||
|
DCD cpuss_interrupts_dw1_10_IRQHandler ; CPUSS DataWire #1, Channel #10
|
||||||
|
DCD cpuss_interrupts_dw1_11_IRQHandler ; CPUSS DataWire #1, Channel #11
|
||||||
|
DCD cpuss_interrupts_dw1_12_IRQHandler ; CPUSS DataWire #1, Channel #12
|
||||||
|
DCD cpuss_interrupts_dw1_13_IRQHandler ; CPUSS DataWire #1, Channel #13
|
||||||
|
DCD cpuss_interrupts_dw1_14_IRQHandler ; CPUSS DataWire #1, Channel #14
|
||||||
|
DCD cpuss_interrupts_dw1_15_IRQHandler ; CPUSS DataWire #1, Channel #15
|
||||||
|
DCD cpuss_interrupts_fault_0_IRQHandler ; CPUSS Fault Structure Interrupt #0
|
||||||
|
DCD cpuss_interrupts_fault_1_IRQHandler ; CPUSS Fault Structure Interrupt #1
|
||||||
|
DCD cpuss_interrupt_crypto_IRQHandler ; CRYPTO Accelerator Interrupt
|
||||||
|
DCD cpuss_interrupt_fm_IRQHandler ; FLASH Macro Interrupt
|
||||||
|
DCD cpuss_interrupts_cm0_cti_0_IRQHandler ; CM0+ CTI #0
|
||||||
|
DCD cpuss_interrupts_cm0_cti_1_IRQHandler ; CM0+ CTI #1
|
||||||
|
DCD cpuss_interrupts_cm4_cti_0_IRQHandler ; CM4 CTI #0
|
||||||
|
DCD cpuss_interrupts_cm4_cti_1_IRQHandler ; CM4 CTI #1
|
||||||
|
DCD tcpwm_0_interrupts_0_IRQHandler ; TCPWM #0, Counter #0
|
||||||
|
DCD tcpwm_0_interrupts_1_IRQHandler ; TCPWM #0, Counter #1
|
||||||
|
DCD tcpwm_0_interrupts_2_IRQHandler ; TCPWM #0, Counter #2
|
||||||
|
DCD tcpwm_0_interrupts_3_IRQHandler ; TCPWM #0, Counter #3
|
||||||
|
DCD tcpwm_0_interrupts_4_IRQHandler ; TCPWM #0, Counter #4
|
||||||
|
DCD tcpwm_0_interrupts_5_IRQHandler ; TCPWM #0, Counter #5
|
||||||
|
DCD tcpwm_0_interrupts_6_IRQHandler ; TCPWM #0, Counter #6
|
||||||
|
DCD tcpwm_0_interrupts_7_IRQHandler ; TCPWM #0, Counter #7
|
||||||
|
DCD tcpwm_1_interrupts_0_IRQHandler ; TCPWM #1, Counter #0
|
||||||
|
DCD tcpwm_1_interrupts_1_IRQHandler ; TCPWM #1, Counter #1
|
||||||
|
DCD tcpwm_1_interrupts_2_IRQHandler ; TCPWM #1, Counter #2
|
||||||
|
DCD tcpwm_1_interrupts_3_IRQHandler ; TCPWM #1, Counter #3
|
||||||
|
DCD tcpwm_1_interrupts_4_IRQHandler ; TCPWM #1, Counter #4
|
||||||
|
DCD tcpwm_1_interrupts_5_IRQHandler ; TCPWM #1, Counter #5
|
||||||
|
DCD tcpwm_1_interrupts_6_IRQHandler ; TCPWM #1, Counter #6
|
||||||
|
DCD tcpwm_1_interrupts_7_IRQHandler ; TCPWM #1, Counter #7
|
||||||
|
DCD tcpwm_1_interrupts_8_IRQHandler ; TCPWM #1, Counter #8
|
||||||
|
DCD tcpwm_1_interrupts_9_IRQHandler ; TCPWM #1, Counter #9
|
||||||
|
DCD tcpwm_1_interrupts_10_IRQHandler ; TCPWM #1, Counter #10
|
||||||
|
DCD tcpwm_1_interrupts_11_IRQHandler ; TCPWM #1, Counter #11
|
||||||
|
DCD tcpwm_1_interrupts_12_IRQHandler ; TCPWM #1, Counter #12
|
||||||
|
DCD tcpwm_1_interrupts_13_IRQHandler ; TCPWM #1, Counter #13
|
||||||
|
DCD tcpwm_1_interrupts_14_IRQHandler ; TCPWM #1, Counter #14
|
||||||
|
DCD tcpwm_1_interrupts_15_IRQHandler ; TCPWM #1, Counter #15
|
||||||
|
DCD tcpwm_1_interrupts_16_IRQHandler ; TCPWM #1, Counter #16
|
||||||
|
DCD tcpwm_1_interrupts_17_IRQHandler ; TCPWM #1, Counter #17
|
||||||
|
DCD tcpwm_1_interrupts_18_IRQHandler ; TCPWM #1, Counter #18
|
||||||
|
DCD tcpwm_1_interrupts_19_IRQHandler ; TCPWM #1, Counter #19
|
||||||
|
DCD tcpwm_1_interrupts_20_IRQHandler ; TCPWM #1, Counter #20
|
||||||
|
DCD tcpwm_1_interrupts_21_IRQHandler ; TCPWM #1, Counter #21
|
||||||
|
DCD tcpwm_1_interrupts_22_IRQHandler ; TCPWM #1, Counter #22
|
||||||
|
DCD tcpwm_1_interrupts_23_IRQHandler ; TCPWM #1, Counter #23
|
||||||
|
DCD udb_interrupts_0_IRQHandler ; UDB Interrupt #0
|
||||||
|
DCD udb_interrupts_1_IRQHandler ; UDB Interrupt #1
|
||||||
|
DCD udb_interrupts_2_IRQHandler ; UDB Interrupt #2
|
||||||
|
DCD udb_interrupts_3_IRQHandler ; UDB Interrupt #3
|
||||||
|
DCD udb_interrupts_4_IRQHandler ; UDB Interrupt #4
|
||||||
|
DCD udb_interrupts_5_IRQHandler ; UDB Interrupt #5
|
||||||
|
DCD udb_interrupts_6_IRQHandler ; UDB Interrupt #6
|
||||||
|
DCD udb_interrupts_7_IRQHandler ; UDB Interrupt #7
|
||||||
|
DCD udb_interrupts_8_IRQHandler ; UDB Interrupt #8
|
||||||
|
DCD udb_interrupts_9_IRQHandler ; UDB Interrupt #9
|
||||||
|
DCD udb_interrupts_10_IRQHandler ; UDB Interrupt #10
|
||||||
|
DCD udb_interrupts_11_IRQHandler ; UDB Interrupt #11
|
||||||
|
DCD udb_interrupts_12_IRQHandler ; UDB Interrupt #12
|
||||||
|
DCD udb_interrupts_13_IRQHandler ; UDB Interrupt #13
|
||||||
|
DCD udb_interrupts_14_IRQHandler ; UDB Interrupt #14
|
||||||
|
DCD udb_interrupts_15_IRQHandler ; UDB Interrupt #15
|
||||||
|
DCD pass_interrupt_sar_IRQHandler ; SAR ADC interrupt
|
||||||
|
DCD audioss_interrupt_i2s_IRQHandler ; I2S Audio interrupt
|
||||||
|
DCD audioss_interrupt_pdm_IRQHandler ; PDM/PCM Audio interrupt
|
||||||
|
DCD profile_interrupt_IRQHandler ; Energy Profiler interrupt
|
||||||
|
DCD smif_interrupt_IRQHandler ; Serial Memory Interface interrupt
|
||||||
|
DCD usb_interrupt_hi_IRQHandler ; USB Interrupt
|
||||||
|
DCD usb_interrupt_med_IRQHandler ; USB Interrupt
|
||||||
|
DCD usb_interrupt_lo_IRQHandler ; USB Interrupt
|
||||||
|
DCD pass_interrupt_dacs_IRQHandler ; Consolidated interrrupt for all DACs
|
||||||
|
|
||||||
|
__Vectors_End
|
||||||
|
|
||||||
|
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||||
|
|
||||||
|
EXPORT __ramVectors
|
||||||
|
AREA RESET_RAM, READWRITE, NOINIT
|
||||||
|
__ramVectors SPACE __Vectors_Size
|
||||||
|
|
||||||
|
|
||||||
|
AREA |.text|, CODE, READONLY
|
||||||
|
|
||||||
|
|
||||||
|
; Weak function for startup customization
|
||||||
|
;
|
||||||
|
; Note. The global resources are not yet initialized (for example global variables, peripherals, clocks)
|
||||||
|
; because this function is executed as the first instruction in the ResetHandler.
|
||||||
|
; The PDL is also not initialized to use the proper register offsets.
|
||||||
|
; The user of this function is responsible for initializing the PDL and resources before using them.
|
||||||
|
;
|
||||||
|
Cy_OnResetUser PROC
|
||||||
|
EXPORT Cy_OnResetUser [WEAK]
|
||||||
|
BX LR
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
|
||||||
|
; Reset Handler
|
||||||
|
Reset_Handler PROC
|
||||||
|
EXPORT Reset_Handler [WEAK]
|
||||||
|
IMPORT Cy_SystemInitFpuEnable
|
||||||
|
IMPORT __main
|
||||||
|
|
||||||
|
; Define strong function for startup customization
|
||||||
|
BL Cy_OnResetUser
|
||||||
|
|
||||||
|
; Disable global interrupts
|
||||||
|
CPSID I
|
||||||
|
|
||||||
|
; Copy vectors from ROM to RAM
|
||||||
|
LDR r1, =__Vectors
|
||||||
|
LDR r0, =__ramVectors
|
||||||
|
LDR r2, =__Vectors_Size
|
||||||
|
Vectors_Copy
|
||||||
|
LDR r3, [r1]
|
||||||
|
STR r3, [r0]
|
||||||
|
ADDS r0, r0, #4
|
||||||
|
ADDS r1, r1, #4
|
||||||
|
SUBS r2, r2, #1
|
||||||
|
CMP r2, #0
|
||||||
|
BNE Vectors_Copy
|
||||||
|
|
||||||
|
; Update Vector Table Offset Register. */
|
||||||
|
LDR r0, =__ramVectors
|
||||||
|
LDR r1, =0xE000ED08
|
||||||
|
STR r0, [r1]
|
||||||
|
dsb 0xF
|
||||||
|
|
||||||
|
; Enable the FPU if used
|
||||||
|
LDR R0, =Cy_SystemInitFpuEnable
|
||||||
|
BLX R0
|
||||||
|
|
||||||
|
LDR R0, =__main
|
||||||
|
BLX R0
|
||||||
|
|
||||||
|
; Should never get here
|
||||||
|
B .
|
||||||
|
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||||
|
NMI_Handler PROC
|
||||||
|
EXPORT NMI_Handler [WEAK]
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
Cy_SysLib_FaultHandler PROC
|
||||||
|
EXPORT Cy_SysLib_FaultHandler [WEAK]
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
HardFault_Wrapper\
|
||||||
|
PROC
|
||||||
|
EXPORT HardFault_Wrapper [WEAK]
|
||||||
|
movs r0, #4
|
||||||
|
mov r1, LR
|
||||||
|
tst r0, r1
|
||||||
|
beq L_MSP
|
||||||
|
mrs r0, PSP
|
||||||
|
bl L_API_call
|
||||||
|
L_MSP
|
||||||
|
mrs r0, MSP
|
||||||
|
L_API_call
|
||||||
|
bl Cy_SysLib_FaultHandler
|
||||||
|
ENDP
|
||||||
|
HardFault_Handler\
|
||||||
|
PROC
|
||||||
|
EXPORT HardFault_Handler [WEAK]
|
||||||
|
B HardFault_Wrapper
|
||||||
|
ENDP
|
||||||
|
MemManage_Handler\
|
||||||
|
PROC
|
||||||
|
EXPORT MemManage_Handler [WEAK]
|
||||||
|
B HardFault_Wrapper
|
||||||
|
ENDP
|
||||||
|
BusFault_Handler\
|
||||||
|
PROC
|
||||||
|
EXPORT BusFault_Handler [WEAK]
|
||||||
|
B HardFault_Wrapper
|
||||||
|
ENDP
|
||||||
|
UsageFault_Handler\
|
||||||
|
PROC
|
||||||
|
EXPORT UsageFault_Handler [WEAK]
|
||||||
|
B HardFault_Wrapper
|
||||||
|
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 Default_Handler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_0_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_1_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_2_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_3_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_4_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_5_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_6_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_7_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_8_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_9_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_10_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_11_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_12_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_13_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupts_gpio_14_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupt_gpio_IRQHandler [WEAK]
|
||||||
|
EXPORT ioss_interrupt_vdd_IRQHandler [WEAK]
|
||||||
|
EXPORT lpcomp_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT scb_8_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT srss_interrupt_mcwdt_0_IRQHandler [WEAK]
|
||||||
|
EXPORT srss_interrupt_mcwdt_1_IRQHandler [WEAK]
|
||||||
|
EXPORT srss_interrupt_backup_IRQHandler [WEAK]
|
||||||
|
EXPORT srss_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT pass_interrupt_ctbs_IRQHandler [WEAK]
|
||||||
|
EXPORT bless_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_0_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_1_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_2_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_3_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_4_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_5_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_6_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_7_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_8_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_9_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_10_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_11_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_12_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_13_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_14_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_ipc_15_IRQHandler [WEAK]
|
||||||
|
EXPORT scb_0_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT scb_1_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT scb_2_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT scb_3_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT scb_4_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT scb_5_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT scb_6_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT scb_7_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT csd_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_0_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_1_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_2_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_3_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_4_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_5_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_6_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_7_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_8_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_9_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_10_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_11_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_12_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_13_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_14_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw0_15_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_0_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_1_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_2_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_3_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_4_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_5_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_6_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_7_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_8_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_9_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_10_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_11_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_12_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_13_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_14_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_dw1_15_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_fault_0_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_fault_1_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupt_crypto_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupt_fm_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_cm0_cti_0_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_cm0_cti_1_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_cm4_cti_0_IRQHandler [WEAK]
|
||||||
|
EXPORT cpuss_interrupts_cm4_cti_1_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_0_interrupts_0_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_0_interrupts_1_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_0_interrupts_2_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_0_interrupts_3_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_0_interrupts_4_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_0_interrupts_5_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_0_interrupts_6_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_0_interrupts_7_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_0_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_1_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_2_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_3_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_4_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_5_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_6_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_7_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_8_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_9_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_10_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_11_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_12_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_13_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_14_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_15_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_16_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_17_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_18_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_19_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_20_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_21_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_22_IRQHandler [WEAK]
|
||||||
|
EXPORT tcpwm_1_interrupts_23_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_0_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_1_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_2_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_3_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_4_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_5_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_6_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_7_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_8_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_9_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_10_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_11_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_12_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_13_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_14_IRQHandler [WEAK]
|
||||||
|
EXPORT udb_interrupts_15_IRQHandler [WEAK]
|
||||||
|
EXPORT pass_interrupt_sar_IRQHandler [WEAK]
|
||||||
|
EXPORT audioss_interrupt_i2s_IRQHandler [WEAK]
|
||||||
|
EXPORT audioss_interrupt_pdm_IRQHandler [WEAK]
|
||||||
|
EXPORT profile_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT smif_interrupt_IRQHandler [WEAK]
|
||||||
|
EXPORT usb_interrupt_hi_IRQHandler [WEAK]
|
||||||
|
EXPORT usb_interrupt_med_IRQHandler [WEAK]
|
||||||
|
EXPORT usb_interrupt_lo_IRQHandler [WEAK]
|
||||||
|
EXPORT pass_interrupt_dacs_IRQHandler [WEAK]
|
||||||
|
|
||||||
|
ioss_interrupts_gpio_0_IRQHandler
|
||||||
|
ioss_interrupts_gpio_1_IRQHandler
|
||||||
|
ioss_interrupts_gpio_2_IRQHandler
|
||||||
|
ioss_interrupts_gpio_3_IRQHandler
|
||||||
|
ioss_interrupts_gpio_4_IRQHandler
|
||||||
|
ioss_interrupts_gpio_5_IRQHandler
|
||||||
|
ioss_interrupts_gpio_6_IRQHandler
|
||||||
|
ioss_interrupts_gpio_7_IRQHandler
|
||||||
|
ioss_interrupts_gpio_8_IRQHandler
|
||||||
|
ioss_interrupts_gpio_9_IRQHandler
|
||||||
|
ioss_interrupts_gpio_10_IRQHandler
|
||||||
|
ioss_interrupts_gpio_11_IRQHandler
|
||||||
|
ioss_interrupts_gpio_12_IRQHandler
|
||||||
|
ioss_interrupts_gpio_13_IRQHandler
|
||||||
|
ioss_interrupts_gpio_14_IRQHandler
|
||||||
|
ioss_interrupt_gpio_IRQHandler
|
||||||
|
ioss_interrupt_vdd_IRQHandler
|
||||||
|
lpcomp_interrupt_IRQHandler
|
||||||
|
scb_8_interrupt_IRQHandler
|
||||||
|
srss_interrupt_mcwdt_0_IRQHandler
|
||||||
|
srss_interrupt_mcwdt_1_IRQHandler
|
||||||
|
srss_interrupt_backup_IRQHandler
|
||||||
|
srss_interrupt_IRQHandler
|
||||||
|
pass_interrupt_ctbs_IRQHandler
|
||||||
|
bless_interrupt_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_0_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_1_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_2_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_3_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_4_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_5_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_6_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_7_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_8_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_9_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_10_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_11_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_12_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_13_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_14_IRQHandler
|
||||||
|
cpuss_interrupts_ipc_15_IRQHandler
|
||||||
|
scb_0_interrupt_IRQHandler
|
||||||
|
scb_1_interrupt_IRQHandler
|
||||||
|
scb_2_interrupt_IRQHandler
|
||||||
|
scb_3_interrupt_IRQHandler
|
||||||
|
scb_4_interrupt_IRQHandler
|
||||||
|
scb_5_interrupt_IRQHandler
|
||||||
|
scb_6_interrupt_IRQHandler
|
||||||
|
scb_7_interrupt_IRQHandler
|
||||||
|
csd_interrupt_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_0_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_1_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_2_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_3_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_4_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_5_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_6_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_7_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_8_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_9_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_10_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_11_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_12_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_13_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_14_IRQHandler
|
||||||
|
cpuss_interrupts_dw0_15_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_0_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_1_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_2_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_3_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_4_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_5_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_6_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_7_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_8_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_9_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_10_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_11_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_12_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_13_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_14_IRQHandler
|
||||||
|
cpuss_interrupts_dw1_15_IRQHandler
|
||||||
|
cpuss_interrupts_fault_0_IRQHandler
|
||||||
|
cpuss_interrupts_fault_1_IRQHandler
|
||||||
|
cpuss_interrupt_crypto_IRQHandler
|
||||||
|
cpuss_interrupt_fm_IRQHandler
|
||||||
|
cpuss_interrupts_cm0_cti_0_IRQHandler
|
||||||
|
cpuss_interrupts_cm0_cti_1_IRQHandler
|
||||||
|
cpuss_interrupts_cm4_cti_0_IRQHandler
|
||||||
|
cpuss_interrupts_cm4_cti_1_IRQHandler
|
||||||
|
tcpwm_0_interrupts_0_IRQHandler
|
||||||
|
tcpwm_0_interrupts_1_IRQHandler
|
||||||
|
tcpwm_0_interrupts_2_IRQHandler
|
||||||
|
tcpwm_0_interrupts_3_IRQHandler
|
||||||
|
tcpwm_0_interrupts_4_IRQHandler
|
||||||
|
tcpwm_0_interrupts_5_IRQHandler
|
||||||
|
tcpwm_0_interrupts_6_IRQHandler
|
||||||
|
tcpwm_0_interrupts_7_IRQHandler
|
||||||
|
tcpwm_1_interrupts_0_IRQHandler
|
||||||
|
tcpwm_1_interrupts_1_IRQHandler
|
||||||
|
tcpwm_1_interrupts_2_IRQHandler
|
||||||
|
tcpwm_1_interrupts_3_IRQHandler
|
||||||
|
tcpwm_1_interrupts_4_IRQHandler
|
||||||
|
tcpwm_1_interrupts_5_IRQHandler
|
||||||
|
tcpwm_1_interrupts_6_IRQHandler
|
||||||
|
tcpwm_1_interrupts_7_IRQHandler
|
||||||
|
tcpwm_1_interrupts_8_IRQHandler
|
||||||
|
tcpwm_1_interrupts_9_IRQHandler
|
||||||
|
tcpwm_1_interrupts_10_IRQHandler
|
||||||
|
tcpwm_1_interrupts_11_IRQHandler
|
||||||
|
tcpwm_1_interrupts_12_IRQHandler
|
||||||
|
tcpwm_1_interrupts_13_IRQHandler
|
||||||
|
tcpwm_1_interrupts_14_IRQHandler
|
||||||
|
tcpwm_1_interrupts_15_IRQHandler
|
||||||
|
tcpwm_1_interrupts_16_IRQHandler
|
||||||
|
tcpwm_1_interrupts_17_IRQHandler
|
||||||
|
tcpwm_1_interrupts_18_IRQHandler
|
||||||
|
tcpwm_1_interrupts_19_IRQHandler
|
||||||
|
tcpwm_1_interrupts_20_IRQHandler
|
||||||
|
tcpwm_1_interrupts_21_IRQHandler
|
||||||
|
tcpwm_1_interrupts_22_IRQHandler
|
||||||
|
tcpwm_1_interrupts_23_IRQHandler
|
||||||
|
udb_interrupts_0_IRQHandler
|
||||||
|
udb_interrupts_1_IRQHandler
|
||||||
|
udb_interrupts_2_IRQHandler
|
||||||
|
udb_interrupts_3_IRQHandler
|
||||||
|
udb_interrupts_4_IRQHandler
|
||||||
|
udb_interrupts_5_IRQHandler
|
||||||
|
udb_interrupts_6_IRQHandler
|
||||||
|
udb_interrupts_7_IRQHandler
|
||||||
|
udb_interrupts_8_IRQHandler
|
||||||
|
udb_interrupts_9_IRQHandler
|
||||||
|
udb_interrupts_10_IRQHandler
|
||||||
|
udb_interrupts_11_IRQHandler
|
||||||
|
udb_interrupts_12_IRQHandler
|
||||||
|
udb_interrupts_13_IRQHandler
|
||||||
|
udb_interrupts_14_IRQHandler
|
||||||
|
udb_interrupts_15_IRQHandler
|
||||||
|
pass_interrupt_sar_IRQHandler
|
||||||
|
audioss_interrupt_i2s_IRQHandler
|
||||||
|
audioss_interrupt_pdm_IRQHandler
|
||||||
|
profile_interrupt_IRQHandler
|
||||||
|
smif_interrupt_IRQHandler
|
||||||
|
usb_interrupt_hi_IRQHandler
|
||||||
|
usb_interrupt_med_IRQHandler
|
||||||
|
usb_interrupt_lo_IRQHandler
|
||||||
|
pass_interrupt_dacs_IRQHandler
|
||||||
|
|
||||||
|
B .
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
ALIGN
|
||||||
|
|
||||||
|
|
||||||
|
; User Initial Stack & Heap
|
||||||
|
|
||||||
|
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 PROC
|
||||||
|
LDR R0, = Heap_Mem
|
||||||
|
LDR R1, =(Stack_Mem + Stack_Size)
|
||||||
|
LDR R2, = (Heap_Mem + Heap_Size)
|
||||||
|
LDR R3, = Stack_Mem
|
||||||
|
BX LR
|
||||||
|
ENDP
|
||||||
|
|
||||||
|
ALIGN
|
||||||
|
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
; [] END OF FILE
|
42
2020TPCApp0.cydsn/post_build_core1.bat
Normal file
42
2020TPCApp0.cydsn/post_build_core1.bat
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
@rem Usage:
|
||||||
|
@rem Call post_build_core1.bat <tool> <output_dir> <project_short_name>
|
||||||
|
@rem E.g. in PSoC Creator 4.2:
|
||||||
|
@rem post_build_core1.bat creator ${OutputDir} ${ProjectShortName}
|
||||||
|
|
||||||
|
@echo ------------------------------------------
|
||||||
|
@echo Post-build commands for Cortex-M4 core
|
||||||
|
@echo ------------------------------------------
|
||||||
|
|
||||||
|
@rem Set proper path to your PDL 3.x and above installation
|
||||||
|
@set PDL_PATH="C:\Program Files (x86)\Cypress\PDL\3.1.7"
|
||||||
|
|
||||||
|
@set CY_MCU_ELF_TOOL=%PDL_PATH%"\tools\win\elf\cymcuelftool.exe"
|
||||||
|
|
||||||
|
@set IDE=%1
|
||||||
|
|
||||||
|
@if "%IDE%" == "creator" (
|
||||||
|
@set OUTPUT_DIR=%2
|
||||||
|
@set PRJ_NAME=%3
|
||||||
|
@set ELF_EXT=.elf
|
||||||
|
)
|
||||||
|
|
||||||
|
@if "%IDE%" == "uvision" (
|
||||||
|
@set OUTPUT_DIR=%2
|
||||||
|
@set PRJ_NAME=%3
|
||||||
|
@set ELF_EXT=.axf
|
||||||
|
)
|
||||||
|
|
||||||
|
@if "%IDE%" == "iar" (
|
||||||
|
@set OUTPUT_DIR=%2
|
||||||
|
@set PRJ_NAME=%3
|
||||||
|
@set ELF_EXT=.out
|
||||||
|
)
|
||||||
|
|
||||||
|
@if "%IDE%" == "eclipse" (
|
||||||
|
@set OUTPUT_DIR=%2
|
||||||
|
@set PRJ_NAME=%3
|
||||||
|
@set ELF_EXT=
|
||||||
|
)
|
||||||
|
|
||||||
|
@rem Sign the application with the RSA private key
|
||||||
|
%CY_MCU_ELF_TOOL% -S %OUTPUT_DIR%\%PRJ_NAME%%ELF_EXT% SHA256 --encrypt RSASSA-PKCS --key ..\Keys\rsa_private.txt --output %OUTPUT_DIR%\%PRJ_NAME%_RSA%ELF_EXT% --hex %OUTPUT_DIR%\%PRJ_NAME%.hex
|
254
2020TPCApp0.cydsn/rsa_to_c.py
Normal file
254
2020TPCApp0.cydsn/rsa_to_c.py
Normal file
|
@ -0,0 +1,254 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
""" This script may be used to generate RSA public key modulus, exponent, and
|
||||||
|
additional coefficients. Additional coefficients are optional and are used
|
||||||
|
only to increase RSA calculation performance up to 4 times.
|
||||||
|
|
||||||
|
The format of output may be defined by command line arguments and is either
|
||||||
|
the raw HEX data, or the array.
|
||||||
|
|
||||||
|
Copyright (C) 2017-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
|
||||||
|
You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
the software package with which this file was provided.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys, subprocess, os
|
||||||
|
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
integer_types = (int, long,)
|
||||||
|
## Used in convert_hexstr_to_list
|
||||||
|
else:
|
||||||
|
integer_types = (int,)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
""" Main function
|
||||||
|
|
||||||
|
Build the strings to print out the public key modulus and exponent.
|
||||||
|
"""
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print("Usage: %s <public_key_file_name> [-norev] [-out <file_name>]" % sys.argv[0])
|
||||||
|
return 1
|
||||||
|
isReverse = True
|
||||||
|
out_file_name = ''
|
||||||
|
for idx in range(len(sys.argv)):
|
||||||
|
if "-norev" == sys.argv[idx]:
|
||||||
|
isReverse = False
|
||||||
|
if "-out" == sys.argv[idx]:
|
||||||
|
out_file_name = sys.argv[idx+1]
|
||||||
|
|
||||||
|
modulus_list = [] # list to collect bytes of modulus
|
||||||
|
rsaExp = "" # string that will contain the parsed RSA exponent
|
||||||
|
key_len = 0 # containt the length in bits of an RSA modulus
|
||||||
|
|
||||||
|
try:
|
||||||
|
# build openssl command line
|
||||||
|
cmd_line = ['openssl', 'rsa', '-text', '-pubin', '-in',
|
||||||
|
sys.argv[1],
|
||||||
|
'-noout']
|
||||||
|
output, error = subprocess.Popen(
|
||||||
|
cmd_line, universal_newlines=True,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
|
||||||
|
|
||||||
|
# check for errors (warnings ignored)
|
||||||
|
lines = error.split("\n")
|
||||||
|
error_lines = []
|
||||||
|
for line in lines:
|
||||||
|
if (len(line) != 0) and (("WARNING:" in line) == False):
|
||||||
|
error_lines.append(line)
|
||||||
|
if len(error_lines) != 0:
|
||||||
|
print ("OpenSSL call failed" + "\n" + " ".join(cmd_line) + "\n" + str(error_lines) )
|
||||||
|
return 1
|
||||||
|
|
||||||
|
modulus_found = False
|
||||||
|
for line in output.split("\n"):
|
||||||
|
if "Public-Key" in line:
|
||||||
|
# get length of RSA modulus
|
||||||
|
key_len = int(line.split(" ")[1].replace("(", ''))
|
||||||
|
if "Modulus" in line:
|
||||||
|
# modulus record is found
|
||||||
|
modulus_found = True; continue
|
||||||
|
if "Exponent" in line:
|
||||||
|
modulus_found = False
|
||||||
|
# Exponent record is found
|
||||||
|
rsaExp = line.split(" ")[2][1:-1]
|
||||||
|
if modulus_found:
|
||||||
|
# Collect bytes of modulus to list
|
||||||
|
modulus_list = modulus_list + line.strip().split(":")
|
||||||
|
except subprocess.CalledProcessError as err:
|
||||||
|
print ("OpenSSL call failed with errorcode=" + str(err.returncode) \
|
||||||
|
+ "\n" + str(err.cmd) + "\n" + str(err.output))
|
||||||
|
return 1
|
||||||
|
|
||||||
|
#normalize data
|
||||||
|
# remove empty strings from modulus_list
|
||||||
|
modulus_list = [i for i in modulus_list if i]
|
||||||
|
if (len(modulus_list) == key_len // 8 + 1) and (int(modulus_list[0]) == 0):
|
||||||
|
# remove first zero byte
|
||||||
|
modulus_list.pop(0)
|
||||||
|
|
||||||
|
# Check parsed data
|
||||||
|
if not key_len:
|
||||||
|
print ("Key length was not gotten by parsing." )
|
||||||
|
return 1
|
||||||
|
if len(modulus_list) != (key_len // 8):
|
||||||
|
print ("Length of parsed Modulus (%s) is not equal to Key length (%s)." % (key_len, len(modulus_list) * 8))
|
||||||
|
return 1
|
||||||
|
|
||||||
|
modulus_hex_str = "".join(modulus_list)
|
||||||
|
(barret, inv_modulo, r_bar) = calculate_additional_rsa_key_coefs(modulus_hex_str)
|
||||||
|
|
||||||
|
barret_list = convert_hexstr_to_list(barret, isReverse)
|
||||||
|
# add three zero bytes
|
||||||
|
barret_list = ([0]*3 + barret_list) if not isReverse else (barret_list + [0]*3)
|
||||||
|
|
||||||
|
barret_str = build_returned_string(barret_list)
|
||||||
|
barret_str = ".barrettData =\n{\n%s\n}," % barret_str
|
||||||
|
|
||||||
|
inv_modulo_list = convert_hexstr_to_list(inv_modulo, isReverse)
|
||||||
|
inv_modulo_str = build_returned_string(inv_modulo_list)
|
||||||
|
inv_modulo_str = ".inverseModuloData =\n{\n%s\n}," % inv_modulo_str
|
||||||
|
|
||||||
|
r_bar_list = convert_hexstr_to_list(r_bar, isReverse)
|
||||||
|
r_bar_str = build_returned_string(r_bar_list)
|
||||||
|
r_bar_str = ".rBarData =\n{\n%s\n}," % r_bar_str
|
||||||
|
|
||||||
|
rsaExp_list = convert_hexstr_to_list(rsaExp, isReverse)
|
||||||
|
rsaExp_list_len = len(rsaExp_list)
|
||||||
|
if rsaExp_list_len % 4 != 0:
|
||||||
|
rsaExp_list = ([0]*(4-(rsaExp_list_len % 4)) + rsaExp_list) if not isReverse \
|
||||||
|
else (rsaExp_list + [0]*(4-(rsaExp_list_len % 4)))
|
||||||
|
|
||||||
|
rsaExp_str = build_returned_string(rsaExp_list)
|
||||||
|
rsaExp_str = ".expData =\n{\n%s\n}," % rsaExp_str
|
||||||
|
|
||||||
|
# Check and apply isReverse flag
|
||||||
|
if isReverse:
|
||||||
|
modulus_list.reverse()
|
||||||
|
modulus_str = build_returned_string(modulus_list)
|
||||||
|
modulus_str = ".moduloData =\n{\n%s\n}," % modulus_str
|
||||||
|
|
||||||
|
if not out_file_name:
|
||||||
|
print(modulus_str)
|
||||||
|
print(rsaExp_str)
|
||||||
|
print(barret_str)
|
||||||
|
print(inv_modulo_str)
|
||||||
|
print(r_bar_str)
|
||||||
|
else:
|
||||||
|
with open(out_file_name, 'w') as outfile:
|
||||||
|
outfile.write(modulus_str + "\n")
|
||||||
|
outfile.write(rsaExp_str + "\n")
|
||||||
|
outfile.write(barret_str + "\n")
|
||||||
|
outfile.write(inv_modulo_str + "\n")
|
||||||
|
outfile.write(r_bar_str + "\n")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def extended_euclid(modulo):
|
||||||
|
''' Calculate greatest common divisor (GCD) of two values.
|
||||||
|
Link: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
|
||||||
|
formula to calculate: ax + by - gcd(a,b)
|
||||||
|
parameters:
|
||||||
|
a, b - two values witch is calculated GCD for.
|
||||||
|
return:
|
||||||
|
absolute values of x and y coefficients
|
||||||
|
|
||||||
|
NOTE: pseudo-code of operation:
|
||||||
|
x, lastX = 0, 1
|
||||||
|
y, lastY = 1, 0
|
||||||
|
while (b != 0):
|
||||||
|
q = a // b
|
||||||
|
a, b = b, a % b
|
||||||
|
x, lastX = lastX - q * x, x
|
||||||
|
y, lastY = lastY - q * y, y
|
||||||
|
return (abs(lastX), abs(lastY))
|
||||||
|
'''
|
||||||
|
|
||||||
|
rInv = 1;
|
||||||
|
nInv = 0;
|
||||||
|
modulo_bit_size = modulo.bit_length()
|
||||||
|
|
||||||
|
for i in range(modulo_bit_size):
|
||||||
|
if not (rInv % 2):
|
||||||
|
rInv = rInv // 2
|
||||||
|
nInv = nInv // 2
|
||||||
|
else:
|
||||||
|
rInv = rInv + modulo;
|
||||||
|
rInv = rInv // 2;
|
||||||
|
nInv = nInv // 2;
|
||||||
|
nInv = nInv + (1 << (modulo_bit_size - 1));
|
||||||
|
return rInv, nInv
|
||||||
|
|
||||||
|
|
||||||
|
def calculate_additional_rsa_key_coefs(modulo):
|
||||||
|
''' Calculate three additional coefficients for modulo value of RSA key
|
||||||
|
1. barret_coef - Barrett coefficient. Equation is: barretCoef = floor((2 << (2 * k)) / n);
|
||||||
|
Main article is here: https://en.wikipedia.org/wiki/Barrett_reduction
|
||||||
|
2. r_bar - pre-calculated value. Equation is: r_bar = (1 << k) mod n;
|
||||||
|
3. inverse_modulo - coefficient. It satisfying rr' - nn' = 1, where r = 1 << k;
|
||||||
|
Main article is here: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
|
||||||
|
parameter:
|
||||||
|
modulo - part of RSA key
|
||||||
|
return:
|
||||||
|
tuple( barret_coef, r_bar, inverse_modulo ) as reversed byte arrays;
|
||||||
|
'''
|
||||||
|
if isinstance(modulo, str):
|
||||||
|
modulo = int(modulo, 16)
|
||||||
|
if modulo <= 0:
|
||||||
|
raise ValueError("Modulus must be positive")
|
||||||
|
if modulo & (modulo - 1) == 0:
|
||||||
|
raise ValueError("Modulus must not be a power of 2")
|
||||||
|
|
||||||
|
modulo_len = modulo.bit_length()
|
||||||
|
barret_coef = (1 << (modulo_len * 2)) // modulo
|
||||||
|
r_bar = (1 << modulo_len) % modulo
|
||||||
|
inverse_modulo = extended_euclid(modulo)
|
||||||
|
ret_arrays = (
|
||||||
|
barret_coef,
|
||||||
|
inverse_modulo[1],
|
||||||
|
r_bar
|
||||||
|
)
|
||||||
|
|
||||||
|
return ret_arrays
|
||||||
|
|
||||||
|
|
||||||
|
def convert_hexstr_to_list(s, reversed=False):
|
||||||
|
''' Converts a string likes '0001aaff...' to list [0, 1, 170, 255].
|
||||||
|
Also an input parameter can be an integer, in this case it will be
|
||||||
|
converted to a hex string.
|
||||||
|
parameter:
|
||||||
|
s - string to convert
|
||||||
|
reversed - a returned list have to be reversed
|
||||||
|
return:
|
||||||
|
a list of an integer values
|
||||||
|
'''
|
||||||
|
if isinstance(s, integer_types):
|
||||||
|
s = hex(s)
|
||||||
|
s = s[2 if s.lower().startswith("0x") else 0 : -1 if s.upper().endswith("L") else len(s)]
|
||||||
|
if len(s) % 2 != 0:
|
||||||
|
s = '0' + s
|
||||||
|
l = [int("0x%s" % s[i:i+2], 16) for i in range(0, len(s), 2)]
|
||||||
|
if reversed:
|
||||||
|
l.reverse()
|
||||||
|
return l
|
||||||
|
|
||||||
|
def build_returned_string(inp_list):
|
||||||
|
''' Converts a list to a C-style array of hexadecimal numbers string
|
||||||
|
'''
|
||||||
|
if isinstance(inp_list[0], int):
|
||||||
|
inp_list = ['%02X' % x for x in inp_list]
|
||||||
|
|
||||||
|
tmp_str = " "
|
||||||
|
for idx in range(0, len(inp_list)):
|
||||||
|
if (idx % 8 == 0) and (idx != 0):
|
||||||
|
tmp_str = tmp_str + "\n "
|
||||||
|
tmp_str = tmp_str + ( "0x%02Xu," % int(inp_list[idx], base=16) )
|
||||||
|
if (idx % 8 != 7) and (idx != len(inp_list) - 1):
|
||||||
|
tmp_str = tmp_str + " "
|
||||||
|
|
||||||
|
return tmp_str
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
648
2020TPCApp0.cydsn/system_psoc6.h
Normal file
648
2020TPCApp0.cydsn/system_psoc6.h
Normal file
|
@ -0,0 +1,648 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file system_psoc6.h
|
||||||
|
* \version 2.20
|
||||||
|
*
|
||||||
|
* \brief Device system header file.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _SYSTEM_PSOC6_H_
|
||||||
|
#define _SYSTEM_PSOC6_H_
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup group_system_config
|
||||||
|
* \{
|
||||||
|
* Provides device startup, system configuration, and linker script files.
|
||||||
|
* The system startup provides the followings features:
|
||||||
|
* - See \ref group_system_config_device_initialization for the:
|
||||||
|
* * \ref group_system_config_dual_core_device_initialization
|
||||||
|
* * \ref group_system_config_single_core_device_initialization
|
||||||
|
* - \ref group_system_config_device_memory_definition
|
||||||
|
* - \ref group_system_config_heap_stack_config
|
||||||
|
* - \ref group_system_config_merge_apps
|
||||||
|
* - \ref group_system_config_default_handlers
|
||||||
|
* - \ref group_system_config_device_vector_table
|
||||||
|
* - \ref group_system_config_cm4_functions
|
||||||
|
*
|
||||||
|
* \section group_system_config_configuration Configuration Considerations
|
||||||
|
*
|
||||||
|
* \subsection group_system_config_device_memory_definition Device Memory Definition
|
||||||
|
* The flash and RAM allocation for each CPU is defined by the linker scripts.
|
||||||
|
* For dual-core devices, the physical flash and RAM memory is shared between the CPU cores.
|
||||||
|
* 2 KB of RAM (allocated at the end of RAM) are reserved for system use.
|
||||||
|
* For Single-Core devices the system reserves additional 80 bytes of RAM.
|
||||||
|
* Using the reserved memory area for other purposes will lead to unexpected behavior.
|
||||||
|
*
|
||||||
|
* \note The linker files provided with the PDL are generic and handle all common
|
||||||
|
* use cases. Your project may not use every section defined in the linker files.
|
||||||
|
* In that case you may see warnings during the build process. To eliminate build
|
||||||
|
* warnings in your project, you can simply comment out or remove the relevant
|
||||||
|
* code in the linker file.
|
||||||
|
*
|
||||||
|
* <b>ARM GCC</b>\n
|
||||||
|
* The flash and RAM sections for the CPU are defined in the linker files:
|
||||||
|
* 'xx_yy.ld', where 'xx' is the device group, and 'yy' is the target CPU; for example,
|
||||||
|
* 'cy8c6xx7_cm0plus.ld' and 'cy8c6xx7_cm4_dual.ld'.
|
||||||
|
* \note If the start of the Cortex-M4 application image is changed, the value
|
||||||
|
* of the of the \ref CY_CORTEX_M4_APPL_ADDR should also be changed. The
|
||||||
|
* \ref CY_CORTEX_M4_APPL_ADDR macro should be used as the parameter for the
|
||||||
|
* Cy_SysEnableCM4() function call.
|
||||||
|
*
|
||||||
|
* Change the flash and RAM sizes by editing the macros value in the
|
||||||
|
* linker files for both CPUs:
|
||||||
|
* - 'xx_cm0plus.ld', where 'xx' is the device group:
|
||||||
|
* \code
|
||||||
|
* flash (rx) : ORIGIN = 0x10000000, LENGTH = 0x00080000
|
||||||
|
* ram (rwx) : ORIGIN = 0x08000000, LENGTH = 0x00024000
|
||||||
|
* \endcode
|
||||||
|
* - 'xx_cm4_dual.ld', where 'xx' is the device group:
|
||||||
|
* \code
|
||||||
|
* flash (rx) : ORIGIN = 0x10080000, LENGTH = 0x00080000
|
||||||
|
* ram (rwx) : ORIGIN = 0x08024000, LENGTH = 0x00023800
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* Change the value of the \ref CY_CORTEX_M4_APPL_ADDR macro to the rom ORIGIN's
|
||||||
|
* value in the 'xx_cm4_dual.ld' file, where 'xx' is the device group. Do this
|
||||||
|
* by either:
|
||||||
|
* - Passing the following commands to the compiler:\n
|
||||||
|
* \code -D CY_CORTEX_M4_APPL_ADDR=0x10080000 \endcode
|
||||||
|
* - Editing the \ref CY_CORTEX_M4_APPL_ADDR value in the 'system_xx.h', where 'xx' is device family:\n
|
||||||
|
* \code #define CY_CORTEX_M4_APPL_ADDR (0x10080000u) \endcode
|
||||||
|
*
|
||||||
|
* <b>ARM MDK</b>\n
|
||||||
|
* The flash and RAM sections for the CPU are defined in the linker files:
|
||||||
|
* 'xx_yy.scat', where 'xx' is the device group, and 'yy' is the target CPU; for example,
|
||||||
|
* 'cy8c6xx7_cm0plus.scat' and 'cy8c6xx7_cm4_dual.scat'.
|
||||||
|
* \note If the start of the Cortex-M4 application image is changed, the value
|
||||||
|
* of the of the \ref CY_CORTEX_M4_APPL_ADDR should also be changed. The
|
||||||
|
* \ref CY_CORTEX_M4_APPL_ADDR macro should be used as the parameter for the \ref
|
||||||
|
* Cy_SysEnableCM4() function call.
|
||||||
|
*
|
||||||
|
* \note The linker files provided with the PDL are generic and handle all common
|
||||||
|
* use cases. Your project may not use every section defined in the linker files.
|
||||||
|
* In that case you may see the warnings during the build process:
|
||||||
|
* L6314W (no section matches pattern) and/or L6329W
|
||||||
|
* (pattern only matches removed unused sections). In your project, you can
|
||||||
|
* suppress the warning by passing the "--diag_suppress=L6314W,L6329W" option to
|
||||||
|
* the linker. You can also comment out or remove the relevant code in the linker
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* Change the flash and RAM sizes by editing the macros value in the
|
||||||
|
* linker files for both CPUs:
|
||||||
|
* - 'xx_cm0plus.scat', where 'xx' is the device group:
|
||||||
|
* \code
|
||||||
|
* #define FLASH_START 0x10000000
|
||||||
|
* #define FLASH_SIZE 0x00080000
|
||||||
|
* #define RAM_START 0x08000000
|
||||||
|
* #define RAM_SIZE 0x00024000
|
||||||
|
* \endcode
|
||||||
|
* - 'xx_cm4_dual.scat', where 'xx' is the device group:
|
||||||
|
* \code
|
||||||
|
* #define FLASH_START 0x10080000
|
||||||
|
* #define FLASH_SIZE 0x00080000
|
||||||
|
* #define RAM_START 0x08024000
|
||||||
|
* #define RAM_SIZE 0x00023800
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* Change the value of the \ref CY_CORTEX_M4_APPL_ADDR macro to the FLASH_START
|
||||||
|
* value in the 'xx_cm4_dual.scat' file,
|
||||||
|
* where 'xx' is the device group. Do this by either:
|
||||||
|
* - Passing the following commands to the compiler:\n
|
||||||
|
* \code -D CY_CORTEX_M4_APPL_ADDR=0x10080000 \endcode
|
||||||
|
* - Editing the \ref CY_CORTEX_M4_APPL_ADDR value in the 'system_xx.h', where
|
||||||
|
* 'xx' is device family:\n
|
||||||
|
* \code #define CY_CORTEX_M4_APPL_ADDR (0x10080000u) \endcode
|
||||||
|
*
|
||||||
|
* <b>IAR</b>\n
|
||||||
|
* The flash and RAM sections for the CPU are defined in the linker files:
|
||||||
|
* 'xx_yy.icf', where 'xx' is the device group, and 'yy' is the target CPU; for example,
|
||||||
|
* 'cy8c6xx7_cm0plus.icf' and 'cy8c6xx7_cm4_dual.icf'.
|
||||||
|
* \note If the start of the Cortex-M4 application image is changed, the value
|
||||||
|
* of the of the \ref CY_CORTEX_M4_APPL_ADDR should also be changed. The
|
||||||
|
* \ref CY_CORTEX_M4_APPL_ADDR macro should be used as the parameter for the \ref
|
||||||
|
* Cy_SysEnableCM4() function call.
|
||||||
|
*
|
||||||
|
* Change the flash and RAM sizes by editing the macros value in the
|
||||||
|
* linker files for both CPUs:
|
||||||
|
* - 'xx_cm0plus.icf', where 'xx' is the device group:
|
||||||
|
* \code
|
||||||
|
* define symbol __ICFEDIT_region_IROM1_start__ = 0x10000000;
|
||||||
|
* define symbol __ICFEDIT_region_IROM1_end__ = 0x10080000;
|
||||||
|
* define symbol __ICFEDIT_region_IRAM1_start__ = 0x08000000;
|
||||||
|
* define symbol __ICFEDIT_region_IRAM1_end__ = 0x08024000;
|
||||||
|
* \endcode
|
||||||
|
* - 'xx_cm4_dual.icf', where 'xx' is the device group:
|
||||||
|
* \code
|
||||||
|
* define symbol __ICFEDIT_region_IROM1_start__ = 0x10080000;
|
||||||
|
* define symbol __ICFEDIT_region_IROM1_end__ = 0x10100000;
|
||||||
|
* define symbol __ICFEDIT_region_IRAM1_start__ = 0x08024000;
|
||||||
|
* define symbol __ICFEDIT_region_IRAM1_end__ = 0x08047800;
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* Change the value of the \ref CY_CORTEX_M4_APPL_ADDR macro to the
|
||||||
|
* __ICFEDIT_region_IROM1_start__ value in the 'xx_cm4_dual.icf' file, where 'xx'
|
||||||
|
* is the device group. Do this by either:
|
||||||
|
* - Passing the following commands to the compiler:\n
|
||||||
|
* \code -D CY_CORTEX_M4_APPL_ADDR=0x10080000 \endcode
|
||||||
|
* - Editing the \ref CY_CORTEX_M4_APPL_ADDR value in the 'system_xx.h', where
|
||||||
|
* 'xx' is device family:\n
|
||||||
|
* \code #define CY_CORTEX_M4_APPL_ADDR (0x10080000u) \endcode
|
||||||
|
*
|
||||||
|
* \subsection group_system_config_device_initialization Device Initialization
|
||||||
|
* After a power-on-reset (POR), the boot process is handled by the boot code
|
||||||
|
* from the on-chip ROM that is always executed by the Cortex-M0+ core. The boot
|
||||||
|
* code passes the control to the Cortex-M0+ startup code located in flash.
|
||||||
|
*
|
||||||
|
* \subsubsection group_system_config_dual_core_device_initialization Dual-Core Devices
|
||||||
|
* The Cortex-M0+ startup code performs the device initialization by a call to
|
||||||
|
* SystemInit() and then calls the main() function. The Cortex-M4 core is disabled
|
||||||
|
* by default. Enable the core using the \ref Cy_SysEnableCM4() function.
|
||||||
|
* See \ref group_system_config_cm4_functions for more details.
|
||||||
|
* \note Startup code executes SystemInit() function for the both Cortex-M0+ and Cortex-M4 cores.
|
||||||
|
* The function has a separate implementation on each core.
|
||||||
|
* Both function implementations unlock and disable the WDT.
|
||||||
|
* Therefore enable the WDT after both cores have been initialized.
|
||||||
|
*
|
||||||
|
* \subsubsection group_system_config_single_core_device_initialization Single-Core Devices
|
||||||
|
* The Cortex-M0+ core is not user-accessible on these devices. In this case the
|
||||||
|
* Flash Boot handles setup of the CM0+ core and starts the Cortex-M4 core.
|
||||||
|
*
|
||||||
|
* \subsection group_system_config_heap_stack_config Heap and Stack Configuration
|
||||||
|
* There are two ways to adjust heap and stack configurations:
|
||||||
|
* -# Editing source code files
|
||||||
|
* -# Specifying via command line
|
||||||
|
*
|
||||||
|
* By default, the stack size is set to 0x00001000 and the heap size is set to 0x00000400.
|
||||||
|
*
|
||||||
|
* \subsubsection group_system_config_heap_stack_config_gcc ARM GCC
|
||||||
|
* - <b>Editing source code files</b>\n
|
||||||
|
* The heap and stack sizes are defined in the assembler startup files
|
||||||
|
* (e.g. startup_psoc6_01_cm0plus.S and startup_psoc6_01_cm4.S).
|
||||||
|
* Change the heap and stack sizes by modifying the following lines:\n
|
||||||
|
* \code .equ Stack_Size, 0x00001000 \endcode
|
||||||
|
* \code .equ Heap_Size, 0x00000400 \endcode
|
||||||
|
*
|
||||||
|
* - <b>Specifying via command line</b>\n
|
||||||
|
* Change the heap and stack sizes passing the following commands to the compiler:\n
|
||||||
|
* \code -D __STACK_SIZE=0x000000400 \endcode
|
||||||
|
* \code -D __HEAP_SIZE=0x000000100 \endcode
|
||||||
|
*
|
||||||
|
* \subsubsection group_system_config_heap_stack_config_mdk ARM MDK
|
||||||
|
* - <b>Editing source code files</b>\n
|
||||||
|
* The heap and stack sizes are defined in the assembler startup files
|
||||||
|
* (e.g. startup_psoc6_01_cm0plus.s and startup_psoc6_01_cm4.s).
|
||||||
|
* Change the heap and stack sizes by modifying the following lines:\n
|
||||||
|
* \code Stack_Size EQU 0x00001000 \endcode
|
||||||
|
* \code Heap_Size EQU 0x00000400 \endcode
|
||||||
|
*
|
||||||
|
* - <b>Specifying via command line</b>\n
|
||||||
|
* Change the heap and stack sizes passing the following commands to the assembler:\n
|
||||||
|
* \code "--predefine=___STACK_SIZE SETA 0x000000400" \endcode
|
||||||
|
* \code "--predefine=__HEAP_SIZE SETA 0x000000100" \endcode
|
||||||
|
*
|
||||||
|
* \subsubsection group_system_config_heap_stack_config_iar IAR
|
||||||
|
* - <b>Editing source code files</b>\n
|
||||||
|
* The heap and stack sizes are defined in the linker scatter files: 'xx_yy.icf',
|
||||||
|
* where 'xx' is the device family, and 'yy' is the target CPU; for example,
|
||||||
|
* cy8c6xx7_cm0plus.icf and cy8c6xx7_cm4_dual.icf.
|
||||||
|
* Change the heap and stack sizes by modifying the following lines:\n
|
||||||
|
* \code Stack_Size EQU 0x00001000 \endcode
|
||||||
|
* \code Heap_Size EQU 0x00000400 \endcode
|
||||||
|
*
|
||||||
|
* - <b>Specifying via command line</b>\n
|
||||||
|
* Change the heap and stack sizes passing the following commands to the
|
||||||
|
* linker (including quotation marks):\n
|
||||||
|
* \code --define_symbol __STACK_SIZE=0x000000400 \endcode
|
||||||
|
* \code --define_symbol __HEAP_SIZE=0x000000100 \endcode
|
||||||
|
*
|
||||||
|
* \subsection group_system_config_merge_apps Merging CM0+ and CM4 Executables
|
||||||
|
* The CM0+ project and linker script build the CM0+ application image. Similarly,
|
||||||
|
* the CM4 linker script builds the CM4 application image. Each specifies
|
||||||
|
* locations, sizes, and contents of sections in memory. See
|
||||||
|
* \ref group_system_config_device_memory_definition for the symbols and default
|
||||||
|
* values.
|
||||||
|
*
|
||||||
|
* The cymcuelftool is invoked by a post-build command. The precise project
|
||||||
|
* setting is IDE-specific.
|
||||||
|
*
|
||||||
|
* The cymcuelftool combines the two executables. The tool examines the
|
||||||
|
* executables to ensure that memory regions either do not overlap, or contain
|
||||||
|
* identical bytes (shared). If there are no problems, it creates a new ELF file
|
||||||
|
* with the merged image, without changing any of the addresses or data.
|
||||||
|
*
|
||||||
|
* \subsection group_system_config_default_handlers Default Interrupt Handlers Definition
|
||||||
|
* The default interrupt handler functions are defined as weak functions to a dummy
|
||||||
|
* handler in the startup file. The naming convention for the interrupt handler names
|
||||||
|
* is <interrupt_name>_IRQHandler. A default interrupt handler can be overwritten in
|
||||||
|
* user code by defining the handler function using the same name. For example:
|
||||||
|
* \code
|
||||||
|
* void scb_0_interrupt_IRQHandler(void)
|
||||||
|
*{
|
||||||
|
* ...
|
||||||
|
*}
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* \subsection group_system_config_device_vector_table Vectors Table Copy from Flash to RAM
|
||||||
|
* This process uses memory sections defined in the linker script. The startup
|
||||||
|
* code actually defines the contents of the vector table and performs the copy.
|
||||||
|
* \subsubsection group_system_config_device_vector_table_gcc ARM GCC
|
||||||
|
* The linker script file is 'xx_yy.ld', where 'xx' is the device family, and
|
||||||
|
* 'yy' is the target CPU; for example, cy8c6xx7_cm0plus.ld and cy8c6xx7_cm4_dual.ld.
|
||||||
|
* It defines sections and locations in memory.\n
|
||||||
|
* Copy interrupt vectors from flash to RAM: \n
|
||||||
|
* From: \code LONG (__Vectors) \endcode
|
||||||
|
* To: \code LONG (__ram_vectors_start__) \endcode
|
||||||
|
* Size: \code LONG (__Vectors_End - __Vectors) \endcode
|
||||||
|
* The vector table address (and the vector table itself) are defined in the
|
||||||
|
* assembler startup files (e.g. startup_psoc6_01_cm0plus.S and startup_psoc6_01_cm4.S).
|
||||||
|
* The code in these files copies the vector table from Flash to RAM.
|
||||||
|
* \subsubsection group_system_config_device_vector_table_mdk ARM MDK
|
||||||
|
* The linker script file is 'xx_yy.scat', where 'xx' is the device family,
|
||||||
|
* and 'yy' is the target CPU; for example, cy8c6xx7_cm0plus.scat and
|
||||||
|
* cy8c6xx7_cm4_dual.scat. The linker script specifies that the vector table
|
||||||
|
* (RESET_RAM) shall be first in the RAM section.\n
|
||||||
|
* RESET_RAM represents the vector table. It is defined in the assembler startup
|
||||||
|
* files (e.g. startup_psoc6_01_cm0plus.s and startup_psoc6_01_cm4.s).
|
||||||
|
* The code in these files copies the vector table from Flash to RAM.
|
||||||
|
*
|
||||||
|
* \subsubsection group_system_config_device_vector_table_iar IAR
|
||||||
|
* The linker script file is 'xx_yy.icf', where 'xx' is the device family, and
|
||||||
|
* 'yy' is the target CPU; for example, cy8c6xx7_cm0plus.icf and cy8c6xx7_cm4_dual.icf.
|
||||||
|
* This file defines the .intvec_ram section and its location.
|
||||||
|
* \code place at start of IRAM1_region { readwrite section .intvec_ram}; \endcode
|
||||||
|
* The vector table address (and the vector table itself) are defined in the
|
||||||
|
* assembler startup files (e.g. startup_psoc6_01_cm0plus.s and startup_psoc6_01_cm4.s).
|
||||||
|
* The code in these files copies the vector table from Flash to RAM.
|
||||||
|
*
|
||||||
|
* \section group_system_config_more_information More Information
|
||||||
|
* Refer to the <a href="..\..\pdl_user_guide.pdf">PDL User Guide</a> for the
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* \section group_system_config_MISRA MISRA Compliance
|
||||||
|
*
|
||||||
|
* <table class="doxtable">
|
||||||
|
* <tr>
|
||||||
|
* <th>MISRA Rule</th>
|
||||||
|
* <th>Rule Class (Required/Advisory)</th>
|
||||||
|
* <th>Rule Description</th>
|
||||||
|
* <th>Description of Deviation(s)</th>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td>2.3</td>
|
||||||
|
* <td>R</td>
|
||||||
|
* <td>The character sequence // shall not be used within a comment.</td>
|
||||||
|
* <td>The comments provide a useful WEB link to the documentation.</td>
|
||||||
|
* </tr>
|
||||||
|
* </table>
|
||||||
|
*
|
||||||
|
* \section group_system_config_changelog Changelog
|
||||||
|
* <table class="doxtable">
|
||||||
|
* <tr>
|
||||||
|
* <th>Version</th>
|
||||||
|
* <th>Changes</th>
|
||||||
|
* <th>Reason for Change</th>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td>2.20</td>
|
||||||
|
* <td>Moved the Cy_IPC_SystemSemaInit(), Cy_IPC_SystemPipeInit() functions implementation from IPC to Startup.</td>
|
||||||
|
* <td>Changed the IPC driver configuration method from compile time to run time.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td rowspan="2"> 2.10</td>
|
||||||
|
* <td>Added constructor attribute to SystemInit() function declaration for ARM MDK compiler. \n
|
||||||
|
* Removed $Sub$$main symbol for ARM MDK compiler.
|
||||||
|
* </td>
|
||||||
|
* <td>uVision Debugger support.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td>Updated description of the Startup behavior for Single-Core Devices. \n
|
||||||
|
* Added note about WDT disabling by SystemInit() function.
|
||||||
|
* </td>
|
||||||
|
* <td>Documentation improvement.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td rowspan="4"> 2.0</td>
|
||||||
|
* <td>Added restoring of FLL registers to the default state in SystemInit() API for single core devices.
|
||||||
|
* Single core device support.
|
||||||
|
* </td>
|
||||||
|
* <td></td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td>Added Normal Access Restrictions, Public Key, TOC part2 and TOC part2 copy to Supervisory flash linker memory regions. \n
|
||||||
|
* Renamed 'wflash' memory region to 'em_eeprom'.
|
||||||
|
* </td>
|
||||||
|
* <td>Linker scripts usability improvement.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td>Added Cy_IPC_SystemSemaInit(), Cy_IPC_SystemPipeInit(), Cy_Flash_Init() functions call to SystemInit() API.</td>
|
||||||
|
* <td>Reserved system resources for internal operations.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td>Added clearing and releasing of IPC structure #7 (reserved for the Deep-Sleep operations) to SystemInit() API.</td>
|
||||||
|
* <td>To avoid deadlocks in case of SW or WDT reset during Deep-Sleep entering.</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td>1.0</td>
|
||||||
|
* <td>Initial version</td>
|
||||||
|
* <td></td>
|
||||||
|
* </tr>
|
||||||
|
* </table>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \defgroup group_system_config_macro Macro
|
||||||
|
* \{
|
||||||
|
* \defgroup group_system_config_system_macro System
|
||||||
|
* \defgroup group_system_config_cm4_status_macro Cortex-M4 Status
|
||||||
|
* \defgroup group_system_config_user_settings_macro User Settings
|
||||||
|
* \}
|
||||||
|
* \defgroup group_system_config_functions Functions
|
||||||
|
* \{
|
||||||
|
* \defgroup group_system_config_system_functions System
|
||||||
|
* \defgroup group_system_config_cm4_functions Cortex-M4 Control
|
||||||
|
* \}
|
||||||
|
* \defgroup group_system_config_globals Global Variables
|
||||||
|
*
|
||||||
|
* \}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup group_system_config_system_functions
|
||||||
|
* \{
|
||||||
|
* \details
|
||||||
|
* The following system functions implement CMSIS Core functions.
|
||||||
|
* Refer to the [CMSIS documentation]
|
||||||
|
* (http://www.keil.com/pack/doc/CMSIS/Core/html/group__system__init__gr.html "System and Clock Configuration")
|
||||||
|
* for more details.
|
||||||
|
* \}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Include files
|
||||||
|
*******************************************************************************/
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Global preprocessor symbols/macros ('define')
|
||||||
|
*******************************************************************************/
|
||||||
|
#if ((defined(__GNUC__) && (__ARM_ARCH == 6) && (__ARM_ARCH_6M__ == 1)) || \
|
||||||
|
(defined (__ICCARM__) && (__CORE__ == __ARM6M__)) || \
|
||||||
|
(defined(__ARMCC_VERSION) && (__TARGET_ARCH_THUMB == 3)))
|
||||||
|
#define CY_SYSTEM_CPU_CM0P 1UL
|
||||||
|
#else
|
||||||
|
#define CY_SYSTEM_CPU_CM0P 0UL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (CY_PSOC_CREATOR_USED) && (CY_PSOC_CREATOR_USED == 1U)
|
||||||
|
#include "cyfitter.h"
|
||||||
|
#endif /* (CY_PSOC_CREATOR_USED) && (CY_PSOC_CREATOR_USED == 1U) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
*
|
||||||
|
* START OF USER SETTINGS HERE
|
||||||
|
* ===========================
|
||||||
|
*
|
||||||
|
* All lines with '<<<' can be set by user.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup group_system_config_user_settings_macro
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined (CYDEV_CLK_EXTCLK__HZ)
|
||||||
|
#define CY_CLK_EXT_FREQ_HZ (CYDEV_CLK_EXTCLK__HZ)
|
||||||
|
#else
|
||||||
|
/***************************************************************************//**
|
||||||
|
* External Clock Frequency (in Hz, [value]UL). If compiled within
|
||||||
|
* PSoC Creator and the clock is enabled in the DWR, the value from DWR used.
|
||||||
|
* Otherwise, edit the value below.
|
||||||
|
* <i>(USER SETTING)</i>
|
||||||
|
*******************************************************************************/
|
||||||
|
#define CY_CLK_EXT_FREQ_HZ (24000000UL) /* <<< 24 MHz */
|
||||||
|
#endif /* (CYDEV_CLK_EXTCLK__HZ) */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (CYDEV_CLK_ECO__HZ)
|
||||||
|
#define CY_CLK_ECO_FREQ_HZ (CYDEV_CLK_ECO__HZ)
|
||||||
|
#else
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \brief External crystal oscillator frequency (in Hz, [value]UL). If compiled
|
||||||
|
* within PSoC Creator and the clock is enabled in the DWR, the value from DWR
|
||||||
|
* used.
|
||||||
|
* <i>(USER SETTING)</i>
|
||||||
|
*******************************************************************************/
|
||||||
|
#define CY_CLK_ECO_FREQ_HZ (24000000UL) /* <<< 24 MHz */
|
||||||
|
#endif /* (CYDEV_CLK_ECO__HZ) */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (CYDEV_CLK_ALTHF__HZ)
|
||||||
|
#define CY_CLK_ALTHF_FREQ_HZ (CYDEV_CLK_ALTHF__HZ)
|
||||||
|
#else
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \brief Alternate high frequency (in Hz, [value]UL). If compiled within
|
||||||
|
* PSoC Creator and the clock is enabled in the DWR, the value from DWR used.
|
||||||
|
* Otherwise, edit the value below.
|
||||||
|
* <i>(USER SETTING)</i>
|
||||||
|
*******************************************************************************/
|
||||||
|
#define CY_CLK_ALTHF_FREQ_HZ (32000000UL) /* <<< 32 MHz */
|
||||||
|
#endif /* (CYDEV_CLK_ALTHF__HZ) */
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \brief Start address of the Cortex-M4 application ([address]UL)
|
||||||
|
* <i>(USER SETTING)</i>
|
||||||
|
*******************************************************************************/
|
||||||
|
#define CY_CORTEX_M4_APPL_ADDR ( CY_FLASH_BASE + CY_FLASH_SIZE / 2U) /* <<< Half of flash is reserved for the Cortex-M0+ application */
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \brief IPC Semaphores allocation ([value]UL).
|
||||||
|
* <i>(USER SETTING)</i>
|
||||||
|
*******************************************************************************/
|
||||||
|
#define CY_IPC_SEMA_COUNT (128UL) /* <<< This will allow 128 (4*32) semaphores */
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \brief IPC Pipe definitions ([value]UL).
|
||||||
|
* <i>(USER SETTING)</i>
|
||||||
|
*******************************************************************************/
|
||||||
|
#define CY_IPC_MAX_ENDPOINTS (8UL) /* <<< 8 endpoints */
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
*
|
||||||
|
* END OF USER SETTINGS HERE
|
||||||
|
* =========================
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/** \} group_system_config_user_settings_macro */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup group_system_config_system_macro
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (CY_SYSTEM_CPU_CM0P == 1UL) || defined(CY_DOXYGEN)
|
||||||
|
/** The Cortex-M0+ startup driver identifier */
|
||||||
|
#define CY_STARTUP_M0P_ID ((uint32_t)((uint32_t)((0x0EU) & 0x3FFFU) << 18U))
|
||||||
|
#endif /* (CY_SYSTEM_CPU_CM0P == 1UL) */
|
||||||
|
|
||||||
|
#if (CY_SYSTEM_CPU_CM0P != 1UL) || defined(CY_DOXYGEN)
|
||||||
|
/** The Cortex-M4 startup driver identifier */
|
||||||
|
#define CY_STARTUP_M4_ID ((uint32_t)((uint32_t)((0x0FU) & 0x3FFFU) << 18U))
|
||||||
|
#endif /* (CY_SYSTEM_CPU_CM0P != 1UL) */
|
||||||
|
|
||||||
|
/** \} group_system_config_system_macro */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup group_system_config_system_functions
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
#if defined(__ARMCC_VERSION)
|
||||||
|
extern void SystemInit(void) __attribute__((constructor));
|
||||||
|
#else
|
||||||
|
extern void SystemInit(void);
|
||||||
|
#endif /* (__ARMCC_VERSION) */
|
||||||
|
|
||||||
|
extern void SystemCoreClockUpdate(void);
|
||||||
|
/** \} group_system_config_system_functions */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup group_system_config_cm4_functions
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
extern uint32_t Cy_SysGetCM4Status(void);
|
||||||
|
extern void Cy_SysEnableCM4(uint32_t vectorTableOffset);
|
||||||
|
extern void Cy_SysDisableCM4(void);
|
||||||
|
extern void Cy_SysRetainCM4(void);
|
||||||
|
extern void Cy_SysResetCM4(void);
|
||||||
|
/** \} group_system_config_cm4_functions */
|
||||||
|
|
||||||
|
|
||||||
|
/** \cond */
|
||||||
|
extern void Default_Handler (void);
|
||||||
|
|
||||||
|
void Cy_SysIpcPipeIsrCm0(void);
|
||||||
|
void Cy_SysIpcPipeIsrCm4(void);
|
||||||
|
|
||||||
|
extern void Cy_SystemInit(void);
|
||||||
|
extern void Cy_SystemInitFpuEnable(void);
|
||||||
|
|
||||||
|
extern uint32_t cy_delayFreqHz;
|
||||||
|
extern uint32_t cy_delayFreqKhz;
|
||||||
|
extern uint8_t cy_delayFreqMhz;
|
||||||
|
extern uint32_t cy_delay32kMs;
|
||||||
|
/** \endcond */
|
||||||
|
|
||||||
|
|
||||||
|
#if (CY_SYSTEM_CPU_CM0P == 1UL) || defined(CY_DOXYGEN)
|
||||||
|
/**
|
||||||
|
* \addtogroup group_system_config_cm4_status_macro
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
#define CY_SYS_CM4_STATUS_ENABLED (3U) /**< The Cortex-M4 core is enabled: power on, clock on, no isolate, no reset and no retain. */
|
||||||
|
#define CY_SYS_CM4_STATUS_DISABLED (0U) /**< The Cortex-M4 core is disabled: power off, clock off, isolate, reset and no retain. */
|
||||||
|
#define CY_SYS_CM4_STATUS_RETAINED (2U) /**< The Cortex-M4 core is retained. power off, clock off, isolate, no reset and retain. */
|
||||||
|
#define CY_SYS_CM4_STATUS_RESET (1U) /**< The Cortex-M4 core is in the Reset mode: clock off, no isolated, no retain and reset. */
|
||||||
|
/** \} group_system_config_cm4_status_macro */
|
||||||
|
|
||||||
|
#endif /* (CY_SYSTEM_CPU_CM0P == 1UL) */
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* IPC Configuration
|
||||||
|
* =========================
|
||||||
|
*******************************************************************************/
|
||||||
|
/* IPC CY_PIPE default configuration */
|
||||||
|
#define CY_SYS_CYPIPE_CLIENT_CNT (8UL)
|
||||||
|
|
||||||
|
#define CY_SYS_INTR_CYPIPE_MUX_EP0 (1UL) /* IPC CYPRESS PIPE */
|
||||||
|
#define CY_SYS_INTR_CYPIPE_PRIOR_EP0 (1UL) /* Notifier Priority */
|
||||||
|
#define CY_SYS_INTR_CYPIPE_PRIOR_EP1 (1UL) /* Notifier Priority */
|
||||||
|
|
||||||
|
#define CY_SYS_CYPIPE_CHAN_MASK_EP0 (0x0001UL << CY_IPC_CHAN_CYPIPE_EP0)
|
||||||
|
#define CY_SYS_CYPIPE_CHAN_MASK_EP1 (0x0001UL << CY_IPC_CHAN_CYPIPE_EP1)
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/*
|
||||||
|
* The System pipe configuration defines the IPC channel number, interrupt
|
||||||
|
* number, and the pipe interrupt mask for the endpoint.
|
||||||
|
*
|
||||||
|
* The format of the endPoint configuration
|
||||||
|
* Bits[31:16] Interrupt Mask
|
||||||
|
* Bits[15:8 ] IPC interrupt
|
||||||
|
* Bits[ 7:0 ] IPC channel
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* System Pipe addresses */
|
||||||
|
/* CyPipe defines */
|
||||||
|
|
||||||
|
#define CY_SYS_CYPIPE_INTR_MASK ( CY_SYS_CYPIPE_CHAN_MASK_EP0 | CY_SYS_CYPIPE_CHAN_MASK_EP1 )
|
||||||
|
|
||||||
|
#define CY_SYS_CYPIPE_CONFIG_EP0 ( (CY_SYS_CYPIPE_INTR_MASK << CY_IPC_PIPE_CFG_IMASK_Pos) \
|
||||||
|
| (CY_IPC_INTR_CYPIPE_EP0 << CY_IPC_PIPE_CFG_INTR_Pos) \
|
||||||
|
| CY_IPC_CHAN_CYPIPE_EP0)
|
||||||
|
#define CY_SYS_CYPIPE_CONFIG_EP1 ( (CY_SYS_CYPIPE_INTR_MASK << CY_IPC_PIPE_CFG_IMASK_Pos) \
|
||||||
|
| (CY_IPC_INTR_CYPIPE_EP1 << CY_IPC_PIPE_CFG_INTR_Pos) \
|
||||||
|
| CY_IPC_CHAN_CYPIPE_EP1)
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/** \addtogroup group_system_config_globals
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern uint32_t SystemCoreClock;
|
||||||
|
extern uint32_t cy_BleEcoClockFreqHz;
|
||||||
|
extern uint32_t cy_Hfclk0FreqHz;
|
||||||
|
extern uint32_t cy_PeriClkFreqHz;
|
||||||
|
|
||||||
|
/** \} group_system_config_globals */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** \cond INTERNAL */
|
||||||
|
/*******************************************************************************
|
||||||
|
* Backward compatibility macro. The following code is DEPRECATED and must
|
||||||
|
* not be used in new projects
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/* BWC defines for functions related to enter/exit critical section */
|
||||||
|
#define Cy_SaveIRQ Cy_SysLib_EnterCriticalSection
|
||||||
|
#define Cy_RestoreIRQ Cy_SysLib_ExitCriticalSection
|
||||||
|
#define CY_SYS_INTR_CYPIPE_EP0 (CY_IPC_INTR_CYPIPE_EP0)
|
||||||
|
#define CY_SYS_INTR_CYPIPE_EP1 (CY_IPC_INTR_CYPIPE_EP1)
|
||||||
|
|
||||||
|
/** \endcond */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _SYSTEM_PSOC6_H_ */
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
699
2020TPCApp0.cydsn/system_psoc6_cm0plus.c
Normal file
699
2020TPCApp0.cydsn/system_psoc6_cm0plus.c
Normal file
|
@ -0,0 +1,699 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file system_psoc6_cm0plus.c
|
||||||
|
* \version 2.20
|
||||||
|
*
|
||||||
|
* The device system-source file.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "system_psoc6.h"
|
||||||
|
#include "cy_device.h"
|
||||||
|
#include "cy_device_headers.h"
|
||||||
|
#include "cy_syslib.h"
|
||||||
|
#include "cy_wdt.h"
|
||||||
|
|
||||||
|
#if !defined(CY_IPC_DEFAULT_CFG_DISABLE)
|
||||||
|
#include "cy_ipc_sema.h"
|
||||||
|
#include "cy_ipc_pipe.h"
|
||||||
|
#include "cy_ipc_drv.h"
|
||||||
|
|
||||||
|
#if defined(CY_DEVICE_PSOC6ABLE2)
|
||||||
|
#include "cy_flash.h"
|
||||||
|
#endif /* defined(CY_DEVICE_PSOC6ABLE2) */
|
||||||
|
|
||||||
|
#endif /* !defined(CY_IPC_DEFAULT_CFG_DISABLE) */
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* SystemCoreClockUpdate()
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/** Default HFClk frequency in Hz */
|
||||||
|
#define CY_CLK_HFCLK0_FREQ_HZ_DEFAULT (150000000UL)
|
||||||
|
|
||||||
|
/** Default PeriClk frequency in Hz */
|
||||||
|
#define CY_CLK_PERICLK_FREQ_HZ_DEFAULT (75000000UL)
|
||||||
|
|
||||||
|
/** Default SlowClk system core frequency in Hz */
|
||||||
|
#define CY_CLK_SYSTEM_FREQ_HZ_DEFAULT (75000000UL)
|
||||||
|
|
||||||
|
/** IMO frequency in Hz */
|
||||||
|
#define CY_CLK_IMO_FREQ_HZ (8000000UL)
|
||||||
|
|
||||||
|
/** HVILO frequency in Hz */
|
||||||
|
#define CY_CLK_HVILO_FREQ_HZ (32000UL)
|
||||||
|
|
||||||
|
/** PILO frequency in Hz */
|
||||||
|
#define CY_CLK_PILO_FREQ_HZ (32768UL)
|
||||||
|
|
||||||
|
/** WCO frequency in Hz */
|
||||||
|
#define CY_CLK_WCO_FREQ_HZ (32768UL)
|
||||||
|
|
||||||
|
/** ALTLF frequency in Hz */
|
||||||
|
#define CY_CLK_ALTLF_FREQ_HZ (32768UL)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds the SlowClk (Cortex-M0+) or FastClk (Cortex-M4) system core clock,
|
||||||
|
* which is the system clock frequency supplied to the SysTick timer and the
|
||||||
|
* processor core clock.
|
||||||
|
* This variable implements CMSIS Core global variable.
|
||||||
|
* Refer to the [CMSIS documentation]
|
||||||
|
* (http://www.keil.com/pack/doc/CMSIS/Core/html/group__system__init__gr.html "System and Clock Configuration")
|
||||||
|
* for more details.
|
||||||
|
* This variable can be used by debuggers to query the frequency
|
||||||
|
* of the debug timer or to configure the trace clock speed.
|
||||||
|
*
|
||||||
|
* \attention Compilers must be configured to avoid removing this variable in case
|
||||||
|
* the application program is not using it. Debugging systems require the variable
|
||||||
|
* to be physically present in memory so that it can be examined to configure the debugger. */
|
||||||
|
uint32_t SystemCoreClock = CY_CLK_SYSTEM_FREQ_HZ_DEFAULT;
|
||||||
|
|
||||||
|
/** Holds the HFClk0 clock frequency. Updated by \ref SystemCoreClockUpdate(). */
|
||||||
|
uint32_t cy_Hfclk0FreqHz = CY_CLK_HFCLK0_FREQ_HZ_DEFAULT;
|
||||||
|
|
||||||
|
/** Holds the PeriClk clock frequency. Updated by \ref SystemCoreClockUpdate(). */
|
||||||
|
uint32_t cy_PeriClkFreqHz = CY_CLK_PERICLK_FREQ_HZ_DEFAULT;
|
||||||
|
|
||||||
|
/** Holds the Alternate high frequency clock in Hz. Updated by \ref SystemCoreClockUpdate(). */
|
||||||
|
#if (defined (CY_IP_MXBLESS) && (CY_IP_MXBLESS == 1UL)) || defined (CY_DOXYGEN)
|
||||||
|
uint32_t cy_BleEcoClockFreqHz = CY_CLK_ALTHF_FREQ_HZ;
|
||||||
|
#endif /* (defined (CY_IP_MXBLESS) && (CY_IP_MXBLESS == 1UL)) || defined (CY_DOXYGEN) */
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* SystemInit()
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/* CLK_FLL_CONFIG default values */
|
||||||
|
#define CY_FB_CLK_FLL_CONFIG_VALUE (0x01000000u)
|
||||||
|
#define CY_FB_CLK_FLL_CONFIG2_VALUE (0x00020001u)
|
||||||
|
#define CY_FB_CLK_FLL_CONFIG3_VALUE (0x00002800u)
|
||||||
|
#define CY_FB_CLK_FLL_CONFIG4_VALUE (0x000000FFu)
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* SystemCoreClockUpdate (void)
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/* Do not use these definitions directly in your application */
|
||||||
|
#define CY_DELAY_MS_OVERFLOW_THRESHOLD (0x8000u)
|
||||||
|
#define CY_DELAY_1K_THRESHOLD (1000u)
|
||||||
|
#define CY_DELAY_1K_MINUS_1_THRESHOLD (CY_DELAY_1K_THRESHOLD - 1u)
|
||||||
|
#define CY_DELAY_1M_THRESHOLD (1000000u)
|
||||||
|
#define CY_DELAY_1M_MINUS_1_THRESHOLD (CY_DELAY_1M_THRESHOLD - 1u)
|
||||||
|
uint32_t cy_delayFreqHz = CY_CLK_SYSTEM_FREQ_HZ_DEFAULT;
|
||||||
|
|
||||||
|
uint32_t cy_delayFreqKhz = (CY_CLK_SYSTEM_FREQ_HZ_DEFAULT + CY_DELAY_1K_MINUS_1_THRESHOLD) /
|
||||||
|
CY_DELAY_1K_THRESHOLD;
|
||||||
|
|
||||||
|
uint8_t cy_delayFreqMhz = (uint8_t)((CY_CLK_SYSTEM_FREQ_HZ_DEFAULT + CY_DELAY_1M_MINUS_1_THRESHOLD) /
|
||||||
|
CY_DELAY_1M_THRESHOLD);
|
||||||
|
|
||||||
|
uint32_t cy_delay32kMs = CY_DELAY_MS_OVERFLOW_THRESHOLD *
|
||||||
|
((CY_CLK_SYSTEM_FREQ_HZ_DEFAULT + CY_DELAY_1K_MINUS_1_THRESHOLD) / CY_DELAY_1K_THRESHOLD);
|
||||||
|
|
||||||
|
#define CY_ROOT_PATH_SRC_IMO (0UL)
|
||||||
|
#define CY_ROOT_PATH_SRC_EXT (1UL)
|
||||||
|
#if (SRSS_ECO_PRESENT == 1U)
|
||||||
|
#define CY_ROOT_PATH_SRC_ECO (2UL)
|
||||||
|
#endif /* (SRSS_ECO_PRESENT == 1U) */
|
||||||
|
#if (SRSS_ALTHF_PRESENT == 1U)
|
||||||
|
#define CY_ROOT_PATH_SRC_ALTHF (3UL)
|
||||||
|
#endif /* (SRSS_ALTHF_PRESENT == 1U) */
|
||||||
|
#define CY_ROOT_PATH_SRC_DSI_MUX (4UL)
|
||||||
|
#define CY_ROOT_PATH_SRC_DSI_MUX_HVILO (16UL)
|
||||||
|
#define CY_ROOT_PATH_SRC_DSI_MUX_WCO (17UL)
|
||||||
|
#if (SRSS_ALTLF_PRESENT == 1U)
|
||||||
|
#define CY_ROOT_PATH_SRC_DSI_MUX_ALTLF (18UL)
|
||||||
|
#endif /* (SRSS_ALTLF_PRESENT == 1U) */
|
||||||
|
#if (SRSS_PILO_PRESENT == 1U)
|
||||||
|
#define CY_ROOT_PATH_SRC_DSI_MUX_PILO (19UL)
|
||||||
|
#endif /* (SRSS_PILO_PRESENT == 1U) */
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Cy_SysEnableCM4(), Cy_SysRetainCM4(), and Cy_SysResetCM4()
|
||||||
|
*******************************************************************************/
|
||||||
|
#define CY_SYS_CM4_PWR_CTL_KEY_OPEN (0x05FAUL)
|
||||||
|
#define CY_SYS_CM4_PWR_CTL_KEY_CLOSE (0xFA05UL)
|
||||||
|
#define CY_SYS_CM4_VECTOR_TABLE_VALID_ADDR (0x000003FFUL)
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: SystemInit
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Initializes the system:
|
||||||
|
* - Restores FLL registers to the default state.
|
||||||
|
* - Unlocks and disables WDT.
|
||||||
|
* - Calls Cy_PDL_Init() function to define the driver library.
|
||||||
|
* - Calls the Cy_SystemInit() function, if compiled from PSoC Creator.
|
||||||
|
* - Calls \ref SystemCoreClockUpdate().
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void SystemInit(void)
|
||||||
|
{
|
||||||
|
Cy_PDL_Init(CY_DEVICE_CFG);
|
||||||
|
|
||||||
|
/* Restore FLL registers to the default state as they are not restored by the ROM code */
|
||||||
|
uint32_t copy = SRSS->CLK_FLL_CONFIG;
|
||||||
|
copy &= ~SRSS_CLK_FLL_CONFIG_FLL_ENABLE_Msk;
|
||||||
|
SRSS->CLK_FLL_CONFIG = copy;
|
||||||
|
|
||||||
|
copy = SRSS->CLK_ROOT_SELECT[0u];
|
||||||
|
copy &= ~SRSS_CLK_ROOT_SELECT_ROOT_DIV_Msk; /* Set ROOT_DIV = 0*/
|
||||||
|
SRSS->CLK_ROOT_SELECT[0u] = copy;
|
||||||
|
|
||||||
|
SRSS->CLK_FLL_CONFIG = CY_FB_CLK_FLL_CONFIG_VALUE;
|
||||||
|
SRSS->CLK_FLL_CONFIG2 = CY_FB_CLK_FLL_CONFIG2_VALUE;
|
||||||
|
SRSS->CLK_FLL_CONFIG3 = CY_FB_CLK_FLL_CONFIG3_VALUE;
|
||||||
|
SRSS->CLK_FLL_CONFIG4 = CY_FB_CLK_FLL_CONFIG4_VALUE;
|
||||||
|
|
||||||
|
/* Unlock and disable WDT */
|
||||||
|
Cy_WDT_Unlock();
|
||||||
|
Cy_WDT_Disable();
|
||||||
|
|
||||||
|
Cy_SystemInit();
|
||||||
|
SystemCoreClockUpdate();
|
||||||
|
|
||||||
|
#if defined(CY_DEVICE_PSOC6ABLE2) && !defined(CY_PSOC6ABLE2_REV_0A_SUPPORT_DISABLE)
|
||||||
|
if (CY_SYSLIB_DEVICE_REV_0A == Cy_SysLib_GetDeviceRevision())
|
||||||
|
{
|
||||||
|
/* Clear data register of IPC structure #7, reserved for the Deep-Sleep operations. */
|
||||||
|
IPC_STRUCT7->DATA = 0UL;
|
||||||
|
/* Release IPC structure #7 to avoid deadlocks in case of SW or WDT reset during Deep-Sleep entering. */
|
||||||
|
IPC_STRUCT7->RELEASE = 0UL;
|
||||||
|
}
|
||||||
|
#endif /* defined(CY_DEVICE_PSOC6ABLE2) && !defined(CY_PSOC6ABLE2_REV_0A_SUPPORT_DISABLE) */
|
||||||
|
|
||||||
|
#if !defined(CY_IPC_DEFAULT_CFG_DISABLE)
|
||||||
|
/* Allocate and initialize semaphores for the system operations. */
|
||||||
|
static uint32_t ipcSemaArray[CY_IPC_SEMA_COUNT / CY_IPC_SEMA_PER_WORD];
|
||||||
|
|
||||||
|
(void) Cy_IPC_Sema_Init(CY_IPC_CHAN_SEMA, CY_IPC_SEMA_COUNT, ipcSemaArray);
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************************************
|
||||||
|
*
|
||||||
|
* Initializes the system pipes. The system pipes are used by BLE and Flash.
|
||||||
|
*
|
||||||
|
* If the default startup file is not used, or SystemInit() is not called in your
|
||||||
|
* project, call the following three functions prior to executing any flash or
|
||||||
|
* EmEEPROM write or erase operation:
|
||||||
|
* -# Cy_IPC_Sema_Init()
|
||||||
|
* -# Cy_IPC_Pipe_Config()
|
||||||
|
* -# Cy_IPC_Pipe_Init()
|
||||||
|
* -# Cy_Flash_Init()
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/* Create an array of endpoint structures */
|
||||||
|
static cy_stc_ipc_pipe_ep_t systemIpcPipeEpArray[CY_IPC_MAX_ENDPOINTS];
|
||||||
|
|
||||||
|
Cy_IPC_Pipe_Config(systemIpcPipeEpArray);
|
||||||
|
|
||||||
|
static cy_ipc_pipe_callback_ptr_t systemIpcPipeSysCbArray[CY_SYS_CYPIPE_CLIENT_CNT];
|
||||||
|
|
||||||
|
static const cy_stc_ipc_pipe_config_t systemIpcPipeConfigCm0 =
|
||||||
|
{
|
||||||
|
/* .ep0ConfigData */
|
||||||
|
{
|
||||||
|
/* .ipcNotifierNumber */ CY_IPC_INTR_CYPIPE_EP0,
|
||||||
|
/* .ipcNotifierPriority */ CY_SYS_INTR_CYPIPE_PRIOR_EP0,
|
||||||
|
/* .ipcNotifierMuxNumber */ CY_SYS_INTR_CYPIPE_MUX_EP0,
|
||||||
|
/* .epAddress */ CY_IPC_EP_CYPIPE_CM0_ADDR,
|
||||||
|
/* .epConfig */ CY_SYS_CYPIPE_CONFIG_EP0
|
||||||
|
},
|
||||||
|
/* .ep1ConfigData */
|
||||||
|
{
|
||||||
|
/* .ipcNotifierNumber */ CY_IPC_INTR_CYPIPE_EP1,
|
||||||
|
/* .ipcNotifierPriority */ CY_SYS_INTR_CYPIPE_PRIOR_EP1,
|
||||||
|
/* .ipcNotifierMuxNumber */ 0u,
|
||||||
|
/* .epAddress */ CY_IPC_EP_CYPIPE_CM4_ADDR,
|
||||||
|
/* .epConfig */ CY_SYS_CYPIPE_CONFIG_EP1
|
||||||
|
},
|
||||||
|
/* .endpointClientsCount */ CY_SYS_CYPIPE_CLIENT_CNT,
|
||||||
|
/* .endpointsCallbacksArray */ systemIpcPipeSysCbArray,
|
||||||
|
/* .userPipeIsrHandler */ &Cy_SysIpcPipeIsrCm0
|
||||||
|
};
|
||||||
|
|
||||||
|
if (cy_device->flashPipeRequired != 0u)
|
||||||
|
{
|
||||||
|
Cy_IPC_Pipe_Init(&systemIpcPipeConfigCm0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CY_DEVICE_PSOC6ABLE2)
|
||||||
|
Cy_Flash_Init();
|
||||||
|
#endif /* defined(CY_DEVICE_PSOC6ABLE2) */
|
||||||
|
|
||||||
|
#endif /* !defined(CY_IPC_DEFAULT_CFG_DISABLE) */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_SystemInit
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* The function is called during device startup. Once project compiled as part of
|
||||||
|
* the PSoC Creator project, the Cy_SystemInit() function is generated by the
|
||||||
|
* PSoC Creator.
|
||||||
|
*
|
||||||
|
* The function generated by PSoC Creator performs all of the necessary device
|
||||||
|
* configuration based on the design settings. This includes settings from the
|
||||||
|
* Design Wide Resources (DWR) such as Clocks and Pins as well as any component
|
||||||
|
* configuration that is necessary.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
__WEAK void Cy_SystemInit(void)
|
||||||
|
{
|
||||||
|
/* Empty weak function. The actual implementation to be in the PSoC Creator
|
||||||
|
* generated strong function.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: SystemCoreClockUpdate
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Gets core clock frequency and updates \ref SystemCoreClock, \ref
|
||||||
|
* cy_Hfclk0FreqHz, and \ref cy_PeriClkFreqHz.
|
||||||
|
*
|
||||||
|
* Updates global variables used by the \ref Cy_SysLib_Delay(), \ref
|
||||||
|
* Cy_SysLib_DelayUs(), and \ref Cy_SysLib_DelayCycles().
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void SystemCoreClockUpdate (void)
|
||||||
|
{
|
||||||
|
uint32_t srcFreqHz;
|
||||||
|
uint32_t pathFreqHz;
|
||||||
|
uint32_t slowClkDiv;
|
||||||
|
uint32_t periClkDiv;
|
||||||
|
uint32_t rootPath;
|
||||||
|
uint32_t srcClk;
|
||||||
|
|
||||||
|
/* Get root path clock for the high-frequency clock # 0 */
|
||||||
|
rootPath = _FLD2VAL(SRSS_CLK_ROOT_SELECT_ROOT_MUX, SRSS->CLK_ROOT_SELECT[0u]);
|
||||||
|
|
||||||
|
/* Get source of the root path clock */
|
||||||
|
srcClk = _FLD2VAL(SRSS_CLK_PATH_SELECT_PATH_MUX, SRSS->CLK_PATH_SELECT[rootPath]);
|
||||||
|
|
||||||
|
/* Get frequency of the source */
|
||||||
|
switch (srcClk)
|
||||||
|
{
|
||||||
|
case CY_ROOT_PATH_SRC_IMO:
|
||||||
|
srcFreqHz = CY_CLK_IMO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_ROOT_PATH_SRC_EXT:
|
||||||
|
srcFreqHz = CY_CLK_EXT_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if (SRSS_ECO_PRESENT == 1U)
|
||||||
|
case CY_ROOT_PATH_SRC_ECO:
|
||||||
|
srcFreqHz = CY_CLK_ECO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
#endif /* (SRSS_ECO_PRESENT == 1U) */
|
||||||
|
|
||||||
|
#if defined (CY_IP_MXBLESS) && (CY_IP_MXBLESS == 1UL) && (SRSS_ALTHF_PRESENT == 1U)
|
||||||
|
case CY_ROOT_PATH_SRC_ALTHF:
|
||||||
|
srcFreqHz = cy_BleEcoClockFreqHz;
|
||||||
|
break;
|
||||||
|
#endif /* defined (CY_IP_MXBLESS) && (CY_IP_MXBLESS == 1UL) && (SRSS_ALTHF_PRESENT == 1U) */
|
||||||
|
|
||||||
|
case CY_ROOT_PATH_SRC_DSI_MUX:
|
||||||
|
{
|
||||||
|
uint32_t dsi_src;
|
||||||
|
dsi_src = _FLD2VAL(SRSS_CLK_DSI_SELECT_DSI_MUX, SRSS->CLK_DSI_SELECT[rootPath]);
|
||||||
|
switch (dsi_src)
|
||||||
|
{
|
||||||
|
case CY_ROOT_PATH_SRC_DSI_MUX_HVILO:
|
||||||
|
srcFreqHz = CY_CLK_HVILO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_ROOT_PATH_SRC_DSI_MUX_WCO:
|
||||||
|
srcFreqHz = CY_CLK_WCO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if (SRSS_ALTLF_PRESENT == 1U)
|
||||||
|
case CY_ROOT_PATH_SRC_DSI_MUX_ALTLF:
|
||||||
|
srcFreqHz = CY_CLK_ALTLF_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
#endif /* (SRSS_ALTLF_PRESENT == 1U) */
|
||||||
|
|
||||||
|
#if (SRSS_PILO_PRESENT == 1U)
|
||||||
|
case CY_ROOT_PATH_SRC_DSI_MUX_PILO:
|
||||||
|
srcFreqHz = CY_CLK_PILO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
#endif /* (SRSS_PILO_PRESENT == 1U) */
|
||||||
|
|
||||||
|
default:
|
||||||
|
srcFreqHz = CY_CLK_HVILO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
srcFreqHz = CY_CLK_EXT_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rootPath == 0UL)
|
||||||
|
{
|
||||||
|
/* FLL */
|
||||||
|
bool fllLocked = ( 0UL != _FLD2VAL(SRSS_CLK_FLL_STATUS_LOCKED, SRSS->CLK_FLL_STATUS));
|
||||||
|
bool fllOutputOutput = ( 3UL == _FLD2VAL(SRSS_CLK_FLL_CONFIG3_BYPASS_SEL, SRSS->CLK_FLL_CONFIG3));
|
||||||
|
bool fllOutputAuto = ((0UL == _FLD2VAL(SRSS_CLK_FLL_CONFIG3_BYPASS_SEL, SRSS->CLK_FLL_CONFIG3)) ||
|
||||||
|
(1UL == _FLD2VAL(SRSS_CLK_FLL_CONFIG3_BYPASS_SEL, SRSS->CLK_FLL_CONFIG3)));
|
||||||
|
if ((fllOutputAuto && fllLocked) || fllOutputOutput)
|
||||||
|
{
|
||||||
|
uint32_t fllMult;
|
||||||
|
uint32_t refDiv;
|
||||||
|
uint32_t outputDiv;
|
||||||
|
|
||||||
|
fllMult = _FLD2VAL(SRSS_CLK_FLL_CONFIG_FLL_MULT, SRSS->CLK_FLL_CONFIG);
|
||||||
|
refDiv = _FLD2VAL(SRSS_CLK_FLL_CONFIG2_FLL_REF_DIV, SRSS->CLK_FLL_CONFIG2);
|
||||||
|
outputDiv = _FLD2VAL(SRSS_CLK_FLL_CONFIG_FLL_OUTPUT_DIV, SRSS->CLK_FLL_CONFIG) + 1UL;
|
||||||
|
|
||||||
|
pathFreqHz = ((srcFreqHz / refDiv) * fllMult) / outputDiv;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pathFreqHz = srcFreqHz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (rootPath == 1UL)
|
||||||
|
{
|
||||||
|
/* PLL */
|
||||||
|
bool pllLocked = ( 0UL != _FLD2VAL(SRSS_CLK_PLL_STATUS_LOCKED, SRSS->CLK_PLL_STATUS[0UL]));
|
||||||
|
bool pllOutputOutput = ( 3UL == _FLD2VAL(SRSS_CLK_PLL_CONFIG_BYPASS_SEL, SRSS->CLK_PLL_CONFIG[0UL]));
|
||||||
|
bool pllOutputAuto = ((0UL == _FLD2VAL(SRSS_CLK_PLL_CONFIG_BYPASS_SEL, SRSS->CLK_PLL_CONFIG[0UL])) ||
|
||||||
|
(1UL == _FLD2VAL(SRSS_CLK_PLL_CONFIG_BYPASS_SEL, SRSS->CLK_PLL_CONFIG[0UL])));
|
||||||
|
if ((pllOutputAuto && pllLocked) || pllOutputOutput)
|
||||||
|
{
|
||||||
|
uint32_t feedbackDiv;
|
||||||
|
uint32_t referenceDiv;
|
||||||
|
uint32_t outputDiv;
|
||||||
|
|
||||||
|
feedbackDiv = _FLD2VAL(SRSS_CLK_PLL_CONFIG_FEEDBACK_DIV, SRSS->CLK_PLL_CONFIG[0UL]);
|
||||||
|
referenceDiv = _FLD2VAL(SRSS_CLK_PLL_CONFIG_REFERENCE_DIV, SRSS->CLK_PLL_CONFIG[0UL]);
|
||||||
|
outputDiv = _FLD2VAL(SRSS_CLK_PLL_CONFIG_OUTPUT_DIV, SRSS->CLK_PLL_CONFIG[0UL]);
|
||||||
|
|
||||||
|
pathFreqHz = ((srcFreqHz * feedbackDiv) / referenceDiv) / outputDiv;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pathFreqHz = srcFreqHz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Direct */
|
||||||
|
pathFreqHz = srcFreqHz;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get frequency after hf_clk pre-divider */
|
||||||
|
pathFreqHz = pathFreqHz >> _FLD2VAL(SRSS_CLK_ROOT_SELECT_ROOT_DIV, SRSS->CLK_ROOT_SELECT[0u]);
|
||||||
|
cy_Hfclk0FreqHz = pathFreqHz;
|
||||||
|
|
||||||
|
/* Slow Clock Divider */
|
||||||
|
slowClkDiv = 1u + _FLD2VAL(CPUSS_CM0_CLOCK_CTL_SLOW_INT_DIV, CPUSS->CM0_CLOCK_CTL);
|
||||||
|
|
||||||
|
/* Peripheral Clock Divider */
|
||||||
|
periClkDiv = 1u + _FLD2VAL(CPUSS_CM0_CLOCK_CTL_PERI_INT_DIV, CPUSS->CM0_CLOCK_CTL);
|
||||||
|
|
||||||
|
pathFreqHz = pathFreqHz / periClkDiv;
|
||||||
|
cy_PeriClkFreqHz = pathFreqHz;
|
||||||
|
pathFreqHz = pathFreqHz / slowClkDiv;
|
||||||
|
SystemCoreClock = pathFreqHz;
|
||||||
|
|
||||||
|
/* Sets clock frequency for Delay API */
|
||||||
|
cy_delayFreqHz = SystemCoreClock;
|
||||||
|
cy_delayFreqMhz = (uint8_t)((cy_delayFreqHz + CY_DELAY_1M_MINUS_1_THRESHOLD) / CY_DELAY_1M_THRESHOLD);
|
||||||
|
cy_delayFreqKhz = (cy_delayFreqHz + CY_DELAY_1K_MINUS_1_THRESHOLD) / CY_DELAY_1K_THRESHOLD;
|
||||||
|
cy_delay32kMs = CY_DELAY_MS_OVERFLOW_THRESHOLD * cy_delayFreqKhz;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if (CY_SYSTEM_CPU_CM0P == 1UL) || defined(CY_DOXYGEN)
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_SysGetCM4Status
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Returns the Cortex-M4 core power mode.
|
||||||
|
*
|
||||||
|
* \return \ref group_system_config_cm4_status_macro
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
uint32_t Cy_SysGetCM4Status(void)
|
||||||
|
{
|
||||||
|
uint32_t regValue;
|
||||||
|
|
||||||
|
/* Get current power mode */
|
||||||
|
regValue = CPUSS->CM4_PWR_CTL & CPUSS_CM4_PWR_CTL_PWR_MODE_Msk;
|
||||||
|
|
||||||
|
return (regValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_SysEnableCM4
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Sets vector table base address and enables the Cortex-M4 core.
|
||||||
|
*
|
||||||
|
* \note If the CPU is already enabled, it is reset and then enabled.
|
||||||
|
*
|
||||||
|
* \param vectorTableOffset The offset of the vector table base address from
|
||||||
|
* memory address 0x00000000. The offset should be multiple to 1024 bytes.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void Cy_SysEnableCM4(uint32_t vectorTableOffset)
|
||||||
|
{
|
||||||
|
uint32_t regValue;
|
||||||
|
uint32_t interruptState;
|
||||||
|
uint32_t cpuState;
|
||||||
|
|
||||||
|
CY_ASSERT_L2((vectorTableOffset & CY_SYS_CM4_VECTOR_TABLE_VALID_ADDR) == 0UL);
|
||||||
|
|
||||||
|
interruptState = Cy_SysLib_EnterCriticalSection();
|
||||||
|
|
||||||
|
cpuState = Cy_SysGetCM4Status();
|
||||||
|
if (CY_SYS_CM4_STATUS_ENABLED == cpuState)
|
||||||
|
{
|
||||||
|
Cy_SysResetCM4();
|
||||||
|
}
|
||||||
|
|
||||||
|
CPUSS->CM4_VECTOR_TABLE_BASE = vectorTableOffset;
|
||||||
|
|
||||||
|
regValue = CPUSS->CM4_PWR_CTL & ~(CPUSS_CM4_PWR_CTL_VECTKEYSTAT_Msk | CPUSS_CM4_PWR_CTL_PWR_MODE_Msk);
|
||||||
|
regValue |= _VAL2FLD(CPUSS_CM4_PWR_CTL_VECTKEYSTAT, CY_SYS_CM4_PWR_CTL_KEY_OPEN);
|
||||||
|
regValue |= CY_SYS_CM4_STATUS_ENABLED;
|
||||||
|
CPUSS->CM4_PWR_CTL = regValue;
|
||||||
|
|
||||||
|
while((CPUSS->CM4_STATUS & CPUSS_CM4_STATUS_PWR_DONE_Msk) == 0UL)
|
||||||
|
{
|
||||||
|
/* Wait for the power mode to take effect */
|
||||||
|
}
|
||||||
|
|
||||||
|
Cy_SysLib_ExitCriticalSection(interruptState);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_SysDisableCM4
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Disables the Cortex-M4 core and waits for the mode to take the effect.
|
||||||
|
*
|
||||||
|
* \warning Do not call the function while the Cortex-M4 is executing because
|
||||||
|
* such a call may corrupt/abort a pending bus-transaction by the CPU and cause
|
||||||
|
* unexpected behavior in the system including a deadlock. Call the function
|
||||||
|
* while the Cortex-M4 core is in the Sleep or Deep Sleep low-power mode. Use
|
||||||
|
* the \ref group_syspm Power Management (syspm) API to put the CPU into the
|
||||||
|
* low-power modes. Use the \ref Cy_SysPm_ReadStatus() to get a status of the
|
||||||
|
* CPU.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void Cy_SysDisableCM4(void)
|
||||||
|
{
|
||||||
|
uint32_t interruptState;
|
||||||
|
uint32_t regValue;
|
||||||
|
|
||||||
|
interruptState = Cy_SysLib_EnterCriticalSection();
|
||||||
|
|
||||||
|
regValue = CPUSS->CM4_PWR_CTL & ~(CPUSS_CM4_PWR_CTL_VECTKEYSTAT_Msk | CPUSS_CM4_PWR_CTL_PWR_MODE_Msk);
|
||||||
|
regValue |= _VAL2FLD(CPUSS_CM4_PWR_CTL_VECTKEYSTAT, CY_SYS_CM4_PWR_CTL_KEY_OPEN);
|
||||||
|
regValue |= CY_SYS_CM4_STATUS_DISABLED;
|
||||||
|
CPUSS->CM4_PWR_CTL = regValue;
|
||||||
|
|
||||||
|
while((CPUSS->CM4_STATUS & CPUSS_CM4_STATUS_PWR_DONE_Msk) == 0UL)
|
||||||
|
{
|
||||||
|
/* Wait for the power mode to take effect */
|
||||||
|
}
|
||||||
|
|
||||||
|
Cy_SysLib_ExitCriticalSection(interruptState);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_SysRetainCM4
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Retains the Cortex-M4 core and exists without waiting for the mode to take
|
||||||
|
* effect.
|
||||||
|
*
|
||||||
|
* \note The retained mode can be entered only from the enabled mode.
|
||||||
|
*
|
||||||
|
* \warning Do not call the function while the Cortex-M4 is executing because
|
||||||
|
* such a call may corrupt/abort a pending bus-transaction by the CPU and cause
|
||||||
|
* unexpected behavior in the system including a deadlock. Call the function
|
||||||
|
* while the Cortex-M4 core is in the Sleep or Deep Sleep low-power mode. Use
|
||||||
|
* the \ref group_syspm Power Management (syspm) API to put the CPU into the
|
||||||
|
* low-power modes. Use the \ref Cy_SysPm_ReadStatus() to get a status of the CPU.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void Cy_SysRetainCM4(void)
|
||||||
|
{
|
||||||
|
uint32_t interruptState;
|
||||||
|
uint32_t regValue;
|
||||||
|
|
||||||
|
interruptState = Cy_SysLib_EnterCriticalSection();
|
||||||
|
|
||||||
|
regValue = CPUSS->CM4_PWR_CTL & ~(CPUSS_CM4_PWR_CTL_VECTKEYSTAT_Msk | CPUSS_CM4_PWR_CTL_PWR_MODE_Msk);
|
||||||
|
regValue |= _VAL2FLD(CPUSS_CM4_PWR_CTL_VECTKEYSTAT, CY_SYS_CM4_PWR_CTL_KEY_OPEN);
|
||||||
|
regValue |= CY_SYS_CM4_STATUS_RETAINED;
|
||||||
|
CPUSS->CM4_PWR_CTL = regValue;
|
||||||
|
|
||||||
|
Cy_SysLib_ExitCriticalSection(interruptState);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_SysResetCM4
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Resets the Cortex-M4 core and waits for the mode to take the effect.
|
||||||
|
*
|
||||||
|
* \note The reset mode can not be entered from the retained mode.
|
||||||
|
*
|
||||||
|
* \warning Do not call the function while the Cortex-M4 is executing because
|
||||||
|
* such a call may corrupt/abort a pending bus-transaction by the CPU and cause
|
||||||
|
* unexpected behavior in the system including a deadlock. Call the function
|
||||||
|
* while the Cortex-M4 core is in the Sleep or Deep Sleep low-power mode. Use
|
||||||
|
* the \ref group_syspm Power Management (syspm) API to put the CPU into the
|
||||||
|
* low-power modes. Use the \ref Cy_SysPm_ReadStatus() to get a status of the CPU.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void Cy_SysResetCM4(void)
|
||||||
|
{
|
||||||
|
uint32_t interruptState;
|
||||||
|
uint32_t regValue;
|
||||||
|
|
||||||
|
interruptState = Cy_SysLib_EnterCriticalSection();
|
||||||
|
|
||||||
|
regValue = CPUSS->CM4_PWR_CTL & ~(CPUSS_CM4_PWR_CTL_VECTKEYSTAT_Msk | CPUSS_CM4_PWR_CTL_PWR_MODE_Msk);
|
||||||
|
regValue |= _VAL2FLD(CPUSS_CM4_PWR_CTL_VECTKEYSTAT, CY_SYS_CM4_PWR_CTL_KEY_OPEN);
|
||||||
|
regValue |= CY_SYS_CM4_STATUS_RESET;
|
||||||
|
CPUSS->CM4_PWR_CTL = regValue;
|
||||||
|
|
||||||
|
while((CPUSS->CM4_STATUS & CPUSS_CM4_STATUS_PWR_DONE_Msk) == 0UL)
|
||||||
|
{
|
||||||
|
/* Wait for the power mode to take effect */
|
||||||
|
}
|
||||||
|
|
||||||
|
Cy_SysLib_ExitCriticalSection(interruptState);
|
||||||
|
}
|
||||||
|
#endif /* #if (CY_SYSTEM_CPU_CM0P == 1UL) || defined(CY_DOXYGEN) */
|
||||||
|
|
||||||
|
#if !defined(CY_IPC_DEFAULT_CFG_DISABLE)
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_SysIpcPipeIsrCm0
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* This is the interrupt service routine for the system pipe.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void Cy_SysIpcPipeIsrCm0(void)
|
||||||
|
{
|
||||||
|
Cy_IPC_Pipe_ExecuteCallback(CY_IPC_EP_CYPIPE_CM0_ADDR);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_MemorySymbols
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* The intention of the function is to declare boundaries of the memories for the
|
||||||
|
* MDK compilers. For the rest of the supported compilers, this is done using
|
||||||
|
* linker configuration files. The following symbols used by the cymcuelftool.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
#if defined (__ARMCC_VERSION)
|
||||||
|
__asm void Cy_MemorySymbols(void)
|
||||||
|
{
|
||||||
|
/* Flash */
|
||||||
|
EXPORT __cy_memory_0_start
|
||||||
|
EXPORT __cy_memory_0_length
|
||||||
|
EXPORT __cy_memory_0_row_size
|
||||||
|
|
||||||
|
/* Working Flash */
|
||||||
|
EXPORT __cy_memory_1_start
|
||||||
|
EXPORT __cy_memory_1_length
|
||||||
|
EXPORT __cy_memory_1_row_size
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
EXPORT __cy_memory_2_start
|
||||||
|
EXPORT __cy_memory_2_length
|
||||||
|
EXPORT __cy_memory_2_row_size
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
EXPORT __cy_memory_3_start
|
||||||
|
EXPORT __cy_memory_3_length
|
||||||
|
EXPORT __cy_memory_3_row_size
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
EXPORT __cy_memory_4_start
|
||||||
|
EXPORT __cy_memory_4_length
|
||||||
|
EXPORT __cy_memory_4_row_size
|
||||||
|
|
||||||
|
|
||||||
|
/* Flash */
|
||||||
|
__cy_memory_0_start EQU __cpp(CY_FLASH_BASE)
|
||||||
|
__cy_memory_0_length EQU __cpp(CY_FLASH_SIZE)
|
||||||
|
__cy_memory_0_row_size EQU 0x200
|
||||||
|
|
||||||
|
/* Flash region for EEPROM emulation */
|
||||||
|
__cy_memory_1_start EQU __cpp(CY_EM_EEPROM_BASE)
|
||||||
|
__cy_memory_1_length EQU __cpp(CY_EM_EEPROM_SIZE)
|
||||||
|
__cy_memory_1_row_size EQU 0x200
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
__cy_memory_2_start EQU __cpp(CY_SFLASH_BASE)
|
||||||
|
__cy_memory_2_length EQU __cpp(CY_SFLASH_SIZE)
|
||||||
|
__cy_memory_2_row_size EQU 0x200
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
__cy_memory_3_start EQU __cpp(CY_XIP_BASE)
|
||||||
|
__cy_memory_3_length EQU __cpp(CY_XIP_SIZE)
|
||||||
|
__cy_memory_3_row_size EQU 0x200
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
__cy_memory_4_start EQU __cpp(0x90700000)
|
||||||
|
__cy_memory_4_length EQU __cpp(0x100000)
|
||||||
|
__cy_memory_4_row_size EQU __cpp(1)
|
||||||
|
}
|
||||||
|
#endif /* defined (__ARMCC_VERSION) */
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
542
2020TPCApp0.cydsn/system_psoc6_cm4.c
Normal file
542
2020TPCApp0.cydsn/system_psoc6_cm4.c
Normal file
|
@ -0,0 +1,542 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file system_psoc6_cm4.c
|
||||||
|
* \version 2.20
|
||||||
|
*
|
||||||
|
* The device system-source file.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "system_psoc6.h"
|
||||||
|
#include "cy_device.h"
|
||||||
|
#include "cy_device_headers.h"
|
||||||
|
#include "cy_syslib.h"
|
||||||
|
#include "cy_wdt.h"
|
||||||
|
|
||||||
|
#if !defined(CY_IPC_DEFAULT_CFG_DISABLE)
|
||||||
|
#include "cy_ipc_sema.h"
|
||||||
|
#include "cy_ipc_pipe.h"
|
||||||
|
#include "cy_ipc_drv.h"
|
||||||
|
|
||||||
|
#if defined(CY_DEVICE_PSOC6ABLE2)
|
||||||
|
#include "cy_flash.h"
|
||||||
|
#endif /* defined(CY_DEVICE_PSOC6ABLE2) */
|
||||||
|
#endif /* !defined(CY_IPC_DEFAULT_CFG_DISABLE) */
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* SystemCoreClockUpdate()
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/** Default HFClk frequency in Hz */
|
||||||
|
#define CY_CLK_HFCLK0_FREQ_HZ_DEFAULT (150000000UL)
|
||||||
|
|
||||||
|
/** Default PeriClk frequency in Hz */
|
||||||
|
#define CY_CLK_PERICLK_FREQ_HZ_DEFAULT (75000000UL)
|
||||||
|
|
||||||
|
/** Default SlowClk system core frequency in Hz */
|
||||||
|
#define CY_CLK_SYSTEM_FREQ_HZ_DEFAULT (75000000UL)
|
||||||
|
|
||||||
|
/** IMO frequency in Hz */
|
||||||
|
#define CY_CLK_IMO_FREQ_HZ (8000000UL)
|
||||||
|
|
||||||
|
/** HVILO frequency in Hz */
|
||||||
|
#define CY_CLK_HVILO_FREQ_HZ (32000UL)
|
||||||
|
|
||||||
|
/** PILO frequency in Hz */
|
||||||
|
#define CY_CLK_PILO_FREQ_HZ (32768UL)
|
||||||
|
|
||||||
|
/** WCO frequency in Hz */
|
||||||
|
#define CY_CLK_WCO_FREQ_HZ (32768UL)
|
||||||
|
|
||||||
|
/** ALTLF frequency in Hz */
|
||||||
|
#define CY_CLK_ALTLF_FREQ_HZ (32768UL)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds the SlowClk (Cortex-M0+) or FastClk (Cortex-M4) system core clock,
|
||||||
|
* which is the system clock frequency supplied to the SysTick timer and the
|
||||||
|
* processor core clock.
|
||||||
|
* This variable implements CMSIS Core global variable.
|
||||||
|
* Refer to the [CMSIS documentation]
|
||||||
|
* (http://www.keil.com/pack/doc/CMSIS/Core/html/group__system__init__gr.html "System and Clock Configuration")
|
||||||
|
* for more details.
|
||||||
|
* This variable can be used by debuggers to query the frequency
|
||||||
|
* of the debug timer or to configure the trace clock speed.
|
||||||
|
*
|
||||||
|
* \attention Compilers must be configured to avoid removing this variable in case
|
||||||
|
* the application program is not using it. Debugging systems require the variable
|
||||||
|
* to be physically present in memory so that it can be examined to configure the debugger. */
|
||||||
|
uint32_t SystemCoreClock = CY_CLK_SYSTEM_FREQ_HZ_DEFAULT;
|
||||||
|
|
||||||
|
/** Holds the HFClk0 clock frequency. Updated by \ref SystemCoreClockUpdate(). */
|
||||||
|
uint32_t cy_Hfclk0FreqHz = CY_CLK_HFCLK0_FREQ_HZ_DEFAULT;
|
||||||
|
|
||||||
|
/** Holds the PeriClk clock frequency. Updated by \ref SystemCoreClockUpdate(). */
|
||||||
|
uint32_t cy_PeriClkFreqHz = CY_CLK_PERICLK_FREQ_HZ_DEFAULT;
|
||||||
|
|
||||||
|
/** Holds the Alternate high frequency clock in Hz. Updated by \ref SystemCoreClockUpdate(). */
|
||||||
|
#if (defined (CY_IP_MXBLESS) && (CY_IP_MXBLESS == 1UL)) || defined (CY_DOXYGEN)
|
||||||
|
uint32_t cy_BleEcoClockFreqHz = CY_CLK_ALTHF_FREQ_HZ;
|
||||||
|
#endif /* (defined (CY_IP_MXBLESS) && (CY_IP_MXBLESS == 1UL)) || defined (CY_DOXYGEN) */
|
||||||
|
|
||||||
|
/* SCB->CPACR */
|
||||||
|
#define SCB_CPACR_CP10_CP11_ENABLE (0xFUL << 20u)
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* SystemInit()
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/* CLK_FLL_CONFIG default values */
|
||||||
|
#define CY_FB_CLK_FLL_CONFIG_VALUE (0x01000000u)
|
||||||
|
#define CY_FB_CLK_FLL_CONFIG2_VALUE (0x00020001u)
|
||||||
|
#define CY_FB_CLK_FLL_CONFIG3_VALUE (0x00002800u)
|
||||||
|
#define CY_FB_CLK_FLL_CONFIG4_VALUE (0x000000FFu)
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* SystemCoreClockUpdate (void)
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/* Do not use these definitions directly in your application */
|
||||||
|
#define CY_DELAY_MS_OVERFLOW_THRESHOLD (0x8000u)
|
||||||
|
#define CY_DELAY_1K_THRESHOLD (1000u)
|
||||||
|
#define CY_DELAY_1K_MINUS_1_THRESHOLD (CY_DELAY_1K_THRESHOLD - 1u)
|
||||||
|
#define CY_DELAY_1M_THRESHOLD (1000000u)
|
||||||
|
#define CY_DELAY_1M_MINUS_1_THRESHOLD (CY_DELAY_1M_THRESHOLD - 1u)
|
||||||
|
uint32_t cy_delayFreqHz = CY_CLK_SYSTEM_FREQ_HZ_DEFAULT;
|
||||||
|
|
||||||
|
uint32_t cy_delayFreqKhz = (CY_CLK_SYSTEM_FREQ_HZ_DEFAULT + CY_DELAY_1K_MINUS_1_THRESHOLD) /
|
||||||
|
CY_DELAY_1K_THRESHOLD;
|
||||||
|
|
||||||
|
uint8_t cy_delayFreqMhz = (uint8_t)((CY_CLK_SYSTEM_FREQ_HZ_DEFAULT + CY_DELAY_1M_MINUS_1_THRESHOLD) /
|
||||||
|
CY_DELAY_1M_THRESHOLD);
|
||||||
|
|
||||||
|
uint32_t cy_delay32kMs = CY_DELAY_MS_OVERFLOW_THRESHOLD *
|
||||||
|
((CY_CLK_SYSTEM_FREQ_HZ_DEFAULT + CY_DELAY_1K_MINUS_1_THRESHOLD) / CY_DELAY_1K_THRESHOLD);
|
||||||
|
|
||||||
|
#define CY_ROOT_PATH_SRC_IMO (0UL)
|
||||||
|
#define CY_ROOT_PATH_SRC_EXT (1UL)
|
||||||
|
#if (SRSS_ECO_PRESENT == 1U)
|
||||||
|
#define CY_ROOT_PATH_SRC_ECO (2UL)
|
||||||
|
#endif /* (SRSS_ECO_PRESENT == 1U) */
|
||||||
|
#if (SRSS_ALTHF_PRESENT == 1U)
|
||||||
|
#define CY_ROOT_PATH_SRC_ALTHF (3UL)
|
||||||
|
#endif /* (SRSS_ALTHF_PRESENT == 1U) */
|
||||||
|
#define CY_ROOT_PATH_SRC_DSI_MUX (4UL)
|
||||||
|
#define CY_ROOT_PATH_SRC_DSI_MUX_HVILO (16UL)
|
||||||
|
#define CY_ROOT_PATH_SRC_DSI_MUX_WCO (17UL)
|
||||||
|
#if (SRSS_ALTLF_PRESENT == 1U)
|
||||||
|
#define CY_ROOT_PATH_SRC_DSI_MUX_ALTLF (18UL)
|
||||||
|
#endif /* (SRSS_ALTLF_PRESENT == 1U) */
|
||||||
|
#if (SRSS_PILO_PRESENT == 1U)
|
||||||
|
#define CY_ROOT_PATH_SRC_DSI_MUX_PILO (19UL)
|
||||||
|
#endif /* (SRSS_PILO_PRESENT == 1U) */
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: SystemInit
|
||||||
|
****************************************************************************//**
|
||||||
|
* \cond
|
||||||
|
* Initializes the system:
|
||||||
|
* - Restores FLL registers to the default state for single core devices.
|
||||||
|
* - Unlocks and disables WDT.
|
||||||
|
* - Calls Cy_PDL_Init() function to define the driver library.
|
||||||
|
* - Calls the Cy_SystemInit() function, if compiled from PSoC Creator.
|
||||||
|
* - Calls \ref SystemCoreClockUpdate().
|
||||||
|
* \endcond
|
||||||
|
*******************************************************************************/
|
||||||
|
void SystemInit(void)
|
||||||
|
{
|
||||||
|
Cy_PDL_Init(CY_DEVICE_CFG);
|
||||||
|
|
||||||
|
#ifdef __CM0P_PRESENT
|
||||||
|
#if (__CM0P_PRESENT == 0)
|
||||||
|
/* Restore FLL registers to the default state as they are not restored by the ROM code */
|
||||||
|
uint32_t copy = SRSS->CLK_FLL_CONFIG;
|
||||||
|
copy &= ~SRSS_CLK_FLL_CONFIG_FLL_ENABLE_Msk;
|
||||||
|
SRSS->CLK_FLL_CONFIG = copy;
|
||||||
|
|
||||||
|
copy = SRSS->CLK_ROOT_SELECT[0u];
|
||||||
|
copy &= ~SRSS_CLK_ROOT_SELECT_ROOT_DIV_Msk; /* Set ROOT_DIV = 0*/
|
||||||
|
SRSS->CLK_ROOT_SELECT[0u] = copy;
|
||||||
|
|
||||||
|
SRSS->CLK_FLL_CONFIG = CY_FB_CLK_FLL_CONFIG_VALUE;
|
||||||
|
SRSS->CLK_FLL_CONFIG2 = CY_FB_CLK_FLL_CONFIG2_VALUE;
|
||||||
|
SRSS->CLK_FLL_CONFIG3 = CY_FB_CLK_FLL_CONFIG3_VALUE;
|
||||||
|
SRSS->CLK_FLL_CONFIG4 = CY_FB_CLK_FLL_CONFIG4_VALUE;
|
||||||
|
|
||||||
|
/* Unlock and disable WDT */
|
||||||
|
Cy_WDT_Unlock();
|
||||||
|
Cy_WDT_Disable();
|
||||||
|
#endif /* (__CM0P_PRESENT == 0) */
|
||||||
|
#endif /* __CM0P_PRESENT */
|
||||||
|
|
||||||
|
Cy_SystemInit();
|
||||||
|
SystemCoreClockUpdate();
|
||||||
|
|
||||||
|
#if !defined(CY_IPC_DEFAULT_CFG_DISABLE)
|
||||||
|
|
||||||
|
#ifdef __CM0P_PRESENT
|
||||||
|
#if (__CM0P_PRESENT == 0)
|
||||||
|
/* Allocate and initialize semaphores for the system operations. */
|
||||||
|
static uint32_t ipcSemaArray[CY_IPC_SEMA_COUNT / CY_IPC_SEMA_PER_WORD];
|
||||||
|
(void) Cy_IPC_Sema_Init(CY_IPC_CHAN_SEMA, CY_IPC_SEMA_COUNT, ipcSemaArray);
|
||||||
|
#else
|
||||||
|
(void) Cy_IPC_Sema_Init(CY_IPC_CHAN_SEMA, 0ul, NULL);
|
||||||
|
#endif /* (__CM0P_PRESENT) */
|
||||||
|
#else
|
||||||
|
(void) Cy_IPC_Sema_Init(CY_IPC_CHAN_SEMA, 0ul, NULL);
|
||||||
|
#endif /* __CM0P_PRESENT */
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************************************
|
||||||
|
*
|
||||||
|
* Initializes the system pipes. The system pipes are used by BLE and Flash.
|
||||||
|
*
|
||||||
|
* If the default startup file is not used, or SystemInit() is not called in your
|
||||||
|
* project, call the following three functions prior to executing any flash or
|
||||||
|
* EmEEPROM write or erase operation:
|
||||||
|
* -# Cy_IPC_Sema_Init()
|
||||||
|
* -# Cy_IPC_Pipe_Config()
|
||||||
|
* -# Cy_IPC_Pipe_Init()
|
||||||
|
* -# Cy_Flash_Init()
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
/* Create an array of endpoint structures */
|
||||||
|
static cy_stc_ipc_pipe_ep_t systemIpcPipeEpArray[CY_IPC_MAX_ENDPOINTS];
|
||||||
|
|
||||||
|
Cy_IPC_Pipe_Config(systemIpcPipeEpArray);
|
||||||
|
|
||||||
|
static cy_ipc_pipe_callback_ptr_t systemIpcPipeSysCbArray[CY_SYS_CYPIPE_CLIENT_CNT];
|
||||||
|
|
||||||
|
static const cy_stc_ipc_pipe_config_t systemIpcPipeConfigCm4 =
|
||||||
|
{
|
||||||
|
/* .ep0ConfigData */
|
||||||
|
{
|
||||||
|
/* .ipcNotifierNumber */ CY_IPC_INTR_CYPIPE_EP0,
|
||||||
|
/* .ipcNotifierPriority */ CY_SYS_INTR_CYPIPE_PRIOR_EP0,
|
||||||
|
/* .ipcNotifierMuxNumber */ CY_SYS_INTR_CYPIPE_MUX_EP0,
|
||||||
|
/* .epAddress */ CY_IPC_EP_CYPIPE_CM0_ADDR,
|
||||||
|
/* .epConfig */ CY_SYS_CYPIPE_CONFIG_EP0
|
||||||
|
},
|
||||||
|
/* .ep1ConfigData */
|
||||||
|
{
|
||||||
|
/* .ipcNotifierNumber */ CY_IPC_INTR_CYPIPE_EP1,
|
||||||
|
/* .ipcNotifierPriority */ CY_SYS_INTR_CYPIPE_PRIOR_EP1,
|
||||||
|
/* .ipcNotifierMuxNumber */ 0u,
|
||||||
|
/* .epAddress */ CY_IPC_EP_CYPIPE_CM4_ADDR,
|
||||||
|
/* .epConfig */ CY_SYS_CYPIPE_CONFIG_EP1
|
||||||
|
},
|
||||||
|
/* .endpointClientsCount */ CY_SYS_CYPIPE_CLIENT_CNT,
|
||||||
|
/* .endpointsCallbacksArray */ systemIpcPipeSysCbArray,
|
||||||
|
/* .userPipeIsrHandler */ &Cy_SysIpcPipeIsrCm4
|
||||||
|
};
|
||||||
|
|
||||||
|
if (cy_device->flashPipeRequired != 0u)
|
||||||
|
{
|
||||||
|
Cy_IPC_Pipe_Init(&systemIpcPipeConfigCm4);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CY_DEVICE_PSOC6ABLE2)
|
||||||
|
Cy_Flash_Init();
|
||||||
|
#endif /* defined(CY_DEVICE_PSOC6ABLE2) */
|
||||||
|
|
||||||
|
#endif /* !defined(CY_IPC_DEFAULT_CFG_DISABLE) */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_SystemInit
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* The function is called during device startup. Once project compiled as part of
|
||||||
|
* the PSoC Creator project, the Cy_SystemInit() function is generated by the
|
||||||
|
* PSoC Creator.
|
||||||
|
*
|
||||||
|
* The function generated by PSoC Creator performs all of the necessary device
|
||||||
|
* configuration based on the design settings. This includes settings from the
|
||||||
|
* Design Wide Resources (DWR) such as Clocks and Pins as well as any component
|
||||||
|
* configuration that is necessary.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
__WEAK void Cy_SystemInit(void)
|
||||||
|
{
|
||||||
|
/* Empty weak function. The actual implementation to be in the PSoC Creator
|
||||||
|
* generated strong function.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: SystemCoreClockUpdate
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Gets core clock frequency and updates \ref SystemCoreClock, \ref
|
||||||
|
* cy_Hfclk0FreqHz, and \ref cy_PeriClkFreqHz.
|
||||||
|
*
|
||||||
|
* Updates global variables used by the \ref Cy_SysLib_Delay(), \ref
|
||||||
|
* Cy_SysLib_DelayUs(), and \ref Cy_SysLib_DelayCycles().
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void SystemCoreClockUpdate (void)
|
||||||
|
{
|
||||||
|
uint32_t srcFreqHz;
|
||||||
|
uint32_t pathFreqHz;
|
||||||
|
uint32_t fastClkDiv;
|
||||||
|
uint32_t periClkDiv;
|
||||||
|
uint32_t rootPath;
|
||||||
|
uint32_t srcClk;
|
||||||
|
|
||||||
|
/* Get root path clock for the high-frequency clock # 0 */
|
||||||
|
rootPath = _FLD2VAL(SRSS_CLK_ROOT_SELECT_ROOT_MUX, SRSS->CLK_ROOT_SELECT[0u]);
|
||||||
|
|
||||||
|
/* Get source of the root path clock */
|
||||||
|
srcClk = _FLD2VAL(SRSS_CLK_PATH_SELECT_PATH_MUX, SRSS->CLK_PATH_SELECT[rootPath]);
|
||||||
|
|
||||||
|
/* Get frequency of the source */
|
||||||
|
switch (srcClk)
|
||||||
|
{
|
||||||
|
case CY_ROOT_PATH_SRC_IMO:
|
||||||
|
srcFreqHz = CY_CLK_IMO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_ROOT_PATH_SRC_EXT:
|
||||||
|
srcFreqHz = CY_CLK_EXT_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if (SRSS_ECO_PRESENT == 1U)
|
||||||
|
case CY_ROOT_PATH_SRC_ECO:
|
||||||
|
srcFreqHz = CY_CLK_ECO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
#endif /* (SRSS_ECO_PRESENT == 1U) */
|
||||||
|
|
||||||
|
#if defined (CY_IP_MXBLESS) && (CY_IP_MXBLESS == 1UL) && (SRSS_ALTHF_PRESENT == 1U)
|
||||||
|
case CY_ROOT_PATH_SRC_ALTHF:
|
||||||
|
srcFreqHz = cy_BleEcoClockFreqHz;
|
||||||
|
break;
|
||||||
|
#endif /* defined (CY_IP_MXBLESS) && (CY_IP_MXBLESS == 1UL) && (SRSS_ALTHF_PRESENT == 1U) */
|
||||||
|
|
||||||
|
case CY_ROOT_PATH_SRC_DSI_MUX:
|
||||||
|
{
|
||||||
|
uint32_t dsi_src;
|
||||||
|
dsi_src = _FLD2VAL(SRSS_CLK_DSI_SELECT_DSI_MUX, SRSS->CLK_DSI_SELECT[rootPath]);
|
||||||
|
switch (dsi_src)
|
||||||
|
{
|
||||||
|
case CY_ROOT_PATH_SRC_DSI_MUX_HVILO:
|
||||||
|
srcFreqHz = CY_CLK_HVILO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_ROOT_PATH_SRC_DSI_MUX_WCO:
|
||||||
|
srcFreqHz = CY_CLK_WCO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if (SRSS_ALTLF_PRESENT == 1U)
|
||||||
|
case CY_ROOT_PATH_SRC_DSI_MUX_ALTLF:
|
||||||
|
srcFreqHz = CY_CLK_ALTLF_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
#endif /* (SRSS_ALTLF_PRESENT == 1U) */
|
||||||
|
|
||||||
|
#if (SRSS_PILO_PRESENT == 1U)
|
||||||
|
case CY_ROOT_PATH_SRC_DSI_MUX_PILO:
|
||||||
|
srcFreqHz = CY_CLK_PILO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
#endif /* (SRSS_PILO_PRESENT == 1U) */
|
||||||
|
|
||||||
|
default:
|
||||||
|
srcFreqHz = CY_CLK_HVILO_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
srcFreqHz = CY_CLK_EXT_FREQ_HZ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rootPath == 0UL)
|
||||||
|
{
|
||||||
|
/* FLL */
|
||||||
|
bool fllLocked = ( 0UL != _FLD2VAL(SRSS_CLK_FLL_STATUS_LOCKED, SRSS->CLK_FLL_STATUS));
|
||||||
|
bool fllOutputOutput = ( 3UL == _FLD2VAL(SRSS_CLK_FLL_CONFIG3_BYPASS_SEL, SRSS->CLK_FLL_CONFIG3));
|
||||||
|
bool fllOutputAuto = ((0UL == _FLD2VAL(SRSS_CLK_FLL_CONFIG3_BYPASS_SEL, SRSS->CLK_FLL_CONFIG3)) ||
|
||||||
|
(1UL == _FLD2VAL(SRSS_CLK_FLL_CONFIG3_BYPASS_SEL, SRSS->CLK_FLL_CONFIG3)));
|
||||||
|
if ((fllOutputAuto && fllLocked) || fllOutputOutput)
|
||||||
|
{
|
||||||
|
uint32_t fllMult;
|
||||||
|
uint32_t refDiv;
|
||||||
|
uint32_t outputDiv;
|
||||||
|
|
||||||
|
fllMult = _FLD2VAL(SRSS_CLK_FLL_CONFIG_FLL_MULT, SRSS->CLK_FLL_CONFIG);
|
||||||
|
refDiv = _FLD2VAL(SRSS_CLK_FLL_CONFIG2_FLL_REF_DIV, SRSS->CLK_FLL_CONFIG2);
|
||||||
|
outputDiv = _FLD2VAL(SRSS_CLK_FLL_CONFIG_FLL_OUTPUT_DIV, SRSS->CLK_FLL_CONFIG) + 1UL;
|
||||||
|
|
||||||
|
pathFreqHz = ((srcFreqHz / refDiv) * fllMult) / outputDiv;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pathFreqHz = srcFreqHz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (rootPath == 1UL)
|
||||||
|
{
|
||||||
|
/* PLL */
|
||||||
|
bool pllLocked = ( 0UL != _FLD2VAL(SRSS_CLK_PLL_STATUS_LOCKED, SRSS->CLK_PLL_STATUS[0UL]));
|
||||||
|
bool pllOutputOutput = ( 3UL == _FLD2VAL(SRSS_CLK_PLL_CONFIG_BYPASS_SEL, SRSS->CLK_PLL_CONFIG[0UL]));
|
||||||
|
bool pllOutputAuto = ((0UL == _FLD2VAL(SRSS_CLK_PLL_CONFIG_BYPASS_SEL, SRSS->CLK_PLL_CONFIG[0UL])) ||
|
||||||
|
(1UL == _FLD2VAL(SRSS_CLK_PLL_CONFIG_BYPASS_SEL, SRSS->CLK_PLL_CONFIG[0UL])));
|
||||||
|
if ((pllOutputAuto && pllLocked) || pllOutputOutput)
|
||||||
|
{
|
||||||
|
uint32_t feedbackDiv;
|
||||||
|
uint32_t referenceDiv;
|
||||||
|
uint32_t outputDiv;
|
||||||
|
|
||||||
|
feedbackDiv = _FLD2VAL(SRSS_CLK_PLL_CONFIG_FEEDBACK_DIV, SRSS->CLK_PLL_CONFIG[0UL]);
|
||||||
|
referenceDiv = _FLD2VAL(SRSS_CLK_PLL_CONFIG_REFERENCE_DIV, SRSS->CLK_PLL_CONFIG[0UL]);
|
||||||
|
outputDiv = _FLD2VAL(SRSS_CLK_PLL_CONFIG_OUTPUT_DIV, SRSS->CLK_PLL_CONFIG[0UL]);
|
||||||
|
|
||||||
|
pathFreqHz = ((srcFreqHz * feedbackDiv) / referenceDiv) / outputDiv;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pathFreqHz = srcFreqHz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Direct */
|
||||||
|
pathFreqHz = srcFreqHz;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get frequency after hf_clk pre-divider */
|
||||||
|
pathFreqHz = pathFreqHz >> _FLD2VAL(SRSS_CLK_ROOT_SELECT_ROOT_DIV, SRSS->CLK_ROOT_SELECT[0u]);
|
||||||
|
cy_Hfclk0FreqHz = pathFreqHz;
|
||||||
|
|
||||||
|
/* Fast Clock Divider */
|
||||||
|
fastClkDiv = 1u + _FLD2VAL(CPUSS_CM4_CLOCK_CTL_FAST_INT_DIV, CPUSS->CM4_CLOCK_CTL);
|
||||||
|
|
||||||
|
/* Peripheral Clock Divider */
|
||||||
|
periClkDiv = 1u + _FLD2VAL(CPUSS_CM0_CLOCK_CTL_PERI_INT_DIV, CPUSS->CM0_CLOCK_CTL);
|
||||||
|
cy_PeriClkFreqHz = pathFreqHz / periClkDiv;
|
||||||
|
|
||||||
|
pathFreqHz = pathFreqHz / fastClkDiv;
|
||||||
|
SystemCoreClock = pathFreqHz;
|
||||||
|
|
||||||
|
/* Sets clock frequency for Delay API */
|
||||||
|
cy_delayFreqHz = SystemCoreClock;
|
||||||
|
cy_delayFreqMhz = (uint8_t)((cy_delayFreqHz + CY_DELAY_1M_MINUS_1_THRESHOLD) / CY_DELAY_1M_THRESHOLD);
|
||||||
|
cy_delayFreqKhz = (cy_delayFreqHz + CY_DELAY_1K_MINUS_1_THRESHOLD) / CY_DELAY_1K_THRESHOLD;
|
||||||
|
cy_delay32kMs = CY_DELAY_MS_OVERFLOW_THRESHOLD * cy_delayFreqKhz;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_SystemInitFpuEnable
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Enables the FPU if it is used. The function is called from the startup file.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void Cy_SystemInitFpuEnable(void)
|
||||||
|
{
|
||||||
|
#if defined (__FPU_USED) && (__FPU_USED == 1U)
|
||||||
|
uint32_t interruptState;
|
||||||
|
interruptState = Cy_SysLib_EnterCriticalSection();
|
||||||
|
SCB->CPACR |= SCB_CPACR_CP10_CP11_ENABLE;
|
||||||
|
__DSB();
|
||||||
|
__ISB();
|
||||||
|
Cy_SysLib_ExitCriticalSection(interruptState);
|
||||||
|
#endif /* (__FPU_USED) && (__FPU_USED == 1U) */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(CY_IPC_DEFAULT_CFG_DISABLE)
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_SysIpcPipeIsrCm4
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* This is the interrupt service routine for the system pipe.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void Cy_SysIpcPipeIsrCm4(void)
|
||||||
|
{
|
||||||
|
Cy_IPC_Pipe_ExecuteCallback(CY_IPC_EP_CYPIPE_CM4_ADDR);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: Cy_MemorySymbols
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* The intention of the function is to declare boundaries of the memories for the
|
||||||
|
* MDK compilers. For the rest of the supported compilers, this is done using
|
||||||
|
* linker configuration files. The following symbols used by the cymcuelftool.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
#if defined (__ARMCC_VERSION)
|
||||||
|
__asm void Cy_MemorySymbols(void)
|
||||||
|
{
|
||||||
|
/* Flash */
|
||||||
|
EXPORT __cy_memory_0_start
|
||||||
|
EXPORT __cy_memory_0_length
|
||||||
|
EXPORT __cy_memory_0_row_size
|
||||||
|
|
||||||
|
/* Working Flash */
|
||||||
|
EXPORT __cy_memory_1_start
|
||||||
|
EXPORT __cy_memory_1_length
|
||||||
|
EXPORT __cy_memory_1_row_size
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
EXPORT __cy_memory_2_start
|
||||||
|
EXPORT __cy_memory_2_length
|
||||||
|
EXPORT __cy_memory_2_row_size
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
EXPORT __cy_memory_3_start
|
||||||
|
EXPORT __cy_memory_3_length
|
||||||
|
EXPORT __cy_memory_3_row_size
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
EXPORT __cy_memory_4_start
|
||||||
|
EXPORT __cy_memory_4_length
|
||||||
|
EXPORT __cy_memory_4_row_size
|
||||||
|
|
||||||
|
/* Flash */
|
||||||
|
__cy_memory_0_start EQU __cpp(CY_FLASH_BASE)
|
||||||
|
__cy_memory_0_length EQU __cpp(CY_FLASH_SIZE)
|
||||||
|
__cy_memory_0_row_size EQU 0x200
|
||||||
|
|
||||||
|
/* Flash region for EEPROM emulation */
|
||||||
|
__cy_memory_1_start EQU __cpp(CY_EM_EEPROM_BASE)
|
||||||
|
__cy_memory_1_length EQU __cpp(CY_EM_EEPROM_SIZE)
|
||||||
|
__cy_memory_1_row_size EQU 0x200
|
||||||
|
|
||||||
|
/* Supervisory Flash */
|
||||||
|
__cy_memory_2_start EQU __cpp(CY_SFLASH_BASE)
|
||||||
|
__cy_memory_2_length EQU __cpp(CY_SFLASH_SIZE)
|
||||||
|
__cy_memory_2_row_size EQU 0x200
|
||||||
|
|
||||||
|
/* XIP */
|
||||||
|
__cy_memory_3_start EQU __cpp(CY_XIP_BASE)
|
||||||
|
__cy_memory_3_length EQU __cpp(CY_XIP_SIZE)
|
||||||
|
__cy_memory_3_row_size EQU 0x200
|
||||||
|
|
||||||
|
/* eFuse */
|
||||||
|
__cy_memory_4_start EQU __cpp(0x90700000)
|
||||||
|
__cy_memory_4_length EQU __cpp(0x100000)
|
||||||
|
__cy_memory_4_row_size EQU __cpp(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* defined (__ARMCC_VERSION) */
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
328
2020TPCApp0.cydsn/transport_ble.c
Normal file
328
2020TPCApp0.cydsn/transport_ble.c
Normal file
|
@ -0,0 +1,328 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file transport_ble.c
|
||||||
|
* \version 3.0
|
||||||
|
*
|
||||||
|
* This file provides the source code of the DFU communication APIs
|
||||||
|
* for the BLE Component.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "transport_ble.h"
|
||||||
|
|
||||||
|
#if defined(CY_PSOC_CREATOR_USED)
|
||||||
|
#include "BLE.h"
|
||||||
|
#else
|
||||||
|
#include "cy_flash.h"
|
||||||
|
#include "ble/cy_ble_gap.h"
|
||||||
|
#include "ble/cy_ble_stack.h"
|
||||||
|
#endif /* defined(CY_PSOC_CREATOR_USED) */
|
||||||
|
|
||||||
|
#include "ble/cy_ble_stack_host_error.h"
|
||||||
|
#include "ble/cy_ble_event_handler.h"
|
||||||
|
#include "ble/cy_ble_bts.h"
|
||||||
|
|
||||||
|
#if CY_BLE_HOST_CORE
|
||||||
|
|
||||||
|
static uint16_t cyBle_btsDataPacketIndex = 0u;
|
||||||
|
static uint8_t cyBle_cmdReceivedFlag = 0u;
|
||||||
|
static uint16_t cyBle_cmdLength = 0u;
|
||||||
|
static uint8_t *cyBle_btsBuffPtr;
|
||||||
|
|
||||||
|
static uint16_t cyBle_btsDataPacketSize = 0u;
|
||||||
|
static uint8_t cyBle_btsDataBuffer[CY_FLASH_SIZEOF_ROW + CYBLE_BTS_COMMAND_CONTROL_BYTES_NUM];
|
||||||
|
|
||||||
|
/* Connection Handle */
|
||||||
|
cy_stc_ble_conn_handle_t appConnHandle;
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: CyBLE_CyBtldrCommStart
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Initializes DFU state for BLE communication.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void CyBLE_CyBtldrCommStart(void)
|
||||||
|
{
|
||||||
|
#if defined(CY_PSOC_CREATOR_USED)
|
||||||
|
/* Start BLE and register the callback function */
|
||||||
|
(void)Cy_BLE_Start(&AppCallBack);
|
||||||
|
/* Registers a callback function for DFU */
|
||||||
|
(void)Cy_BLE_BTS_RegisterAttrCallback(&DFUCallBack);
|
||||||
|
#endif /* defined(CY_PSOC_CREATOR_USED) */
|
||||||
|
cyBle_btsDataPacketIndex = 0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: CyBLE_CyBtldrCommStop
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Disconnects from the peer device and stops BLE component.
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
void CyBLE_CyBtldrCommStop(void)
|
||||||
|
{
|
||||||
|
cy_stc_ble_gap_disconnect_info_t disconnectInfoParam =
|
||||||
|
{
|
||||||
|
.bdHandle = appConnHandle.bdHandle,
|
||||||
|
.reason = CY_BLE_HCI_ERROR_OTHER_END_TERMINATED_USER
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Initiate disconnection from the peer device*/
|
||||||
|
if(Cy_BLE_GAP_Disconnect(&disconnectInfoParam) == CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Wait for disconnection event */
|
||||||
|
while(Cy_BLE_GetConnectionState(appConnHandle) == CY_BLE_CONN_STATE_CONNECTED)
|
||||||
|
{
|
||||||
|
/* Process BLE events */
|
||||||
|
Cy_BLE_ProcessEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Stop BLE component. Ignores an error code because current function returns nothing */
|
||||||
|
(void) Cy_BLE_Disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: CyBtldrCommReset
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Resets DFU state for BLE communication.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void CyBLE_CyBtldrCommReset(void)
|
||||||
|
{
|
||||||
|
cyBle_btsDataPacketIndex = 0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: CyBLE_CyBtldrCommWrite
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Requests that the provided size (number of bytes) should be written from the
|
||||||
|
* input data buffer to the host device. This function in turn invokes the
|
||||||
|
* CyBle_GattsNotification() API to sent the data. If a notification is
|
||||||
|
* accepted, the function returns CYRET_SUCCESS. The timeOut parameter is ignored
|
||||||
|
* in this case.
|
||||||
|
*
|
||||||
|
* \param data The pointer to the buffer containing data to be written.
|
||||||
|
* \param size The number of bytes from the data buffer to write.
|
||||||
|
* \param count The pointer to where the BLE component will write the number
|
||||||
|
* of written bytes, generally the same as the size.
|
||||||
|
* \param timeOut Ignored. Used for consistency.
|
||||||
|
*
|
||||||
|
* \return
|
||||||
|
* The return value is of type \ref cy_en_dfu_status_t:
|
||||||
|
* - CY_DFU_SUCCESS - Indicates if a notification is successful.
|
||||||
|
* - CY_DFU_ERROR_UNKNOWN - Failed to send notification to the host.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
cy_en_dfu_status_t CyBLE_CyBtldrCommWrite(const uint8_t pData[], uint32_t size, uint32_t *count, uint32_t timeout)
|
||||||
|
{
|
||||||
|
cy_en_dfu_status_t status = CY_DFU_ERROR_UNKNOWN;
|
||||||
|
|
||||||
|
if (timeout == 0u)
|
||||||
|
{
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Cy_BLE_BTSS_SendNotification(appConnHandle, CY_BLE_BTS_BT_SERVICE, size, (const uint8 *)pData) == CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
*count = size;
|
||||||
|
status = CY_DFU_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*count = 0u;
|
||||||
|
}
|
||||||
|
return (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: CyBLE_CyBtldrCommRead
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Requests that the provided size (number of bytes) is read from the host device
|
||||||
|
* and stored in the provided data buffer. Once the read is done, the "count" is
|
||||||
|
* endorsed with the number of bytes written. The timeOut parameter is used to
|
||||||
|
* provide an upper bound on the time that the function is allowed to operate. If
|
||||||
|
* the read completes early, it should return success code as soon as possible.
|
||||||
|
* If the read was not successful before the allocated time has expired, it
|
||||||
|
* should return an error.
|
||||||
|
*
|
||||||
|
* \param data The pointer to the buffer to store data from the host controller.
|
||||||
|
* \param size The number of bytes to read into the data buffer.
|
||||||
|
* \param count The pointer to where the BLE component will write the number of
|
||||||
|
* read bytes.
|
||||||
|
* \param timeout The amount of time (in milliseconds) for which the
|
||||||
|
* BLE component should wait before indicating communication
|
||||||
|
* time out.
|
||||||
|
*
|
||||||
|
* \return
|
||||||
|
* The return value is of type \ref cy_en_dfu_status_t:
|
||||||
|
* - CY_DFU_SUCCESS - A command was successfully read.
|
||||||
|
* - CY_DFU_ERROR_DATA - The size of the command exceeds the buffer.
|
||||||
|
* - CY_DFU_ERROR_TIMEOUT - The host controller did not respond during
|
||||||
|
specified time out.
|
||||||
|
* \sideeffect
|
||||||
|
* \ref CyBle_ProcessEvents() is called as a part of this function.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
cy_en_dfu_status_t CyBLE_CyBtldrCommRead(uint8_t pData[], uint32_t size, uint32_t *count, uint32_t timeout)
|
||||||
|
{
|
||||||
|
cy_en_dfu_status_t status = CY_DFU_ERROR_UNKNOWN;
|
||||||
|
|
||||||
|
if ((pData != NULL) && (size > 0u))
|
||||||
|
{
|
||||||
|
status = CY_DFU_ERROR_TIMEOUT;
|
||||||
|
|
||||||
|
while(timeout != 0u)
|
||||||
|
{
|
||||||
|
/* Process BLE events */
|
||||||
|
Cy_BLE_ProcessEvents();
|
||||||
|
|
||||||
|
if(cyBle_cmdReceivedFlag == 1u)
|
||||||
|
{
|
||||||
|
/* Clear command receive flag */
|
||||||
|
cyBle_cmdReceivedFlag = 0u;
|
||||||
|
|
||||||
|
if(cyBle_cmdLength < size)
|
||||||
|
{
|
||||||
|
(void) memcpy((void *) pData, (const void *) cyBle_btsBuffPtr, (uint32_t)cyBle_cmdLength);
|
||||||
|
|
||||||
|
/* Return actual received command length */
|
||||||
|
*count = cyBle_cmdLength;
|
||||||
|
|
||||||
|
status = CY_DFU_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pData = NULL;
|
||||||
|
*count = 0u;
|
||||||
|
status = CY_DFU_ERROR_DATA;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Wait 1 ms and update timeout counter */
|
||||||
|
Cy_SysLib_Delay(1u);
|
||||||
|
--timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Process BLE events */
|
||||||
|
Cy_BLE_ProcessEvents();
|
||||||
|
}
|
||||||
|
return (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: DFUCallBack
|
||||||
|
****************************************************************************//**
|
||||||
|
*
|
||||||
|
* Handles the events from the BLE stack for the DFU Service.
|
||||||
|
*
|
||||||
|
* \param eventCode Event code
|
||||||
|
* \param eventParam Event parameters
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void DFUCallBack(uint32 event, void* eventParam)
|
||||||
|
{
|
||||||
|
/* To remove incorrect compiler warning */
|
||||||
|
(void)eventParam;
|
||||||
|
|
||||||
|
switch ((cy_en_ble_evt_t)event)
|
||||||
|
{
|
||||||
|
case CY_BLE_EVT_BTSS_NOTIFICATION_ENABLED:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_BTSS_NOTIFICATION_DISABLED:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_BTSS_EXEC_WRITE_REQ:
|
||||||
|
/* Check the execWriteFlag before execute or cancel write long operation */
|
||||||
|
if(((cy_stc_ble_gatts_exec_write_req_t *)eventParam)->execWriteFlag == CY_BLE_GATT_EXECUTE_WRITE_EXEC_FLAG)
|
||||||
|
{
|
||||||
|
cyBle_btsBuffPtr = ((cy_stc_ble_gatts_exec_write_req_t *)eventParam)->baseAddr[0u].handleValuePair.value.val;
|
||||||
|
|
||||||
|
/* Extract length of command data and add control bytes to data
|
||||||
|
* length to get command length.
|
||||||
|
*/
|
||||||
|
cyBle_cmdLength = (((uint16)(((uint16) cyBle_btsBuffPtr[CYBLE_BTS_COMMAND_DATA_LEN_OFFSET + 1u]) << 8u)) |
|
||||||
|
(uint16) cyBle_btsBuffPtr[CYBLE_BTS_COMMAND_DATA_LEN_OFFSET]) +
|
||||||
|
CYBLE_BTS_COMMAND_CONTROL_BYTES_NUM;
|
||||||
|
|
||||||
|
if(cyBle_cmdLength > CYBLE_BTS_COMMAND_MAX_LENGTH)
|
||||||
|
{
|
||||||
|
cyBle_cmdLength = CYBLE_BTS_COMMAND_MAX_LENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set flag for DFU to know that command is received from host */
|
||||||
|
cyBle_cmdReceivedFlag = 1u;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_BTSS_PREP_WRITE_REQ:
|
||||||
|
if(((cy_stc_ble_gatts_prep_write_req_param_t *)eventParam)->currentPrepWriteReqCount == 1u)
|
||||||
|
{
|
||||||
|
/* Send Prepare Write Response which identifies acknowledgement for
|
||||||
|
* long characteristic value write.
|
||||||
|
*/
|
||||||
|
cyBle_cmdLength = 0u;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CY_BLE_EVT_BTSS_WRITE_CMD_REQ:
|
||||||
|
{
|
||||||
|
uint8 *localDataBuffer = ((cy_stc_ble_bts_char_value_t *)eventParam)->value->val;
|
||||||
|
|
||||||
|
/* This is the beginning of the packet, let's read the size now */
|
||||||
|
if(cyBle_btsDataPacketIndex == 0u)
|
||||||
|
{
|
||||||
|
cyBle_btsDataPacketSize = (((uint16)(((uint16) localDataBuffer[CYBLE_BTS_COMMAND_DATA_LEN_OFFSET + 1u]) << 8u)) |
|
||||||
|
(uint16) localDataBuffer[CYBLE_BTS_COMMAND_DATA_LEN_OFFSET]) +
|
||||||
|
CYBLE_BTS_COMMAND_CONTROL_BYTES_NUM;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
(void) memcpy(&cyBle_btsDataBuffer[cyBle_btsDataPacketIndex], localDataBuffer, (uint32_t) ((cy_stc_ble_bts_char_value_t *)eventParam)->value->len);
|
||||||
|
|
||||||
|
cyBle_btsDataPacketIndex += ((cy_stc_ble_bts_char_value_t *)eventParam)->value->len;
|
||||||
|
|
||||||
|
if(cyBle_btsDataPacketIndex == cyBle_btsDataPacketSize)
|
||||||
|
{
|
||||||
|
cyBle_btsBuffPtr = &cyBle_btsDataBuffer[0];
|
||||||
|
cyBle_cmdLength = cyBle_btsDataPacketSize;
|
||||||
|
cyBle_cmdReceivedFlag = 1u;
|
||||||
|
cyBle_btsDataPacketIndex = 0u;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case CY_BLE_EVT_BTSS_WRITE_REQ:
|
||||||
|
cyBle_btsBuffPtr =
|
||||||
|
CY_BLE_GATT_DB_ATTR_GET_ATTR_GEN_PTR(cy_ble_btsConfigPtr->btss->btServiceInfo[0u].btServiceCharHandle);
|
||||||
|
|
||||||
|
/* Extract length of command data and add control bytes to data
|
||||||
|
* length to get command length.
|
||||||
|
*/
|
||||||
|
cyBle_cmdLength = (((uint16)(((uint16) cyBle_btsBuffPtr[CYBLE_BTS_COMMAND_DATA_LEN_OFFSET + 1u]) << 8u)) |
|
||||||
|
(uint16) cyBle_btsBuffPtr[CYBLE_BTS_COMMAND_DATA_LEN_OFFSET]) +
|
||||||
|
CYBLE_BTS_COMMAND_CONTROL_BYTES_NUM;
|
||||||
|
|
||||||
|
/* Set flag for DFU to know that command is received from host */
|
||||||
|
cyBle_cmdReceivedFlag = 1u;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CY_BLE_HOST_CORE */
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
55
2020TPCApp0.cydsn/transport_ble.h
Normal file
55
2020TPCApp0.cydsn/transport_ble.h
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/***************************************************************************//**
|
||||||
|
* \file transport_ble.h
|
||||||
|
* \version 3.0
|
||||||
|
*
|
||||||
|
* This file provides constants and parameter values of the DFU
|
||||||
|
* communication APIs for the BLE Component.
|
||||||
|
*
|
||||||
|
********************************************************************************
|
||||||
|
* \copyright
|
||||||
|
* Copyright 2016-2018, Cypress Semiconductor Corporation. All rights reserved.
|
||||||
|
* You may use this file only in accordance with the license, terms, conditions,
|
||||||
|
* disclaimers, and limitations in the end user license agreement accompanying
|
||||||
|
* the software package with which this file was provided.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(TRANSPORT_BLE_H)
|
||||||
|
#define TRANSPORT_BLE_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "cy_dfu.h"
|
||||||
|
#include "ble/cy_ble.h"
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Function Prototypes
|
||||||
|
***************************************/
|
||||||
|
|
||||||
|
/* BLE DFU physical layer functions */
|
||||||
|
void CyBLE_CyBtldrCommStart(void);
|
||||||
|
void CyBLE_CyBtldrCommStop (void);
|
||||||
|
void CyBLE_CyBtldrCommReset(void);
|
||||||
|
cy_en_dfu_status_t CyBLE_CyBtldrCommRead (uint8_t pData[], uint32_t size, uint32_t *count, uint32_t timeout);
|
||||||
|
cy_en_dfu_status_t CyBLE_CyBtldrCommWrite(const uint8_t pData[], uint32_t size, uint32_t *count, uint32_t timeout);
|
||||||
|
void DFUCallBack(uint32 event, void* eventParam);
|
||||||
|
|
||||||
|
/* BLE Callback */
|
||||||
|
extern void AppCallBack(uint32 event, void* eventParam);
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* API Constants
|
||||||
|
***************************************/
|
||||||
|
#define CYBLE_BTS_COMMAND_DATA_LEN_OFFSET (2u)
|
||||||
|
#define CYBLE_BTS_COMMAND_CONTROL_BYTES_NUM (7u)
|
||||||
|
#define CYBLE_BTS_COMMAND_MAX_LENGTH (265u)
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Global variables declaration
|
||||||
|
***************************************/
|
||||||
|
extern cy_stc_ble_conn_handle_t appConnHandle;
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !defined(TRANSPORT_BLE_H) */
|
||||||
|
|
||||||
|
|
||||||
|
/* [] END OF FILE */
|
1242
2020TPCApp1.cydsn/2020TPCApp1.cydwr
Normal file
1242
2020TPCApp1.cydsn/2020TPCApp1.cydwr
Normal file
File diff suppressed because it is too large
Load diff
6435
2020TPCApp1.cydsn/2020TPCApp1.cyprj
Normal file
6435
2020TPCApp1.cydsn/2020TPCApp1.cyprj
Normal file
File diff suppressed because it is too large
Load diff
BIN
2020TPCApp1.cydsn/2020TPCApp1_datasheet.pdf
Normal file
BIN
2020TPCApp1.cydsn/2020TPCApp1_datasheet.pdf
Normal file
Binary file not shown.
288
2020TPCApp1.cydsn/Audio.c
Normal file
288
2020TPCApp1.cydsn/Audio.c
Normal file
|
@ -0,0 +1,288 @@
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
QueueHandle_t xQueueAudio;
|
||||||
|
TaskHandle_t Audio_Task_Handle;
|
||||||
|
|
||||||
|
static const uint8_t START_BYTE = 0x7E;
|
||||||
|
static const uint8_t VERSION_BYTE = 0xFF;
|
||||||
|
static const uint8_t END_BYTE = 0xEF;
|
||||||
|
|
||||||
|
// Valid volumes are 0 - 30.
|
||||||
|
static const uint8_t COMMAND_SPECIFY_VOLUME = 0x06;
|
||||||
|
static const uint8_t COMMAND_PAUSE = 0x0E;
|
||||||
|
static const uint8_t COMMAND_PLAY_TRACK_IN_FOLDER = 0x0F;
|
||||||
|
|
||||||
|
__attribute__((always_inline)) inline uint16_t CalculateChecksum(uint8_t * buffer, uint8_t length)
|
||||||
|
{
|
||||||
|
uint16_t checksum = 0;
|
||||||
|
|
||||||
|
for (uint_fast8_t i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
checksum += buffer[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0 - checksum);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Send_Command(uint8_t command, bool requireFeedback, uint16_t parameter)
|
||||||
|
{
|
||||||
|
uint8_t buffer[10];
|
||||||
|
uint16_t checksum;
|
||||||
|
|
||||||
|
buffer[0] = START_BYTE;
|
||||||
|
buffer[1] = VERSION_BYTE;
|
||||||
|
buffer[2] = 6; // count
|
||||||
|
buffer[3] = command;
|
||||||
|
buffer[4] = requireFeedback;
|
||||||
|
buffer[5] = (uint8_t)(parameter >> 8);
|
||||||
|
buffer[6] = (uint8_t)(parameter);
|
||||||
|
|
||||||
|
checksum = CalculateChecksum(&buffer[1], 6);
|
||||||
|
|
||||||
|
buffer[7] = (uint8_t)(checksum >> 8);
|
||||||
|
buffer[8] = (uint8_t)(checksum);
|
||||||
|
buffer[9] = END_BYTE;
|
||||||
|
|
||||||
|
for (uint_fast8_t i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
UART_Audio_Put(buffer[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemKResult_T Perform_Audio_Action(AudioAction_T * action)
|
||||||
|
{
|
||||||
|
if (xQueueSend(xQueueAudio, action, 0) == pdTRUE)
|
||||||
|
{
|
||||||
|
return SYSTEMK_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return SYSTEMK_RESULT_QUEUE_IS_FULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init_Audio(void)
|
||||||
|
{
|
||||||
|
UART_Audio_Start();
|
||||||
|
|
||||||
|
xQueueAudio = xQueueCreate(5, sizeof(AudioAction_T));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio_Task(void * pvParameters)
|
||||||
|
{
|
||||||
|
portBASE_TYPE xStatus;
|
||||||
|
|
||||||
|
while (IsNVMInitialized() == false)
|
||||||
|
{
|
||||||
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
Send_Command(COMMAND_SPECIFY_VOLUME, false, NVM_VOLUME);
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
AudioAction_T action;
|
||||||
|
|
||||||
|
xStatus = xQueueReceive(xQueueAudio, &action, 0);
|
||||||
|
|
||||||
|
if (xStatus == pdPASS)
|
||||||
|
{
|
||||||
|
switch (action.ID)
|
||||||
|
{
|
||||||
|
case AUDIO_SET_VOLUME:
|
||||||
|
{
|
||||||
|
uint8_t volume = *((uint8_t *)action.Data);
|
||||||
|
if (volume <= 30)
|
||||||
|
{
|
||||||
|
Send_Command(COMMAND_SPECIFY_VOLUME, false, volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_SILENCE:
|
||||||
|
Send_Command(COMMAND_PAUSE, false, 0x0000);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_STARTUP_SOUND:
|
||||||
|
// Play track "001" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0101);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_SHOT_FIRED:
|
||||||
|
// Play track "002" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0102);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_TAG_RECEIVED:
|
||||||
|
// Play track "003" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0103);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_TAGGED_OUT:
|
||||||
|
// Play track "004" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0104);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_MISFIRE:
|
||||||
|
// Play track "005" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0105);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PRONOUNCE_NUMBER_0_TO_100:
|
||||||
|
{
|
||||||
|
uint8_t file_index = *((uint8_t *)action.Data);
|
||||||
|
if (file_index > 100)
|
||||||
|
{
|
||||||
|
file_index = 100;
|
||||||
|
}
|
||||||
|
else if (file_index == 0)
|
||||||
|
{
|
||||||
|
file_index = 101;
|
||||||
|
}
|
||||||
|
// The numbers are stored in folder "10".
|
||||||
|
// 001.mp3 is "one", 100.mp3 is "one hundred", and 101.mp3 is "zero".
|
||||||
|
uint16_t filenumber = 0x0A00 + file_index;
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, filenumber);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_MENU_PROMPT:
|
||||||
|
// Play track "006" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0106);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_SELECTION_INDICATOR:
|
||||||
|
// Play track "007" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0107);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_HEALTH_REMAINING:
|
||||||
|
// Play track "008" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0108);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_ELECTRONIC_DANCE_MUSIC:
|
||||||
|
// Play track "009" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0109);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case AUDIO_PLAY_GENERIC_ERROR:
|
||||||
|
// Play track "010" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x010A);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_VOLUME_PROMPT:
|
||||||
|
// Play track "011" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x010B);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_RIGHT_HANDED:
|
||||||
|
// Play track "012" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x010C);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_LEFT_HANDED:
|
||||||
|
// Play track "013" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x010D);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_GAME_ON:
|
||||||
|
// Play track "014" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x010E);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_HARDWARE_SETTINGS_PROMPT:
|
||||||
|
// Play track "015" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x010F);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_GAME_SETTINGS_PROMPT:
|
||||||
|
// Play track "016" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0110);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_BONK:
|
||||||
|
// Play track "017" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0111);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_NEAR_MISS:
|
||||||
|
// Play track "018" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0112);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_PLAYER_ID_PROMPT:
|
||||||
|
// Play track "019" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0113);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_TEAM_ID_PROMPT:
|
||||||
|
// Play track "020" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0114);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_FRIENDLY_FIRE:
|
||||||
|
// Play track "021" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0115);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_STARTING_THEME:
|
||||||
|
// Play track "022" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0116);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_BOOP:
|
||||||
|
// Play track "023" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0117);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_BEEP:
|
||||||
|
// Play track "024" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0118);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_REPROGRAMMING:
|
||||||
|
// Play track "025" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x0119);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_BOMB:
|
||||||
|
// Play track "026" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x011A);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_PLAY_GAME_OVER:
|
||||||
|
// Play track "027" in folder "01".
|
||||||
|
Send_Command(COMMAND_PLAY_TRACK_IN_FOLDER, false, 0x011B);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action.Play_To_Completion == true)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
|
} while (Is_Audio_Playing() == true);
|
||||||
|
|
||||||
|
KEvent_T command_received_event = {.ID = KEVENT_AUDIO_COMPLETED, .Data = (void *)action.ID};
|
||||||
|
Post_KEvent(&command_received_event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Is_Audio_Playing()
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
// The signal is active low.
|
||||||
|
if (Cy_GPIO_Read(Pin_Audio_Busy_PORT, Pin_Audio_Busy_NUM) == 0)
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
7
2020TPCApp1.cydsn/Audio.h
Normal file
7
2020TPCApp1.cydsn/Audio.h
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
extern QueueHandle_t xQueueAudio;
|
||||||
|
extern TaskHandle_t Audio_Task_Handle;
|
||||||
|
|
||||||
|
void Init_Audio(void);
|
||||||
|
void Audio_Task(void * pvParameters);
|
||||||
|
bool Is_Audio_Playing();
|
1013
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.c
Normal file
1013
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.c
Normal file
File diff suppressed because it is too large
Load diff
79
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.h
Normal file
79
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE.h
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
/** \dir "BLE"
|
||||||
|
*
|
||||||
|
* \brief This directory contains source code for managing Bluetooth Low Energy communications.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines the interface to the Bluetooth Low Energy communications used by this software.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_BLE_H
|
||||||
|
#define COMM_BLE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
// Define this to print out BLE trace statements to the console.
|
||||||
|
//#define TRACE_BLE
|
||||||
|
//#define VERBOSE_BLE_TRACE
|
||||||
|
|
||||||
|
#define COMM_BLE_TASK_STACK_SIZE_in_bytes 4096
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
COMM_BLE_DEFAULT,
|
||||||
|
COMM_BLE_INITIALIZING,
|
||||||
|
COMM_BLE_IDLE,
|
||||||
|
COMM_BLE_SCANNING_FOR_KTAG_PACKETS,
|
||||||
|
COMM_BLE_ADVERTISING_AS_PERIPHERAL,
|
||||||
|
COMM_BLE_ADVERTISING_AS_BROADCASTER,
|
||||||
|
COMM_BLE_SCANNING_AND_ADVERTISING
|
||||||
|
} COMM_BLE_StateID_T;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
COMM_BLE_COMMAND_NO_OP,
|
||||||
|
COMM_BLE_REQUEST_STATE_CHANGE,
|
||||||
|
COMM_BLE_PROCESS_BLE_EVENTS,
|
||||||
|
COMM_BLE_SCAN_FOR_KTAG_PACKETS,
|
||||||
|
COMM_BLE_ADVERTISE_AS_BROADCASTER,
|
||||||
|
COMM_BLE_ADVERTISE_AS_PERIPHERAL,
|
||||||
|
COMM_BLE_STOP_ADVERTISING,
|
||||||
|
COMM_BLE_SCAN_AND_ADVERTISE,
|
||||||
|
// COMM_BLE_COMMAND_IS_OUT_OF_RANGE is one more than the last valid command.
|
||||||
|
COMM_BLE_COMMAND_IS_OUT_OF_RANGE
|
||||||
|
} COMM_BLE_Command_ID_T;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
COMM_BLE_Command_ID_T ID;
|
||||||
|
void * Data;
|
||||||
|
} COMM_BLE_Command_T;
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
extern cy_stc_ble_conn_handle_t appConnHandle[CY_BLE_CONN_COUNT];
|
||||||
|
extern volatile uint8_t COMM_BLE_IASAlertLevel;
|
||||||
|
|
||||||
|
extern QueueHandle_t COMM_BLE_CommandQueue;
|
||||||
|
|
||||||
|
//! Handle of the COMM_BLE_Task() given when the task was created.
|
||||||
|
extern TaskHandle_t COMM_BLE_Task_Handle;
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
void COMM_BLE_Init(void);
|
||||||
|
void COMM_BLE_Task(void * pvParameters);
|
||||||
|
void COMM_BLE_RequestState(COMM_BLE_StateID_T state);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_BLE_H
|
252
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE_Bond.c
Normal file
252
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE_Bond.c
Normal file
|
@ -0,0 +1,252 @@
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
static bool removeBondListFlag = false;
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: App_DisplayBondList()
|
||||||
|
********************************************************************************
|
||||||
|
*
|
||||||
|
* Summary:
|
||||||
|
* This function displays the bond list.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void App_DisplayBondList(void)
|
||||||
|
{
|
||||||
|
#ifdef TRACE_BLE
|
||||||
|
cy_en_ble_api_result_t apiResult;
|
||||||
|
cy_stc_ble_gap_peer_addr_info_t bondedDeviceInfo[CY_BLE_MAX_BONDED_DEVICES];
|
||||||
|
cy_stc_ble_gap_bonded_device_list_info_t bondedDeviceList =
|
||||||
|
{
|
||||||
|
.bdHandleAddrList = bondedDeviceInfo
|
||||||
|
};
|
||||||
|
uint8_t deviceCount;
|
||||||
|
|
||||||
|
/* Find out whether the device has bonded information stored already or not */
|
||||||
|
apiResult = Cy_BLE_GAP_GetBondList(&bondedDeviceList);
|
||||||
|
if (apiResult != CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("[BLE] Cy_BLE_GAP_GetBondList API Error: 0x");
|
||||||
|
COMM_Console_Print_UInt32AsHex(apiResult);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deviceCount = bondedDeviceList.noOfDevices;
|
||||||
|
|
||||||
|
if(deviceCount != 0u)
|
||||||
|
{
|
||||||
|
uint8_t counter;
|
||||||
|
|
||||||
|
COMM_Console_Print_String("[BLE] Bond list:\n");
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String(" ");
|
||||||
|
COMM_Console_Print_UInt8(deviceCount);
|
||||||
|
COMM_Console_Print_String(". ");
|
||||||
|
|
||||||
|
deviceCount--;
|
||||||
|
|
||||||
|
if(bondedDeviceList.bdHandleAddrList[deviceCount].bdAddr.type == CY_BLE_GAP_ADDR_TYPE_RANDOM)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Peer Random Address:");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Peer Public Address:");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (counter = CY_BLE_GAP_BD_ADDR_SIZE; counter > 0u; counter--)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String(" ");
|
||||||
|
COMM_Console_Print_UInt8AsHex(bondedDeviceList.bdHandleAddrList[deviceCount].bdAddr.bdAddr[counter - 1u]);
|
||||||
|
}
|
||||||
|
COMM_Console_Print_String(", bdHandle: 0x");
|
||||||
|
COMM_Console_Print_UInt8AsHex(bondedDeviceList.bdHandleAddrList[deviceCount].bdHandle);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
} while (deviceCount != 0u);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // TRACE_BLE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: App_RemoveDevidesFromBondList
|
||||||
|
********************************************************************************
|
||||||
|
*
|
||||||
|
* Summary:
|
||||||
|
* Remove devices from the bond list.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void App_RemoveDevicesFromBondList(void)
|
||||||
|
{
|
||||||
|
#if(CY_BLE_BONDING_REQUIREMENT == CY_BLE_BONDING_YES)
|
||||||
|
cy_en_ble_api_result_t apiResult;
|
||||||
|
cy_stc_ble_gap_bd_addr_t peerBdAddr = { .type = 0u };
|
||||||
|
#ifdef TRACE_BLE
|
||||||
|
COMM_Console_Print_String("[BLE] Cleaning Bond List...\n\n");
|
||||||
|
#endif // TRACE_BLE
|
||||||
|
|
||||||
|
/* Remove all bonded devices in the list */
|
||||||
|
apiResult = Cy_BLE_GAP_RemoveBondedDevice(&peerBdAddr);
|
||||||
|
if (apiResult != CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
#ifdef TRACE_BLE
|
||||||
|
COMM_Console_Print_String("[BLE] Cy_BLE_GAP_RemoveBondedDevice API Error: 0x");
|
||||||
|
COMM_Console_Print_UInt32AsHex(apiResult);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
#endif // TRACE_BLE
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef TRACE_BLE
|
||||||
|
COMM_Console_Print_String("[BLE] Cy_BLE_GAP_RemoveBondedDevice complete.\n\n");
|
||||||
|
#endif // TRACE_BLE
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#ifdef TRACE_BLE
|
||||||
|
COMM_Console_Print_String("[BLE] Bonding is disabled...no need to remove bonded devices.\n\n");
|
||||||
|
#endif // TRACE_BLE
|
||||||
|
#endif /* (CY_BLE_BONDING_REQUIREMENT == CY_BLE_BONDING_YES) */
|
||||||
|
|
||||||
|
/* Clean flag */
|
||||||
|
removeBondListFlag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: App_GetCountOfBondedDevices()
|
||||||
|
********************************************************************************
|
||||||
|
*
|
||||||
|
* Summary:
|
||||||
|
* This function returns the count of bonded devices
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* uint32_t The count of bonded devices
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
uint32_t App_GetCountOfBondedDevices(void)
|
||||||
|
{
|
||||||
|
cy_en_ble_api_result_t apiResult;
|
||||||
|
cy_stc_ble_gap_peer_addr_info_t bondedDeviceInfo[CY_BLE_MAX_BONDED_DEVICES];
|
||||||
|
cy_stc_ble_gap_bonded_device_list_info_t bondedDeviceList =
|
||||||
|
{
|
||||||
|
.bdHandleAddrList = bondedDeviceInfo
|
||||||
|
};
|
||||||
|
uint32_t deviceCount = 0u;
|
||||||
|
|
||||||
|
/* Find out whether the device has bonded information stored already or not */
|
||||||
|
apiResult = Cy_BLE_GAP_GetBondList(&bondedDeviceList);
|
||||||
|
if (apiResult != CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
#ifdef TRACE_BLE
|
||||||
|
COMM_Console_Print_String("[BLE] Cy_BLE_GAP_GetBondList API Error: 0x");
|
||||||
|
COMM_Console_Print_UInt32AsHex(apiResult);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
#endif // TRACE_BLE
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deviceCount = bondedDeviceList.noOfDevices;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (deviceCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: App_IsDeviceInBondList()
|
||||||
|
********************************************************************************
|
||||||
|
*
|
||||||
|
* Summary:
|
||||||
|
* This function check if device with bdHandle is in the bond list
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* bdHandle - bond device handler
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* bool - true value when bdHandle exists in bond list
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
bool App_IsDeviceInBondList(uint32_t bdHandle)
|
||||||
|
{
|
||||||
|
cy_en_ble_api_result_t apiResult;
|
||||||
|
cy_stc_ble_gap_peer_addr_info_t bondedDeviceInfo[CY_BLE_MAX_BONDED_DEVICES];
|
||||||
|
cy_stc_ble_gap_bonded_device_list_info_t bondedDeviceList =
|
||||||
|
{
|
||||||
|
.bdHandleAddrList = bondedDeviceInfo
|
||||||
|
};
|
||||||
|
bool deviceIsDetected = false;
|
||||||
|
uint32_t deviceCount;
|
||||||
|
|
||||||
|
/* Find out whether the device has bonding information stored already or not */
|
||||||
|
apiResult = Cy_BLE_GAP_GetBondList(&bondedDeviceList);
|
||||||
|
if (apiResult != CY_BLE_SUCCESS)
|
||||||
|
{
|
||||||
|
#ifdef TRACE_BLE
|
||||||
|
COMM_Console_Print_String("[BLE] Cy_BLE_GAP_GetBondList API Error: 0x");
|
||||||
|
COMM_Console_Print_UInt32AsHex(apiResult);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
#endif // TRACE_BLE
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deviceCount = bondedDeviceList.noOfDevices;
|
||||||
|
|
||||||
|
if(deviceCount != 0u)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
deviceCount--;
|
||||||
|
if(bdHandle == bondedDeviceList.bdHandleAddrList[deviceCount].bdHandle)
|
||||||
|
{
|
||||||
|
deviceIsDetected = 1u;
|
||||||
|
}
|
||||||
|
} while(deviceCount != 0u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(deviceIsDetected);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: App_SetRemoveBondListFlag()
|
||||||
|
********************************************************************************
|
||||||
|
* Summary:
|
||||||
|
* Set flag for removing bond list
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
void App_SetRemoveBondListFlag(void)
|
||||||
|
{
|
||||||
|
removeBondListFlag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name: App_IsRemoveBondListFlag()
|
||||||
|
********************************************************************************
|
||||||
|
* Summary:
|
||||||
|
* Get value of remove bond list flag
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* true - remove bond list flag is set
|
||||||
|
* false - remove bond list flag is clear
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
bool App_IsRemoveBondListFlag(void)
|
||||||
|
{
|
||||||
|
return ((removeBondListFlag == true) ? true : false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Private Functions */
|
32
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE_Bond.h
Normal file
32
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE_Bond.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file declares Bluetooth Low Energy bond list helper functions.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_BLE_BOND_H
|
||||||
|
#define COMM_BLE_BOND_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
void App_DisplayBondList(void);
|
||||||
|
void App_RemoveDevicesFromBondListBySW2Press(uint32_t seconds);
|
||||||
|
void App_RemoveDevicesFromBondList(void);
|
||||||
|
void App_SetRemoveBondListFlag(void);
|
||||||
|
bool App_IsRemoveBondListFlag(void);
|
||||||
|
bool App_IsDeviceInBondList(uint32_t bdHandle);
|
||||||
|
uint32_t App_GetCountOfBondedDevices(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_BLE_BOND_H
|
177
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE_UART.c
Normal file
177
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE_UART.c
Normal file
|
@ -0,0 +1,177 @@
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
#define UART_CIRCULAR_BUFFER_SIZE 1024
|
||||||
|
#define BLE_UART_BUFFER_CHARACTERISTIC_SIZE 20
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
static uint_fast16_t UART_Tx_Notifications_Enabled = 0;
|
||||||
|
|
||||||
|
static uint8_t UART_Tx_Buffer_Storage[UART_CIRCULAR_BUFFER_SIZE];
|
||||||
|
static UTIL_CircularBuffer_T UART_Tx_Buffer;
|
||||||
|
static uint8_t BLE_UART_Tx_Buffer[BLE_UART_BUFFER_CHARACTERISTIC_SIZE];
|
||||||
|
static uint8_t Rx_Buffer[BLE_UART_BUFFER_CHARACTERISTIC_SIZE + 1];
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
void COMM_BLE_UART_Init(void)
|
||||||
|
{
|
||||||
|
UTIL_InitCircularBuffer(&UART_Tx_Buffer, UART_Tx_Buffer_Storage, UART_CIRCULAR_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Sends a message over the BLE UART.
|
||||||
|
void COMM_BLE_UART_PutString(const char8 * string, uint16_t length)
|
||||||
|
{
|
||||||
|
for (uint8_t i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
(void) UTIL_PushToCircularBuffer(&UART_Tx_Buffer, *string++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Sends a single character over the BLE UART.
|
||||||
|
void COMM_BLE_UART_PutChar(char8 character)
|
||||||
|
{
|
||||||
|
(void) UTIL_PushToCircularBuffer(&UART_Tx_Buffer, character);
|
||||||
|
}
|
||||||
|
|
||||||
|
void COMM_BLE_UART_MaybeSendData(void)
|
||||||
|
{
|
||||||
|
int8_t length = 0;
|
||||||
|
|
||||||
|
if (UTIL_IsCircularBufferEmpty(&UART_Tx_Buffer) == false)
|
||||||
|
{
|
||||||
|
while ((length < BLE_UART_BUFFER_CHARACTERISTIC_SIZE) && (UTIL_IsCircularBufferEmpty(&UART_Tx_Buffer) == false))
|
||||||
|
{
|
||||||
|
uint8_t value;
|
||||||
|
if (UTIL_PopFromCircularBuffer(&UART_Tx_Buffer, &value) == UTIL_CIRCULARBUFFERRESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
BLE_UART_Tx_Buffer[length] = value;
|
||||||
|
length++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length > 0)
|
||||||
|
{
|
||||||
|
for (uint_fast8_t i = 0; i < CY_BLE_CONN_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (Cy_BLE_GetConnectionState(appConnHandle[i]) >= CY_BLE_CONN_STATE_CONNECTED)
|
||||||
|
{
|
||||||
|
cy_stc_ble_gatt_handle_value_pair_t tempHandle;
|
||||||
|
|
||||||
|
tempHandle.attrHandle = CY_BLE_NORDIC_UART_SERVICE_TX_CHAR_HANDLE;
|
||||||
|
tempHandle.value.val = (uint8 *) BLE_UART_Tx_Buffer;
|
||||||
|
tempHandle.value.actualLen = length;
|
||||||
|
tempHandle.value.len = length;
|
||||||
|
|
||||||
|
Cy_BLE_GATTS_WriteAttributeValueLocal(&tempHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send notification to each client that has TX notifications enabled.
|
||||||
|
for (uint_fast8_t i = 0; i < CY_BLE_CONN_COUNT; i++)
|
||||||
|
{
|
||||||
|
if ((Cy_BLE_GetConnectionState(appConnHandle[i]) >= CY_BLE_CONN_STATE_CONNECTED) &&
|
||||||
|
Cy_BLE_GATTS_IsNotificationEnabled(&appConnHandle[i],
|
||||||
|
CY_BLE_NORDIC_UART_SERVICE_TX_TXCCCD_DESC_HANDLE))
|
||||||
|
{
|
||||||
|
cy_stc_ble_gatt_handle_value_pair_t tempHandle;
|
||||||
|
|
||||||
|
tempHandle.attrHandle = CY_BLE_NORDIC_UART_SERVICE_TX_CHAR_HANDLE;
|
||||||
|
tempHandle.value.val = (uint8 *) BLE_UART_Tx_Buffer;
|
||||||
|
tempHandle.value.actualLen = length;
|
||||||
|
tempHandle.value.len = length;
|
||||||
|
|
||||||
|
Cy_BLE_GATTS_SendNotification(&appConnHandle[i], &tempHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! BLE event handler for the BLE UART feature.
|
||||||
|
/*!
|
||||||
|
* This function should be called *before* events are handled in the event handler passed to
|
||||||
|
* Cy_BLE_Start(). If it returns `false`, then the rest of the event handler should proceed.
|
||||||
|
*
|
||||||
|
* \param event BLE stack event code received from the BLE middleware (one of cy_en_ble_event_t).
|
||||||
|
* \param eventParam pointer to an event-specific data structure containing the relevant event information.
|
||||||
|
* \return true if this handler has completely handled the event, and no further
|
||||||
|
* handling is necessary; false otherwise.
|
||||||
|
*/
|
||||||
|
bool COMM_BLE_UART_HandleEvent(uint32 event, void * eventParam)
|
||||||
|
{
|
||||||
|
static cy_stc_ble_gatts_write_cmd_req_param_t * writeReqParameter;
|
||||||
|
bool handled = false;
|
||||||
|
|
||||||
|
/* Take an action based on the current event */
|
||||||
|
switch ((cy_en_ble_event_t)event)
|
||||||
|
{
|
||||||
|
// Handle a write request.
|
||||||
|
case CY_BLE_EVT_GATTS_WRITE_REQ:
|
||||||
|
|
||||||
|
writeReqParameter = (cy_stc_ble_gatts_write_cmd_req_param_t*)eventParam;
|
||||||
|
|
||||||
|
// Request to write the UART.
|
||||||
|
// https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.2.0%2Fble_sdk_app_nus_eval.html&cp=5_5_0_4_1_2_24
|
||||||
|
if (writeReqParameter->handleValPair.attrHandle == CY_BLE_NORDIC_UART_SERVICE_RX_CHAR_HANDLE)
|
||||||
|
{
|
||||||
|
// Only update the value and write the response if the requested write is allowed.
|
||||||
|
if (CY_BLE_GATT_ERR_NONE == Cy_BLE_GATTS_WriteAttributeValuePeer(&writeReqParameter->connHandle, &writeReqParameter->handleValPair))
|
||||||
|
{
|
||||||
|
uint16_t i;
|
||||||
|
|
||||||
|
for (i = 0; (i < BLE_UART_BUFFER_CHARACTERISTIC_SIZE) && (i < writeReqParameter->handleValPair.value.len); i++)
|
||||||
|
{
|
||||||
|
Rx_Buffer[i] = writeReqParameter->handleValPair.value.val[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// NULL-terminate the buffer.
|
||||||
|
Rx_Buffer[i] = 0x00;
|
||||||
|
|
||||||
|
Cy_BLE_GATTS_WriteRsp(writeReqParameter->connHandle);
|
||||||
|
|
||||||
|
COMM_Console_Execute_Internal_Command(Rx_Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request for UART Tx notifications.
|
||||||
|
if (writeReqParameter->handleValPair.attrHandle == CY_BLE_NORDIC_UART_SERVICE_TX_TXCCCD_DESC_HANDLE)
|
||||||
|
{
|
||||||
|
if (CY_BLE_GATT_ERR_NONE == Cy_BLE_GATTS_WriteAttributeValuePeer(&writeReqParameter->connHandle, &writeReqParameter->handleValPair))
|
||||||
|
{
|
||||||
|
UART_Tx_Notifications_Enabled = writeReqParameter->handleValPair.value.val[0] & 0x01;
|
||||||
|
|
||||||
|
if (UART_Tx_Notifications_Enabled)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("[BLE] UART Tx notifications enabled.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("[BLE] UART Tx notifications disabled.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
Cy_BLE_GATTS_WriteRsp(writeReqParameter->connHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// (`handled` is already set to false.)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Private Functions */
|
30
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE_UART.h
Normal file
30
2020TPCApp1.cydsn/COMM/BLE/COMM_BLE_UART.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file declares interface functions to a BLE UART implementation.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_BLE_UART_H
|
||||||
|
#define COMM_BLE_UART_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
void COMM_BLE_UART_Init(void);
|
||||||
|
void COMM_BLE_UART_PutString(const char8 * string, uint16_t length);
|
||||||
|
void COMM_BLE_UART_PutChar(char8 character);
|
||||||
|
void COMM_BLE_UART_MaybeSendData(void);
|
||||||
|
bool COMM_BLE_UART_HandleEvent(uint32 event, void * eventParam);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_BLE_UART_H
|
50
2020TPCApp1.cydsn/COMM/COMM.h
Normal file
50
2020TPCApp1.cydsn/COMM/COMM.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/** \dir "COMM"
|
||||||
|
*
|
||||||
|
* \brief This directory contains source code for the communication interfaces used by this software.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines the interface to the communications used by this software.
|
||||||
|
*
|
||||||
|
* This file should be included by any file outside the COMM package wishing to make use
|
||||||
|
* of any of the configuration information provided by the COMM package.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_H
|
||||||
|
#define COMM_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include "COMM_IPC_Messages.h"
|
||||||
|
#include "BLE/COMM_BLE.h"
|
||||||
|
#include "BLE/COMM_BLE_Bond.h"
|
||||||
|
#include "BLE/COMM_BLE_UART.h"
|
||||||
|
#include "COMM_Console.h"
|
||||||
|
#include "COMM_Console_Util.h"
|
||||||
|
#include "COMM_I2C_Bus.h"
|
||||||
|
#include "COMM_Util.h"
|
||||||
|
#include "ConsoleCommands/COMM_ConsoleCommands.h"
|
||||||
|
#include "ConsoleCommands/COMM_BLE_ConsoleCommands.h"
|
||||||
|
#include "ConsoleCommands/COMM_NVM_ConsoleCommands.h"
|
||||||
|
#include "ConsoleCommands/COMM_RTOS_ConsoleCommands.h"
|
||||||
|
#include "ConsoleCommands/COMM_STATE_ConsoleCommands.h"
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
#define DebugPrintf(...)
|
||||||
|
#define Task_DebugPrintf(...)
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_H
|
639
2020TPCApp1.cydsn/COMM/COMM_Console.c
Normal file
639
2020TPCApp1.cydsn/COMM/COMM_Console.c
Normal file
|
@ -0,0 +1,639 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file implements a simple serial debug console and command interpreter.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \defgroup CONSOLE Console
|
||||||
|
*
|
||||||
|
* \brief Serial debug console command interpreter.
|
||||||
|
*
|
||||||
|
* \todo Describe the command interpreter.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
//! Text representations of numeric digits, used by COMM_Console_Print_UInt32().
|
||||||
|
static const char8 DIGITS[] = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
//! Maximum number of characters (save one) able to be printed by COMM_Console_Print_String().
|
||||||
|
#define MAX_CONSOLE_STRING_LENGTH 81
|
||||||
|
|
||||||
|
//! States in the COMM_Console_Task() state machine.
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
COMM_STATE_INITIALIZING = 0,
|
||||||
|
COMM_STATE_DISPLAY_POWERUP_INFO,
|
||||||
|
COMM_STATE_IDLE,
|
||||||
|
COMM_STATE_COMMAND_TOO_LONG,
|
||||||
|
COMM_STATE_IDENTIFY_COMMAND,
|
||||||
|
COMM_STATE_EXECUTE_COMMAND,
|
||||||
|
COMM_STATE_UNKNOWN_COMMAND
|
||||||
|
} COMM_Console_State_T;
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
char8 Command_Buffer[COMM_CONSOLE_COMMAND_MAX_LENGTH];
|
||||||
|
uint_fast16_t Command_Buffer_Index = 0;
|
||||||
|
TaskHandle_t COMM_Console_Task_Handle;
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
//! Current state of the COMM_Console_Task() state machine.
|
||||||
|
static COMM_Console_State_T Current_State = COMM_STATE_INITIALIZING;
|
||||||
|
|
||||||
|
//! Next state of the COMM_Console_Task() state machine.
|
||||||
|
static COMM_Console_State_T Next_State = COMM_STATE_INITIALIZING;
|
||||||
|
|
||||||
|
//! Index into the #COMM_Console_Command_Table for the command currently being handled.
|
||||||
|
/*!
|
||||||
|
* If #Current_Command is set to UINT_FAST16_MAX, the command being handled is unknown, or no command is being handled.
|
||||||
|
*/
|
||||||
|
static uint_fast16_t Current_Command = 0;
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
static void ConsoleISR(void);
|
||||||
|
static bool ConsoleCommandMatches(const char8 * const command_name);
|
||||||
|
static void ReverseString(char8 * value, uint32_t length);
|
||||||
|
|
||||||
|
/* Inline Functions */
|
||||||
|
|
||||||
|
//! Swaps the characters in x and y.
|
||||||
|
static inline void Swap_Char8(char8 * x, char8 * y)
|
||||||
|
{
|
||||||
|
uint8_t temp = *x;
|
||||||
|
*x = *y;
|
||||||
|
*y = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void Reset_Command_Buffer()
|
||||||
|
{
|
||||||
|
taskENTER_CRITICAL();
|
||||||
|
for (uint_fast16_t i = 0; i < COMM_CONSOLE_COMMAND_MAX_LENGTH; i++)
|
||||||
|
{
|
||||||
|
Command_Buffer[i] = COMM_CONSOLE_STRING_TERMINATOR;
|
||||||
|
}
|
||||||
|
Command_Buffer_Index = 0;
|
||||||
|
taskEXIT_CRITICAL();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
//! Initializes the console.
|
||||||
|
/*!
|
||||||
|
* \ingroup CONSOLE
|
||||||
|
*/
|
||||||
|
void COMM_Console_Init(void)
|
||||||
|
{
|
||||||
|
// Enable the pullup on the Rx pin to keep the noise down.
|
||||||
|
Cy_GPIO_SetDrivemode(UART_Console_rx_PORT, UART_Console_rx_NUM, CY_GPIO_DM_PULLUP);
|
||||||
|
UART_Console_Start();
|
||||||
|
|
||||||
|
/// Unmask only the RX FIFO not empty interrupt bit.
|
||||||
|
UART_Console_HW->INTR_RX_MASK = SCB_INTR_RX_MASK_NOT_EMPTY_Msk;
|
||||||
|
Cy_SysInt_Init(&Int_UART_Console_cfg, ConsoleISR);
|
||||||
|
NVIC_ClearPendingIRQ(Int_UART_Console_cfg.intrSrc);
|
||||||
|
NVIC_EnableIRQ(Int_UART_Console_cfg.intrSrc);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Parses and handle console commands in the background.
|
||||||
|
/*!
|
||||||
|
* \ingroup CONSOLE
|
||||||
|
*
|
||||||
|
* The [UML State Machine Diagram](http://www.uml-diagrams.org/state-machine-diagrams.html) below
|
||||||
|
* shows how the console messages processed by this code. Note that all of the *Character Rx'd*
|
||||||
|
* transitions occur in the #UART_Console_SPI_UART_ISR_EntryCallback() itself on the PSoC4, in
|
||||||
|
* #ConsoleRxISR() on the PSoC5, and in #ConsoleISR() on the PSoC6, to improve overall performance.
|
||||||
|
*
|
||||||
|
* \startuml{COMM_Console_Task.png} "Console Task"
|
||||||
|
*
|
||||||
|
* skinparam headerFontSize 18
|
||||||
|
* skinparam state {
|
||||||
|
* BackgroundColor #eeeeee
|
||||||
|
* BackgroundColor<<Error>> #ffaaaa
|
||||||
|
* FontName Impact
|
||||||
|
* FontSize 18
|
||||||
|
* }
|
||||||
|
* skinparam note {
|
||||||
|
* FontName "Comic Sans MS"
|
||||||
|
* FontStyle italic
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* state "Initializing" as STATE_INITIALIZING
|
||||||
|
* [*] --> STATE_INITIALIZING
|
||||||
|
* note left of STATE_INITIALIZING : Wait for the rest of the system to come online.
|
||||||
|
* state "Display Powerup Info" as STATE_DISPLAY_POWERUP_INFO
|
||||||
|
* STATE_DISPLAY_POWERUP_INFO : do/ print OS version
|
||||||
|
* STATE_DISPLAY_POWERUP_INFO : do/ print configuration (debug or release)
|
||||||
|
* STATE_INITIALIZING --> STATE_DISPLAY_POWERUP_INFO : after(100ms)
|
||||||
|
* state "Idle" as STATE_IDLE
|
||||||
|
* STATE_IDLE : do/ RTOS_Sleep()
|
||||||
|
* STATE_DISPLAY_POWERUP_INFO --> STATE_IDLE
|
||||||
|
* state STATE_IS_EOM <<choice>>
|
||||||
|
* note top of STATE_IS_EOM : This happens in\nUART_Console_SPI_UART_ISR_ExitCallback() on PSoC4,\nConsoleRxISR() on PSoC5,\nand ConsoleISR() on PSoC6.
|
||||||
|
* STATE_IDLE --> STATE_IS_EOM : character rx'd
|
||||||
|
* state STATE_IS_COMMAND_BUFFER_FULL <<choice>>
|
||||||
|
* note top of STATE_IS_COMMAND_BUFFER_FULL : This happens in\nUART_Console_SPI_UART_ISR_ExitCallback() on PSoC4,\nConsoleRxISR() on PSoC5,\nand ConsoleISR() on PSoC6.
|
||||||
|
* STATE_IS_EOM --> STATE_IS_COMMAND_BUFFER_FULL : [else]
|
||||||
|
* state "Identify Command" as STATE_IDENTIFY_COMMAND
|
||||||
|
* STATE_IDENTIFY_COMMAND : do/ look for command in the COMM_Console_Command_Table[]
|
||||||
|
* STATE_IS_EOM --> STATE_IDENTIFY_COMMAND : [rx'd character is EOM]
|
||||||
|
* STATE_IDLE --> STATE_IDENTIFY_COMMAND : COMM_Console_Execute_Internal_Command()
|
||||||
|
* state "Command Too Long" as STATE_COMMAND_TOO_LONG
|
||||||
|
* STATE_COMMAND_TOO_LONG : do/ print error message
|
||||||
|
* STATE_COMMAND_TOO_LONG : do/ reset command buffer
|
||||||
|
* STATE_IS_COMMAND_BUFFER_FULL --> STATE_COMMAND_TOO_LONG : [command buffer is full]
|
||||||
|
* STATE_IS_COMMAND_BUFFER_FULL --> STATE_IDLE : [else]/\nAppend received character to command buffer
|
||||||
|
* STATE_COMMAND_TOO_LONG --> STATE_IDLE
|
||||||
|
* state "Execute Command" as STATE_EXECUTE_COMMAND
|
||||||
|
* STATE_EXECUTE_COMMAND : do/ execute console command
|
||||||
|
* STATE_EXECUTE_COMMAND : exit/ reset command buffer
|
||||||
|
* STATE_EXECUTE_COMMAND --> STATE_IDLE
|
||||||
|
* STATE_IDENTIFY_COMMAND --> STATE_EXECUTE_COMMAND : [command matched]
|
||||||
|
* state "Unknown Command" as STATE_UNKNOWN_COMMAND
|
||||||
|
* STATE_UNKNOWN_COMMAND : do/ print error message
|
||||||
|
* STATE_UNKNOWN_COMMAND : do/ reset command buffer
|
||||||
|
* STATE_IDENTIFY_COMMAND --> STATE_UNKNOWN_COMMAND : [else]
|
||||||
|
* STATE_UNKNOWN_COMMAND --> STATE_IDLE
|
||||||
|
*
|
||||||
|
* left footer Key: UML 2.5\nLast modified 2020-12-14
|
||||||
|
* \enduml
|
||||||
|
*
|
||||||
|
* \return None (infinite loop)
|
||||||
|
*/
|
||||||
|
void COMM_Console_Task(void * pvParameters)
|
||||||
|
{
|
||||||
|
static TickType_t xTicksToWait = pdMS_TO_TICKS(10);
|
||||||
|
static uint32_t * NotificationValue;
|
||||||
|
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
(void) xTaskNotifyWait(0, 0, (uint32_t *)&NotificationValue, xTicksToWait);
|
||||||
|
|
||||||
|
// Change to the next state atomically.
|
||||||
|
taskENTER_CRITICAL();
|
||||||
|
Current_State = Next_State;
|
||||||
|
taskEXIT_CRITICAL();
|
||||||
|
|
||||||
|
switch (Current_State)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case COMM_STATE_INITIALIZING:
|
||||||
|
Next_State = COMM_STATE_DISPLAY_POWERUP_INFO;
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
xTicksToWait = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMM_STATE_DISPLAY_POWERUP_INFO:
|
||||||
|
COMM_Console_Print_String("[COMM] ");
|
||||||
|
COMM_RTOS_HandleConsoleVersion(NULL, 0);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
COMM_Console_Print_String("[COMM] Console ready (awaiting commands).\n");
|
||||||
|
Next_State = COMM_STATE_IDLE;
|
||||||
|
xTicksToWait = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMM_STATE_IDLE:
|
||||||
|
xTicksToWait = pdMS_TO_TICKS(100);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMM_STATE_COMMAND_TOO_LONG:
|
||||||
|
COMM_Console_Print_String("[COMM] ERROR: Command \"");
|
||||||
|
COMM_Console_Print_String(Command_Buffer);
|
||||||
|
COMM_Console_Print_String("\" too long!\n");
|
||||||
|
Reset_Command_Buffer();
|
||||||
|
Next_State = COMM_STATE_IDLE;
|
||||||
|
xTicksToWait = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMM_STATE_IDENTIFY_COMMAND:
|
||||||
|
Current_Command = UINT_FAST16_MAX;
|
||||||
|
|
||||||
|
for (uint_fast16_t i = 0; i < COMM_N_CONSOLE_COMMANDS; i++)
|
||||||
|
{
|
||||||
|
if (ConsoleCommandMatches(COMM_Console_Command_Table[i].Command_Name) == true)
|
||||||
|
{
|
||||||
|
Current_Command = i;
|
||||||
|
Next_State = COMM_STATE_EXECUTE_COMMAND;
|
||||||
|
xTicksToWait = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Current_Command == UINT_FAST16_MAX)
|
||||||
|
{
|
||||||
|
// No matching command was found.
|
||||||
|
Next_State = COMM_STATE_UNKNOWN_COMMAND;
|
||||||
|
xTicksToWait = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMM_STATE_EXECUTE_COMMAND:
|
||||||
|
if (COMM_Console_Command_Table[Current_Command].Execute_Command != NULL)
|
||||||
|
{
|
||||||
|
COMM_Console_Command_Result_T result = COMM_Console_Command_Table[Current_Command].Execute_Command(Command_Buffer, Command_Buffer_Index);
|
||||||
|
|
||||||
|
if (result == COMM_CONSOLE_CMD_RESULT_PARAMETER_ERROR)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: Parameter error!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reset_Command_Buffer();
|
||||||
|
Next_State = COMM_STATE_IDLE;
|
||||||
|
xTicksToWait = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMM_STATE_UNKNOWN_COMMAND:
|
||||||
|
COMM_Console_Print_String("ERROR: Command \"");
|
||||||
|
COMM_Console_Print_String(Command_Buffer);
|
||||||
|
COMM_Console_Print_String("\" not recognized! Try '?' for help.\n");
|
||||||
|
Reset_Command_Buffer();
|
||||||
|
Next_State = COMM_STATE_IDLE;
|
||||||
|
xTicksToWait = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemKResult_T HW_Execute_Console_Command(const uint8_t * const command)
|
||||||
|
{
|
||||||
|
COMM_Console_Execute_Internal_Command(command);
|
||||||
|
|
||||||
|
return SYSTEMK_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Executes a (potentially cross-task) console command.
|
||||||
|
/*!
|
||||||
|
* This function is used to initiate a console command from a software source internal to this
|
||||||
|
* CPU. This provides a way to use preexisting console commands on TX-only consoles.
|
||||||
|
*
|
||||||
|
* \note If two calls to this function are made back-to-back (before the COMM_Console_Task() has an
|
||||||
|
* opportunity to run), only the second command will be executed, as it will have overwritten the
|
||||||
|
* first. Allow time for the console commands to execute between calls to this function.
|
||||||
|
*
|
||||||
|
* \param command String containing the command to be executed.
|
||||||
|
*/
|
||||||
|
void COMM_Console_Execute_Internal_Command(const uint8_t * const command)
|
||||||
|
{
|
||||||
|
bool finished = false;
|
||||||
|
uint_fast16_t i = 0;
|
||||||
|
|
||||||
|
taskENTER_CRITICAL();
|
||||||
|
while ( (finished == false) &&
|
||||||
|
(i < COMM_CONSOLE_COMMAND_MAX_LENGTH) &&
|
||||||
|
(command[i] != COMM_CONSOLE_END_OF_MESSAGE ) &&
|
||||||
|
(command[i] != COMM_CONSOLE_STRING_TERMINATOR )
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Command_Buffer[i] = command[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
Command_Buffer_Index = i;
|
||||||
|
|
||||||
|
// If there is still room, terminate the command.
|
||||||
|
if (i < COMM_CONSOLE_COMMAND_MAX_LENGTH)
|
||||||
|
{
|
||||||
|
Command_Buffer[i] = COMM_CONSOLE_END_OF_MESSAGE;
|
||||||
|
}
|
||||||
|
taskEXIT_CRITICAL();
|
||||||
|
|
||||||
|
Next_State = COMM_STATE_IDENTIFY_COMMAND;
|
||||||
|
xTaskNotifyGive(COMM_Console_Task_Handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints a NULL-terminated string to the serial console.
|
||||||
|
void COMM_Console_Print_String(const char8 * const text)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < MAX_CONSOLE_STRING_LENGTH; i++)
|
||||||
|
{
|
||||||
|
// Check for the end of the string. If there is no NULL terminator, up to
|
||||||
|
// MAX_CONSOLE_STRING_LENGTH characters of randomness will be printed.
|
||||||
|
if (text[i] == COMM_CONSOLE_STRING_TERMINATOR)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send out the string, one character at a time.
|
||||||
|
COMM_Console_PutChar(text[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints a 32-bit unsigned integer to the serial console.
|
||||||
|
void COMM_Console_Print_UInt32(uint32_t value)
|
||||||
|
{
|
||||||
|
// The largest string for a unit32_t is 10 characters (4294967296).
|
||||||
|
char8 buffer[10+1];
|
||||||
|
uint_fast8_t buffer_index = 0;
|
||||||
|
|
||||||
|
while (value > 9)
|
||||||
|
{
|
||||||
|
uint8_t digit_index = value % 10;
|
||||||
|
buffer[buffer_index] = DIGITS[digit_index];
|
||||||
|
value = value / 10;
|
||||||
|
buffer_index++;
|
||||||
|
}
|
||||||
|
buffer[buffer_index] = DIGITS[value];
|
||||||
|
buffer_index++;
|
||||||
|
ReverseString(buffer, buffer_index);
|
||||||
|
|
||||||
|
// NULL-terminate the string.
|
||||||
|
buffer[buffer_index] = 0;
|
||||||
|
|
||||||
|
COMM_Console_Print_String(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints a 32-bit signed integer to the serial console.
|
||||||
|
void COMM_Console_Print_SInt32(int32_t value)
|
||||||
|
{
|
||||||
|
if (value < 0)
|
||||||
|
{
|
||||||
|
value *= -1;
|
||||||
|
COMM_Console_PutChar('-');
|
||||||
|
}
|
||||||
|
|
||||||
|
COMM_Console_Print_UInt32(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints a 32-bit unsigned integer to the serial console using a hexadecimal representation.
|
||||||
|
void COMM_Console_Print_UInt32AsHex(uint32_t value)
|
||||||
|
{
|
||||||
|
// The largest hexadecimal string for a unit32_t is 8 characters (FFFFFFFF).
|
||||||
|
char8 buffer[8+1];
|
||||||
|
uint_fast8_t buffer_index = 0;
|
||||||
|
|
||||||
|
while (value > 15)
|
||||||
|
{
|
||||||
|
uint8_t digit_index = value % 16;
|
||||||
|
buffer[buffer_index] = DIGITS[digit_index];
|
||||||
|
value = value / 16;
|
||||||
|
buffer_index++;
|
||||||
|
}
|
||||||
|
buffer[buffer_index] = DIGITS[value];
|
||||||
|
buffer_index++;
|
||||||
|
ReverseString(buffer, buffer_index);
|
||||||
|
|
||||||
|
// NULL-terminate the string.
|
||||||
|
buffer[buffer_index] = 0;
|
||||||
|
|
||||||
|
COMM_Console_PutChar('0');
|
||||||
|
COMM_Console_PutChar('x');
|
||||||
|
COMM_Console_Print_String(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints a 64-bit unsigned integer to the serial console.
|
||||||
|
void COMM_Console_Print_UInt64(uint64_t value)
|
||||||
|
{
|
||||||
|
// The largest string for a unit64_t is 20 characters (18446744073709551615).
|
||||||
|
char8 buffer[20+1];
|
||||||
|
uint_fast8_t buffer_index = 0;
|
||||||
|
|
||||||
|
while (value > 9)
|
||||||
|
{
|
||||||
|
uint8_t digit_index = value % 10;
|
||||||
|
buffer[buffer_index] = DIGITS[digit_index];
|
||||||
|
value = value / 10;
|
||||||
|
buffer_index++;
|
||||||
|
}
|
||||||
|
buffer[buffer_index] = DIGITS[value];
|
||||||
|
buffer_index++;
|
||||||
|
ReverseString(buffer, buffer_index);
|
||||||
|
|
||||||
|
// NULL-terminate the string.
|
||||||
|
buffer[buffer_index] = 0;
|
||||||
|
|
||||||
|
COMM_Console_Print_String(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints a 64-bit unsigned integer to the serial console using a hexadecimal representation.
|
||||||
|
void COMM_Console_Print_UInt64AsHex(uint64_t value)
|
||||||
|
{
|
||||||
|
// The largest hexadecimal string for a unit64_t is 16 characters (FFFFFFFFFFFFFFFF).
|
||||||
|
char8 buffer[16+1];
|
||||||
|
uint_fast8_t buffer_index = 0;
|
||||||
|
|
||||||
|
while (value > 15)
|
||||||
|
{
|
||||||
|
uint8_t digit_index = value % 16;
|
||||||
|
buffer[buffer_index] = DIGITS[digit_index];
|
||||||
|
value = value / 16;
|
||||||
|
buffer_index++;
|
||||||
|
}
|
||||||
|
buffer[buffer_index] = DIGITS[value];
|
||||||
|
buffer_index++;
|
||||||
|
ReverseString(buffer, buffer_index);
|
||||||
|
|
||||||
|
// NULL-terminate the string.
|
||||||
|
buffer[buffer_index] = 0;
|
||||||
|
|
||||||
|
COMM_Console_PutChar('0');
|
||||||
|
COMM_Console_PutChar('x');
|
||||||
|
COMM_Console_Print_String(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints a floating-point number to the serial console.
|
||||||
|
/*!
|
||||||
|
* With thanks to Rick Regan and his [Quick and Dirty Floating-Point to Decimal Conversion](https://www.exploringbinary.com/quick-and-dirty-floating-point-to-decimal-conversion/).
|
||||||
|
*/
|
||||||
|
void COMM_Console_Print_Float(float value)
|
||||||
|
{
|
||||||
|
#define MAX_INTEGRAL_DIGITS 12
|
||||||
|
#define MAX_FRACTIONAL_DIGITS 6
|
||||||
|
#define BUFFER_SIZE (MAX_INTEGRAL_DIGITS + MAX_FRACTIONAL_DIGITS + 2)
|
||||||
|
|
||||||
|
char8 buffer[BUFFER_SIZE];
|
||||||
|
char8 integral_buffer_reversed[MAX_INTEGRAL_DIGITS];
|
||||||
|
uint16_t buffer_index = 0;
|
||||||
|
double integral_value;
|
||||||
|
double fractional_value;
|
||||||
|
bool overflow = false;
|
||||||
|
|
||||||
|
if (value < 0.0)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("-");
|
||||||
|
value *= -1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Break the given value into fractional and integral parts.
|
||||||
|
fractional_value = modf(value, &integral_value);
|
||||||
|
|
||||||
|
if (integral_value > 0)
|
||||||
|
{
|
||||||
|
// Convert the integral part.
|
||||||
|
while ((integral_value > 0) && (buffer_index < MAX_INTEGRAL_DIGITS))
|
||||||
|
{
|
||||||
|
integral_buffer_reversed[buffer_index++] = '0' + (int)fmod(integral_value, 10);
|
||||||
|
integral_value = floor(integral_value / 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there is still an integral part remaining, and overflow has occurred.
|
||||||
|
if (integral_value > 0)
|
||||||
|
{
|
||||||
|
overflow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reverse and append the integral part.
|
||||||
|
for (uint16_t i = 0; i < buffer_index; i++)
|
||||||
|
{
|
||||||
|
buffer[i] = integral_buffer_reversed[buffer_index-i-1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Append a leading zero.
|
||||||
|
buffer[buffer_index++] = '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append the decimal point.
|
||||||
|
buffer[buffer_index++] = '.';
|
||||||
|
|
||||||
|
// Convert the fractional part, even if it is zero, and leave room for the NULL terminator.
|
||||||
|
while (buffer_index < (BUFFER_SIZE - 1))
|
||||||
|
{
|
||||||
|
fractional_value *= 10;
|
||||||
|
buffer[buffer_index++] = '0' + (int)fractional_value;
|
||||||
|
fractional_value = modf(fractional_value, &integral_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append the NULL terminator.
|
||||||
|
buffer[buffer_index] = 0;
|
||||||
|
|
||||||
|
if (overflow == true)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("OVERFLOW");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
//! Converts a byte to a two-character hexadecimal representation.
|
||||||
|
/*!
|
||||||
|
* \param buffer Buffer into which to place the resulting sting. It needs to be at least three
|
||||||
|
* characters wide.
|
||||||
|
* \param byte The byte to be converted.
|
||||||
|
*/
|
||||||
|
void COMM_Console_ByteToHex(char8 * buffer, uint8_t byte)
|
||||||
|
{
|
||||||
|
if (byte < 16)
|
||||||
|
{
|
||||||
|
buffer[0] = '0';
|
||||||
|
buffer[1] = DIGITS[byte];
|
||||||
|
buffer[2] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer[0] = DIGITS[byte / 16];
|
||||||
|
buffer[1] = DIGITS[byte % 16];
|
||||||
|
buffer[2] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Private Functions */
|
||||||
|
|
||||||
|
static void ConsoleISR(void)
|
||||||
|
{
|
||||||
|
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
||||||
|
// Check for the "Rx FIFO not empty" interrput.
|
||||||
|
if ((UART_Console_HW->INTR_RX_MASKED & SCB_INTR_RX_MASKED_NOT_EMPTY_Msk ) != 0)
|
||||||
|
{
|
||||||
|
// Clear the "Rx FIFO not empty" interrput.
|
||||||
|
UART_Console_HW->INTR_RX = UART_Console_HW->INTR_RX & SCB_INTR_RX_NOT_EMPTY_Msk;
|
||||||
|
|
||||||
|
// Get the character.
|
||||||
|
uint32_t value = UART_Console_Get();
|
||||||
|
|
||||||
|
// Check if there is actually data. Sometimes the flag is set when there is no data (why?).
|
||||||
|
if (value != CY_SCB_UART_RX_NO_DATA)
|
||||||
|
{
|
||||||
|
char8 rx_data = (char8) value;
|
||||||
|
|
||||||
|
// Determine what to do with it.
|
||||||
|
if (Command_Buffer_Index < COMM_CONSOLE_COMMAND_MAX_LENGTH)
|
||||||
|
{
|
||||||
|
if (rx_data == COMM_CONSOLE_END_OF_MESSAGE)
|
||||||
|
{
|
||||||
|
Command_Buffer[Command_Buffer_Index] = COMM_CONSOLE_STRING_TERMINATOR;
|
||||||
|
Next_State = COMM_STATE_IDENTIFY_COMMAND;
|
||||||
|
vTaskNotifyGiveFromISR(COMM_Console_Task_Handle, &xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Command_Buffer[Command_Buffer_Index] = rx_data;
|
||||||
|
Command_Buffer_Index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Next_State = COMM_STATE_COMMAND_TOO_LONG;
|
||||||
|
vTaskNotifyGiveFromISR(COMM_Console_Task_Handle, &xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NVIC_ClearPendingIRQ(Int_UART_Console_cfg.intrSrc);
|
||||||
|
|
||||||
|
// If the state needs to change, a context switch might be required.
|
||||||
|
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ConsoleCommandMatches(const char8 * const command_name)
|
||||||
|
{
|
||||||
|
uint32_t i = 0;
|
||||||
|
bool is_match = false;
|
||||||
|
|
||||||
|
if (Command_Buffer[i] == command_name[i])
|
||||||
|
{
|
||||||
|
is_match = true;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( (is_match == true) &&
|
||||||
|
(i < COMM_CONSOLE_COMMAND_MAX_LENGTH) &&
|
||||||
|
(Command_Buffer[i] != COMM_CONSOLE_PARAMETER_DELIMITER) &&
|
||||||
|
(Command_Buffer[i] != COMM_CONSOLE_END_OF_MESSAGE ) &&
|
||||||
|
(Command_Buffer[i] != COMM_CONSOLE_STRING_TERMINATOR )
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( Command_Buffer[i] != command_name[i] )
|
||||||
|
{
|
||||||
|
is_match = false;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_match;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Reverses a string in place.
|
||||||
|
/*!
|
||||||
|
* \param value Pointer to the string to be reversed.
|
||||||
|
* \param length Length of the string, including the NULL terminator.
|
||||||
|
*/
|
||||||
|
static void ReverseString(char8 * value, uint32_t length)
|
||||||
|
{
|
||||||
|
if (length > 1)
|
||||||
|
{
|
||||||
|
uint_fast32_t start = 0;
|
||||||
|
uint_fast32_t end = length - 1;
|
||||||
|
while (start < end)
|
||||||
|
{
|
||||||
|
Swap_Char8(value + start, value + end);
|
||||||
|
start++;
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
144
2020TPCApp1.cydsn/COMM/COMM_Console.h
Normal file
144
2020TPCApp1.cydsn/COMM/COMM_Console.h
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines the interface to a simple serial debug console and command interpreter.
|
||||||
|
*
|
||||||
|
* \note As always, <project.h> and <CONFIG.h> should be included <I>before</I> this file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_CONSOLE_H
|
||||||
|
#define COMM_CONSOLE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
#define COMM_CONSOLE_TASK_STACK_SIZE_in_bytes 512
|
||||||
|
|
||||||
|
#define COMM_Console_PutChar UART_and_BLE_PutChar
|
||||||
|
#define COMM_Console_PutString UART_and_BLE_PutString
|
||||||
|
|
||||||
|
#define COMM_CONSOLE_COMMAND_MAX_LENGTH 50
|
||||||
|
|
||||||
|
//! Character signifying the end of a console message.
|
||||||
|
#define COMM_CONSOLE_END_OF_MESSAGE ('\n')
|
||||||
|
|
||||||
|
//! Character used between parameters in a console message.
|
||||||
|
#define COMM_CONSOLE_PARAMETER_DELIMITER (' ')
|
||||||
|
|
||||||
|
//! Character signifying the end of a string.
|
||||||
|
#define COMM_CONSOLE_STRING_TERMINATOR ('\0')
|
||||||
|
|
||||||
|
//! Result of executing a console command callback.
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
COMM_CONSOLE_CMD_RESULT_UNKNOWN = 0,
|
||||||
|
COMM_CONSOLE_CMD_RESULT_SUCCESS = 1,
|
||||||
|
COMM_CONSOLE_CMD_RESULT_PARAMETER_ERROR = 2
|
||||||
|
} COMM_Console_Command_Result_T;
|
||||||
|
|
||||||
|
//! Result of parsing a console command parameter.
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
COMM_CONSOLE_PARAMETER_RESULT_UNKNOWN = 0,
|
||||||
|
COMM_CONSOLE_PARAMETER_RESULT_SUCCESS = 1,
|
||||||
|
COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR = 2,
|
||||||
|
COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_END = 3
|
||||||
|
} COMM_Console_Parameter_Result_T;
|
||||||
|
|
||||||
|
//! Prototype of a console command callback.
|
||||||
|
/*!
|
||||||
|
* \ingroup CONSOLE
|
||||||
|
* All console commands must use this signature.
|
||||||
|
*
|
||||||
|
* \param[in] data Pointer to the string containg the console command (and any arguments).
|
||||||
|
* \param[in] size Size (in char8) of the data string.
|
||||||
|
* \return #COMM_CONSOLE_CMD_RESULT_SUCCESS on success
|
||||||
|
* \return #COMM_Console_Command_Result_T otherwise
|
||||||
|
*/
|
||||||
|
typedef COMM_Console_Command_Result_T (* const COMM_Console_Command_Handler_T)(char8 * data, uint32_t size);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const char8 * const Command_Name;
|
||||||
|
const char8 * const Help;
|
||||||
|
COMM_Console_Command_Handler_T Execute_Command;
|
||||||
|
} COMM_Console_Command_Table_Entry_T;
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
//! Handle of the COMM_Console_Task() given when the task was created.
|
||||||
|
extern TaskHandle_t COMM_Console_Task_Handle;
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
void COMM_Console_Init(void);
|
||||||
|
void COMM_Console_Task(void * pvParameters);
|
||||||
|
void COMM_Console_Execute_Internal_Command(const uint8_t * const command);
|
||||||
|
void COMM_Console_Print_String(const char8 * const text);
|
||||||
|
void COMM_Console_Print_UInt32(uint32_t value);
|
||||||
|
void COMM_Console_Print_SInt32(int32_t value);
|
||||||
|
void COMM_Console_Print_UInt32AsHex(uint32_t value);
|
||||||
|
void COMM_Console_Print_UInt64(uint64_t value);
|
||||||
|
void COMM_Console_Print_UInt64AsHex(uint64_t value);
|
||||||
|
void COMM_Console_Print_Float(float value);
|
||||||
|
|
||||||
|
void COMM_Console_ByteToHex(char8 * buffer, uint8_t byte);
|
||||||
|
|
||||||
|
/* Inline Functions */
|
||||||
|
|
||||||
|
//! Prints an 8-bit unsigned integer to the serial console.
|
||||||
|
inline void COMM_Console_Print_UInt8(uint8_t value)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_UInt32((uint32_t) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints an 8-bit unsigned integer to the serial console using a hexadecimal representation.
|
||||||
|
inline void COMM_Console_Print_UInt8AsHex(uint8_t value)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_UInt32AsHex((uint32_t) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints an 8-bit signed integer to the serial console.
|
||||||
|
inline void COMM_Console_Print_Int8(int8_t value)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_SInt32((int32_t) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints a 16-bit unsigned integer to the serial console.
|
||||||
|
inline void COMM_Console_Print_UInt16(uint16_t value)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_UInt32((uint32_t) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints a 16-bit unsigned integer to the serial console using a hexadecimal representation.
|
||||||
|
inline void COMM_Console_Print_UInt16AsHex(uint16_t value)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_UInt32AsHex((uint32_t) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints a 16-bit signed integer to the serial console.
|
||||||
|
inline void COMM_Console_Print_Int16(int16_t value)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_SInt32((int32_t) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void UART_and_BLE_PutChar(uint8 txDataByte)
|
||||||
|
{
|
||||||
|
UART_Console_Put(txDataByte);
|
||||||
|
COMM_BLE_UART_PutChar(txDataByte);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void UART_and_BLE_PutString(const char8 string[])
|
||||||
|
{
|
||||||
|
UART_Console_PutString(string);
|
||||||
|
COMM_BLE_UART_PutString(string, strlen(string));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_CONSOLE_H
|
254
2020TPCApp1.cydsn/COMM/COMM_Console_Util.c
Normal file
254
2020TPCApp1.cydsn/COMM/COMM_Console_Util.c
Normal file
|
@ -0,0 +1,254 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file implements utility functions used by the command interpreter.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup CONSOLE
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
//! Find the start location of the nth parameter in the buffer.
|
||||||
|
/*!
|
||||||
|
* \note The command itself is parameter 0.
|
||||||
|
*/
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_FindNthParameter(const char * const buffer, const uint8_t parameterNumber, const char ** parameterLocation)
|
||||||
|
{
|
||||||
|
uint32_t buffer_index = 0;
|
||||||
|
uint32_t parameter_index = 0;
|
||||||
|
COMM_Console_Parameter_Result_T result = COMM_CONSOLE_PARAMETER_RESULT_SUCCESS;
|
||||||
|
|
||||||
|
while (parameterNumber != parameter_index)
|
||||||
|
{
|
||||||
|
if (buffer[buffer_index] == COMM_CONSOLE_PARAMETER_DELIMITER)
|
||||||
|
{
|
||||||
|
parameter_index++;
|
||||||
|
}
|
||||||
|
else if (buffer[buffer_index] == COMM_CONSOLE_END_OF_MESSAGE)
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (buffer[buffer_index] == COMM_CONSOLE_STRING_TERMINATOR)
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buffer_index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
*parameterLocation = &buffer[buffer_index];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterUInt8(const char * const buffer, uint8_t * const parameterUInt8)
|
||||||
|
{
|
||||||
|
uint8_t value = 0;
|
||||||
|
COMM_Console_Parameter_Result_T result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR;
|
||||||
|
|
||||||
|
// Strings containing uint8s range from "0" to "255". The large number has three characters.
|
||||||
|
uint_fast16_t MAX_CHARACTERS = 3;
|
||||||
|
uint_fast16_t index = 0;
|
||||||
|
|
||||||
|
while (index < (MAX_CHARACTERS + 1))
|
||||||
|
{
|
||||||
|
if ((buffer[index] >= '0') && (buffer[index] <= '9'))
|
||||||
|
{
|
||||||
|
value *= 10;
|
||||||
|
value += buffer[index] - '0';
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
else if ( (buffer[index] == COMM_CONSOLE_PARAMETER_DELIMITER) ||
|
||||||
|
(buffer[index] == COMM_CONSOLE_STRING_TERMINATOR) ||
|
||||||
|
(buffer[index] == COMM_CONSOLE_END_OF_MESSAGE) )
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_END;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_END)
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_SUCCESS;
|
||||||
|
*parameterUInt8 = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterUInt16(const char * const buffer, uint16_t * const parameterUInt16)
|
||||||
|
{
|
||||||
|
uint16_t value = 0;
|
||||||
|
COMM_Console_Parameter_Result_T result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR;
|
||||||
|
|
||||||
|
// Strings containing uint16s range from "0" to "65535". The large number has five characters.
|
||||||
|
uint_fast16_t MAX_CHARACTERS = 5;
|
||||||
|
uint_fast16_t index = 0;
|
||||||
|
|
||||||
|
while (index < (MAX_CHARACTERS + 1))
|
||||||
|
{
|
||||||
|
if ((buffer[index] >= '0') && (buffer[index] <= '9'))
|
||||||
|
{
|
||||||
|
value *= 10;
|
||||||
|
value += buffer[index] - '0';
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
else if ( (buffer[index] == COMM_CONSOLE_PARAMETER_DELIMITER) ||
|
||||||
|
(buffer[index] == COMM_CONSOLE_STRING_TERMINATOR) ||
|
||||||
|
(buffer[index] == COMM_CONSOLE_END_OF_MESSAGE) )
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_END;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_END)
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_SUCCESS;
|
||||||
|
*parameterUInt16 = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterInt32(const char * const buffer, int32_t * const parameterInt32)
|
||||||
|
{
|
||||||
|
int32_t value = 0;
|
||||||
|
COMM_Console_Parameter_Result_T result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR;
|
||||||
|
bool is_negative = false;
|
||||||
|
|
||||||
|
// Strings containing int32s range from "-2147483648" to "2147483647". The negative number has eleven characters.
|
||||||
|
uint_fast16_t MAX_CHARACTERS = 11;
|
||||||
|
uint_fast16_t index = 0;
|
||||||
|
|
||||||
|
if (buffer[index] == '-')
|
||||||
|
{
|
||||||
|
is_negative = true;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (index < (MAX_CHARACTERS + 1))
|
||||||
|
{
|
||||||
|
if ((buffer[index] >= '0') && (buffer[index] <= '9'))
|
||||||
|
{
|
||||||
|
value *= 10;
|
||||||
|
value += buffer[index] - '0';
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
else if ( (buffer[index] == COMM_CONSOLE_PARAMETER_DELIMITER) ||
|
||||||
|
(buffer[index] == COMM_CONSOLE_STRING_TERMINATOR) ||
|
||||||
|
(buffer[index] == COMM_CONSOLE_END_OF_MESSAGE) )
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_END;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_negative == true)
|
||||||
|
{
|
||||||
|
value *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_END)
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_SUCCESS;
|
||||||
|
*parameterInt32 = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterUInt32(const char * const buffer, uint32_t * const parameterUInt32)
|
||||||
|
{
|
||||||
|
uint32_t value = 0;
|
||||||
|
COMM_Console_Parameter_Result_T result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR;
|
||||||
|
|
||||||
|
// Strings containing uint32s range from "0" to "4294967296". The large number has ten characters.
|
||||||
|
uint_fast16_t MAX_CHARACTERS = 10;
|
||||||
|
uint_fast16_t index = 0;
|
||||||
|
|
||||||
|
while (index < (MAX_CHARACTERS + 1))
|
||||||
|
{
|
||||||
|
if ((buffer[index] >= '0') && (buffer[index] <= '9'))
|
||||||
|
{
|
||||||
|
value *= 10;
|
||||||
|
value += buffer[index] - '0';
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
else if ( (buffer[index] == COMM_CONSOLE_PARAMETER_DELIMITER) ||
|
||||||
|
(buffer[index] == COMM_CONSOLE_STRING_TERMINATOR) ||
|
||||||
|
(buffer[index] == COMM_CONSOLE_END_OF_MESSAGE) )
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_END;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_END)
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_SUCCESS;
|
||||||
|
*parameterUInt32 = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_DecodeHexParameterUInt64(const char * const buffer, uint64_t * const parameterUInt64)
|
||||||
|
{
|
||||||
|
COMM_Console_Parameter_Result_T result = COMM_CONSOLE_PARAMETER_RESULT_SUCCESS;
|
||||||
|
struct _reent context;
|
||||||
|
|
||||||
|
context._errno = 0;
|
||||||
|
|
||||||
|
*parameterUInt64 = _strtoull_r(&context, buffer, NULL, 16);
|
||||||
|
|
||||||
|
if (context._errno != 0)
|
||||||
|
{
|
||||||
|
result = COMM_CONSOLE_PARAMETER_RESULT_PARAMETER_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Private Functions */
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
50
2020TPCApp1.cydsn/COMM/COMM_Console_Util.h
Normal file
50
2020TPCApp1.cydsn/COMM/COMM_Console_Util.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/** \file
|
||||||
|
* \brief Utility functions used by the command interpreter.
|
||||||
|
*
|
||||||
|
* \note As always, <project.h> and <RTOS.h> should be included <I>before</I> this file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_CONSOLE_UTIL_H
|
||||||
|
#define COMM_CONSOLE_UTIL_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_FindNthParameter(const char * const buffer, const uint8_t parameterNumber, const char ** parameterLocation);
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterUInt8(const char * const buffer, uint8_t * const parameterUInt8);
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterUInt16(const char * const buffer, uint16_t * const parameterUInt16);
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterInt32(const char * const buffer, int32_t * const parameterInt32);
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_DecodeParameterUInt32(const char * const buffer, uint32_t * const parameterUInt32);
|
||||||
|
COMM_Console_Parameter_Result_T COMM_Console_DecodeHexParameterUInt64(const char * const buffer, uint64_t * const parameterUInt64);
|
||||||
|
|
||||||
|
//! Returns `true` if this character marks the end of a console message; `false` otherwise.
|
||||||
|
inline bool COMM_Console_IsEndOfMessage(char8 character)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
if ( (character == COMM_CONSOLE_END_OF_MESSAGE) ||
|
||||||
|
(character == COMM_CONSOLE_STRING_TERMINATOR) )
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_CONSOLE_UTIL_H
|
33
2020TPCApp1.cydsn/COMM/COMM_I2C_Bus.c
Normal file
33
2020TPCApp1.cydsn/COMM/COMM_I2C_Bus.c
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file implements the I²C bus.
|
||||||
|
*
|
||||||
|
* See COMM_I2C_Bus.h for a detailed description of the functionality implemented by this code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
SemaphoreHandle_t COMM_I2C_Bus_Mutex = NULL;
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
//! Initializes the I²C bus.
|
||||||
|
/*!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void COMM_I2C_Init(void)
|
||||||
|
{
|
||||||
|
COMM_I2C_Bus_Mutex = xSemaphoreCreateMutex();
|
||||||
|
I2C_Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Private Functions */
|
29
2020TPCApp1.cydsn/COMM/COMM_I2C_Bus.h
Normal file
29
2020TPCApp1.cydsn/COMM/COMM_I2C_Bus.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines the interface to the I²C bus.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_I2C_BUS_H
|
||||||
|
#define COMM_I2C_BUS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
extern SemaphoreHandle_t COMM_I2C_Bus_Mutex;
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
void COMM_I2C_Init(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_I2C_BUS_H
|
285
2020TPCApp1.cydsn/COMM/COMM_IPC_Messages.c
Normal file
285
2020TPCApp1.cydsn/COMM/COMM_IPC_Messages.c
Normal file
|
@ -0,0 +1,285 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file implements messaging using inter-processor communication (IPC).
|
||||||
|
*
|
||||||
|
* \see https://community.cypress.com/thread/36182.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup CONSOLE
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <project.h>
|
||||||
|
|
||||||
|
#include "COMM_IPC_Messages.h"
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 0)
|
||||||
|
static void Message_Received_for_CM0(uint32_t * msg);
|
||||||
|
static void Message_Received_by_CM4(void);
|
||||||
|
#endif // (__CORTEX_M == 0)
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 4)
|
||||||
|
static void Message_Received_for_CM4(uint32_t * msg);
|
||||||
|
static void Message_Received_by_CM0(void);
|
||||||
|
#endif // (__CORTEX_M == 4)
|
||||||
|
|
||||||
|
static void IPC_UserPipeInit(void);
|
||||||
|
static void IPC_UserPipeISR(void);
|
||||||
|
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
//! Number of clients supported on the user pipe.
|
||||||
|
#define CY_IPC_USRPIPE_CLIENT_CNT (uint32_t)(8u)
|
||||||
|
|
||||||
|
#define CY_IPC_CHAN_USRPIPE_CM0 (uint32_t)(8u)
|
||||||
|
#define CY_IPC_CHAN_USRPIPE_CM4 (uint32_t)(9u)
|
||||||
|
|
||||||
|
#define CY_IPC_INTR_USRPIPE_CM0 (uint32_t)(8u)
|
||||||
|
#define CY_IPC_INTR_USRPIPE_CM4 (uint32_t)(9u)
|
||||||
|
|
||||||
|
#define CY_IPC_EP_USRPIPE_ADDR_CM0_EP (uint32_t)(2u)
|
||||||
|
#define CY_IPC_EP_USRPIPE_ADDR_CM4_EP (uint32_t)(3u)
|
||||||
|
|
||||||
|
#if (CY_CPU_CORTEX_M0P)
|
||||||
|
#define IPC_EP_USRPIPE_ADDR CY_IPC_EP_USRPIPE_ADDR_CM0_EP
|
||||||
|
#else
|
||||||
|
#define IPC_EP_USRPIPE_ADDR CY_IPC_EP_USRPIPE_ADDR_CM4_EP
|
||||||
|
#endif /* (CY_CPU_CORTEX_M0P) */
|
||||||
|
|
||||||
|
/* User Pipe Configuration */
|
||||||
|
|
||||||
|
#define IPC_USRPIPE_CHAN_MASK_CM0 (uint32_t)(0x0001ul << CY_IPC_CHAN_USRPIPE_CM0)
|
||||||
|
#define IPC_USRPIPE_CHAN_MASK_CM4 (uint32_t)(0x0001ul << CY_IPC_CHAN_USRPIPE_CM4)
|
||||||
|
#define IPC_USRPIPE_INTR_MASK (uint32_t)( IPC_USRPIPE_CHAN_MASK_CM0 | IPC_USRPIPE_CHAN_MASK_CM4 )
|
||||||
|
#define IPC_INTR_USRPIPE_PRIOR_CM0 (uint32_t)(1u) /* Notifier Priority */
|
||||||
|
#define IPC_INTR_USRPIPE_PRIOR_CM4 (uint32_t)(1u) /* Notifier Priority */
|
||||||
|
#define IPC_INTR_USRPIPE_MUX_CM0 (uint32_t)(7u) /* IPC CYPRESS PIPE */
|
||||||
|
#define IPC_USRPIPE_CONFIG_CM0 (uint32_t)(IPC_USRPIPE_INTR_MASK << CY_IPC_PIPE_CFG_IMASK_Pos)\
|
||||||
|
|(CY_IPC_INTR_USRPIPE_CM0 << CY_IPC_PIPE_CFG_INTR_Pos )\
|
||||||
|
|(CY_IPC_CHAN_USRPIPE_CM0)
|
||||||
|
#define IPC_USRPIPE_CONFIG_CM4 (uint32_t)(IPC_USRPIPE_INTR_MASK << CY_IPC_PIPE_CFG_IMASK_Pos)\
|
||||||
|
|(CY_IPC_INTR_USRPIPE_CM4 << CY_IPC_PIPE_CFG_INTR_Pos )\
|
||||||
|
|(CY_IPC_CHAN_USRPIPE_CM4)
|
||||||
|
|
||||||
|
#define USRPIPE_CONFIG \
|
||||||
|
{\
|
||||||
|
/* .ep0ConfigData */ {\
|
||||||
|
/* .ipcNotifierNumber */ CY_IPC_INTR_USRPIPE_CM0,\
|
||||||
|
/* .ipcNotifierPriority */ IPC_INTR_USRPIPE_PRIOR_CM0,\
|
||||||
|
/* .ipcNotifierMuxNumber */ IPC_INTR_USRPIPE_MUX_CM0,\
|
||||||
|
/* .epAddress */ CY_IPC_EP_USRPIPE_ADDR_CM0_EP,\
|
||||||
|
/* .epConfig */ IPC_USRPIPE_CONFIG_CM0\
|
||||||
|
},\
|
||||||
|
/* .ep1ConfigData */ {\
|
||||||
|
/* .ipcNotifierNumber */ CY_IPC_INTR_USRPIPE_CM4,\
|
||||||
|
/* .ipcNotifierPriority */ IPC_INTR_USRPIPE_PRIOR_CM4,\
|
||||||
|
/* .ipcNotifierMuxNumber */ 0u,\
|
||||||
|
/* .epAddress */ CY_IPC_EP_USRPIPE_ADDR_CM4_EP,\
|
||||||
|
/* .epConfig */ IPC_USRPIPE_CONFIG_CM4\
|
||||||
|
},\
|
||||||
|
/* .endpointClientsCount */ CY_IPC_USRPIPE_CLIENT_CNT,\
|
||||||
|
/* .endpointsCallbacksArray */ ipc_pipe_CbArray,\
|
||||||
|
/* .userPipeIsrHandler */ &IPC_UserPipeISR\
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Client ID for messages from the CM0 to the CM4
|
||||||
|
#define COMM_IPC_CM0_TO_CM4_CLIENT_ID 0
|
||||||
|
//! Client ID for messages from the CM4 to the CM0
|
||||||
|
#define COMM_IPC_CM4_TO_CM0_CLIENT_ID 1
|
||||||
|
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 0)
|
||||||
|
static COMM_IPCMessage_T MessageBuffer =
|
||||||
|
{
|
||||||
|
.ClientID = _VAL2FLD(CY_IPC_PIPE_MSG_CLIENT, COMM_IPC_CM0_TO_CM4_CLIENT_ID) | _VAL2FLD(CY_IPC_PIPE_MSG_USR, 0) | _VAL2FLD(CY_IPC_PIPE_MSG_RELEASE, IPC_USRPIPE_INTR_MASK),
|
||||||
|
.MessageID = COMM_SMM_DefaultNoMessage,
|
||||||
|
.Data = NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static volatile bool OK_to_send_from_CM0_to_CM4 = true;
|
||||||
|
#endif // (__CORTEX_M == 0)
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 4)
|
||||||
|
static COMM_IPCMessage_T MessageBuffer =
|
||||||
|
{
|
||||||
|
.ClientID = _VAL2FLD(CY_IPC_PIPE_MSG_CLIENT, COMM_IPC_CM4_TO_CM0_CLIENT_ID) | _VAL2FLD(CY_IPC_PIPE_MSG_USR, 0) | _VAL2FLD(CY_IPC_PIPE_MSG_RELEASE, IPC_USRPIPE_INTR_MASK),
|
||||||
|
.MessageID = COMM_SMM_DefaultNoMessage,
|
||||||
|
.Data = NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static volatile bool OK_to_send_from_CM4_to_CM0 = true;
|
||||||
|
#endif // (__CORTEX_M == 4)
|
||||||
|
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 0)
|
||||||
|
//! Initializes the inter-processor communications on the Cortex-M0 core.
|
||||||
|
/*!
|
||||||
|
* This should be called *before* calling Cy_SysEnableCM4().
|
||||||
|
*/
|
||||||
|
void COMM_InitIPCMessages(void)
|
||||||
|
{
|
||||||
|
IPC_UserPipeInit();
|
||||||
|
|
||||||
|
// Register a callback to handle messages from CM4.
|
||||||
|
Cy_IPC_Pipe_RegisterCallback(IPC_EP_USRPIPE_ADDR,
|
||||||
|
Message_Received_for_CM0,
|
||||||
|
CY_IPC_EP_CYPIPE_CM4_ADDR);
|
||||||
|
}
|
||||||
|
#endif // (__CORTEX_M == 0)
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 4)
|
||||||
|
//! Initializes the inter-processor communications on the Cortex-M4 core.
|
||||||
|
void COMM_InitIPCMessages(void)
|
||||||
|
{
|
||||||
|
IPC_UserPipeInit();
|
||||||
|
|
||||||
|
// Register a callback to handle messages from CM0.
|
||||||
|
Cy_IPC_Pipe_RegisterCallback(IPC_EP_USRPIPE_ADDR,
|
||||||
|
Message_Received_for_CM4,
|
||||||
|
CY_IPC_EP_CYPIPE_CM0_ADDR);
|
||||||
|
}
|
||||||
|
#endif // (__CORTEX_M == 4)
|
||||||
|
|
||||||
|
|
||||||
|
//! Sends an inter-processor communication message to the other core.
|
||||||
|
bool COMM_SendMessageToOtherCore(COMM_IPCMessageID_T message_ID, void * message_data)
|
||||||
|
{
|
||||||
|
bool message_sent = false;
|
||||||
|
|
||||||
|
MessageBuffer.MessageID = message_ID;
|
||||||
|
MessageBuffer.Data = message_data;
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 0)
|
||||||
|
if (OK_to_send_from_CM0_to_CM4 == true)
|
||||||
|
{
|
||||||
|
OK_to_send_from_CM0_to_CM4 = false;
|
||||||
|
uint32_t timeout_in_us = 2000;
|
||||||
|
cy_en_ipc_pipe_status_t ipcStatus;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ipcStatus = Cy_IPC_Pipe_SendMessage(CY_IPC_EP_USRPIPE_ADDR_CM4_EP,
|
||||||
|
CY_IPC_EP_USRPIPE_ADDR_CM0_EP,
|
||||||
|
(uint32_t *) &MessageBuffer,
|
||||||
|
Message_Received_by_CM4);
|
||||||
|
Cy_SysLib_DelayUs(1u);
|
||||||
|
timeout_in_us--;
|
||||||
|
} while((ipcStatus != CY_IPC_PIPE_SUCCESS) && (timeout_in_us != 0));
|
||||||
|
|
||||||
|
message_sent = true;
|
||||||
|
}
|
||||||
|
#endif // (__CORTEX_M == 0)
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 4)
|
||||||
|
if (OK_to_send_from_CM4_to_CM0 == true)
|
||||||
|
{
|
||||||
|
OK_to_send_from_CM4_to_CM0 = false;
|
||||||
|
uint32_t timeout_in_us = 2000;
|
||||||
|
cy_en_ipc_pipe_status_t ipcStatus;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ipcStatus = Cy_IPC_Pipe_SendMessage(CY_IPC_EP_USRPIPE_ADDR_CM0_EP,
|
||||||
|
CY_IPC_EP_USRPIPE_ADDR_CM4_EP,
|
||||||
|
(uint32_t *) &MessageBuffer,
|
||||||
|
Message_Received_by_CM0);
|
||||||
|
Cy_SysLib_DelayUs(1u);
|
||||||
|
timeout_in_us--;
|
||||||
|
} while((ipcStatus != CY_IPC_PIPE_SUCCESS) && (timeout_in_us != 0));
|
||||||
|
|
||||||
|
message_sent = true;
|
||||||
|
}
|
||||||
|
#endif // (__CORTEX_M == 4)
|
||||||
|
|
||||||
|
return message_sent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Private Functions */
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 0)
|
||||||
|
//! Callback for messages received by the CM0 core from the CM4 core.
|
||||||
|
/*!
|
||||||
|
* \note This code is executed inside an interrupt handler.
|
||||||
|
*/
|
||||||
|
static void Message_Received_for_CM0(uint32_t * msg)
|
||||||
|
{
|
||||||
|
switch (((COMM_IPCMessage_T *)msg)->MessageID)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case COMM_SMM_DefaultNoMessage:
|
||||||
|
case COMM_SMM_NoMessage:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMM_SMM_RebootImmediately:
|
||||||
|
// Perform a software reset of both cores.
|
||||||
|
NVIC_SystemReset();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Message_Received_by_CM4(void)
|
||||||
|
{
|
||||||
|
OK_to_send_from_CM0_to_CM4 = true;
|
||||||
|
}
|
||||||
|
#endif // (__CORTEX_M == 0)
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 4)
|
||||||
|
//! Callback for messages received by the CM4 core from the CM0 core.
|
||||||
|
/*!
|
||||||
|
* \note This code is executed inside an interrupt handler.
|
||||||
|
*/
|
||||||
|
static void Message_Received_for_CM4(uint32_t * msg)
|
||||||
|
{
|
||||||
|
switch (((COMM_IPCMessage_T *)msg)->MessageID)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case COMM_SMM_DefaultNoMessage:
|
||||||
|
case COMM_SMM_NoMessage:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMM_SMM_RebootImmediately:
|
||||||
|
// This message does nothing on CM4
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Message_Received_by_CM0(void)
|
||||||
|
{
|
||||||
|
OK_to_send_from_CM4_to_CM0 = true;
|
||||||
|
}
|
||||||
|
#endif // (__CORTEX_M == 4)
|
||||||
|
|
||||||
|
//! Initializes the IPC user pipe.
|
||||||
|
static void IPC_UserPipeInit(void)
|
||||||
|
{
|
||||||
|
static cy_ipc_pipe_callback_ptr_t ipc_pipe_CbArray[CY_IPC_USRPIPE_CLIENT_CNT];
|
||||||
|
static const cy_stc_ipc_pipe_config_t userPipeConfig = USRPIPE_CONFIG;
|
||||||
|
|
||||||
|
uint32_t savedIntrStatus = Cy_SysLib_EnterCriticalSection();
|
||||||
|
|
||||||
|
Cy_IPC_Pipe_Init(&userPipeConfig);
|
||||||
|
|
||||||
|
Cy_SysLib_ExitCriticalSection(savedIntrStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Interrupt service routine for the user pipe.
|
||||||
|
void IPC_UserPipeISR(void)
|
||||||
|
{
|
||||||
|
Cy_IPC_Pipe_ExecuteCallback(IPC_EP_USRPIPE_ADDR);
|
||||||
|
}
|
||||||
|
|
49
2020TPCApp1.cydsn/COMM/COMM_IPC_Messages.h
Normal file
49
2020TPCApp1.cydsn/COMM/COMM_IPC_Messages.h
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \brief This file contains definitions and prototypes for messaging using inter-processor
|
||||||
|
* communication (IPC).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_IPC_MESSAGES_H
|
||||||
|
#define COMM_IPC_MESSAGES_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
//! This is not an actual message. Upon receipt, do nothing.
|
||||||
|
COMM_SMM_DefaultNoMessage = 0,
|
||||||
|
//! Reboot the system immediately upon receipt of this message (Data is "don't care").
|
||||||
|
COMM_SMM_RebootImmediately,
|
||||||
|
//! This is not an actual message. Upon receipt, do nothing.
|
||||||
|
COMM_SMM_NoMessage = 0xFFFFFFFF,
|
||||||
|
} COMM_IPCMessageID_T;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
//! The client ID number is the index into the callback array.
|
||||||
|
uint32_t ClientID;
|
||||||
|
//! The message ID represents the meaning of the message being sent.
|
||||||
|
COMM_IPCMessageID_T MessageID;
|
||||||
|
//! The contents of Data are different for each message ID. See #COMM_IPCMessageID_T for more details.
|
||||||
|
void * Data;
|
||||||
|
} COMM_IPCMessage_T;
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
void COMM_InitIPCMessages(void);
|
||||||
|
bool COMM_SendMessageToOtherCore(COMM_IPCMessageID_T message_ID, void * message_data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_IPC_MESSAGES_H
|
48
2020TPCApp1.cydsn/COMM/COMM_Util.c
Normal file
48
2020TPCApp1.cydsn/COMM/COMM_Util.c
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file implements utility functions used by the communications package.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup CONSOLE
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
static char8 uint64_buffer[20+1];
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
//! Converts a UInt64 to a NULL-terminated string.
|
||||||
|
/*!
|
||||||
|
* This function is necessary because newlib-nano does not support "%llu" / #PRIu64.
|
||||||
|
* \see https://answers.launchpad.net/gcc-arm-embedded/+question/257014
|
||||||
|
*
|
||||||
|
* \note This function is not reentrant!
|
||||||
|
*
|
||||||
|
* \param value pointer to the digital input object.
|
||||||
|
* \return pointer to a NULL-terminated string containing the base-10 textual representation of #value.
|
||||||
|
*/
|
||||||
|
char8 * COMM_UInt64ToDecimal(uint64_t value)
|
||||||
|
{
|
||||||
|
char8 * p = uint64_buffer + sizeof(uint64_buffer);
|
||||||
|
*(--p) = 0x00;
|
||||||
|
|
||||||
|
for (bool first_time = true; value || first_time; first_time = false)
|
||||||
|
{
|
||||||
|
const uint32_t digit = value % 10;
|
||||||
|
const char c = '0' + digit;
|
||||||
|
*(--p) = c;
|
||||||
|
value = value / 10;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Private Functions */
|
27
2020TPCApp1.cydsn/COMM/COMM_Util.h
Normal file
27
2020TPCApp1.cydsn/COMM/COMM_Util.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/** \file
|
||||||
|
* \brief Utility functions used by the communications package.
|
||||||
|
*
|
||||||
|
* \note As always, <project.h> and <RTOS.h> should be included <I>before</I> this file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_UTIL_H
|
||||||
|
#define COMM_UTIL_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
char8 * COMM_UInt64ToDecimal(uint64_t value);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_UTIL_H
|
|
@ -0,0 +1,78 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines the serial console commands for the Bluetooth Low Energy subsystem.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED) && (CONFIG__FEATURE_BLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
/* Private Functions */
|
||||||
|
|
||||||
|
//! Console command handler for subcommands of the 'ble' command.
|
||||||
|
COMM_Console_Command_Result_T COMM_HandleBLECommand(char8 * data, uint32_t size)
|
||||||
|
{
|
||||||
|
// data[0] through data[3] is 'ble '.
|
||||||
|
|
||||||
|
if (data[4] == '?')
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ble ? Display this help.\n");
|
||||||
|
COMM_Console_Print_String("ble cmd <id> Inject the BLE command with ID <id>.\n");
|
||||||
|
}
|
||||||
|
else if ( (data[4] == 'c') &&
|
||||||
|
(data[5] == 'm') &&
|
||||||
|
(data[6] == 'd') )
|
||||||
|
|
||||||
|
{
|
||||||
|
if (COMM_Console_IsEndOfMessage(data[7]))
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: missing BLE command ID!\n");
|
||||||
|
}
|
||||||
|
else if (data[7] == ' ')
|
||||||
|
{
|
||||||
|
uint16_t id = 0;
|
||||||
|
|
||||||
|
if (COMM_Console_DecodeParameterUInt16(&(data[8]), &id) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
if ((id > COMM_BLE_COMMAND_NO_OP) && (id < COMM_BLE_COMMAND_IS_OUT_OF_RANGE))
|
||||||
|
{
|
||||||
|
COMM_BLE_Command_T command = {.ID = id, .Data = (void *)0x00};
|
||||||
|
xQueueSend(COMM_BLE_CommandQueue, &command, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: specified BLE command ID (");
|
||||||
|
COMM_Console_Print_UInt16(id);
|
||||||
|
COMM_Console_Print_String(") is invalid!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: could not comprehend BLE command ID!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: unrecognized or mangled command!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: Unknown BLE command!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED) && (CONFIG__FEATURE_BLE == CONFIG__FEATURE_ENABLED)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file declares the serial console commands for the Bluetooth Low Energy subsystem.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_BLE_CONSOLECOMMANDS_H
|
||||||
|
#define COMM_BLE_CONSOLECOMMANDS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
COMM_Console_Command_Result_T COMM_HandleBLECommand(char8 * data, uint32_t size);
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_BLE_CONSOLECOMMANDS_H
|
|
@ -0,0 +1,73 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines the serial console commands for this CPU.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
static COMM_Console_Command_Result_T HandleConsoleHelp(char8 * data, uint32_t size);
|
||||||
|
static COMM_Console_Command_Result_T HandleConsoleComment(char8 * data, uint32_t size);
|
||||||
|
static COMM_Console_Command_Result_T HandleConsoleUptime(char8 * data, uint32_t size);
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
const COMM_Console_Command_Table_Entry_T COMM_Console_Command_Table[] =
|
||||||
|
{
|
||||||
|
{"?", " Show this help.", HandleConsoleHelp},
|
||||||
|
{"#", " Comment (Do not omit the space after the #.)", HandleConsoleComment},
|
||||||
|
{"event", " Generate an event in the high-level state machine (\'event ?\' for help).", COMM_HandleEventCommand},
|
||||||
|
{"ble", " Interact with the Bluetooth Low Energy subsystem (try \'ble ?\').", COMM_HandleBLECommand},
|
||||||
|
{"up", " Display uptime.", HandleConsoleUptime},
|
||||||
|
{"cpu (r)", " Display CPU usage ('r' to reset maximum).", COMM_RTOS_HandleConsoleCPU},
|
||||||
|
{"stack", " Display stack usage.", COMM_RTOS_HandleConsoleStack},
|
||||||
|
{"version", " Display RTOS version.", COMM_RTOS_HandleConsoleVersion},
|
||||||
|
{"reboot", " Performs a software reset on both cores.", COMM_RTOS_HandleConsoleReboot},
|
||||||
|
{"nvm", " Interact with the Nonvolatile Memory (try \'nvm ?\').", COMM_NVM_HandleConsoleNVMCommand},
|
||||||
|
{"reprogram", " Loads the KTag bootloader for OTA reprogramming.", COMM_RTOS_HandleConsoleReprogram},
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Size of the #COMM_Console_Command_Table array (i.e. the number of console commands).
|
||||||
|
const uint_fast16_t COMM_N_CONSOLE_COMMANDS = (uint_fast16_t) (sizeof(COMM_Console_Command_Table) / sizeof(COMM_Console_Command_Table_Entry_T));
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
/* Private Functions */
|
||||||
|
|
||||||
|
static COMM_Console_Command_Result_T HandleConsoleHelp(char8 * data, uint32_t size)
|
||||||
|
{
|
||||||
|
for (uint_fast16_t i = 0; i < COMM_N_CONSOLE_COMMANDS; i++)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String(COMM_Console_Command_Table[i].Command_Name);
|
||||||
|
COMM_Console_Print_String(" ");
|
||||||
|
COMM_Console_Print_String(COMM_Console_Command_Table[i].Help);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static COMM_Console_Command_Result_T HandleConsoleComment(char8 * data, uint32_t size)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Comment.\n");
|
||||||
|
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static COMM_Console_Command_Result_T HandleConsoleUptime(char8 * data, uint32_t size)
|
||||||
|
{
|
||||||
|
#if (configTICK_RATE_HZ != 1000)
|
||||||
|
#error This code assumes configTICK_RATE_HZ is set to 1000 (== 1ms ticks)!
|
||||||
|
#endif // (configTICK_RATE_HZ != 1000)
|
||||||
|
COMM_Console_Print_String("Up ");
|
||||||
|
COMM_Console_Print_UInt32(xTaskGetTickCount());
|
||||||
|
COMM_Console_Print_String(" milliseconds.\n");
|
||||||
|
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
|
@ -0,0 +1,30 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file configures the serial console commands on this CPU.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_CONSOLECOMMANDS_H
|
||||||
|
#define COMM_CONSOLECOMMANDS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
extern const COMM_Console_Command_Table_Entry_T COMM_Console_Command_Table[];
|
||||||
|
extern const uint_fast16_t COMM_N_CONSOLE_COMMANDS;
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_CONSOLECOMMANDS_H
|
|
@ -0,0 +1,207 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines the serial console commands for the Nonvolatile Memory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
/* Private Functions */
|
||||||
|
|
||||||
|
//! Console command handler for subcommands of the 'nvm' command.
|
||||||
|
COMM_Console_Command_Result_T COMM_NVM_HandleConsoleNVMCommand(char8 * data, uint32_t size)
|
||||||
|
{
|
||||||
|
// data[0] through data[3] is 'nvm '.
|
||||||
|
if (data[4] == '?')
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("nvm ? Display this help.\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
COMM_Console_Print_String("nvm dump Display the entire Nonvolatile Memory.\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
COMM_Console_Print_String("nvm names Display the NVM parameter names.\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
COMM_Console_Print_String("nvm get <parameter> Display an individual parameter from NVM.\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
COMM_Console_Print_String("nvm set <parameter> <value> Assign a value to an individual parameter in NVM (be careful!).\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
else if ((data[4] == 'd') && (data[5] == 'u') && (data[6] == 'm') && (data[7] == 'p'))
|
||||||
|
{
|
||||||
|
for (uint8_t i = 0; i < NVM_N_ONCHIP_EEPROM_ENTRIES; i++)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("NVM[");
|
||||||
|
COMM_Console_Print_UInt16(i);
|
||||||
|
COMM_Console_Print_String("]: ");
|
||||||
|
|
||||||
|
for (uint8_t j = 0; j < NVM_OnChipEEPROMEntries[i]->Size; j++)
|
||||||
|
{
|
||||||
|
char8 buffer[3];
|
||||||
|
|
||||||
|
COMM_Console_ByteToHex(buffer, *(NVM_OnChipEEPROMEntries[i]->Value + j));
|
||||||
|
COMM_Console_Print_String("0x");
|
||||||
|
COMM_Console_Print_String(buffer);
|
||||||
|
COMM_Console_Print_String(" ");
|
||||||
|
}
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((data[4] == 'n') && (data[5] == 'a') && (data[6] == 'm') && (data[7] == 'e') && (data[8] == 's'))
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Valid NVM parameters:\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
COMM_Console_Print_String(" test_1\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
COMM_Console_Print_String(" test_2\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
COMM_Console_Print_String(" volume\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
else if ((data[4] == 'g') && (data[5] == 'e') && (data[6] == 't') && (data[7] == ' '))
|
||||||
|
{
|
||||||
|
if (strncmp(&data[8], "volume", 6) == 0)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Volume: ");
|
||||||
|
COMM_Console_Print_UInt8(NVM_VOLUME);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
else if (strncmp(&data[8], "test_1", 6) == 0)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Test 1: ");
|
||||||
|
COMM_Console_Print_UInt16(NVM_ONCHIP_TEST_1);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
else if (strncmp(&data[8], "test_2", 6) == 0)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Test 2: ");
|
||||||
|
COMM_Console_Print_UInt32(NVM_ONCHIP_TEST_2);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
else if (strncmp(&data[8], "test_3", 6) == 0)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Test 3: ");
|
||||||
|
COMM_Console_Print_UInt16(NVM_EXTERNAL_TEST_3);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
else if (strncmp(&data[8], "test_4", 6) == 0)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Test 4: ");
|
||||||
|
COMM_Console_Print_UInt32(NVM_EXTERNAL_TEST_4);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: Unknown NVM parameter!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((data[4] == 's') && (data[5] == 'e') && (data[6] == 't') && (data[7] == ' '))
|
||||||
|
{
|
||||||
|
if (strncmp(&data[8], "volume", 6) == 0)
|
||||||
|
{
|
||||||
|
uint8_t volume = 0;
|
||||||
|
if (COMM_Console_DecodeParameterUInt8(&(data[15]), &volume) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
NVM_VOLUME = volume;
|
||||||
|
NVM_SaveExternalEEPROMEntry(NVM_VOLUME_ENTRY_PTR);
|
||||||
|
|
||||||
|
COMM_Console_Print_String("Volume changed to ");
|
||||||
|
COMM_Console_Print_UInt8(NVM_VOLUME);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: Parameter value unrecognized or missing!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strncmp(&data[8], "test_1", 6) == 0)
|
||||||
|
{
|
||||||
|
uint16_t test_value = 0;
|
||||||
|
if (COMM_Console_DecodeParameterUInt16(&(data[15]), &test_value) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
NVM_ONCHIP_TEST_1 = test_value;
|
||||||
|
NVM_SaveOnChipEEPROMEntry(NVM_ONCHIP_TEST_1_ENTRY_PTR);
|
||||||
|
|
||||||
|
COMM_Console_Print_String("Test 1 value changed to ");
|
||||||
|
COMM_Console_Print_UInt16(NVM_ONCHIP_TEST_1);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: Parameter value unrecognized or missing!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strncmp(&data[8], "test_2", 6) == 0)
|
||||||
|
{
|
||||||
|
uint32_t test_value = 0;
|
||||||
|
if (COMM_Console_DecodeParameterUInt32(&(data[15]), &test_value) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
NVM_ONCHIP_TEST_2 = test_value;
|
||||||
|
NVM_SaveOnChipEEPROMEntry(NVM_ONCHIP_TEST_2_ENTRY_PTR);
|
||||||
|
|
||||||
|
COMM_Console_Print_String("Test 2 value changed to ");
|
||||||
|
COMM_Console_Print_UInt32(NVM_ONCHIP_TEST_2);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: Parameter value unrecognized or missing!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strncmp(&data[8], "test_3", 6) == 0)
|
||||||
|
{
|
||||||
|
uint16_t test_value = 0;
|
||||||
|
if (COMM_Console_DecodeParameterUInt16(&(data[15]), &test_value) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
NVM_EXTERNAL_TEST_3 = test_value;
|
||||||
|
NVM_SaveExternalEEPROMEntry(NVM_EXTERNAL_TEST_3_ENTRY_PTR);
|
||||||
|
|
||||||
|
COMM_Console_Print_String("Test 3 value changed to ");
|
||||||
|
COMM_Console_Print_UInt16(NVM_EXTERNAL_TEST_3);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: Parameter value unrecognized or missing!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strncmp(&data[8], "test_4", 6) == 0)
|
||||||
|
{
|
||||||
|
uint32_t test_value = 0;
|
||||||
|
if (COMM_Console_DecodeParameterUInt32(&(data[15]), &test_value) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
NVM_EXTERNAL_TEST_4 = test_value;
|
||||||
|
NVM_SaveExternalEEPROMEntry(NVM_EXTERNAL_TEST_4_ENTRY_PTR);
|
||||||
|
|
||||||
|
COMM_Console_Print_String("Test 4 value changed to ");
|
||||||
|
COMM_Console_Print_UInt32(NVM_EXTERNAL_TEST_4);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: Parameter value unrecognized or missing!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: Unknown NVM parameter!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: Unknown NVM command!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file declares the serial console commands for the Nonvolatile Memory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_NVM_CONSOLECOMMANDS_H
|
||||||
|
#define COMM_NVM_CONSOLECOMMANDS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
COMM_Console_Command_Result_T COMM_NVM_HandleConsoleNVMCommand(char8 * data, uint32_t size);
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_NVM_CONSOLECOMMANDS_H
|
|
@ -0,0 +1,120 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines the serial console commands for the RTOS package.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
/* Private Functions */
|
||||||
|
|
||||||
|
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleVersion(char8 * data, uint32_t size)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("PSoC 6 running FreeRTOS ");
|
||||||
|
|
||||||
|
COMM_Console_Print_String(tskKERNEL_VERSION_NUMBER);
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
COMM_Console_Print_String(" (Release, compiled ");
|
||||||
|
#else
|
||||||
|
COMM_Console_Print_String(" (Debug, compiled ");
|
||||||
|
#endif // NDEBUG
|
||||||
|
|
||||||
|
COMM_Console_Print_String(__DATE__);
|
||||||
|
COMM_Console_Print_String(" ");
|
||||||
|
COMM_Console_Print_String(__TIME__);
|
||||||
|
COMM_Console_Print_String(").\n");
|
||||||
|
|
||||||
|
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleStack(char8 * data, uint32_t size)
|
||||||
|
{
|
||||||
|
for (uint_fast8_t i = 0; i < CONFIG_N_TASK_HANDLES; i++)
|
||||||
|
{
|
||||||
|
TaskStatus_t status;
|
||||||
|
vTaskGetInfo(*CONFIG_TaskHandles[i], &status, pdTRUE, eInvalid);
|
||||||
|
COMM_Console_Print_String(status.pcTaskName);
|
||||||
|
COMM_Console_Print_String(": ");
|
||||||
|
COMM_Console_Print_UInt16(status.usStackHighWaterMark);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Repeat for the Idle Task.
|
||||||
|
{
|
||||||
|
TaskStatus_t status;
|
||||||
|
vTaskGetInfo(xTaskGetIdleTaskHandle(), &status, pdTRUE, eInvalid);
|
||||||
|
COMM_Console_Print_String(status.pcTaskName);
|
||||||
|
COMM_Console_Print_String(": ");
|
||||||
|
COMM_Console_Print_UInt16(status.usStackHighWaterMark);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleCPU(char8 * data, uint32_t size)
|
||||||
|
{
|
||||||
|
// data[0] through data[3] is 'cpu '.
|
||||||
|
if (data[4] == 'r')
|
||||||
|
{
|
||||||
|
//COMM_Console_Print_String("Max CPU reset.\n");
|
||||||
|
COMM_Console_Print_String("(Not yet implemented.)\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (uint_fast8_t i = 0; i < CONFIG_N_TASK_HANDLES; i++)
|
||||||
|
{
|
||||||
|
TaskStatus_t status;
|
||||||
|
vTaskGetInfo(*CONFIG_TaskHandles[i], &status, pdTRUE, eInvalid);
|
||||||
|
COMM_Console_Print_String(status.pcTaskName);
|
||||||
|
COMM_Console_Print_String(": ");
|
||||||
|
COMM_Console_Print_UInt32(status.ulRunTimeCounter);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Repeat for the Idle Task.
|
||||||
|
{
|
||||||
|
TaskStatus_t status;
|
||||||
|
vTaskGetInfo(xTaskGetIdleTaskHandle(), &status, pdTRUE, eInvalid);
|
||||||
|
COMM_Console_Print_String(status.pcTaskName);
|
||||||
|
COMM_Console_Print_String(": ");
|
||||||
|
COMM_Console_Print_UInt16(status.ulRunTimeCounter);
|
||||||
|
COMM_Console_Print_String("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleReboot(char8 * data, uint32_t size)
|
||||||
|
{
|
||||||
|
(void) COMM_SendMessageToOtherCore(COMM_SMM_RebootImmediately, NULL);
|
||||||
|
|
||||||
|
// Not that it matters...
|
||||||
|
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleReprogram(char8 * data, uint32_t size)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Entering bootloader for BLE reprogramming.\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
|
|
||||||
|
Cy_DFU_ExecuteApp(0u);
|
||||||
|
|
||||||
|
// Not that it matters...
|
||||||
|
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
|
@ -0,0 +1,33 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file declares the serial console commands for the RTOS package.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_RTOS_CONSOLECOMMANDS_H
|
||||||
|
#define COMM_RTOS_CONSOLECOMMANDS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleVersion(char8 * data, uint32_t size);
|
||||||
|
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleStack(char8 * data, uint32_t size);
|
||||||
|
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleCPU(char8 * data, uint32_t size);
|
||||||
|
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleReboot(char8 * data, uint32_t size);
|
||||||
|
COMM_Console_Command_Result_T COMM_RTOS_HandleConsoleReprogram(char8 * data, uint32_t size);
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_RTOS_CONSOLECOMMANDS_H
|
|
@ -0,0 +1,189 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines the serial console commands for the high-level state machine.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
static void Simulate_Hit(uint8_t team_ID, uint16_t damage);
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
//! Console command handler for the 'event' command.
|
||||||
|
COMM_Console_Command_Result_T COMM_HandleEventCommand(char8 * data, uint32_t size)
|
||||||
|
{
|
||||||
|
// data[0] through data[5] is 'event '.
|
||||||
|
|
||||||
|
if (data[6] == '?')
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("event ? Display this help.\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
COMM_Console_Print_String("event raw <id> Inject the event with ID <id>.\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
COMM_Console_Print_String("event tag <n> Send <n> tag(s).\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
COMM_Console_Print_String("event hit <t> <d> Simulate a hit from team <t> for <d> damage.\n");
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
else if ( (data[6] == 'r') &&
|
||||||
|
(data[7] == 'a') &&
|
||||||
|
(data[8] == 'w') )
|
||||||
|
|
||||||
|
{
|
||||||
|
if (COMM_Console_IsEndOfMessage(data[9]))
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: missing event ID!\n");
|
||||||
|
}
|
||||||
|
else if (data[9] == ' ')
|
||||||
|
{
|
||||||
|
uint16_t id = 0;
|
||||||
|
|
||||||
|
if (COMM_Console_DecodeParameterUInt16(&(data[10]), &id) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
if ((id > KEVENT_NO_EVENT) && (id < KEVENT_IS_OUT_OF_RANGE))
|
||||||
|
{
|
||||||
|
KEvent_T raw_event = { .ID = id, .Data = (void *)0x00 };
|
||||||
|
Post_KEvent(&raw_event);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: specified event ID (");
|
||||||
|
COMM_Console_Print_UInt16(id);
|
||||||
|
COMM_Console_Print_String(") is invalid!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: could not comprehend event ID!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: unrecognized or mangled command!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( (data[6] == 't') &&
|
||||||
|
(data[7] == 'a') &&
|
||||||
|
(data[8] == 'g') )
|
||||||
|
|
||||||
|
{
|
||||||
|
if (COMM_Console_IsEndOfMessage(data[9]))
|
||||||
|
{
|
||||||
|
if (Send_Tag() == SYSTEMK_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Tag sent.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Error: Couldn't send tag!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (data[9] == ' ')
|
||||||
|
{
|
||||||
|
uint16_t times = 0;
|
||||||
|
|
||||||
|
if (COMM_Console_DecodeParameterUInt16(&(data[10]), ×) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
while (times > 0)
|
||||||
|
{
|
||||||
|
if (Send_Tag() == SYSTEMK_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Tag sent.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Error: Couldn't send tag!\n");
|
||||||
|
}
|
||||||
|
//! \todo Why can't the console command 'event tag <n>' send tags faster than once per second?
|
||||||
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
|
times--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: could not comprehend tag repetitions!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: unrecognized or mangled command!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( (data[6] == 'h') &&
|
||||||
|
(data[7] == 'i') &&
|
||||||
|
(data[8] == 't') )
|
||||||
|
|
||||||
|
{
|
||||||
|
if (COMM_Console_IsEndOfMessage(data[9]))
|
||||||
|
{
|
||||||
|
Simulate_Hit(1, 10);
|
||||||
|
COMM_Console_Print_String("Hit!\n");
|
||||||
|
}
|
||||||
|
else if (data[9] == ' ')
|
||||||
|
{
|
||||||
|
uint8_t team_ID = 0;
|
||||||
|
uint16_t damage = 10;
|
||||||
|
|
||||||
|
if (COMM_Console_DecodeParameterUInt8(&(data[10]), &team_ID) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
const char * damage_location;
|
||||||
|
|
||||||
|
// Damage is the first parameter after team ID.
|
||||||
|
if (COMM_Console_FindNthParameter(&(data[10]), 1, &damage_location) == COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
if (COMM_Console_DecodeParameterUInt16(damage_location, &damage) != COMM_CONSOLE_PARAMETER_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: could not comprehend damage--using default.\n");
|
||||||
|
damage = 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Simulate_Hit(team_ID, damage);
|
||||||
|
COMM_Console_Print_String("Hit!\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: could not comprehend team ID!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: unrecognized or mangled command!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("ERROR: Unknown event command!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return COMM_CONSOLE_CMD_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Private Functions */
|
||||||
|
|
||||||
|
static void Simulate_Hit(uint8_t team_ID, uint16_t damage)
|
||||||
|
{
|
||||||
|
static DecodedPacket_T Simulated_Tag_Rx_Buffer;
|
||||||
|
static KEvent_T tag_received_event;
|
||||||
|
|
||||||
|
Simulated_Tag_Rx_Buffer.Tag.type = DECODED_PACKET_TYPE_TAG_RECEIVED;
|
||||||
|
Simulated_Tag_Rx_Buffer.Tag.protocol = LASER_X_PROTOCOL;
|
||||||
|
Simulated_Tag_Rx_Buffer.Tag.player_ID = 0x00;
|
||||||
|
Simulated_Tag_Rx_Buffer.Tag.team_ID = team_ID;
|
||||||
|
Simulated_Tag_Rx_Buffer.Tag.damage = damage;
|
||||||
|
Simulated_Tag_Rx_Buffer.Tag.color = GetColorFromTeamID(team_ID);
|
||||||
|
tag_received_event.ID = KEVENT_TAG_RECEIVED;
|
||||||
|
tag_received_event.Data = &Simulated_Tag_Rx_Buffer;
|
||||||
|
Post_KEvent(&tag_received_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file declares the serial console commands for the high-level state machine.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMM_STATE_CONSOLECOMMANDS_H
|
||||||
|
#define COMM_STATE_CONSOLECOMMANDS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
COMM_Console_Command_Result_T COMM_HandleEventCommand(char8 * data, uint32_t size);
|
||||||
|
|
||||||
|
#endif // (CONFIG__FEATURE_COMM_CONSOLE == CONFIG__FEATURE_ENABLED)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMM_STATE_CONSOLECOMMANDS_H
|
83
2020TPCApp1.cydsn/CONFIG/CONFIG.h
Normal file
83
2020TPCApp1.cydsn/CONFIG/CONFIG.h
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
/** \dir "CONFIG"
|
||||||
|
*
|
||||||
|
* \brief This directory contains configuration files for this software.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \brief This file includes project-wide for this software.
|
||||||
|
*
|
||||||
|
* This file should be included by every file outside the CONFIG package!
|
||||||
|
*
|
||||||
|
* \note As always, <project.h> should be included <I>before</I> this file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_H
|
||||||
|
#define CONFIG_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "CONFIG_RTOS.h"
|
||||||
|
|
||||||
|
//! Value of audio volume represeting the maximum volume possible for this device.
|
||||||
|
#define CONFIG_KTAG_MAX_AUDIO_VOLUME 30
|
||||||
|
|
||||||
|
//! Value of audio volume represeting the minimum volume possible for this device.
|
||||||
|
#define CONFIG_KTAG_MIN_AUDIO_VOLUME 5
|
||||||
|
|
||||||
|
//! Time (in milliseconds) after starting a game before the countdown begins.
|
||||||
|
#define CONFIG_KTAG_T_DEFAULT_START_GAME_in_ms (30 * 1000)
|
||||||
|
|
||||||
|
//! true if the hardware includes internal (on-chip) NVM.
|
||||||
|
#define CONFIG__HAS_INTERNAL_NVM true
|
||||||
|
|
||||||
|
//! true if the hardware includes an external (I2C) NVM chip.
|
||||||
|
#define CONFIG__HAS_EXTERNAL_NVM true
|
||||||
|
|
||||||
|
// '||' || '|| '||''|. TM
|
||||||
|
// || ... || || || ... .. ... ... .... ...
|
||||||
|
// || || || ||'''|. ||' '' || || '|. |
|
||||||
|
// || || || || || || || || '|.|
|
||||||
|
// .||.....| .||. .||. .||...|' .||. '|..'|. '|
|
||||||
|
|
||||||
|
#if (defined LIL_BRUV) || (defined LITTLE_BOY_BLUE)
|
||||||
|
|
||||||
|
//! Number of NeoPixel channels supported.
|
||||||
|
#define CONFIG_KTAG_N_NEOPIXEL_CHANNELS 1
|
||||||
|
|
||||||
|
//! Maximum number of NeoPixels on a single channel.
|
||||||
|
#define CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL 5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// /\ /\\ /\ /\\ TM
|
||||||
|
// ( ) || || ( ) || || |''||''| '||''|. ..|'''.|
|
||||||
|
// // || || // || || || || || .|' '
|
||||||
|
// // || || // || || || ||...|' ||
|
||||||
|
// /( || || /( || || || || '|. .
|
||||||
|
// {___ \\/ {___ \\/ .||. .||. ''|....'
|
||||||
|
|
||||||
|
#elif (defined TWENTY20TPC)
|
||||||
|
|
||||||
|
//! Number of NeoPixel channels supported.
|
||||||
|
#define CONFIG_KTAG_N_NEOPIXEL_CHANNELS 4
|
||||||
|
|
||||||
|
//! Maximum number of NeoPixels on a single channel.
|
||||||
|
#define CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL 8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "No recognized KTag models defined. Supported models are: LIL_BRUV, LITTLE_BOY_BLUE, and TWENTY20TPC."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//! Time between NeoPixel animation frames, in milliseconds.
|
||||||
|
#define CONFIG_KTAG_ANIMATION_STEP_TIME_IN_ms 10
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CONFIG_H
|
113
2020TPCApp1.cydsn/CONFIG/CONFIG_RTOS.c
Normal file
113
2020TPCApp1.cydsn/CONFIG/CONFIG_RTOS.c
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines and registers the tasks used by the Real-Time Operating System.
|
||||||
|
*
|
||||||
|
* See CONFIG_RTOS.h for a detailed description of the functionality implemented by this code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Task priorities: Low priority numbers denote low priority tasks.
|
||||||
|
*
|
||||||
|
* Low == 0 == tskIDLE_PRIORITY
|
||||||
|
* ...
|
||||||
|
* High == (configMAX_PRIORITIES - 1)
|
||||||
|
*
|
||||||
|
* See http://www.freertos.org/RTOS-task-priority.html for more information.
|
||||||
|
*/
|
||||||
|
#define CAPSENSE_TASK_PRIORITY (tskIDLE_PRIORITY + 3)
|
||||||
|
#define SAMPLE_TASK_PRIORITY (tskIDLE_PRIORITY + 2)
|
||||||
|
#define FIRE_CONTROL_TASK_PRIORITY (tskIDLE_PRIORITY + 1)
|
||||||
|
#define AUDIO_TASK_PRIORITY (tskIDLE_PRIORITY + 2)
|
||||||
|
#define NEOPIXELS_TASK_PRIORITY (tskIDLE_PRIORITY + 2)
|
||||||
|
#define TAG_SENSORS_TASK_PRIORITY (tskIDLE_PRIORITY + 5)
|
||||||
|
#define SWITCHES_TASK_PRIORITY (tskIDLE_PRIORITY + 2)
|
||||||
|
#define NVM_EXTERNAL_TASK_PRIORITY (tskIDLE_PRIORITY + 2)
|
||||||
|
#define NVM_ON_CHIP_EEPROM_TASK_PRIORITY (tskIDLE_PRIORITY + 1)
|
||||||
|
#define COMM_CONSOLE_TASK_PRIORITY (tskIDLE_PRIORITY + 2)
|
||||||
|
#define COMM_BLE_TASK_PRIORITY (tskIDLE_PRIORITY + 4)
|
||||||
|
|
||||||
|
|
||||||
|
/* External Variables [Only if necessary!] */
|
||||||
|
|
||||||
|
/* External Function Prototypes [Only if necessary!] */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
//! Array of all the handles for the configured RTOS tasks.
|
||||||
|
TaskHandle_t * const CONFIG_TaskHandles[] = {&HW_CapSense_Task_Handle,
|
||||||
|
&Fire_Control_Task_Handle,
|
||||||
|
&Sample_Task_Handle,
|
||||||
|
&Audio_Task_Handle,
|
||||||
|
&NeoPixels_Task_Handle,
|
||||||
|
&Tag_Sensors_Task_Handle,
|
||||||
|
&Switches_Task_Handle,
|
||||||
|
&State_Machine_Task_Handle,
|
||||||
|
&NVM_ExternalEEPROM_Task_Handle,
|
||||||
|
&NVM_OnChipEEPROM_Task_Handle,
|
||||||
|
&COMM_Console_Task_Handle,
|
||||||
|
&COMM_BLE_Task_Handle};
|
||||||
|
|
||||||
|
//! Size of the #CONFIG_TaskHandles array (i.e. the number of configured tasks).
|
||||||
|
const uint8_t CONFIG_N_TASK_HANDLES = (uint8_t) (sizeof(CONFIG_TaskHandles) / sizeof(TaskHandle_t *));
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
void CONFIG_InitTasks(void)
|
||||||
|
{
|
||||||
|
HW_CapSense_Init();
|
||||||
|
COMM_I2C_Init();
|
||||||
|
NVM_InitExternalEEPROM();
|
||||||
|
NVM_InitOnChipEEPROM();
|
||||||
|
Sample_Task_Init();
|
||||||
|
Init_Fire_Control();
|
||||||
|
Tag_Sensors_Init();
|
||||||
|
Init_Audio();
|
||||||
|
Switches_Init();
|
||||||
|
COMM_Console_Init();
|
||||||
|
COMM_BLE_Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Registers tasks with the kernel, and then runs them.
|
||||||
|
/*!
|
||||||
|
* This function should not return.
|
||||||
|
*/
|
||||||
|
void CONFIG_RunTasks(void)
|
||||||
|
{
|
||||||
|
(void) xTaskCreate(HW_CapSense_Task, "CapSense Task", HW_CAPSENSE_TASK_STACK_SIZE_in_bytes, NULL, CAPSENSE_TASK_PRIORITY, &HW_CapSense_Task_Handle);
|
||||||
|
(void) xTaskCreate(Fire_Control_Task, "Fire Control Task", configMINIMAL_STACK_SIZE, NULL, FIRE_CONTROL_TASK_PRIORITY, &Fire_Control_Task_Handle);
|
||||||
|
(void) xTaskCreate(Sample_Task, "Sample Task", configMINIMAL_STACK_SIZE, NULL, SAMPLE_TASK_PRIORITY, &Sample_Task_Handle);
|
||||||
|
(void) xTaskCreate(Audio_Task, "Audio Task", configMINIMAL_STACK_SIZE, NULL, AUDIO_TASK_PRIORITY, &Audio_Task_Handle);
|
||||||
|
(void) xTaskCreate(NeoPixels_Task, "NeoPixels Task", configMINIMAL_STACK_SIZE, NULL, NEOPIXELS_TASK_PRIORITY, &NeoPixels_Task_Handle);
|
||||||
|
(void) xTaskCreate(Tag_Sensors_Task, "Tag Sensors Task", configMINIMAL_STACK_SIZE, NULL, TAG_SENSORS_TASK_PRIORITY, &Tag_Sensors_Task_Handle);
|
||||||
|
(void) xTaskCreate(Switches_Task, "Switches Task", configMINIMAL_STACK_SIZE, NULL, SWITCHES_TASK_PRIORITY, &Switches_Task_Handle);
|
||||||
|
(void) xTaskCreate(NVM_OnChipEEPROMTask, "NVMOn", NVM_ON_CHIP_EEPROM_TASK_STACK_SIZE_in_bytes, NULL, NVM_ON_CHIP_EEPROM_TASK_PRIORITY, &NVM_OnChipEEPROM_Task_Handle);
|
||||||
|
(void) xTaskCreate(NVM_ExternalEEPROMTask, "NVMEx", NVM_EXTERNAL_EEPROM_TASK_STACK_SIZE_in_bytes, NULL, NVM_EXTERNAL_TASK_PRIORITY, &NVM_ExternalEEPROM_Task_Handle);
|
||||||
|
(void) xTaskCreate(COMM_Console_Task, "Console Task", COMM_CONSOLE_TASK_STACK_SIZE_in_bytes, NULL, COMM_CONSOLE_TASK_PRIORITY, &COMM_Console_Task_Handle);
|
||||||
|
(void) xTaskCreate(COMM_BLE_Task, "BLE Task", COMM_BLE_TASK_STACK_SIZE_in_bytes, NULL, COMM_BLE_TASK_PRIORITY, &COMM_BLE_Task_Handle);
|
||||||
|
|
||||||
|
if (Initialize_SystemK() != SYSTEMK_RESULT_SUCCESS)
|
||||||
|
{
|
||||||
|
KLOG_ERROR("CONFIG", "Failed to initilaize SystemK!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This should not return. */
|
||||||
|
vTaskStartScheduler();
|
||||||
|
|
||||||
|
// Something went wrong.
|
||||||
|
#ifdef DEBUG
|
||||||
|
// Break into the debugger.
|
||||||
|
__BKPT(0);
|
||||||
|
#else // DEBUG
|
||||||
|
__NVIC_SystemReset();
|
||||||
|
#endif // DEBUG
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Private Functions */
|
29
2020TPCApp1.cydsn/CONFIG/CONFIG_RTOS.h
Normal file
29
2020TPCApp1.cydsn/CONFIG/CONFIG_RTOS.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file configures the Real-Time Operating System (RTOS).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_RTOS_H
|
||||||
|
#define CONFIG_RTOS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
extern TaskHandle_t * const CONFIG_TaskHandles[];
|
||||||
|
extern const uint8_t CONFIG_N_TASK_HANDLES;
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
void CONFIG_InitTasks(void);
|
||||||
|
void CONFIG_RunTasks(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CONFIG_RTOS_H
|
223
2020TPCApp1.cydsn/Fire_Control.c
Normal file
223
2020TPCApp1.cydsn/Fire_Control.c
Normal file
|
@ -0,0 +1,223 @@
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
#define FIRE_CONTROL_REGISTER__IR_OFF 0b00000
|
||||||
|
#define FIRE_CONTROL_REGISTER__IR_ON_MODULATED_LOW_POWER 0b00011
|
||||||
|
#define FIRE_CONTROL_REGISTER__IR_ON_MODULATED_HIGH_POWER 0b00101
|
||||||
|
#define FIRE_CONTROL_REGISTER__IR_ON_MODULATED_MAX_POWER 0b11111
|
||||||
|
#define FIRE_CONTROL_REGISTER__IR_ON_UNMODULATED_LOW_POWER 0b00010
|
||||||
|
#define FIRE_CONTROL_REGISTER__IR_ON_UNMODULATED_HIGH_POWER 0b00100
|
||||||
|
#define FIRE_CONTROL_REGISTER__IR_ON_UNMODULATED_MAX_POWER 0b00110
|
||||||
|
|
||||||
|
#define TRIGGER_STATUS_REGISTER__NO_ACTION 0x00
|
||||||
|
#define TRIGGER_STATUS_REGISTER__TRIGGER_PULLED 0x01
|
||||||
|
#define TRIGGER_STATUS_REGISTER__TRIGGER_RELEASED 0x02
|
||||||
|
|
||||||
|
|
||||||
|
void Trigger_Interrupt_ISR();
|
||||||
|
void Bit_Stream_Timer_ISR();
|
||||||
|
|
||||||
|
TimedPulseTrain_T * Shot_Buffer;
|
||||||
|
TagPacket_T Shot_Packet;
|
||||||
|
|
||||||
|
TaskHandle_t Fire_Control_Task_Handle;
|
||||||
|
|
||||||
|
static TimedPulseTrain_T * Active_Pulse_Train = NULL;
|
||||||
|
static uint8_t Active_Bitstream_Index = 0;
|
||||||
|
|
||||||
|
static TickType_t TicksAtTriggerPress;
|
||||||
|
|
||||||
|
static inline void Initiate_Pulse_Train(TimedPulseTrain_T * pulsetrain)
|
||||||
|
{
|
||||||
|
Bit_Stream_Timer_Disable();
|
||||||
|
Active_Pulse_Train = pulsetrain;
|
||||||
|
Active_Bitstream_Index = 0;
|
||||||
|
|
||||||
|
if (Active_Pulse_Train->bitstream[Active_Bitstream_Index].symbol == MARK)
|
||||||
|
{
|
||||||
|
Fire_Control_Register_Write(FIRE_CONTROL_REGISTER__IR_ON_MODULATED_MAX_POWER);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Fire_Control_Register_Write(FIRE_CONTROL_REGISTER__IR_OFF);
|
||||||
|
}
|
||||||
|
Bit_Stream_Timer_SetPeriod(Active_Pulse_Train->bitstream[0].duration);
|
||||||
|
Bit_Stream_Timer_SetCounter(0);
|
||||||
|
Active_Bitstream_Index++;
|
||||||
|
Bit_Stream_Timer_Enable();
|
||||||
|
Bit_Stream_Timer_TriggerStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void Next_Bit(void)
|
||||||
|
{
|
||||||
|
static BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
||||||
|
Bit_Stream_Timer_Disable();
|
||||||
|
|
||||||
|
if (Active_Pulse_Train->bitstream[Active_Bitstream_Index].duration != LAST_PULSE)
|
||||||
|
{
|
||||||
|
if (Active_Pulse_Train->bitstream[Active_Bitstream_Index].symbol == MARK)
|
||||||
|
{
|
||||||
|
Fire_Control_Register_Write(FIRE_CONTROL_REGISTER__IR_ON_MODULATED_MAX_POWER);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Fire_Control_Register_Write(FIRE_CONTROL_REGISTER__IR_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Active_Bitstream_Index < ((2*MAX_PULSES) - 2))
|
||||||
|
{
|
||||||
|
Bit_Stream_Timer_SetPeriod(Active_Pulse_Train->bitstream[Active_Bitstream_Index].duration);
|
||||||
|
Bit_Stream_Timer_SetCounter(0);
|
||||||
|
Active_Bitstream_Index++;
|
||||||
|
Bit_Stream_Timer_Enable();
|
||||||
|
Bit_Stream_Timer_TriggerStart();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The bitstream is too long!
|
||||||
|
|
||||||
|
// Turn the IR Emitter off, and wait a long time.
|
||||||
|
Fire_Control_Register_Write(FIRE_CONTROL_REGISTER__IR_OFF);
|
||||||
|
xSemaphoreGiveFromISR(NeoPixels_Semaphore, &xHigherPriorityTaskWoken);
|
||||||
|
Bit_Stream_Timer_SetPeriod(UINT16_MAX);
|
||||||
|
Bit_Stream_Timer_SetCounter(0);
|
||||||
|
Active_Pulse_Train = NULL;
|
||||||
|
Bit_Stream_Timer_Enable();
|
||||||
|
Bit_Stream_Timer_TriggerStart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Turn the IR Emitter off, and wait a long time.
|
||||||
|
Fire_Control_Register_Write(FIRE_CONTROL_REGISTER__IR_OFF);
|
||||||
|
xSemaphoreGiveFromISR(NeoPixels_Semaphore, &xHigherPriorityTaskWoken);
|
||||||
|
Bit_Stream_Timer_SetPeriod(UINT16_MAX);
|
||||||
|
Bit_Stream_Timer_SetCounter(0);
|
||||||
|
Active_Pulse_Train = NULL;
|
||||||
|
Bit_Stream_Timer_Enable();
|
||||||
|
Bit_Stream_Timer_TriggerStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init_Fire_Control(void)
|
||||||
|
{
|
||||||
|
// Register and enable the ISRs.
|
||||||
|
Cy_SysInt_Init(&Trigger_Interrupt_cfg, Trigger_Interrupt_ISR);
|
||||||
|
Cy_SysInt_Init(&Bit_Stream_Timer_Interrupt_cfg, Bit_Stream_Timer_ISR);
|
||||||
|
NVIC_EnableIRQ(Trigger_Interrupt_cfg.intrSrc);
|
||||||
|
NVIC_EnableIRQ(Bit_Stream_Timer_Interrupt_cfg.intrSrc);
|
||||||
|
|
||||||
|
// Initialize the hardware.
|
||||||
|
Bit_Stream_Timer_Clock_Enable();
|
||||||
|
Bit_Stream_Timer_Init(&Bit_Stream_Timer_config);
|
||||||
|
Bit_Stream_Timer_SetPeriod(2);
|
||||||
|
Bit_Stream_Timer_Start();
|
||||||
|
SW_CLK_Enable();
|
||||||
|
PWM_IR_Modulation_Start();
|
||||||
|
|
||||||
|
|
||||||
|
Fire_Control_Register_Write(FIRE_CONTROL_REGISTER__IR_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Fire_Control_Task(void * pvParameters)
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemKResult_T Prepare_Tag()
|
||||||
|
{
|
||||||
|
Shot_Packet.player_ID = NVM_PLAYER_ID;
|
||||||
|
Shot_Packet.team_ID = NVM_TEAM_ID;
|
||||||
|
Weapon_t weapon = GetWeaponFromID(NVM_WEAPON_ID);
|
||||||
|
Shot_Packet.color = (uint32_t)PROTOCOLS_GetColor(weapon.Protocol, Shot_Packet.team_ID, Shot_Packet.player_ID);
|
||||||
|
Shot_Packet.protocol = weapon.Protocol;
|
||||||
|
Shot_Packet.damage = weapon.Damage_Per_Shot;
|
||||||
|
Shot_Buffer = PROTOCOLS_EncodePacket(&Shot_Packet);
|
||||||
|
Fire_Control_Set_Modulation_Frequency(PROTOCOLS_GetModulationFrequency(weapon.Protocol));
|
||||||
|
return SYSTEMK_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemKResult_T Send_Tag()
|
||||||
|
{
|
||||||
|
xSemaphoreTake(NeoPixels_Semaphore, portMAX_DELAY);
|
||||||
|
Initiate_Pulse_Train(Shot_Buffer);
|
||||||
|
|
||||||
|
KEvent_T tag_sent_event = { .ID = KEVENT_TAG_SENT, .Data = (void *)0x00 };
|
||||||
|
Post_KEvent(&tag_sent_event);
|
||||||
|
|
||||||
|
return SYSTEMK_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Fire_Control_Set_Modulation_Frequency(ModulationFrequency_T freq)
|
||||||
|
{
|
||||||
|
PWM_IR_Modulation_TriggerKill();
|
||||||
|
if (freq == FREQUENCY_38kHz)
|
||||||
|
{
|
||||||
|
PWM_IR_Modulation_SetPeriod0(314);
|
||||||
|
//PWM_IR_Modulation_SetCompare0(314/2); // 50% Duty Cycle
|
||||||
|
PWM_IR_Modulation_SetCompare0((314 * 3)/10); // 30% Duty Cycle
|
||||||
|
}
|
||||||
|
else // (freq == FREQUENCY_56kHz)
|
||||||
|
{
|
||||||
|
PWM_IR_Modulation_SetPeriod0(213);
|
||||||
|
//PWM_IR_Modulation_SetCompare0(213/2); // 50% Duty Cycle
|
||||||
|
PWM_IR_Modulation_SetCompare0((213 * 3)/10); // 30% Duty Cycle
|
||||||
|
}
|
||||||
|
PWM_IR_Modulation_TriggerStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! ISR for the trigger input.
|
||||||
|
void Trigger_Interrupt_ISR()
|
||||||
|
{
|
||||||
|
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
||||||
|
// Clear the interrupt.
|
||||||
|
NVIC_ClearPendingIRQ(Trigger_Interrupt_cfg.intrSrc);
|
||||||
|
|
||||||
|
// Read the trigger register to know if this was a pull or a release.
|
||||||
|
uint8_t trigger_status = Trigger_Status_Reg_Read();
|
||||||
|
|
||||||
|
if ((trigger_status & TRIGGER_STATUS_REGISTER__TRIGGER_PULLED) == TRIGGER_STATUS_REGISTER__TRIGGER_PULLED)
|
||||||
|
{
|
||||||
|
TicksAtTriggerPress = xTaskGetTickCountFromISR();
|
||||||
|
KEvent_T switch_event = {.ID = KEVENT_CENTER_SWITCH_PRESSED, .Data = NULL};
|
||||||
|
Post_KEvent_From_ISR(&switch_event, &xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
else if ((trigger_status & TRIGGER_STATUS_REGISTER__TRIGGER_RELEASED) == TRIGGER_STATUS_REGISTER__TRIGGER_RELEASED)
|
||||||
|
{
|
||||||
|
uint32_t triggerPressDurationInms = pdTICKS_TO_MS(xTaskGetTickCountFromISR() - TicksAtTriggerPress);
|
||||||
|
KEvent_T switch_event = {.ID = KEVENT_CENTER_SWITCH_RELEASED, .Data = (void *) triggerPressDurationInms};
|
||||||
|
Post_KEvent_From_ISR(&switch_event, &xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// What happened!!?
|
||||||
|
}
|
||||||
|
|
||||||
|
// If an event was enqueued above, a context switch might be required.
|
||||||
|
// xHigherPriorityTaskWoken was initialized to pdFALSE on interrupt entry. If calling
|
||||||
|
// xSemaphoreGiveFromISR() caused a task to unblock, and the unblocked task has a
|
||||||
|
// priority equal to or higher than the currently running task (the task that was
|
||||||
|
// interrupted by this ISR), then xHigherPriorityTaskWoken will have been set to pdTRUE
|
||||||
|
// and portEND_SWITCHING_ISR() will request a context switch to the newly unblocked task.
|
||||||
|
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bit_Stream_Timer_ISR()
|
||||||
|
{
|
||||||
|
// Get all the enabled pending interrupts...
|
||||||
|
uint32_t source = Bit_Stream_Timer_GetInterruptStatusMasked();
|
||||||
|
// ...and clear them.
|
||||||
|
Bit_Stream_Timer_ClearInterrupt(source);
|
||||||
|
|
||||||
|
if (Active_Pulse_Train != NULL)
|
||||||
|
{
|
||||||
|
Next_Bit();
|
||||||
|
}
|
||||||
|
}
|
13
2020TPCApp1.cydsn/Fire_Control.h
Normal file
13
2020TPCApp1.cydsn/Fire_Control.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef FIRE_CONTROL_H
|
||||||
|
#define FIRE_CONTROL_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern TaskHandle_t Fire_Control_Task_Handle;
|
||||||
|
|
||||||
|
void Init_Fire_Control(void);
|
||||||
|
void Fire_Control_Task(void * pvParameters);
|
||||||
|
void Fire_Control_Set_Modulation_Frequency(ModulationFrequency_T freq);
|
||||||
|
|
||||||
|
#endif // FIRE_CONTROL_H
|
228
2020TPCApp1.cydsn/FreeRTOSConfig.h
Normal file
228
2020TPCApp1.cydsn/FreeRTOSConfig.h
Normal file
|
@ -0,0 +1,228 @@
|
||||||
|
/*
|
||||||
|
* FreeRTOS Kernel V10.0.1
|
||||||
|
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* http://www.FreeRTOS.org
|
||||||
|
* http://aws.amazon.com/freertos
|
||||||
|
*
|
||||||
|
* 1 tab == 4 spaces!
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FREERTOS_CONFIG_H
|
||||||
|
#define FREERTOS_CONFIG_H
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------
|
||||||
|
* Application specific definitions.
|
||||||
|
*
|
||||||
|
* These definitions should be adjusted for your particular hardware and
|
||||||
|
* application requirements.
|
||||||
|
*
|
||||||
|
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||||
|
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||||
|
*
|
||||||
|
* See http://www.freertos.org/a00110.html.
|
||||||
|
*----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "syslib/cy_syslib.h"
|
||||||
|
|
||||||
|
#define configUSE_PREEMPTION 1
|
||||||
|
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||||
|
#define configUSE_TICKLESS_IDLE 0
|
||||||
|
#define configCPU_CLOCK_HZ SystemCoreClock
|
||||||
|
#define configTICK_RATE_HZ 1000u
|
||||||
|
#define configMAX_PRIORITIES 15
|
||||||
|
#define configMINIMAL_STACK_SIZE 512
|
||||||
|
#define configMAX_TASK_NAME_LEN 16
|
||||||
|
#define configUSE_16_BIT_TICKS 0
|
||||||
|
#define configIDLE_SHOULD_YIELD 1
|
||||||
|
#define configUSE_TASK_NOTIFICATIONS 1
|
||||||
|
#define configUSE_MUTEXES 1
|
||||||
|
#define configUSE_RECURSIVE_MUTEXES 1
|
||||||
|
#define configUSE_COUNTING_SEMAPHORES 1
|
||||||
|
#define configQUEUE_REGISTRY_SIZE 10
|
||||||
|
#define configUSE_QUEUE_SETS 0
|
||||||
|
#define configUSE_TIME_SLICING 0
|
||||||
|
#define configUSE_NEWLIB_REENTRANT 0
|
||||||
|
#define configENABLE_BACKWARD_COMPATIBILITY 0
|
||||||
|
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
|
||||||
|
|
||||||
|
/* Memory allocation related definitions. */
|
||||||
|
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||||
|
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||||
|
#define configTOTAL_HEAP_SIZE (64*1024)
|
||||||
|
#define configAPPLICATION_ALLOCATED_HEAP 0
|
||||||
|
|
||||||
|
/* Hook function related definitions. */
|
||||||
|
#define configUSE_IDLE_HOOK 1
|
||||||
|
#define configUSE_TICK_HOOK 0
|
||||||
|
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||||
|
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||||
|
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
|
||||||
|
|
||||||
|
/* Run time and task stats gathering related definitions. */
|
||||||
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
|
#define configUSE_TRACE_FACILITY 1
|
||||||
|
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
|
||||||
|
|
||||||
|
|
||||||
|
//! Debug Exception and Monitor Control register
|
||||||
|
#define CORE_DBG_EXC_MON_CTL (*(uint32_t *)0xE000EDFC)
|
||||||
|
|
||||||
|
//! DWT Control Register
|
||||||
|
#define DWT_CTRL (*(uint32_t *)0xE0001000)
|
||||||
|
|
||||||
|
//! DWT Current PC Sampler Cycle Count Register
|
||||||
|
/*!
|
||||||
|
* Use the DWT Current PC Sampler Cycle Count Register to count the number of core cycles. This
|
||||||
|
* count can measure elapsed execution time.
|
||||||
|
*/
|
||||||
|
#define DWT_CYCCNT (*(uint32_t *)0xE0001004)
|
||||||
|
|
||||||
|
//! Initializes the Data Watchpoint and Trace Unit and starts the CYCCNT counter.
|
||||||
|
static inline void vCONFIGURE_TIMER_FOR_RUN_TIME_STATS(void)
|
||||||
|
{
|
||||||
|
// If the Data Watchpoint and Trace Unit is present, #DWT_CTRL will be non-zero.
|
||||||
|
if (DWT_CTRL != 0)
|
||||||
|
{
|
||||||
|
// Set bit 24 (TRCENA) on the CORE_DBG_EXC_MON_CTL register to enable use of the DWT.
|
||||||
|
CORE_DBG_EXC_MON_CTL |= (1 << 24);
|
||||||
|
// Initialize the count register.
|
||||||
|
DWT_CYCCNT = 0;
|
||||||
|
// Set bit 0 (CYCCNTENA) on the DWT_CTRL register to enable the CYCCNT counter.
|
||||||
|
DWT_CTRL |= (1 << 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS vCONFIGURE_TIMER_FOR_RUN_TIME_STATS
|
||||||
|
|
||||||
|
//! Returns the current value of the DWT Current PC Sampler Cycle Count Register
|
||||||
|
/*!
|
||||||
|
* Use the DWT Current PC Sampler Cycle Count Register to count the number of core cycles. This
|
||||||
|
* count can measure elapsed execution time.
|
||||||
|
*/
|
||||||
|
static inline uint32_t ulGET_RUN_TIME_COUNTER_VALUE(void)
|
||||||
|
{
|
||||||
|
return DWT_CYCCNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define portGET_RUN_TIME_COUNTER_VALUE ulGET_RUN_TIME_COUNTER_VALUE
|
||||||
|
|
||||||
|
/* Co-routine related definitions. */
|
||||||
|
#define configUSE_CO_ROUTINES 1
|
||||||
|
#define configMAX_CO_ROUTINE_PRIORITIES 2
|
||||||
|
|
||||||
|
/* Software timer related definitions. */
|
||||||
|
#define configUSE_TIMERS 1
|
||||||
|
#define configTIMER_TASK_PRIORITY 3
|
||||||
|
#define configTIMER_QUEUE_LENGTH 10
|
||||||
|
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
|
||||||
|
|
||||||
|
/* FreeRTOS MPU specific definitions. */
|
||||||
|
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
Interrupt nesting behavior configuration.
|
||||||
|
This is explained here: http://www.freertos.org/a00110.html
|
||||||
|
|
||||||
|
Priorities are controlled by two macros:
|
||||||
|
- configKERNEL_INTERRUPT_PRIORITY determines the priority of the RTOS daemon task
|
||||||
|
- configMAX_API_CALL_INTERRUPT_PRIORITY dictates the priority of ISRs that make API calls
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
1. Interrupts that do not call API functions should be >= configKERNEL_INTERRUPT_PRIORITY
|
||||||
|
and will nest.
|
||||||
|
2. Interrupts that call API functions must have priority between KERNEL_INTERRUPT_PRIORITY
|
||||||
|
and MAX_API_CALL_INTERRUPT_PRIORITY (inclusive).
|
||||||
|
3. Interrupts running above MAX_API_CALL_INTERRUPT_PRIORITY are never delayed by the OS.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
PSoC 6 __NVIC_PRIO_BITS = 3
|
||||||
|
|
||||||
|
0 (high)
|
||||||
|
1 MAX_API_CALL_INTERRUPT_PRIORITY 001xxxxx (0x3F)
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7 (low) KERNEL_INTERRUPT_PRIORITY 111xxxxx (0xFF)
|
||||||
|
|
||||||
|
!!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
||||||
|
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html
|
||||||
|
|
||||||
|
If you call a FreeRTOS API function from an interrupt with priority higher than
|
||||||
|
MAX_API_CALL_INTERRUPT_PRIORITY FreeRTOS will generate an exception. If you need
|
||||||
|
to call a FreeRTOS API function from your system’s highest priority interrupt
|
||||||
|
you must reduce all interrupt priorities to MAX_API_CALL_INTERRUPT_PRIORITY or
|
||||||
|
lower.
|
||||||
|
|
||||||
|
If your system pipe (IPC) interrupt priority is less than or equal to
|
||||||
|
MAX_API_CALL_INTERRUPT_PRIORITY then care must be taken with code that writes to
|
||||||
|
flash (including the Flash/BLE/Emulated EEPROM/Bootloader drivers from Cypress
|
||||||
|
PDL). The duration of critical sections must be kept short - see the
|
||||||
|
Configuration Considerations section of the flash driver in the PDL API
|
||||||
|
Reference.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Put KERNEL_INTERRUPT_PRIORITY in top __NVIC_PRIO_BITS bits of CM4 register */
|
||||||
|
#define configKERNEL_INTERRUPT_PRIORITY 0xFF
|
||||||
|
/*
|
||||||
|
Put MAX_SYSCALL_INTERRUPT_PRIORITY in top __NVIC_PRIO_BITS bits of CM4 register
|
||||||
|
NOTE For IAR compiler make sure that changes of this macro is reflected in
|
||||||
|
file portable\IAR\CM4F\portasm.s in PendSV_Handler: routine
|
||||||
|
*/
|
||||||
|
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 0x3F
|
||||||
|
/* configMAX_API_CALL_INTERRUPT_PRIORITY is a new name for configMAX_SYSCALL_INTERRUPT_PRIORITY
|
||||||
|
that is used by newer ports only. The two are equivalent. */
|
||||||
|
#define configMAX_API_CALL_INTERRUPT_PRIORITY configMAX_SYSCALL_INTERRUPT_PRIORITY
|
||||||
|
|
||||||
|
|
||||||
|
/* Set the following definitions to 1 to include the API function, or zero
|
||||||
|
to exclude the API function. */
|
||||||
|
#define INCLUDE_vTaskPrioritySet 1
|
||||||
|
#define INCLUDE_uxTaskPriorityGet 1
|
||||||
|
#define INCLUDE_vTaskDelete 1
|
||||||
|
#define INCLUDE_vTaskSuspend 1
|
||||||
|
#define INCLUDE_xResumeFromISR 1
|
||||||
|
#define INCLUDE_vTaskDelayUntil 1
|
||||||
|
#define INCLUDE_vTaskDelay 1
|
||||||
|
#define INCLUDE_xTaskGetSchedulerState 1
|
||||||
|
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
||||||
|
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||||
|
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||||
|
#define INCLUDE_eTaskGetState 1
|
||||||
|
#define INCLUDE_xEventGroupSetBitFromISR 1
|
||||||
|
#define INCLUDE_xTimerPendFunctionCall 0
|
||||||
|
#define INCLUDE_xTaskAbortDelay 0
|
||||||
|
#define INCLUDE_xTaskGetHandle 0
|
||||||
|
#define INCLUDE_xTaskResumeFromISR 1
|
||||||
|
|
||||||
|
/* Normal assert() semantics without relying on the provision of an assert.h
|
||||||
|
header file. */
|
||||||
|
#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
|
||||||
|
|
||||||
|
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
|
||||||
|
standard names - or at least those used in the unmodified vector table. */
|
||||||
|
#define vPortSVCHandler SVC_Handler
|
||||||
|
#define xPortPendSVHandler PendSV_Handler
|
||||||
|
#define xPortSysTickHandler SysTick_Handler
|
||||||
|
|
||||||
|
#endif /* FREERTOS_CONFIG_H */
|
50
2020TPCApp1.cydsn/HW/HW.h
Normal file
50
2020TPCApp1.cydsn/HW/HW.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/** \dir "HW"
|
||||||
|
*
|
||||||
|
* \brief This directory contains source code interfacing to the lowest level of the hardware on this CPU.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines the interface to the low-level hardware used by this software.
|
||||||
|
*
|
||||||
|
* This file should be included by any file outside the HW package wishing to make use
|
||||||
|
* of any of the HW functionality.
|
||||||
|
*
|
||||||
|
* \note As always, <project.h> and <CONFIG.h> should be included <I>before</I> this file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HW_H
|
||||||
|
#define HW_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
//! Represents the states of a Digital Input or Digital Output.
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
//! Represents low voltage (logic '0') on a digital input or output.
|
||||||
|
HW_DIGITAL_STATE_LOW = 0,
|
||||||
|
|
||||||
|
//! Represents high voltage (logic '1') on a digital input or output.
|
||||||
|
HW_DIGITAL_STATE_HIGH = 1,
|
||||||
|
|
||||||
|
//! Used when the state of a digital input or output cannot be determined.
|
||||||
|
HW_DIGITAL_STATE_UNKNOWN = 2
|
||||||
|
} HW_DigitalState_T;
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
#include "HW_CapSense.h"
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // HW_H
|
125
2020TPCApp1.cydsn/HW/HW_CapSense.c
Normal file
125
2020TPCApp1.cydsn/HW/HW_CapSense.c
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
/* Local Definitions and Constants */
|
||||||
|
|
||||||
|
#define CAPSENSE_TASK_PERIOD_IN_ms 50
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
TaskHandle_t HW_CapSense_Task_Handle;
|
||||||
|
|
||||||
|
/* Private Variables */
|
||||||
|
|
||||||
|
static const TickType_t CapSense_Task_Delay = CAPSENSE_TASK_PERIOD_IN_ms / portTICK_PERIOD_MS;
|
||||||
|
|
||||||
|
static bool CapSense_One_Pressed = false;
|
||||||
|
static bool CapSense_Two_Pressed = false;
|
||||||
|
|
||||||
|
/* Private Function Prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
|
||||||
|
//! Initializes the capacitive touch sensing.
|
||||||
|
void HW_CapSense_Init(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Capacitive touch sensing task: Manages the capsense, using the PSoC API functions.
|
||||||
|
/*!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void HW_CapSense_Task(void * pvParameters)
|
||||||
|
{
|
||||||
|
TickType_t xLastWakeTime;
|
||||||
|
|
||||||
|
// Initialize the xLastWakeTime variable with the current time.
|
||||||
|
xLastWakeTime = xTaskGetTickCount();
|
||||||
|
|
||||||
|
// Start up the capsense component, and initiate the first scan.
|
||||||
|
// Note that this can't be done in HW_CapSense_Init(), since it requires interrupts to be enabled.
|
||||||
|
CapSense_Start();
|
||||||
|
CapSense_ScanAllWidgets();
|
||||||
|
|
||||||
|
vTaskDelayUntil(&xLastWakeTime, CapSense_Task_Delay);
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
// Check to see if the CapSense hardware is still busy with a previous scan.
|
||||||
|
if (CapSense_IsBusy() == CapSense_NOT_BUSY)
|
||||||
|
{
|
||||||
|
// Process all the widgets and read the touch information.
|
||||||
|
CapSense_ProcessAllWidgets();
|
||||||
|
|
||||||
|
// Perform the on-change logic for "Button One".
|
||||||
|
if (CapSense_IsSensorActive(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID))
|
||||||
|
{
|
||||||
|
if (CapSense_One_Pressed == false)
|
||||||
|
{
|
||||||
|
KEvent_T switch_event = {.ID = KEVENT_CAPSENSE_ONE_PRESSED, .Data = NULL};
|
||||||
|
Post_KEvent(&switch_event);
|
||||||
|
}
|
||||||
|
CapSense_One_Pressed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (CapSense_One_Pressed == true)
|
||||||
|
{
|
||||||
|
KEvent_T switch_event = {.ID = KEVENT_CAPSENSE_ONE_RELEASED, .Data = NULL};
|
||||||
|
Post_KEvent(&switch_event);
|
||||||
|
}
|
||||||
|
CapSense_One_Pressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform the on-change logic for "Button Two".
|
||||||
|
if (CapSense_IsSensorActive(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS1_ID))
|
||||||
|
{
|
||||||
|
if (CapSense_Two_Pressed == false)
|
||||||
|
{
|
||||||
|
KEvent_T switch_event = {.ID = KEVENT_CAPSENSE_TWO_PRESSED, .Data = NULL};
|
||||||
|
Post_KEvent(&switch_event);
|
||||||
|
}
|
||||||
|
CapSense_Two_Pressed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (CapSense_Two_Pressed == true)
|
||||||
|
{
|
||||||
|
KEvent_T switch_event = {.ID = KEVENT_CAPSENSE_TWO_RELEASED, .Data = NULL};
|
||||||
|
Post_KEvent(&switch_event);
|
||||||
|
}
|
||||||
|
CapSense_Two_Pressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initiate the next scan.
|
||||||
|
CapSense_ScanAllWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelayUntil(&xLastWakeTime, CapSense_Task_Delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Gets the state of the given CapSense button.
|
||||||
|
/*!
|
||||||
|
* \param button the button in question
|
||||||
|
* \return true if the button was pressed last time it was checked; false otherwise
|
||||||
|
*/
|
||||||
|
bool HW_IsCapsenseButtonPressed(HW_CapSenseButton_T button)
|
||||||
|
{
|
||||||
|
bool pressed = false;
|
||||||
|
|
||||||
|
if ((button == HW_CAPSENSE_BUTTON_ONE) && (CapSense_One_Pressed == true))
|
||||||
|
{
|
||||||
|
pressed = true;
|
||||||
|
}
|
||||||
|
else if ((button == HW_CAPSENSE_BUTTON_TWO) && (CapSense_Two_Pressed == true))
|
||||||
|
{
|
||||||
|
pressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Private Functions */
|
||||||
|
|
40
2020TPCApp1.cydsn/HW/HW_CapSense.h
Normal file
40
2020TPCApp1.cydsn/HW/HW_CapSense.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This file defines the interface to the capacitive touch sensing used by this software.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HW_CAPSENSE_H
|
||||||
|
#define HW_CAPSENSE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Preprocessor and Type Definitions */
|
||||||
|
|
||||||
|
#define HW_CAPSENSE_TASK_STACK_SIZE_in_bytes 128
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
HW_CAPSENSE_BUTTON_ONE,
|
||||||
|
HW_CAPSENSE_BUTTON_TWO
|
||||||
|
} HW_CapSenseButton_T;
|
||||||
|
|
||||||
|
/* Include Files */
|
||||||
|
|
||||||
|
/* Public Variables */
|
||||||
|
|
||||||
|
//! Handle of the HW_CapSense_Task() given when the task was created.
|
||||||
|
extern TaskHandle_t HW_CapSense_Task_Handle;
|
||||||
|
|
||||||
|
/* Public Functions */
|
||||||
|
void HW_CapSense_Init(void);
|
||||||
|
void HW_CapSense_Task(void * pvParameters);
|
||||||
|
bool HW_IsCapsenseButtonPressed(HW_CapSenseButton_T button);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // HW_CAPSENSE_H
|
||||||
|
|
392
2020TPCApp1.cydsn/HW/HW_NeoPixels.c
Normal file
392
2020TPCApp1.cydsn/HW/HW_NeoPixels.c
Normal file
|
@ -0,0 +1,392 @@
|
||||||
|
// NeoPixel Driver using Direct Memory Access
|
||||||
|
//
|
||||||
|
// This implementation is based on the one by Alan Hawse of Elkhorn Creek,
|
||||||
|
// documented at https://iotexpert.com/2019/01/08/psoc-6-dma-ws2812-leds/.
|
||||||
|
// We are grateful to Mr. Hawse for sharing this.
|
||||||
|
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
#define NEOPIXEL_ZOFFSET (1)
|
||||||
|
#define NEOPIXEL_ONE3 (0b110<<24)
|
||||||
|
#define NEOPIXEL_ZERO3 (0b100<<24)
|
||||||
|
#define NEOPIXEL_SPI_BIT_PER_BIT (3)
|
||||||
|
#define NEOPIXEL_COLOR_PER_PIXEL (3)
|
||||||
|
#define NEOPIXEL_BYTES_PER_PIXEL (NEOPIXEL_SPI_BIT_PER_BIT * NEOPIXEL_COLOR_PER_PIXEL)
|
||||||
|
#define FRAME_BUFFER_SIZE (NEOPIXEL_ZOFFSET + (CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL * NEOPIXEL_BYTES_PER_PIXEL))
|
||||||
|
|
||||||
|
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
|
||||||
|
static uint8_t NeoPixel_Barrel_Channel_Frame_Buffer[FRAME_BUFFER_SIZE];
|
||||||
|
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
|
||||||
|
static uint8_t NeoPixel_Barrel_Channel_Frame_Buffer[FRAME_BUFFER_SIZE];
|
||||||
|
static uint8_t NeoPixel_Receiver_Channel_Frame_Buffer[FRAME_BUFFER_SIZE];
|
||||||
|
static uint8_t NeoPixel_Display_Channel_Frame_Buffer[FRAME_BUFFER_SIZE];
|
||||||
|
static uint8_t NeoPixel_Effects_Channel_Frame_Buffer[FRAME_BUFFER_SIZE];
|
||||||
|
#else
|
||||||
|
#error "Unsupported number of NeoPixel channels defined. Supported configurations are 1 and 4."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static uint8_t* NeoPixel_Frame_Buffers[CONFIG_KTAG_N_NEOPIXEL_CHANNELS] =
|
||||||
|
{
|
||||||
|
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
|
||||||
|
NeoPixel_Barrel_Channel_Frame_Buffer
|
||||||
|
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
|
||||||
|
NeoPixel_Barrel_Channel_Frame_Buffer,
|
||||||
|
NeoPixel_Receiver_Channel_Frame_Buffer,
|
||||||
|
NeoPixel_Display_Channel_Frame_Buffer,
|
||||||
|
NeoPixel_Effects_Channel_Frame_Buffer
|
||||||
|
#else
|
||||||
|
#error "Unsupported number of NeoPixel channels defined. Supported configurations are 1 and 4."
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
ColorOrder_T ColorOrderByChannel[CONFIG_KTAG_N_NEOPIXEL_CHANNELS];
|
||||||
|
|
||||||
|
// Since the descriptors are (or should be) set to "trigger on descriptor completion" (`.interruptType = CY_DMA_DESCR`),
|
||||||
|
// this ISR is called after each channel has been written.
|
||||||
|
static void NeoPixel_DMA_Complete(void)
|
||||||
|
{
|
||||||
|
static BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
||||||
|
Cy_DMA_Channel_ClearInterrupt(DMA_NeoPixel_HW, DMA_NeoPixel_DW_CHANNEL);
|
||||||
|
|
||||||
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define NEOPIXEL_N_DESCRIPTORS CONFIG_KTAG_N_NEOPIXEL_CHANNELS
|
||||||
|
static cy_stc_dma_descriptor_t NeoPixel_Descriptors[NEOPIXEL_N_DESCRIPTORS];
|
||||||
|
static void NeoPixel_Configure_DMA(void)
|
||||||
|
{
|
||||||
|
// I [AH] copied this structure from the PSoC Creator Component configuration
|
||||||
|
// in the generated source.
|
||||||
|
const cy_stc_dma_descriptor_config_t NeoPixel_DMA_Descriptor_Config =
|
||||||
|
{
|
||||||
|
.retrigger = CY_DMA_RETRIG_IM,
|
||||||
|
.interruptType = CY_DMA_DESCR,
|
||||||
|
.triggerOutType = CY_DMA_1ELEMENT,
|
||||||
|
.channelState = CY_DMA_CHANNEL_ENABLED,
|
||||||
|
.triggerInType = CY_DMA_1ELEMENT,
|
||||||
|
.dataSize = CY_DMA_BYTE,
|
||||||
|
.srcTransferSize = CY_DMA_TRANSFER_SIZE_DATA,
|
||||||
|
.dstTransferSize = CY_DMA_TRANSFER_SIZE_WORD,
|
||||||
|
.descriptorType = CY_DMA_1D_TRANSFER,
|
||||||
|
.srcAddress = NULL,
|
||||||
|
.dstAddress = NULL,
|
||||||
|
.srcXincrement = 1L,
|
||||||
|
.dstXincrement = 0L,
|
||||||
|
.xCount = 256UL,
|
||||||
|
.srcYincrement = 0L,
|
||||||
|
.dstYincrement = 0L,
|
||||||
|
.yCount = 1UL,
|
||||||
|
.nextDescriptor = NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
for (uint_fast8_t i=0; i < NEOPIXEL_N_DESCRIPTORS; i++)
|
||||||
|
{
|
||||||
|
Cy_DMA_Descriptor_Init(&NeoPixel_Descriptors[i], &NeoPixel_DMA_Descriptor_Config);
|
||||||
|
Cy_DMA_Descriptor_SetSrcAddress(&NeoPixel_Descriptors[i], (uint8_t *)&NeoPixel_Frame_Buffers[i][0]);
|
||||||
|
Cy_DMA_Descriptor_SetDstAddress(&NeoPixel_Descriptors[i], (void *)&SPI_NeoPixel_HW->TX_FIFO_WR);
|
||||||
|
Cy_DMA_Descriptor_SetXloopDataCount(&NeoPixel_Descriptors[i], FRAME_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize and enable the interrupt from DMA_NeoPixel_HW.
|
||||||
|
Cy_SysInt_Init(&DMA_NeoPixel_Int_cfg, &NeoPixel_DMA_Complete);
|
||||||
|
NVIC_EnableIRQ(DMA_NeoPixel_Int_cfg.intrSrc);
|
||||||
|
Cy_DMA_Channel_SetInterruptMask(DMA_NeoPixel_HW, DMA_NeoPixel_DW_CHANNEL, DMA_NeoPixel_INTR_MASK);
|
||||||
|
|
||||||
|
Cy_DMA_Enable(DMA_NeoPixel_HW);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function: NeoPixel_Trigger_DMA
|
||||||
|
// This function sets up the channel... then enables it to dump the frameBuffer to pixels.
|
||||||
|
void NeoPixel_Trigger_DMA(uint_fast8_t channel)
|
||||||
|
{
|
||||||
|
cy_stc_dma_channel_config_t channel_config;
|
||||||
|
channel_config.descriptor = &NeoPixel_Descriptors[channel];
|
||||||
|
channel_config.preemptable = DMA_NeoPixel_PREEMPTABLE;
|
||||||
|
channel_config.priority = DMA_NeoPixel_PRIORITY;
|
||||||
|
channel_config.enable = false;
|
||||||
|
Cy_DMA_Channel_Init(DMA_NeoPixel_HW, DMA_NeoPixel_DW_CHANNEL, &channel_config);
|
||||||
|
Cy_DMA_Channel_Enable(DMA_NeoPixel_HW, DMA_NeoPixel_DW_CHANNEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Takes an 8-bit value representing a color level and turns it into a WS2812 bit code...
|
||||||
|
/*!
|
||||||
|
* ...where 1=110 and 0=011
|
||||||
|
* One input byte turns into three output bytes of a uint32_t.
|
||||||
|
*/
|
||||||
|
uint32_t NeoPixel_ConvertTo3Code(uint8_t input)
|
||||||
|
{
|
||||||
|
uint32_t rval=0;
|
||||||
|
for (uint_fast8_t i=0; i < 8; i++)
|
||||||
|
{
|
||||||
|
if (input % 2)
|
||||||
|
{
|
||||||
|
rval |= NEOPIXEL_ONE3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rval |= NEOPIXEL_ZERO3;
|
||||||
|
}
|
||||||
|
rval = rval >> 3;
|
||||||
|
|
||||||
|
input = input >> 1;
|
||||||
|
}
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Takes a position and a three byte RGB value and updates the corresponding NeoPixel_Frame_Buffer with the correct nine bytes.
|
||||||
|
SystemKResult_T HW_NeoPixels_Set_RGB(NeoPixelsChannel_T channel, uint8_t position, uint8_t red, uint8_t green, uint8_t blue)
|
||||||
|
{
|
||||||
|
typedef union {
|
||||||
|
uint8_t bytes[4];
|
||||||
|
uint32_t word;
|
||||||
|
} NeoPixel_ColorByNumber;
|
||||||
|
|
||||||
|
NeoPixel_ColorByNumber color;
|
||||||
|
ColorOrder_T order = ColorOrderByChannel[channel];
|
||||||
|
|
||||||
|
if (order == COLOR_ORDER_RGB)
|
||||||
|
{
|
||||||
|
color.word = NeoPixel_ConvertTo3Code(red);
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+0+NEOPIXEL_ZOFFSET] = color.bytes[2];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+1+NEOPIXEL_ZOFFSET] = color.bytes[1];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+2+NEOPIXEL_ZOFFSET] = color.bytes[0];
|
||||||
|
|
||||||
|
color.word = NeoPixel_ConvertTo3Code(green);
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+3+NEOPIXEL_ZOFFSET] = color.bytes[2];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+4+NEOPIXEL_ZOFFSET] = color.bytes[1];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+5+NEOPIXEL_ZOFFSET] = color.bytes[0];
|
||||||
|
|
||||||
|
color.word = NeoPixel_ConvertTo3Code(blue);
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+6+NEOPIXEL_ZOFFSET] = color.bytes[2];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+7+NEOPIXEL_ZOFFSET] = color.bytes[1];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+8+NEOPIXEL_ZOFFSET] = color.bytes[0];
|
||||||
|
}
|
||||||
|
else if (order == COLOR_ORDER_GRB)
|
||||||
|
{
|
||||||
|
color.word = NeoPixel_ConvertTo3Code(green);
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+0+NEOPIXEL_ZOFFSET] = color.bytes[2];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+1+NEOPIXEL_ZOFFSET] = color.bytes[1];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+2+NEOPIXEL_ZOFFSET] = color.bytes[0];
|
||||||
|
|
||||||
|
color.word = NeoPixel_ConvertTo3Code(red);
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+3+NEOPIXEL_ZOFFSET] = color.bytes[2];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+4+NEOPIXEL_ZOFFSET] = color.bytes[1];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+5+NEOPIXEL_ZOFFSET] = color.bytes[0];
|
||||||
|
|
||||||
|
color.word = NeoPixel_ConvertTo3Code(blue);
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+6+NEOPIXEL_ZOFFSET] = color.bytes[2];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+7+NEOPIXEL_ZOFFSET] = color.bytes[1];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+8+NEOPIXEL_ZOFFSET] = color.bytes[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Color order is not handled--log this and use RGB.
|
||||||
|
{
|
||||||
|
static bool error_logged = false;
|
||||||
|
if (error_logged == false)
|
||||||
|
{
|
||||||
|
COMM_Console_Print_String("Color order ");
|
||||||
|
COMM_Console_Print_UInt8(order);
|
||||||
|
COMM_Console_Print_String(" not yet supported!");
|
||||||
|
error_logged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
color.word = NeoPixel_ConvertTo3Code(red);
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+0+NEOPIXEL_ZOFFSET] = color.bytes[2];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+1+NEOPIXEL_ZOFFSET] = color.bytes[1];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+2+NEOPIXEL_ZOFFSET] = color.bytes[0];
|
||||||
|
|
||||||
|
color.word = NeoPixel_ConvertTo3Code(green);
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+3+NEOPIXEL_ZOFFSET] = color.bytes[2];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+4+NEOPIXEL_ZOFFSET] = color.bytes[1];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+5+NEOPIXEL_ZOFFSET] = color.bytes[0];
|
||||||
|
|
||||||
|
color.word = NeoPixel_ConvertTo3Code(blue);
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+6+NEOPIXEL_ZOFFSET] = color.bytes[2];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+7+NEOPIXEL_ZOFFSET] = color.bytes[1];
|
||||||
|
NeoPixel_Frame_Buffers[channel][position*NEOPIXEL_BYTES_PER_PIXEL+8+NEOPIXEL_ZOFFSET] = color.bytes[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return SYSTEMK_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! Initializes the hardware.
|
||||||
|
SystemKResult_T HW_NeoPixels_Init(void)
|
||||||
|
{
|
||||||
|
Cy_SCB_SPI_Init(SPI_NeoPixel_HW, &SPI_NeoPixel_config, &SPI_NeoPixel_context);
|
||||||
|
Cy_SCB_SPI_Enable(SPI_NeoPixel_HW);
|
||||||
|
NeoPixel_Configure_DMA();
|
||||||
|
|
||||||
|
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
|
||||||
|
ColorOrderByChannel[NEOPIXEL_CHANNEL_BARREL] = NVM_BARREL_COLOR_ORDER;
|
||||||
|
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
|
||||||
|
ColorOrderByChannel[NEOPIXEL_CHANNEL_BARREL] = NVM_BARREL_COLOR_ORDER;
|
||||||
|
ColorOrderByChannel[NEOPIXEL_CHANNEL_RECEIVER] = NVM_RECEIVER_COLOR_ORDER;
|
||||||
|
ColorOrderByChannel[NEOPIXEL_CHANNEL_DISPLAY] = NVM_DISPLAY_COLOR_ORDER;
|
||||||
|
ColorOrderByChannel[NEOPIXEL_CHANNEL_EFFECTS] = NVM_EFFECTS_COLOR_ORDER;
|
||||||
|
#else
|
||||||
|
#error "Unsupported number of NeoPixel channels defined. Supported configurations are 1 and 4."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return SYSTEMK_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixels_Set_Color_On_All_Channels(uint8_t position, color_t color)
|
||||||
|
{
|
||||||
|
HW_NeoPixels_Set_RGB(NEOPIXEL_CHANNEL_BARREL, position, Gamma8[Red(color)], Gamma8[Green(color)], Gamma8[Blue(color)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Disable_All_Channels()
|
||||||
|
{
|
||||||
|
// Nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Enable_Channel(uint_fast8_t __attribute__ ((unused)) channel)
|
||||||
|
{
|
||||||
|
// Nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Disable_Channel(uint_fast8_t __attribute__ ((unused)) channel)
|
||||||
|
{
|
||||||
|
// Nothing to do.
|
||||||
|
}
|
||||||
|
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Enable_Barrel_Channel()
|
||||||
|
{
|
||||||
|
Cy_GPIO_Write(Pin_NeoPixel_Select_0_PORT, Pin_NeoPixel_Select_0_NUM, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Disable_Barrel_Channel()
|
||||||
|
{
|
||||||
|
Cy_GPIO_Write(Pin_NeoPixel_Select_0_PORT, Pin_NeoPixel_Select_0_NUM, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Enable_Receiver_Channel()
|
||||||
|
{
|
||||||
|
Cy_GPIO_Write(Pin_NeoPixel_Select_1_PORT, Pin_NeoPixel_Select_1_NUM, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Disable_Receiver_Channel()
|
||||||
|
{
|
||||||
|
Cy_GPIO_Write(Pin_NeoPixel_Select_1_PORT, Pin_NeoPixel_Select_1_NUM, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Enable_Display_Channel()
|
||||||
|
{
|
||||||
|
Cy_GPIO_Write(Pin_NeoPixel_Select_2_PORT, Pin_NeoPixel_Select_2_NUM, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Disable_Display_Channel()
|
||||||
|
{
|
||||||
|
Cy_GPIO_Write(Pin_NeoPixel_Select_2_PORT, Pin_NeoPixel_Select_2_NUM, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Enable_Effects_Channel()
|
||||||
|
{
|
||||||
|
Cy_GPIO_Write(Pin_NeoPixel_Select_3_PORT, Pin_NeoPixel_Select_3_NUM, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Disable_Effects_Channel()
|
||||||
|
{
|
||||||
|
Cy_GPIO_Write(Pin_NeoPixel_Select_3_PORT, Pin_NeoPixel_Select_3_NUM, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Enable_All_Channels()
|
||||||
|
{
|
||||||
|
NeoPixel_Enable_Barrel_Channel();
|
||||||
|
NeoPixel_Enable_Receiver_Channel();
|
||||||
|
NeoPixel_Enable_Display_Channel();
|
||||||
|
NeoPixel_Enable_Effects_Channel();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Disable_All_Channels()
|
||||||
|
{
|
||||||
|
NeoPixel_Disable_Barrel_Channel();
|
||||||
|
NeoPixel_Disable_Receiver_Channel();
|
||||||
|
NeoPixel_Disable_Display_Channel();
|
||||||
|
NeoPixel_Disable_Effects_Channel();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Enable_Channel(uint_fast8_t channel)
|
||||||
|
{
|
||||||
|
switch (channel)
|
||||||
|
{
|
||||||
|
case NEOPIXEL_CHANNEL_BARREL:
|
||||||
|
NeoPixel_Enable_Barrel_Channel();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NEOPIXEL_CHANNEL_RECEIVER:
|
||||||
|
NeoPixel_Enable_Receiver_Channel();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NEOPIXEL_CHANNEL_DISPLAY:
|
||||||
|
NeoPixel_Enable_Display_Channel();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NEOPIXEL_CHANNEL_EFFECTS:
|
||||||
|
NeoPixel_Enable_Effects_Channel();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Do nothing.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) void NeoPixel_Disable_Channel(uint_fast8_t channel)
|
||||||
|
{
|
||||||
|
switch (channel)
|
||||||
|
{
|
||||||
|
case NEOPIXEL_CHANNEL_BARREL:
|
||||||
|
NeoPixel_Disable_Barrel_Channel();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NEOPIXEL_CHANNEL_RECEIVER:
|
||||||
|
NeoPixel_Disable_Receiver_Channel();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NEOPIXEL_CHANNEL_DISPLAY:
|
||||||
|
NeoPixel_Disable_Display_Channel();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NEOPIXEL_CHANNEL_EFFECTS:
|
||||||
|
NeoPixel_Disable_Effects_Channel();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Do nothing.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#error "Unsupported number of NeoPixel channels defined. Supported configurations are 1 and 4."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SystemKResult_T HW_NeoPixels_Publish(void)
|
||||||
|
{
|
||||||
|
// Update the NeoPixels using DMA.
|
||||||
|
for (uint_fast8_t Current_NeoPixel_Channel = 0; Current_NeoPixel_Channel < CONFIG_KTAG_N_NEOPIXEL_CHANNELS; Current_NeoPixel_Channel++)
|
||||||
|
{
|
||||||
|
xSemaphoreTake(NeoPixels_Semaphore, portMAX_DELAY);
|
||||||
|
NeoPixel_Enable_Channel(Current_NeoPixel_Channel);
|
||||||
|
NeoPixel_Trigger_DMA(Current_NeoPixel_Channel);
|
||||||
|
// Allow time for the DMA transfer to go out on the wire.
|
||||||
|
vTaskDelay(portTICK_PERIOD_MS);
|
||||||
|
NeoPixel_Disable_Channel(Current_NeoPixel_Channel);
|
||||||
|
xSemaphoreGive(NeoPixels_Semaphore);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SYSTEMK_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \todo Refactor this somehow...it doesn't belong here.
|
||||||
|
color_t HW_NeoPixels_Get_My_Color(void)
|
||||||
|
{
|
||||||
|
return PROTOCOLS_GetColor(GetWeaponFromID(NVM_WEAPON_ID).Protocol, NVM_TEAM_ID, NVM_PLAYER_ID);
|
||||||
|
}
|
81
2020TPCApp1.cydsn/KTag.h
Normal file
81
2020TPCApp1.cydsn/KTag.h
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
/** \file
|
||||||
|
* \brief This is the top-level include file for the entire project.
|
||||||
|
*
|
||||||
|
* By including this file (and only this file), include dependency order is maintained.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKKKKKKKKKKKKky+.`/ykKKKKKKKKKKKKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKKKKKKKKds/. -+o:` ./sdNKKKKKKKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKKNds+-` `-+hNKKKKNho:` `-+shNKKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKNkhyo+:. `-/sdNKKKKKKKKKKKKKky+:` .-/oyhdNKKKKKKKKKK
|
||||||
|
// KKys++:-.````.-:+oykNKKKKKKKKKKKKKKKKKKKKKKNkhs+/-.````.-:/+syKK
|
||||||
|
// KK -/+osydkNNNKKKkkkkkkkNKKKKKKKKKKKkkkkkkkkNKKKKNNkdhyso/: KK
|
||||||
|
// KK sKKKKKKKKKKKKK```````/KKKKKKKKKd-```````:kKKKKKKKKKKKKKd `KK
|
||||||
|
// KK- oKKKKKKKKKKKKK :KKKKKKKKo` `oNKKKKKKKKKKKKKKh :KK
|
||||||
|
// KK/ +KKKKKKKKKKKKK :KKKKKKd- -dKKKKKKKKKKKKKKKKy /KK
|
||||||
|
// KK+ /KKKKKKKKKKKKK :KKKKKs` +NKKKKKKKKKKKKKKKKKs +KK
|
||||||
|
// KKo :KKKKKKKKKKKKK :KKKk: .hKKKKKKKKKKKKKKKKKKKo oKK
|
||||||
|
// KKy -KKKKKKKKKKKKK :KKy` +NKKKKKKKKKKKKKKKKKKKK/ yKK
|
||||||
|
// KKd `KKKKKKKKKKKKK :k/ .hKKKKKKKKKKKKKKKKKKKKKK: dKK
|
||||||
|
// KKN NKKKKKKKKKKKK .. /kKKKKKKKKKKKKKKKKKKKKKKK. NKK
|
||||||
|
// KKK. dKKKKKKKKKKKK .yKKKKKKKKKKKKKKKKKKKKKKKKN .KKK
|
||||||
|
// KKK+ oKKKKKKKKKKKK -kKKKKKKKKKKKKKKKKKKKKKKKKKh +KKK
|
||||||
|
// KKKd .KKKKKKKKKKKK `sNKKKKKKKKKKKKKKKKKKKKKKKK/ dKKK
|
||||||
|
// KKKK: hKKKKKKKKKKK :kKKKKKKKKKKKKKKKKKKKKKKk :KKKK
|
||||||
|
// KKKKh -KKKKKKKKKKK `` .yKKKKKKKKKKKKKKKKKKKKK+ hKKKK
|
||||||
|
// KKKKK/ yKKKKKKKKKK T :d: /kKKKKKKKKKKKKKKKKKKk`:KKKKK
|
||||||
|
// KKKKKk`.NKKKKKKKKK :KNo` .hKKKKKKKKKKKKKKKKK:`kKKKKK
|
||||||
|
// KKKKKKy /KKKKKKKKK A :KKKd- +NKKKKKKKKKKKKKKo yKKKKKK
|
||||||
|
// KKKKKKK+ oKKKKKKKK :KKKKN+` -hKKKKKKKKKKKKy`+KKKKKKK
|
||||||
|
// KKKKKKKN/ sKKKKKKK G :KKKKKKh. `oNKKKKKKKKKh`/KKKKKKKK
|
||||||
|
// KKKKKKKKN/`sKKKKKK :KKKKKKKN/ -dKKKKKKKh`/NKKKKKKKK
|
||||||
|
// KKKKKKKKKK+ +NKKKK :KKKKKKKKKy. `sNKKKKs`+KKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKs`:kKKK-------+KKKKKKKKKKk/--------oKKN+`sKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKh..yKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKd--dKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKN+`/kKKKKKKKKKKKKKKKKKKKKKKKKKKKKNo`+NKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKh-`sNKKKKKKKKKKKKKKKKKKKKKKKKNy.-hKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKs..sNKKKKKKKKKKKKKKKKKKKKNy-.yKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKKNs..okKKKKKKKKKKKKKKKKNs-.sNKKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKKKKKy-`/hKKKKKKKKKKKKd+`-yKKKKKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKKKKKKKd/`.odKKKKKKks-`/dKKKKKKKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKKKKKKKKKNs: .+yy+-`:sNKKKKKKKKKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKKKKKKKKKKKKNy/..+yNKKKKKKKKKKKKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
|
||||||
|
// KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef KTAG_H
|
||||||
|
#define KTAG_H
|
||||||
|
|
||||||
|
/* Include FreeRTOS APIs and defines */
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "croutine.h"
|
||||||
|
#include "semphr.h"
|
||||||
|
#include "portmacro.h"
|
||||||
|
#include "timers.h"
|
||||||
|
|
||||||
|
/* Include PSoC system and component APIs and defines */
|
||||||
|
#include <project.h>
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "CONFIG.h"
|
||||||
|
#include "SystemK.h"
|
||||||
|
#include "HW.h"
|
||||||
|
#include "Audio.h"
|
||||||
|
#include "NVM.h"
|
||||||
|
#include "COMM.h"
|
||||||
|
#include "Fire_Control.h"
|
||||||
|
#include "Sample_Tasks.h"
|
||||||
|
#include "Tag_Sensors.h"
|
||||||
|
#include "Switches.h"
|
||||||
|
#include "Util.h"
|
||||||
|
|
||||||
|
#endif // KTAG_H
|
79
2020TPCApp1.cydsn/Menu/GameSettings/GameMenuItem.c
Normal file
79
2020TPCApp1.cydsn/Menu/GameSettings/GameMenuItem.c
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
static uint8_t SubmenuIndex = 0;
|
||||||
|
static MenuItem_T const * const Submenus[] =
|
||||||
|
{
|
||||||
|
&TeamIDMenuItem,
|
||||||
|
&PlayerIDMenuItem
|
||||||
|
};
|
||||||
|
static const uint8_t N_SUBMENUS = (sizeof(Submenus) / sizeof(MenuItem_T *));
|
||||||
|
|
||||||
|
static void OnFocus(bool IncludeDetails);
|
||||||
|
static MenuItem_T const * OnSelect();
|
||||||
|
static void OnIncrement();
|
||||||
|
static void OnDecrement();
|
||||||
|
|
||||||
|
const MenuItem_T GameMenuItem =
|
||||||
|
{
|
||||||
|
.OnFocus = OnFocus,
|
||||||
|
.OnSelect = OnSelect,
|
||||||
|
.OnIncrement = OnIncrement,
|
||||||
|
.OnDecrement = OnDecrement
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static void OnFocus(bool IncludeDetails)
|
||||||
|
{
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_GAME_SETTINGS_PROMPT, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
|
||||||
|
if (IncludeDetails == true)
|
||||||
|
{
|
||||||
|
if (Submenus[SubmenuIndex]->OnFocus != NULL)
|
||||||
|
{
|
||||||
|
Submenus[SubmenuIndex]->OnFocus(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static MenuItem_T const * OnSelect()
|
||||||
|
{
|
||||||
|
return Submenus[SubmenuIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnIncrement()
|
||||||
|
{
|
||||||
|
if (SubmenuIndex < (N_SUBMENUS -1))
|
||||||
|
{
|
||||||
|
SubmenuIndex++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Wrap around.
|
||||||
|
SubmenuIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Submenus[SubmenuIndex]->OnFocus != NULL)
|
||||||
|
{
|
||||||
|
Submenus[SubmenuIndex]->OnFocus(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnDecrement()
|
||||||
|
{
|
||||||
|
if (SubmenuIndex > 0)
|
||||||
|
{
|
||||||
|
SubmenuIndex--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Wrap around.
|
||||||
|
SubmenuIndex = (N_SUBMENUS -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Submenus[SubmenuIndex]->OnFocus != NULL)
|
||||||
|
{
|
||||||
|
Submenus[SubmenuIndex]->OnFocus(false);
|
||||||
|
}
|
||||||
|
}
|
6
2020TPCApp1.cydsn/Menu/GameSettings/GameMenuItem.h
Normal file
6
2020TPCApp1.cydsn/Menu/GameSettings/GameMenuItem.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef GAMEMENUITEM_H
|
||||||
|
#define GAMEMENUITEM_H
|
||||||
|
|
||||||
|
const MenuItem_T GameMenuItem;
|
||||||
|
|
||||||
|
#endif // GAMEMENUITEM_H
|
66
2020TPCApp1.cydsn/Menu/GameSettings/PlayerIDMenuItem.c
Normal file
66
2020TPCApp1.cydsn/Menu/GameSettings/PlayerIDMenuItem.c
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
#define MIN_PLAYER_ID 0b0000000
|
||||||
|
#define MAX_PLAYER_ID 0b1111111
|
||||||
|
|
||||||
|
static void OnFocus(bool IncludeDetails);
|
||||||
|
static MenuItem_T const * OnSelect();
|
||||||
|
static void OnIncrement();
|
||||||
|
static void OnDecrement();
|
||||||
|
|
||||||
|
const MenuItem_T PlayerIDMenuItem =
|
||||||
|
{
|
||||||
|
.OnFocus = OnFocus,
|
||||||
|
.OnSelect = OnSelect,
|
||||||
|
.OnIncrement = OnIncrement,
|
||||||
|
.OnDecrement = OnDecrement
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static void OnFocus(bool IncludeDetails)
|
||||||
|
{
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_PLAYER_ID_PROMPT, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
|
||||||
|
if (IncludeDetails == true)
|
||||||
|
{
|
||||||
|
AudioAction_T volume_action = {.ID = AUDIO_PRONOUNCE_NUMBER_0_TO_100, .Play_To_Completion = true, .Data = (void *)&NVM_PLAYER_ID};
|
||||||
|
xQueueSend(xQueueAudio, &volume_action, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static MenuItem_T const * OnSelect()
|
||||||
|
{
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_SELECTION_INDICATOR, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnIncrement()
|
||||||
|
{
|
||||||
|
if (NVM_PLAYER_ID < MAX_PLAYER_ID)
|
||||||
|
{
|
||||||
|
NVM_PLAYER_ID++;
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_PLAYER_ID_PROMPT, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
|
||||||
|
AudioAction_T volume_action = {.ID = AUDIO_PRONOUNCE_NUMBER_0_TO_100, .Play_To_Completion = true, .Data = (void *)&NVM_PLAYER_ID};
|
||||||
|
xQueueSend(xQueueAudio, &volume_action, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnDecrement()
|
||||||
|
{
|
||||||
|
if (NVM_PLAYER_ID > MIN_PLAYER_ID)
|
||||||
|
{
|
||||||
|
NVM_PLAYER_ID--;
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_PLAYER_ID_PROMPT, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
|
||||||
|
AudioAction_T volume_action = {.ID = AUDIO_PRONOUNCE_NUMBER_0_TO_100, .Play_To_Completion = true, .Data = (void *)&NVM_PLAYER_ID};
|
||||||
|
xQueueSend(xQueueAudio, &volume_action, 0);
|
||||||
|
}
|
6
2020TPCApp1.cydsn/Menu/GameSettings/PlayerIDMenuItem.h
Normal file
6
2020TPCApp1.cydsn/Menu/GameSettings/PlayerIDMenuItem.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef PLAYERIDMENUITEM_H
|
||||||
|
#define PLAYERIDMENUITEM_H
|
||||||
|
|
||||||
|
const MenuItem_T PlayerIDMenuItem;
|
||||||
|
|
||||||
|
#endif // PLAYERIDMENUITEM_H
|
66
2020TPCApp1.cydsn/Menu/GameSettings/TeamIDMenuItem.c
Normal file
66
2020TPCApp1.cydsn/Menu/GameSettings/TeamIDMenuItem.c
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
#define MIN_TEAM_ID 0
|
||||||
|
#define MAX_TEAM_ID 3
|
||||||
|
|
||||||
|
static void OnFocus(bool IncludeDetails);
|
||||||
|
static MenuItem_T const * OnSelect();
|
||||||
|
static void OnIncrement();
|
||||||
|
static void OnDecrement();
|
||||||
|
|
||||||
|
const MenuItem_T TeamIDMenuItem =
|
||||||
|
{
|
||||||
|
.OnFocus = OnFocus,
|
||||||
|
.OnSelect = OnSelect,
|
||||||
|
.OnIncrement = OnIncrement,
|
||||||
|
.OnDecrement = OnDecrement
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static void OnFocus(bool IncludeDetails)
|
||||||
|
{
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_TEAM_ID_PROMPT, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
|
||||||
|
if (IncludeDetails == true)
|
||||||
|
{
|
||||||
|
AudioAction_T volume_action = {.ID = AUDIO_PRONOUNCE_NUMBER_0_TO_100, .Play_To_Completion = true, .Data = (void *)&NVM_TEAM_ID};
|
||||||
|
xQueueSend(xQueueAudio, &volume_action, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static MenuItem_T const * OnSelect()
|
||||||
|
{
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_SELECTION_INDICATOR, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnIncrement()
|
||||||
|
{
|
||||||
|
if (NVM_TEAM_ID < MAX_TEAM_ID)
|
||||||
|
{
|
||||||
|
NVM_TEAM_ID++;
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_TEAM_ID_PROMPT, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
|
||||||
|
AudioAction_T volume_action = {.ID = AUDIO_PRONOUNCE_NUMBER_0_TO_100, .Play_To_Completion = true, .Data = (void *)&NVM_TEAM_ID};
|
||||||
|
xQueueSend(xQueueAudio, &volume_action, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnDecrement()
|
||||||
|
{
|
||||||
|
if (NVM_TEAM_ID > MIN_TEAM_ID)
|
||||||
|
{
|
||||||
|
NVM_TEAM_ID--;
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_TEAM_ID_PROMPT, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
|
||||||
|
AudioAction_T volume_action = {.ID = AUDIO_PRONOUNCE_NUMBER_0_TO_100, .Play_To_Completion = true, .Data = (void *)&NVM_TEAM_ID};
|
||||||
|
xQueueSend(xQueueAudio, &volume_action, 0);
|
||||||
|
}
|
6
2020TPCApp1.cydsn/Menu/GameSettings/TeamIDMenuItem.h
Normal file
6
2020TPCApp1.cydsn/Menu/GameSettings/TeamIDMenuItem.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef TEAMIDMENUITEM_H
|
||||||
|
#define TEAMIDMENUITEM_H
|
||||||
|
|
||||||
|
const MenuItem_T TeamIDMenuItem;
|
||||||
|
|
||||||
|
#endif // TEAMIDMENUITEM_H
|
64
2020TPCApp1.cydsn/Menu/HardwareSettings/HandedMenuItem.c
Normal file
64
2020TPCApp1.cydsn/Menu/HardwareSettings/HandedMenuItem.c
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
static void OnFocus(bool IncludeDetails);
|
||||||
|
static MenuItem_T const * OnSelect();
|
||||||
|
static void OnIncrement();
|
||||||
|
static void OnDecrement();
|
||||||
|
static void ToggleHanded();
|
||||||
|
|
||||||
|
const MenuItem_T HandedMenuItem =
|
||||||
|
{
|
||||||
|
.OnFocus = OnFocus,
|
||||||
|
.OnSelect = OnSelect,
|
||||||
|
.OnIncrement = OnIncrement,
|
||||||
|
.OnDecrement = OnDecrement
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static void OnFocus(bool IncludeDetails)
|
||||||
|
{
|
||||||
|
if (NVM_IS_RIGHT_HANDED == true)
|
||||||
|
{
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_RIGHT_HANDED, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_LEFT_HANDED, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static MenuItem_T const * OnSelect()
|
||||||
|
{
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_SELECTION_INDICATOR, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnIncrement()
|
||||||
|
{
|
||||||
|
ToggleHanded();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnDecrement()
|
||||||
|
{
|
||||||
|
ToggleHanded();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ToggleHanded()
|
||||||
|
{
|
||||||
|
if (NVM_IS_RIGHT_HANDED == true)
|
||||||
|
{
|
||||||
|
NVM_IS_RIGHT_HANDED = false;
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_LEFT_HANDED, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NVM_IS_RIGHT_HANDED = true;
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_RIGHT_HANDED, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
}
|
||||||
|
}
|
6
2020TPCApp1.cydsn/Menu/HardwareSettings/HandedMenuItem.h
Normal file
6
2020TPCApp1.cydsn/Menu/HardwareSettings/HandedMenuItem.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef HANDEDMENUITEM_H
|
||||||
|
#define HANDEDMENUITEM_H
|
||||||
|
|
||||||
|
const MenuItem_T HandedMenuItem;
|
||||||
|
|
||||||
|
#endif // VOLUMEMENUITEM_H
|
79
2020TPCApp1.cydsn/Menu/HardwareSettings/HardwareMenuItem.c
Normal file
79
2020TPCApp1.cydsn/Menu/HardwareSettings/HardwareMenuItem.c
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
/* Include Files */
|
||||||
|
#include "KTag.h"
|
||||||
|
|
||||||
|
static uint8_t SubmenuIndex = 0;
|
||||||
|
static MenuItem_T const * const Submenus[] =
|
||||||
|
{
|
||||||
|
&VolumeMenuItem,
|
||||||
|
&HandedMenuItem
|
||||||
|
};
|
||||||
|
static const uint8_t N_SUBMENUS = (sizeof(Submenus) / sizeof(MenuItem_T *));
|
||||||
|
|
||||||
|
static void OnFocus(bool IncludeDetails);
|
||||||
|
static MenuItem_T const * OnSelect();
|
||||||
|
static void OnIncrement();
|
||||||
|
static void OnDecrement();
|
||||||
|
|
||||||
|
const MenuItem_T HardwareMenuItem =
|
||||||
|
{
|
||||||
|
.OnFocus = OnFocus,
|
||||||
|
.OnSelect = OnSelect,
|
||||||
|
.OnIncrement = OnIncrement,
|
||||||
|
.OnDecrement = OnDecrement
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static void OnFocus(bool IncludeDetails)
|
||||||
|
{
|
||||||
|
AudioAction_T audio_action = {.ID = AUDIO_PLAY_HARDWARE_SETTINGS_PROMPT, .Play_To_Completion = true, .Data = (void *)0x00};
|
||||||
|
xQueueSend(xQueueAudio, &audio_action, 0);
|
||||||
|
|
||||||
|
if (IncludeDetails == true)
|
||||||
|
{
|
||||||
|
if (Submenus[SubmenuIndex]->OnFocus != NULL)
|
||||||
|
{
|
||||||
|
Submenus[SubmenuIndex]->OnFocus(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static MenuItem_T const * OnSelect()
|
||||||
|
{
|
||||||
|
return Submenus[SubmenuIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnIncrement()
|
||||||
|
{
|
||||||
|
if (SubmenuIndex < (N_SUBMENUS -1))
|
||||||
|
{
|
||||||
|
SubmenuIndex++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Wrap around.
|
||||||
|
SubmenuIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Submenus[SubmenuIndex]->OnFocus != NULL)
|
||||||
|
{
|
||||||
|
Submenus[SubmenuIndex]->OnFocus(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnDecrement()
|
||||||
|
{
|
||||||
|
if (SubmenuIndex > 0)
|
||||||
|
{
|
||||||
|
SubmenuIndex--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Wrap around.
|
||||||
|
SubmenuIndex = (N_SUBMENUS -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Submenus[SubmenuIndex]->OnFocus != NULL)
|
||||||
|
{
|
||||||
|
Submenus[SubmenuIndex]->OnFocus(false);
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue