sy8834 朗讯客户J8项目源码。
This commit is contained in:
commit
fcca7a0a4c
BIN
Out/SY883X_EVB_mcu_2024_09_03_152604.bin
Normal file
BIN
Out/SY883X_EVB_mcu_2024_09_03_152604.bin
Normal file
Binary file not shown.
202
Out/SY883X_EVB_mcu_2024_09_03_152604.hex
Normal file
202
Out/SY883X_EVB_mcu_2024_09_03_152604.hex
Normal file
@ -0,0 +1,202 @@
|
||||
:03000000020413E4
|
||||
:10041300758E3075D20078FFE4F6D8FD75815302EE
|
||||
:02042300046073
|
||||
:0F0A1A00120537D2AED2BE1209291205BB80F4E5
|
||||
:0404A500024F000002
|
||||
:0208E500AD075D
|
||||
:1008E700E4FCFBFAF527F52875FE2975FF8BEDC4A7
|
||||
:1008F70054F04401F5A5E5A520E0FBAFA1AB07AF98
|
||||
:10090700A2EFFEEEFAEB2528F528EA3527F5270CA6
|
||||
:10091700BC08DBE528AE277803CEC313CE13D8F97E
|
||||
:01092700FFD0
|
||||
:0109280022AC
|
||||
:10096800E4F524F5257F051208E58E248F257F06FA
|
||||
:100978001208E5E4FCFDC004A905AA06AB07AE24ED
|
||||
:10098800AF257C077DD012023BD0001201998E243E
|
||||
:020998008F25A9
|
||||
:01099A00223A
|
||||
:10099B00E4F525F5267F041208E58E258F267F06C4
|
||||
:1009AB001208E5E4FCFDC004A905AA06AB07AE25B9
|
||||
:1009BB00AF267C037DE812023BD0001201998E25F5
|
||||
:0209CB008F2675
|
||||
:0109CD002207
|
||||
:0204A900C1157B
|
||||
:1006B700E4FFFEF52412099BC3EF94D0EE940740A4
|
||||
:1006C700037F0122D3EF9436EE94055030EF942246
|
||||
:1006D700EE94024028301312EF9414EE940550075D
|
||||
:1006E700C213E4F524800375240130142BD3EF944F
|
||||
:1006F70044EE9402401FC214E4F524801BD3EF9408
|
||||
:1007070036EE94054004D213800BC3EF9422EE9487
|
||||
:0A071700025002D214752401AF2431
|
||||
:0107210022B5
|
||||
:10072200E5E620E70953B3FE75F210C21522E5F2A1
|
||||
:10073200540C601053B3FEE5F354C0603B75F20CE9
|
||||
:1007420075F3C022E5F354C0600375F3C01206B717
|
||||
:10075200EF600453B3FE22E5F230E417C37850E6AB
|
||||
:1007620094EB18E6940F500575F210800353B3FE14
|
||||
:09077200D2152243B301C2152285
|
||||
:0404AB00C116C1179E
|
||||
:10080000E5E530E103C21622E5E230E705C216D283
|
||||
:100810001722E5E830E00EC216300A35C20A75E844
|
||||
:100820000175B501221206B7EF6006C216E4F5B5F0
|
||||
:1008300022D21630171BE5E630E716C37850E6944F
|
||||
:100840001018E6940E4005D216C21722E4F5B5C280
|
||||
:0208500016226E
|
||||
:0704AF00C118C1190135FF5E
|
||||
:10002600E5E25408FF6535601AE5E230E30575340C
|
||||
:10003600018003E4F534D218D219E4F537F51E8FA2
|
||||
:0300460035D21E92
|
||||
:010049002294
|
||||
:0B04B600C112C110C10FC111015300A1
|
||||
:1009E600E5EF600EE5EF30E606D20F785376037535
|
||||
:0309F600EFFF22EE
|
||||
:0D000E00EF146006047005D28422D2832214
|
||||
:0D0A3800EF146006047005C28422C2832200
|
||||
:10063B00E4FE74382EF8E66067743C2EF9743E2E97
|
||||
:10064B00F8E6D397AF06500512000E8003120A3856
|
||||
:10065B00743E2EF8E6C394AA401EE4F674422EF8BC
|
||||
:10066B00E66008743C2EF81616800D74402EF8E6E2
|
||||
:10067B006006743C2EF80606743C2EF8E6FF74AA4E
|
||||
:10068B00D39F500A74422EF876017440800EEFD33C
|
||||
:10069B009401500C74402EF8760174422EF8E4F657
|
||||
:0B06AB00743E2EF8060EEE640270870D
|
||||
:0106B6002221
|
||||
:0504C10001360AC11E16
|
||||
:1009F900E5E620E706200803301E04C21EC322D301
|
||||
:010A090022CA
|
||||
:1005370075FE8043FF3075FE0153FFFC75FE0E7597
|
||||
:10054700FF05D2DF43878075BA0375AAFD7598D07A
|
||||
:10055700D299D298D2AC75B7C375FE6A53FFE04300
|
||||
:10056700FF04758901758CFC758A17D2A9D28C4353
|
||||
:100577008910758DFF758B9BD2ABD28E75FE067574
|
||||
:10058700FF1C75FE0375FF3CC284C283E4F58675C4
|
||||
:10059700FE0F43FF8075FE4F75FF1075FE1775FF41
|
||||
:1005A7003CD2A8D2B9D2AF75F21C75F3C075E80C6E
|
||||
:0405B70043B3102218
|
||||
:03000300020006F2
|
||||
:0100060032C7
|
||||
:03004B00020A4561
|
||||
:060A450075EB3CD21E32ED
|
||||
:0F04C6000B440000000000000000000000C11BFC
|
||||
:0607D1008B2B8A2C892D00
|
||||
:1007D700E4FEEEC39F5016201AFD782BE475F00156
|
||||
:0D07E70012022B120144D21AF5990E80E582
|
||||
:0107F40022E2
|
||||
:03002300020A29A5
|
||||
:0F0A2900309904C299C21A309804C298D21E3272
|
||||
:0504D500013700C11F0A
|
||||
:10035300300141E537C39402500261DFE537C394AE
|
||||
:100363005550190537301C0A78387601E408F6C26F
|
||||
:100373008322E47838F6087601C28422E47838F6DA
|
||||
:1003830008F6783E76AA0876AAC284C283C201C25E
|
||||
:1003930019F53722E5E630E72A301504D283801EAB
|
||||
:1003A300E537C394025008C284C2830537800FE542
|
||||
:1003B30037C394C850060537D2848002C284C21959
|
||||
:1003C300D21F22301F09C284C283E4F537C21F3013
|
||||
:1003D300193D301C1CE537C394025004C284801AB3
|
||||
:1003E300E537C3943250050537D28422C284C2193B
|
||||
:1003F30022C284E537C394025005C283053722E540
|
||||
:1004030037C3943250050537D28322C283C21922DF
|
||||
:1005BB00300921C209120968784FA60608A607124E
|
||||
:1005CB0000261209E6120800120722120268120313
|
||||
:1005DB005312077B300B58C20BE536D394004009FE
|
||||
:1005EB001536301E4AC21E80431209F9503E75FE65
|
||||
:1005FB002443FF3CC2ACC2B9C2A9C2AB53B7CFE4D0
|
||||
:10060B00F5B575FE2953FF7F75FE4FF5FF75FE801F
|
||||
:10061B0053FFCF43870275FE8043FF3075FE4F7546
|
||||
:10062B00FF10D2ACD2B9D2A9D2AB800075360A2258
|
||||
:0707F50000000000000000FD
|
||||
:1004DA00C108C101011E00011D00C103C107C106F7
|
||||
:0E04EA00C102011F00C100C105011C00C104B8
|
||||
:100A0A00D282EF700753B7CF43B7302253B7CF2202
|
||||
:10026800E5E8540C6013051FE51FC39402400AE437
|
||||
:10027800F51F75E80CFF020A0A30183F301633D212
|
||||
:1002880082201C0DE5B5700475B50122E4FF120A41
|
||||
:100298000AE534700CD203C218D208C206F51D80D4
|
||||
:1002A8001AC203E4F51DD206C200C218C204F51F23
|
||||
:1002B80080097F01120A0AC208C218300668E51DC3
|
||||
:1002C800C394055003051D22E51EC39405500BC2B7
|
||||
:1002D80082E4F5B5051ED205804C30050DC205D265
|
||||
:1002E80082C2087F01120A0A800B200008D200E5AA
|
||||
:1002F800E354A0F51C30002EE5E354A0651C600B08
|
||||
:10030800D201E4F537E5E354A0F51C300F18E51FDA
|
||||
:10031800C3940A500CE51F20E003120852051F8001
|
||||
:1003280005C20FE4F51F300321E5E354AC64AC606B
|
||||
:1003380003301C16E51DC394325003051D22E4F555
|
||||
:0B034800B57F01120A0AC208C282221F
|
||||
:1008520078247C007D007BFF7A0779F57E007F0794
|
||||
:1008620012011E7524557525AA752602752706756F
|
||||
:1008720028DD7529BAC282E4F5FE75FF0375FE0E06
|
||||
:1008820043FF04FB7A0079247F071207D175FE0E1D
|
||||
:0B08920053FFF375FE0153FFFCD28200
|
||||
:01089D002238
|
||||
:1004F800015200C11CC11D01511E14080C800CE4DE
|
||||
:100508000D480E4C0E920ED80F3C0F8C0FD210686F
|
||||
:10077B00E4FFEF25E02408F8E6FC08E6FDC378501B
|
||||
:10078B00E69D18E69C40040FBF0AE77852E6FEEFA1
|
||||
:10079B00D39E4004180680037851167851E6FED399
|
||||
:1007AB0094325006EEC3940A50077852A607187677
|
||||
:1007BB001E7852E6FFD394015003D21C22EFD39440
|
||||
:0507CB00024002C21C07
|
||||
:0107D0002206
|
||||
:10051800013100012F00012E00013000C10DC10A78
|
||||
:0E052800C109C10B013300013200C10CC10E2C
|
||||
:10092900E533603AE4F5330531E531C3940A40050E
|
||||
:10093900E4F531D20D052EE52EC394644005E4F5A6
|
||||
:100949002ED209052FE52FC394FA4012E4F52FD2D0
|
||||
:0F0959000A0530E53094044005E4F530D20B2256
|
||||
:03000B000209CE19
|
||||
:1009CE00C0E0C0D074FC258CF58C7417258AF58A8E
|
||||
:0809DE00753301D0D0D0E032E6
|
||||
:03001B0002089E3A
|
||||
:10089E00C0E0C0F0C083C082C0D075D000C000C020
|
||||
:1008AE0001C002C003C004C005C006C007C28F1538
|
||||
:1008BE008D749B258BF58B12063BD20ED007D0067E
|
||||
:1008CE00D005D004D003D002D001D000D0D0D08239
|
||||
:0708DE00D083D0F0D0E0321E
|
||||
:030BFD00010101F2
|
||||
:10042500020A1AE493A3F8E493A34003F68001F2C9
|
||||
:1004350008DFF48029E493A3F85407240CC8C333D8
|
||||
:10044500C4540F4420C8834004F456800146F6DFA7
|
||||
:10045500E4800B01020408102040809004A5E47E8E
|
||||
:10046500019360BCA3FF543F30E509541FFEE4939C
|
||||
:10047500A360010ECF54C025E060A840B8E493A363
|
||||
:10048500FAE493A3F8E493A3C8C582C8CAC583CA8E
|
||||
:10049500F0A3C8C582C8CAC583CADFE9DEE780BE46
|
||||
:0105360000C4
|
||||
:10004E00E709F608DFFA8046E709F208DFFA803E94
|
||||
:10005E0088828C83E709F0A3DFFA8032E309F60881
|
||||
:10006E00DFFA8078E309F208DFFA807088828C83E9
|
||||
:10007E00E309F0A3DFFA806489828A83E0A3F6089D
|
||||
:10008E00DFFA805889828A83E0A3F208DFFA804C77
|
||||
:10009E0080D280FA80C680D4806980F2803380104E
|
||||
:1000AE0080A680EA809A80A880DA80E280CA8033B7
|
||||
:1000BE0089828A83ECFAE493A3C8C582C8CCC5832F
|
||||
:1000CE00CCF0A3C8C582C8CCC583CCDFE9DEE780FF
|
||||
:1000DE000D89828A83E493A3F608DFF9ECFAA9F07E
|
||||
:1000EE00EDFB2289828A83ECFAE0A3C8C582C8CCD4
|
||||
:1000FE00C583CCF0A3C8C582C8CCC583CCDFEADEED
|
||||
:10010E00E880DB89828A83E493A3F208DFF980CC4E
|
||||
:10011E0088F0EF60010E4E60C388F0ED2402B40447
|
||||
:10012E000050B9F582EB2402B4040050AF232345EE
|
||||
:06013E00822390009E7375
|
||||
:10014400BB010689828A83E0225002E722BBFE02B9
|
||||
:09015400E32289828A83E49322EC
|
||||
:10015D0075F008758200EF2FFFEE33FECD33CDCC59
|
||||
:10016D0033CCC58233C5829BED9AEC99E5829840DC
|
||||
:10017D000CF582EE9BFEED9AFDEC99FC0FD5F0D6B9
|
||||
:10018D00E4CEFBE4CDFAE4CCF9A88222B800C1B9E3
|
||||
:10019D000059BA002DEC8BF084CFCECDFCE5F0CB21
|
||||
:1001AD00F97818EF2FFFEE33FEED33FDEC33FCEB5A
|
||||
:1001BD0033FB10D703994004EB99FB0FD8E5E4F915
|
||||
:1001CD00FA227818EF2FFFEE33FEED33FDEC33FC02
|
||||
:1001DD00C933C910D7059BE99A4007EC9BFCE99AF6
|
||||
:1001ED00F90FD8E0E4C9FAE4CCFB2275F010EF2F3B
|
||||
:1001FD00FFEE33FEED33FDCC33CCC833C810D7073B
|
||||
:10020D009BEC9AE899400AED9BFDEC9AFCE899F875
|
||||
:0E021D000FD5F0DAE4CDFBE4CCFAE4C8F92208
|
||||
:10022B00FAE6FB0808E6F925F0F618E6CA3AF622D4
|
||||
:10023B00EC8EF0A4CCC5F0CCCDF8EFA4CEC5F02D50
|
||||
:10024B00FDE43CFCE8A42EC8C5F03DFDE43CFCEF0E
|
||||
:0D025B00A4FFE5F028FEE43DFDE43CFC229C
|
||||
:00000001FF
|
BIN
Out/SY883X_EVB_mcu_2024_09_03_152604_crc(821c)_V010101.bin
Normal file
BIN
Out/SY883X_EVB_mcu_2024_09_03_152604_crc(821c)_V010101.bin
Normal file
Binary file not shown.
3754
Project/TP3102_Demo.uvgui.GH
Normal file
3754
Project/TP3102_Demo.uvgui.GH
Normal file
File diff suppressed because one or more lines are too long
3682
Project/TP3102_Demo.uvgui.GH.bak
Normal file
3682
Project/TP3102_Demo.uvgui.GH.bak
Normal file
File diff suppressed because one or more lines are too long
473
Project/TP3102_Demo.uvopt
Normal file
473
Project/TP3102_Demo.uvopt
Normal file
@ -0,0 +1,473 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_opt.xsd">
|
||||
|
||||
<SchemaVersion>1.0</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Extensions>
|
||||
<cExt>*.c</cExt>
|
||||
<aExt>*.s*; *.src; *.a*</aExt>
|
||||
<oExt>*.obj; *.o</oExt>
|
||||
<lExt>*.lib</lExt>
|
||||
<tExt>*.txt; *.h; *.inc</tExt>
|
||||
<pExt>*.plm</pExt>
|
||||
<CppX>*.cpp</CppX>
|
||||
<nMigrate>0</nMigrate>
|
||||
</Extensions>
|
||||
|
||||
<DaveTm>
|
||||
<dwLowDateTime>0</dwLowDateTime>
|
||||
<dwHighDateTime>0</dwHighDateTime>
|
||||
</DaveTm>
|
||||
|
||||
<Target>
|
||||
<TargetName>Target 1</TargetName>
|
||||
<ToolsetNumber>0x0</ToolsetNumber>
|
||||
<ToolsetName>MCS-51</ToolsetName>
|
||||
<TargetOption>
|
||||
<CLK51>12000000</CLK51>
|
||||
<OPTTT>
|
||||
<gFlags>1</gFlags>
|
||||
<BeepAtEnd>1</BeepAtEnd>
|
||||
<RunSim>1</RunSim>
|
||||
<RunTarget>0</RunTarget>
|
||||
<RunAbUc>0</RunAbUc>
|
||||
</OPTTT>
|
||||
<OPTHX>
|
||||
<HexSelection>0</HexSelection>
|
||||
<FlashByte>65535</FlashByte>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
</OPTHX>
|
||||
<OPTLEX>
|
||||
<PageWidth>120</PageWidth>
|
||||
<PageLength>65</PageLength>
|
||||
<TabStop>8</TabStop>
|
||||
<ListingPath>.\Listings\</ListingPath>
|
||||
</OPTLEX>
|
||||
<ListingPage>
|
||||
<CreateCListing>1</CreateCListing>
|
||||
<CreateAListing>1</CreateAListing>
|
||||
<CreateLListing>1</CreateLListing>
|
||||
<CreateIListing>0</CreateIListing>
|
||||
<AsmCond>1</AsmCond>
|
||||
<AsmSymb>1</AsmSymb>
|
||||
<AsmXref>0</AsmXref>
|
||||
<CCond>1</CCond>
|
||||
<CCode>1</CCode>
|
||||
<CListInc>0</CListInc>
|
||||
<CSymb>0</CSymb>
|
||||
<LinkerCodeListing>0</LinkerCodeListing>
|
||||
</ListingPage>
|
||||
<OPTXL>
|
||||
<LMap>1</LMap>
|
||||
<LComments>1</LComments>
|
||||
<LGenerateSymbols>1</LGenerateSymbols>
|
||||
<LLibSym>1</LLibSym>
|
||||
<LLines>1</LLines>
|
||||
<LLocSym>1</LLocSym>
|
||||
<LPubSym>1</LPubSym>
|
||||
<LXref>0</LXref>
|
||||
<LExpSel>0</LExpSel>
|
||||
</OPTXL>
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>255</CpuCode>
|
||||
<Books>
|
||||
<Book>
|
||||
<Number>0</Number>
|
||||
<Title>Data Sheet</Title>
|
||||
<Path>DATASHTS\CAST\CAST_R8051XC.PDF</Path>
|
||||
</Book>
|
||||
</Books>
|
||||
<DebugOpt>
|
||||
<uSim>1</uSim>
|
||||
<uTrg>0</uTrg>
|
||||
<sLdApp>1</sLdApp>
|
||||
<sGomain>1</sGomain>
|
||||
<sRbreak>1</sRbreak>
|
||||
<sRwatch>1</sRwatch>
|
||||
<sRmem>1</sRmem>
|
||||
<sRfunc>1</sRfunc>
|
||||
<sRbox>1</sRbox>
|
||||
<tLdApp>1</tLdApp>
|
||||
<tGomain>1</tGomain>
|
||||
<tRbreak>1</tRbreak>
|
||||
<tRwatch>1</tRwatch>
|
||||
<tRmem>1</tRmem>
|
||||
<tRfunc>0</tRfunc>
|
||||
<tRbox>1</tRbox>
|
||||
<tRtrace>1</tRtrace>
|
||||
<sRSysVw>1</sRSysVw>
|
||||
<tRSysVw>1</tRSysVw>
|
||||
<sRunDeb>0</sRunDeb>
|
||||
<sLrtime>0</sLrtime>
|
||||
<bEvRecOn>1</bEvRecOn>
|
||||
<bSchkAxf>0</bSchkAxf>
|
||||
<bTchkAxf>0</bTchkAxf>
|
||||
<nTsel>10</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
<sDlgPa></sDlgPa>
|
||||
<sIfile></sIfile>
|
||||
<tDll></tDll>
|
||||
<tDllPa></tDllPa>
|
||||
<tDlgDll></tDlgDll>
|
||||
<tDlgPa></tDlgPa>
|
||||
<tIfile></tIfile>
|
||||
<pMon>BIN\SY8831.dll</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGDC51</Key>
|
||||
<Name>(94=-1,-1,-1,-1,0)(80=-1,-1,-1,-1,0)(81=-1,-1,-1,-1,0)(82=-1,-1,-1,-1,0)(83=-1,-1,-1,-1,0)(84=-1,-1,-1,-1,0)(1201=-1,-1,-1,-1,0)(90=-1,-1,-1,-1,0)(91=-1,-1,-1,-1,0)(5045=-1,-1,-1,-1,0)(5046=-1,-1,-1,-1,0)(5031=-1,-1,-1,-1,0)(104=-1,-1,-1,-1,0)(5015=-1,-1,-1,-1,0)(5160=-1,-1,-1,-1,0)(5057=-1,-1,-1,-1,0)(5166=-1,-1,-1,-1,0)(5164=-1,-1,-1,-1,0)(5165=-1,-1,-1,-1,0)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>SY8831</Key>
|
||||
<Name>-S14 -B921600 -O1799</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGTC51</Key>
|
||||
<Name></Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>TP3102</Key>
|
||||
<Name>-S14 -B921600 -O1799</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>n_ADC_Plus,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>n_Vbat_Data,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>F_sys_tim_1s</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>Protect_Type_Flg</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>4</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>Decnt_SleepDelay</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow1>
|
||||
<Mm>
|
||||
<WinNumber>1</WinNumber>
|
||||
<SubType>0</SubType>
|
||||
<ItemText>X:0</ItemText>
|
||||
<AccSizeX>0</AccSizeX>
|
||||
</Mm>
|
||||
</MemoryWindow1>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
</Tracepoint>
|
||||
<DebugFlag>
|
||||
<trace>0</trace>
|
||||
<periodic>1</periodic>
|
||||
<aLwin>1</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
<aPa>0</aPa>
|
||||
<viewmode>1</viewmode>
|
||||
<vrSel>0</vrSel>
|
||||
<aSym>0</aSym>
|
||||
<aTbox>0</aTbox>
|
||||
<AscS1>0</AscS1>
|
||||
<AscS2>0</AscS2>
|
||||
<AscS3>0</AscS3>
|
||||
<aSer3>0</aSer3>
|
||||
<eProf>0</eProf>
|
||||
<aLa>0</aLa>
|
||||
<aPa1>0</aPa1>
|
||||
<AscS4>0</AscS4>
|
||||
<aSer4>0</aSer4>
|
||||
<StkLoc>1</StkLoc>
|
||||
<TrcWin>0</TrcWin>
|
||||
<newCpu>0</newCpu>
|
||||
<uProt>0</uProt>
|
||||
</DebugFlag>
|
||||
<LintExecutable></LintExecutable>
|
||||
<LintConfigFile></LintConfigFile>
|
||||
<bLintAuto>0</bLintAuto>
|
||||
<bAutoGenD>0</bAutoGenD>
|
||||
<LntExFlags>0</LntExFlags>
|
||||
<pMisraName></pMisraName>
|
||||
<pszMrule></pszMrule>
|
||||
<pSingCmds></pSingCmds>
|
||||
<pMultCmds></pMultCmds>
|
||||
<pMisraNamep></pMisraNamep>
|
||||
<pszMrulep></pszMrulep>
|
||||
<pSingCmdsp></pSingCmdsp>
|
||||
<pMultCmdsp></pMultCmdsp>
|
||||
</TargetOption>
|
||||
</Target>
|
||||
|
||||
<Group>
|
||||
<GroupName>Startup</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>1</FileNumber>
|
||||
<FileType>2</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Src\startup\STARTUP.A51</PathWithFileName>
|
||||
<FilenameWithoutPath>STARTUP.A51</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>UsrSrc</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>2</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\main.c</PathWithFileName>
|
||||
<FilenameWithoutPath>main.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>3</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\adc\adc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>adc.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\charger\charger_module.c</PathWithFileName>
|
||||
<FilenameWithoutPath>charger_module.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\discharge\discharge_module.c</PathWithFileName>
|
||||
<FilenameWithoutPath>discharge_module.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\gpio\gpio.c</PathWithFileName>
|
||||
<FilenameWithoutPath>gpio.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\hall\hall.c</PathWithFileName>
|
||||
<FilenameWithoutPath>hall.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\key\key.c</PathWithFileName>
|
||||
<FilenameWithoutPath>key.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\led\led.c</PathWithFileName>
|
||||
<FilenameWithoutPath>led.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\sleep\sleep.c</PathWithFileName>
|
||||
<FilenameWithoutPath>sleep.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\system\system.c</PathWithFileName>
|
||||
<FilenameWithoutPath>system.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\uart\uart.c</PathWithFileName>
|
||||
<FilenameWithoutPath>uart.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\userapp\userapp.c</PathWithFileName>
|
||||
<FilenameWithoutPath>userapp.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\vox\vox_module.c</PathWithFileName>
|
||||
<FilenameWithoutPath>vox_module.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\watchdog\watchdog.c</PathWithFileName>
|
||||
<FilenameWithoutPath>watchdog.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\bat\bat.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bat.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\timer\sys_tim.c</PathWithFileName>
|
||||
<FilenameWithoutPath>sys_tim.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\InitVars.c</PathWithFileName>
|
||||
<FilenameWithoutPath>InitVars.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\UsrSrc\gpio_comm\gpio_comm.c</PathWithFileName>
|
||||
<FilenameWithoutPath>gpio_comm.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
</ProjectOpt>
|
500
Project/TP3102_Demo.uvproj
Normal file
500
Project/TP3102_Demo.uvproj
Normal file
@ -0,0 +1,500 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_proj.xsd">
|
||||
|
||||
<SchemaVersion>1.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>Target 1</TargetName>
|
||||
<ToolsetNumber>0x0</ToolsetNumber>
|
||||
<ToolsetName>MCS-51</ToolsetName>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>R8051XC</Device>
|
||||
<Vendor>CAST, Inc.</Vendor>
|
||||
<Cpu>IRAM(0-0xFF) CLOCK(24000000) MOD517DP MDU_R515</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile>"LIB\STARTUP.A51" ("Standard 8051 Startup Code")</StartupFile>
|
||||
<FlashDriverDll></FlashDriverDll>
|
||||
<DeviceId>4129</DeviceId>
|
||||
<RegisterFile>REG51XC.H</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile></SFDFile>
|
||||
<bCustSvd>0</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath>Evatronix\</RegisterFilePath>
|
||||
<DBRegisterFilePath>Evatronix\</DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\Objects\</OutputDirectory>
|
||||
<OutputName>mcu</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\Listings\</ListingPath>
|
||||
<HexFormatSelection>0</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>1</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name>.\..\Tools\HEXBIN.bat .\..\Tools\hex2bin_TP.exe .\..\Tools\bin_crc.exe mcu \Objects\</UserProg1Name>
|
||||
<UserProg2Name>.\..\Tools\hex2bin_TP.exe .\Objects\mcu.hex .\Objects\bin.bin 3 0</UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
<BankNo>65535</BankNo>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>S8051.DLL</SimDllName>
|
||||
<SimDllArguments>-PMW -DPC -BSE</SimDllArguments>
|
||||
<SimDlgDll>DCore51.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pR8051XC -o38081BDBFFF</SimDlgDllArguments>
|
||||
<TargetDllName>S8051.DLL</TargetDllName>
|
||||
<TargetDllArguments></TargetDllArguments>
|
||||
<TargetDlgDll>TCore51.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pR8051XC</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>0</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
<Simulator>
|
||||
<UseSimulator>1</UseSimulator>
|
||||
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
|
||||
<RunToMain>1</RunToMain>
|
||||
<RestoreBreakpoints>1</RestoreBreakpoints>
|
||||
<RestoreWatchpoints>1</RestoreWatchpoints>
|
||||
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
|
||||
<RestoreFunctions>1</RestoreFunctions>
|
||||
<RestoreToolbox>1</RestoreToolbox>
|
||||
<LimitSpeedToRealTime>0</LimitSpeedToRealTime>
|
||||
<RestoreSysVw>1</RestoreSysVw>
|
||||
</Simulator>
|
||||
<Target>
|
||||
<UseTarget>0</UseTarget>
|
||||
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
|
||||
<RunToMain>1</RunToMain>
|
||||
<RestoreBreakpoints>1</RestoreBreakpoints>
|
||||
<RestoreWatchpoints>1</RestoreWatchpoints>
|
||||
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
|
||||
<RestoreFunctions>0</RestoreFunctions>
|
||||
<RestoreToolbox>1</RestoreToolbox>
|
||||
<RestoreTracepoints>1</RestoreTracepoints>
|
||||
<RestoreSysVw>1</RestoreSysVw>
|
||||
</Target>
|
||||
<RunDebugAfterBuild>0</RunDebugAfterBuild>
|
||||
<TargetSelection>10</TargetSelection>
|
||||
<SimDlls>
|
||||
<CpuDll></CpuDll>
|
||||
<CpuDllArguments></CpuDllArguments>
|
||||
<PeripheralDll></PeripheralDll>
|
||||
<PeripheralDllArguments></PeripheralDllArguments>
|
||||
<InitializationFile></InitializationFile>
|
||||
</SimDlls>
|
||||
<TargetDlls>
|
||||
<CpuDll></CpuDll>
|
||||
<CpuDllArguments></CpuDllArguments>
|
||||
<PeripheralDll></PeripheralDll>
|
||||
<PeripheralDllArguments></PeripheralDllArguments>
|
||||
<InitializationFile></InitializationFile>
|
||||
<Driver>BIN\SY8831.dll</Driver>
|
||||
</TargetDlls>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>0</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>0</UpdateFlashBeforeDebugging>
|
||||
<Capability>0</Capability>
|
||||
<DriverSelection>-1</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>0</bUseTDR>
|
||||
<Flash2></Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<Target51>
|
||||
<Target51Misc>
|
||||
<MemoryModel>0</MemoryModel>
|
||||
<RTOS>0</RTOS>
|
||||
<RomSize>1</RomSize>
|
||||
<DataHold>0</DataHold>
|
||||
<XDataHold>0</XDataHold>
|
||||
<UseOnchipRom>0</UseOnchipRom>
|
||||
<UseOnchipArithmetic>0</UseOnchipArithmetic>
|
||||
<UseMultipleDPTR>0</UseMultipleDPTR>
|
||||
<UseOnchipXram>0</UseOnchipXram>
|
||||
<HadIRAM>1</HadIRAM>
|
||||
<HadXRAM>0</HadXRAM>
|
||||
<HadIROM>0</HadIROM>
|
||||
<Moda2>0</Moda2>
|
||||
<Moddp2>0</Moddp2>
|
||||
<Modp2>0</Modp2>
|
||||
<Mod517dp>1</Mod517dp>
|
||||
<Mod517au>0</Mod517au>
|
||||
<Mode2>0</Mode2>
|
||||
<useCB>0</useCB>
|
||||
<useXB>0</useXB>
|
||||
<useL251>0</useL251>
|
||||
<useA251>0</useA251>
|
||||
<Mx51>0</Mx51>
|
||||
<ModC812>0</ModC812>
|
||||
<ModCont>0</ModCont>
|
||||
<Lp51>0</Lp51>
|
||||
<useXBS>0</useXBS>
|
||||
<ModDA>0</ModDA>
|
||||
<ModAB2>0</ModAB2>
|
||||
<Mx51P>0</Mx51P>
|
||||
<hadXRAM2>0</hadXRAM2>
|
||||
<uocXram2>0</uocXram2>
|
||||
<hadXRAM3>0</hadXRAM3>
|
||||
<ModC2>0</ModC2>
|
||||
<ModH2>0</ModH2>
|
||||
<Mdu_R515>1</Mdu_R515>
|
||||
<Mdu_F120>0</Mdu_F120>
|
||||
<Psoc>0</Psoc>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<hadIROM3>0</hadIROM3>
|
||||
<ModSmx2>0</ModSmx2>
|
||||
<cBanks>0</cBanks>
|
||||
<xBanks>0</xBanks>
|
||||
<OnChipMemories>
|
||||
<RCB>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0xffff</Size>
|
||||
</RCB>
|
||||
<RXB>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</RXB>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocr1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocr1>
|
||||
<Ocr2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocr2>
|
||||
<Ocr3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocr3>
|
||||
<IRO>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</IRO>
|
||||
<IRA>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x100</Size>
|
||||
</IRA>
|
||||
<XRA>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRA>
|
||||
<XRA512>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRA512>
|
||||
<IROM512>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</IROM512>
|
||||
<XRA513>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRA513>
|
||||
<IROM513>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</IROM513>
|
||||
</OnChipMemories>
|
||||
</Target51Misc>
|
||||
<C51>
|
||||
<RegisterColoring>0</RegisterColoring>
|
||||
<VariablesInOrder>0</VariablesInOrder>
|
||||
<IntegerPromotion>1</IntegerPromotion>
|
||||
<uAregs>0</uAregs>
|
||||
<UseInterruptVector>1</UseInterruptVector>
|
||||
<Fuzzy>3</Fuzzy>
|
||||
<Optimize>9</Optimize>
|
||||
<WarningLevel>2</WarningLevel>
|
||||
<SizeSpeed>0</SizeSpeed>
|
||||
<ObjectExtend>1</ObjectExtend>
|
||||
<ACallAJmp>0</ACallAJmp>
|
||||
<InterruptVectorAddress>0</InterruptVectorAddress>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\UsrInc\adc;..\UsrInc\charger;..\UsrInc\discharge;..\UsrInc\gpio;..\UsrInc\hall;..\UsrInc\i2c_simu;..\UsrInc\inc;..\UsrInc\key;..\UsrInc\led;..\UsrInc\mtp;..\UsrInc\pwm;..\UsrInc\sleep;..\UsrInc\system;..\UsrInc\uart;..\UsrInc\userapp;..\UsrInc\vox;..\UsrInc\vox_comm;..\UsrInc\watchdog;..\UsrInc\bat;..\UsrInc\timer;..\UsrInc\gpio_comm</IncludePath>
|
||||
</VariousControls>
|
||||
</C51>
|
||||
<Ax51>
|
||||
<UseMpl>0</UseMpl>
|
||||
<UseStandard>1</UseStandard>
|
||||
<UseCase>0</UseCase>
|
||||
<UseMod51>0</UseMod51>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Ax51>
|
||||
<Lx51>
|
||||
<useFile>0</useFile>
|
||||
<linkonly>0</linkonly>
|
||||
<UseMemoryFromTarget>1</UseMemoryFromTarget>
|
||||
<CaseSensitiveSymbols>0</CaseSensitiveSymbols>
|
||||
<WarningLevel>2</WarningLevel>
|
||||
<DataOverlaying>1</DataOverlaying>
|
||||
<OverlayString></OverlayString>
|
||||
<MiscControls></MiscControls>
|
||||
<DisableWarningNumbers></DisableWarningNumbers>
|
||||
<LinkerCmdFile></LinkerCmdFile>
|
||||
<Assign></Assign>
|
||||
<ReserveString></ReserveString>
|
||||
<CClasses></CClasses>
|
||||
<UserClasses></UserClasses>
|
||||
<CSection></CSection>
|
||||
<UserSection></UserSection>
|
||||
<CodeBaseAddress></CodeBaseAddress>
|
||||
<XDataBaseAddress></XDataBaseAddress>
|
||||
<PDataBaseAddress></PDataBaseAddress>
|
||||
<BitBaseAddress></BitBaseAddress>
|
||||
<DataBaseAddress></DataBaseAddress>
|
||||
<IDataBaseAddress></IDataBaseAddress>
|
||||
<Precede></Precede>
|
||||
<Stack></Stack>
|
||||
<CodeSegmentName>?CO?INITVARS(0x0BFD)</CodeSegmentName>
|
||||
<XDataSegmentName></XDataSegmentName>
|
||||
<BitSegmentName></BitSegmentName>
|
||||
<DataSegmentName></DataSegmentName>
|
||||
<IDataSegmentName></IDataSegmentName>
|
||||
</Lx51>
|
||||
</Target51>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>Startup</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>STARTUP.A51</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>..\Src\startup\STARTUP.A51</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>UsrSrc</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\main.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\adc\adc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>charger_module.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\charger\charger_module.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>discharge_module.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\discharge\discharge_module.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\gpio\gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>hall.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\hall\hall.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>key.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\key\key.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>led.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\led\led.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sleep.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\sleep\sleep.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\system\system.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\uart\uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>userapp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\userapp\userapp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>vox_module.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\vox\vox_module.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>watchdog.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\watchdog\watchdog.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>bat.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\bat\bat.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sys_tim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\timer\sys_tim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>InitVars.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\InitVars.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio_comm.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\UsrSrc\gpio_comm\gpio_comm.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<LayerInfo>
|
||||
<Layers>
|
||||
<Layer>
|
||||
<LayName><Project Info></LayName>
|
||||
<LayDesc></LayDesc>
|
||||
<LayUrl></LayUrl>
|
||||
<LayKeys></LayKeys>
|
||||
<LayCat></LayCat>
|
||||
<LayLic></LayLic>
|
||||
<LayTarg>0</LayTarg>
|
||||
<LayPrjMark>1</LayPrjMark>
|
||||
</Layer>
|
||||
</Layers>
|
||||
</LayerInfo>
|
||||
|
||||
</Project>
|
205
Src/startup/STARTUP.A51
Normal file
205
Src/startup/STARTUP.A51
Normal file
@ -0,0 +1,205 @@
|
||||
$NOMOD51
|
||||
;------------------------------------------------------------------------------
|
||||
; This file is part of the C51 Compiler package
|
||||
; Copyright (c) 1988-2005 Keil Elektronik GmbH and Keil Software, Inc.
|
||||
; Version 8.01
|
||||
;
|
||||
; *** <<< Use Configuration Wizard in Context Menu >>> ***
|
||||
;------------------------------------------------------------------------------
|
||||
; STARTUP.A51: This code is executed after processor reset.
|
||||
;
|
||||
; To translate this file use A51 with the following invocation:
|
||||
;
|
||||
; A51 STARTUP.A51
|
||||
;
|
||||
; To link the modified STARTUP.OBJ file to your application use the following
|
||||
; Lx51 invocation:
|
||||
;
|
||||
; Lx51 your object file list, STARTUP.OBJ controls
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; User-defined <h> Power-On Initialization of Memory
|
||||
;
|
||||
; With the following EQU statements the initialization of memory
|
||||
; at processor reset can be defined:
|
||||
;
|
||||
; <o> IDATALEN: IDATA memory size <0x0-0x100>
|
||||
; <i> Note: The absolute start-address of IDATA memory is always 0
|
||||
; <i> The IDATA space overlaps physically the DATA and BIT areas.
|
||||
IDATALEN EQU 100H
|
||||
;
|
||||
; <o> XDATASTART: XDATA memory start address <0x0-0xFFFF>
|
||||
; <i> The absolute start address of XDATA memory
|
||||
XDATASTART EQU 0
|
||||
;
|
||||
; <o> XDATALEN: XDATA memory size <0x0-0xFFFF>
|
||||
; <i> The length of XDATA memory in bytes.
|
||||
XDATALEN EQU 0H
|
||||
;
|
||||
; <o> PDATASTART: PDATA memory start address <0x0-0xFFFF>
|
||||
; <i> The absolute start address of PDATA memory
|
||||
PDATASTART EQU 0H
|
||||
;
|
||||
; <o> PDATALEN: PDATA memory size <0x0-0xFF>
|
||||
; <i> The length of PDATA memory in bytes.
|
||||
PDATALEN EQU 0H
|
||||
;
|
||||
;</h>
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
;<h> Reentrant Stack Initialization
|
||||
;
|
||||
; The following EQU statements define the stack pointer for reentrant
|
||||
; functions and initialized it:
|
||||
;
|
||||
; <h> Stack Space for reentrant functions in the SMALL model.
|
||||
; <q> IBPSTACK: Enable SMALL model reentrant stack
|
||||
; <i> Stack space for reentrant functions in the SMALL model.
|
||||
IBPSTACK EQU 0 ; set to 1 if small reentrant is used.
|
||||
; <o> IBPSTACKTOP: End address of SMALL model stack <0x0-0xFF>
|
||||
; <i> Set the top of the stack to the highest location.
|
||||
IBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1
|
||||
; </h>
|
||||
;
|
||||
; <h> Stack Space for reentrant functions in the LARGE model.
|
||||
; <q> XBPSTACK: Enable LARGE model reentrant stack
|
||||
; <i> Stack space for reentrant functions in the LARGE model.
|
||||
XBPSTACK EQU 0 ; set to 1 if large reentrant is used.
|
||||
; <o> XBPSTACKTOP: End address of LARGE model stack <0x0-0xFFFF>
|
||||
; <i> Set the top of the stack to the highest location.
|
||||
XBPSTACKTOP EQU 0xFFFF +1 ; default 0FFFFH+1
|
||||
; </h>
|
||||
;
|
||||
; <h> Stack Space for reentrant functions in the COMPACT model.
|
||||
; <q> PBPSTACK: Enable COMPACT model reentrant stack
|
||||
; <i> Stack space for reentrant functions in the COMPACT model.
|
||||
PBPSTACK EQU 0 ; set to 1 if compact reentrant is used.
|
||||
;
|
||||
; <o> PBPSTACKTOP: End address of COMPACT model stack <0x0-0xFFFF>
|
||||
; <i> Set the top of the stack to the highest location.
|
||||
PBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1
|
||||
; </h>
|
||||
;</h>
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Memory Page for Using the Compact Model with 64 KByte xdata RAM
|
||||
; <e>Compact Model Page Definition
|
||||
;
|
||||
; <i>Define the XDATA page used for PDATA variables.
|
||||
; <i>PPAGE must conform with the PPAGE set in the linker invocation.
|
||||
;
|
||||
; Enable pdata memory page initalization
|
||||
PPAGEENABLE EQU 0 ; set to 1 if pdata object are used.
|
||||
;
|
||||
; <o> PPAGE number <0x0-0xFF>
|
||||
; <i> uppermost 256-byte address of the page used for PDATA variables.
|
||||
PPAGE EQU 0
|
||||
;
|
||||
; <o> SFR address which supplies uppermost address byte <0x0-0xFF>
|
||||
; <i> most 8051 variants use P2 as uppermost address byte
|
||||
PPAGE_SFR DATA 0A0H
|
||||
;
|
||||
; </e>
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Standard SFR Symbols
|
||||
ACC DATA 0E0H
|
||||
B DATA 0F0H
|
||||
SP DATA 81H
|
||||
DPL DATA 82H
|
||||
DPH DATA 83H
|
||||
CKCON DATA 8EH
|
||||
CLKPRE DATA 0D2H
|
||||
PCON DATA 87H
|
||||
|
||||
NAME ?C_STARTUP
|
||||
|
||||
|
||||
?C_C51STARTUP SEGMENT CODE
|
||||
?STACK SEGMENT IDATA
|
||||
|
||||
RSEG ?STACK
|
||||
DS 1
|
||||
|
||||
EXTRN CODE (?C_START)
|
||||
PUBLIC ?C_STARTUP
|
||||
|
||||
CSEG AT 0
|
||||
?C_STARTUP: LJMP STARTUP1
|
||||
|
||||
RSEG ?C_C51STARTUP
|
||||
|
||||
STARTUP1:
|
||||
;Set Wait State to 0x30 and CPU CLK Prescaler to 1 to Accelerate Startup
|
||||
;MOV PCON, #02H ;Enter Standby
|
||||
MOV CKCON, #30H ;Wait State = 0x30
|
||||
MOV CLKPRE, #0 ;CLK Prescaler = 1
|
||||
|
||||
IF IDATALEN <> 0
|
||||
MOV R0,#IDATALEN - 1
|
||||
CLR A
|
||||
IDATALOOP: MOV @R0,A
|
||||
DJNZ R0,IDATALOOP
|
||||
ENDIF
|
||||
|
||||
IF XDATALEN <> 0
|
||||
MOV DPTR,#XDATASTART
|
||||
MOV R7,#LOW (XDATALEN)
|
||||
IF (LOW (XDATALEN)) <> 0
|
||||
MOV R6,#(HIGH (XDATALEN)) +1
|
||||
ELSE
|
||||
MOV R6,#HIGH (XDATALEN)
|
||||
ENDIF
|
||||
CLR A
|
||||
XDATALOOP: MOVX @DPTR,A
|
||||
INC DPTR
|
||||
DJNZ R7,XDATALOOP
|
||||
DJNZ R6,XDATALOOP
|
||||
ENDIF
|
||||
|
||||
IF PPAGEENABLE <> 0
|
||||
MOV PPAGE_SFR,#PPAGE
|
||||
ENDIF
|
||||
|
||||
IF PDATALEN <> 0
|
||||
MOV R0,#LOW (PDATASTART)
|
||||
MOV R7,#LOW (PDATALEN)
|
||||
CLR A
|
||||
PDATALOOP: MOVX @R0,A
|
||||
INC R0
|
||||
DJNZ R7,PDATALOOP
|
||||
ENDIF
|
||||
|
||||
IF IBPSTACK <> 0
|
||||
EXTRN DATA (?C_IBP)
|
||||
|
||||
MOV ?C_IBP,#LOW IBPSTACKTOP
|
||||
ENDIF
|
||||
|
||||
IF XBPSTACK <> 0
|
||||
EXTRN DATA (?C_XBP)
|
||||
|
||||
MOV ?C_XBP,#HIGH XBPSTACKTOP
|
||||
MOV ?C_XBP+1,#LOW XBPSTACKTOP
|
||||
ENDIF
|
||||
|
||||
IF PBPSTACK <> 0
|
||||
EXTRN DATA (?C_PBP)
|
||||
MOV ?C_PBP,#LOW PBPSTACKTOP
|
||||
ENDIF
|
||||
|
||||
MOV SP,#?STACK-1
|
||||
|
||||
; This code is required if you use L51_BANK.A51 with Banking Mode 4
|
||||
;<h> Code Banking
|
||||
; <q> Select Bank 0 for L51_BANK.A51 Mode 4
|
||||
#if 0
|
||||
; <i> Initialize bank mechanism to code bank 0 when using L51_BANK.A51 with Banking Mode 4.
|
||||
EXTRN CODE (?B_SWITCH0)
|
||||
CALL ?B_SWITCH0 ; init bank mechanism to code bank 0
|
||||
#endif
|
||||
;</h>
|
||||
LJMP ?C_START
|
||||
|
||||
END
|
3
TP3310_Demo.si4project/TP3310_Demo.SearchResults
Normal file
3
TP3310_Demo.si4project/TP3310_Demo.SearchResults
Normal file
@ -0,0 +1,3 @@
|
||||
---- VOX_VOUT_5V_LEAST_CNT Matches (2 in 1 files) ----
|
||||
vox_module.c (UsrSrc\vox) line 46 : #define VOX_VOUT_5V_LEAST_CNT 250
|
||||
Vox_Det_Machine in vox_module.c (UsrSrc\vox) : if( Vox_Vol_Hold_Timer < VOX_VOUT_5V_LEAST_CNT ) //开盖后5V 500ms。
|
7
TP3310_Demo.si4project/TP3310_Demo.bookmarks.xml
Normal file
7
TP3310_Demo.si4project/TP3310_Demo.bookmarks.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<SourceInsightBookmarks
|
||||
AppVer="4.00.0084"
|
||||
AppVerMinReader="4.00.0009"
|
||||
>
|
||||
<Bookmarks/>
|
||||
</SourceInsightBookmarks>
|
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_sym
Normal file
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_sym
Normal file
Binary file not shown.
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xab
Normal file
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xab
Normal file
Binary file not shown.
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xad
Normal file
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xad
Normal file
Binary file not shown.
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xc
Normal file
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xc
Normal file
Binary file not shown.
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xf
Normal file
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xf
Normal file
Binary file not shown.
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xm
Normal file
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xm
Normal file
Binary file not shown.
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xr
Normal file
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xr
Normal file
Binary file not shown.
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xsb
Normal file
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xsb
Normal file
Binary file not shown.
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xsd
Normal file
BIN
TP3310_Demo.si4project/TP3310_Demo.sip_xsd
Normal file
Binary file not shown.
BIN
TP3310_Demo.si4project/TP3310_Demo.siproj
Normal file
BIN
TP3310_Demo.si4project/TP3310_Demo.siproj
Normal file
Binary file not shown.
22
TP3310_Demo.si4project/TP3310_Demo.siproj_settings.xml
Normal file
22
TP3310_Demo.si4project/TP3310_Demo.siproj_settings.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ProjectSettings
|
||||
AppVer="4.00.0084"
|
||||
AppVerMinReader="4.00.0034"
|
||||
GlobalConfiguration="1"
|
||||
GlobalWorkspace="0"
|
||||
LocalsInDb="0"
|
||||
IndexMembers="1"
|
||||
IndexFragments="1"
|
||||
UseMasterFileList="0"
|
||||
SourceDir="..\"
|
||||
BackupDir="%PROJECT_DATA_DIR%\Backup"
|
||||
MasterFileList="%PROJECT_SOURCE_DIR%\%PROJECT_NAME%_filelist.txt"
|
||||
IsImportProject="0"
|
||||
>
|
||||
<Imports>
|
||||
<ImportedLibs/>
|
||||
</Imports>
|
||||
<ParseConditions>
|
||||
<Defines/>
|
||||
</ParseConditions>
|
||||
</ProjectSettings>
|
BIN
TP3310_Demo.si4project/TP3310_Demo.siwork
Normal file
BIN
TP3310_Demo.si4project/TP3310_Demo.siwork
Normal file
Binary file not shown.
7
TP3310_Demo.si4project/TP3310_Demo.snippets.xml
Normal file
7
TP3310_Demo.si4project/TP3310_Demo.snippets.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<SourceInsightCodeSnippets
|
||||
AppVer="4.00.0084"
|
||||
AppVerMinReader="4.00.0019"
|
||||
>
|
||||
<SnippetList/>
|
||||
</SourceInsightCodeSnippets>
|
72
Tools/HEXBIN.bat
Normal file
72
Tools/HEXBIN.bat
Normal file
@ -0,0 +1,72 @@
|
||||
:: @File Name: HEXBIN.bat
|
||||
:: @Version : 1.0
|
||||
:: @Author : Alex-XU
|
||||
:: @Creat Date : 2023-03-30
|
||||
:: @Brief :
|
||||
:: 在keil中,生成hex、bin文件到 Out 文件夹中.
|
||||
:: 复制本文件到keil工程文件所在目录下(/Project目录下)
|
||||
:: 在keil 魔法棒USER里填写
|
||||
:: .\Out.bat $K !P @P
|
||||
:: $K hextobin转换工具位置 !P 工程名 @P 工程目录
|
||||
:: .\HEXBIN.bat .\Objects\hex2bin_TP.exe mcu \Objects\
|
||||
|
||||
::关闭显示
|
||||
@echo off
|
||||
::获取时间
|
||||
set year=%date:~0,4%
|
||||
set month=%date:~5,2%
|
||||
set day=%date:~8,2%
|
||||
set hour=%time:~0,2%
|
||||
set min=%time:~3,2%
|
||||
set sec=%time:~6,2%
|
||||
::创建输出文件夹 Out
|
||||
if exist .\..\Out (
|
||||
echo Out file exist
|
||||
) else (
|
||||
mkdir .\..\Out
|
||||
)
|
||||
|
||||
::设置hex2bin_TP.exe位置 ,\Objects\hex2bin_TP.exe
|
||||
set exe_location=%1
|
||||
::获取工程名 mcu.hex
|
||||
set project_name=%3
|
||||
::设置.hex文件所在目录路径\Objects\
|
||||
set crc_path=%2
|
||||
::设置.hex文件所在目录路径\Objects\
|
||||
set obj_path=%4
|
||||
::设置输出后的文件名
|
||||
set output_nameTmp=SY883X_EVB_%project_name%_%date:~0,4%_%date:~5,2%_%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%
|
||||
::如果hour小于10,会有空格,下面这句话可以除去字符串中的空格,并用0代替。
|
||||
set output_name=%output_nameTmp: =0%
|
||||
|
||||
::将bin文件生成到HEXBIN文件夹 >nul屏蔽成功命令 .\Objects\hex2bin_TP.exe .\Objects\mcu.hex .\Objects\bin.bin 3 0
|
||||
%exe_location% .%obj_path%%project_name%.hex .%obj_path%%output_name%.bin 3 0 >nul
|
||||
::将hex文件重命名
|
||||
ren .%obj_path%%project_name%.hex %output_name%.hex >nul
|
||||
|
||||
ECHO Add CRC16 At the end of the .bin file
|
||||
ECHO -------------------------------------
|
||||
|
||||
::SET SREC_PATH=D:\Keil_v5\SREC
|
||||
SET SREC_PATH=..\Tools\SREC
|
||||
|
||||
for /f %%i in ('dir /s /b .%obj_path%%output_name%.bin') do (
|
||||
set indexdx=%%~zi
|
||||
)
|
||||
|
||||
ECHO --- size= %indexdx% Bytes ---
|
||||
::计算程序CRC16校验和,并加在.bin文件最后
|
||||
ECHO %SREC_PATH%\srec_cat.exe .%obj_path%%output_name%.bin -Binary -crop 0 %indexdx% -CRC16_Big_Endian %indexdx% -XMODEM -o .%obj_path%%output_name%_crc.bin -Binary
|
||||
%SREC_PATH%\srec_cat.exe .%obj_path%%output_name%.bin -Binary -crop 0 %indexdx% -CRC16_Big_Endian %indexdx% -XMODEM -o .%obj_path%%output_name%_crc.bin -Binary
|
||||
|
||||
::获取软件CRC校验和以及版本号
|
||||
%crc_path% .%obj_path%%output_name%_crc.bin
|
||||
|
||||
del /q ..\Out\*.*
|
||||
::将hex文件复制到HEXBIN文件夹
|
||||
move .%obj_path%%output_name%.hex .\..\Out >nul
|
||||
move .%obj_path%%output_name%.bin .\..\Out >nul
|
||||
::del .%obj_path%%output_name%.hex
|
||||
::del .%obj_path%%output_name%.bin
|
||||
del .%obj_path%%output_name%_crc.bin
|
||||
move .%obj_path%%output_name%_crc(*.bin .\..\Out >nul
|
BIN
Tools/SREC/libgcc_s_seh-1.dll
Normal file
BIN
Tools/SREC/libgcc_s_seh-1.dll
Normal file
Binary file not shown.
BIN
Tools/SREC/libgcrypt-20.dll
Normal file
BIN
Tools/SREC/libgcrypt-20.dll
Normal file
Binary file not shown.
BIN
Tools/SREC/libgpg-error-0.dll
Normal file
BIN
Tools/SREC/libgpg-error-0.dll
Normal file
Binary file not shown.
BIN
Tools/SREC/libstdc++-6.dll
Normal file
BIN
Tools/SREC/libstdc++-6.dll
Normal file
Binary file not shown.
BIN
Tools/SREC/libwinpthread-1.dll
Normal file
BIN
Tools/SREC/libwinpthread-1.dll
Normal file
Binary file not shown.
BIN
Tools/SREC/srec_cat.exe
Normal file
BIN
Tools/SREC/srec_cat.exe
Normal file
Binary file not shown.
BIN
Tools/SREC/srec_cmp.exe
Normal file
BIN
Tools/SREC/srec_cmp.exe
Normal file
Binary file not shown.
BIN
Tools/SREC/srec_info.exe
Normal file
BIN
Tools/SREC/srec_info.exe
Normal file
Binary file not shown.
BIN
Tools/bin_crc.exe
Normal file
BIN
Tools/bin_crc.exe
Normal file
Binary file not shown.
BIN
Tools/hex2bin_TP.exe
Normal file
BIN
Tools/hex2bin_TP.exe
Normal file
Binary file not shown.
64
UsrDoc/HEXBIN.bat
Normal file
64
UsrDoc/HEXBIN.bat
Normal file
@ -0,0 +1,64 @@
|
||||
:: @File Name: HEXBIN.bat
|
||||
:: @Version : 1.0
|
||||
:: @Author : Alex-XU
|
||||
:: @Creat Date : 2023-03-30
|
||||
:: @Brief :
|
||||
:: 在keil中,生成hex、bin文件到 Out 文件夹中.
|
||||
:: 复制本文件到keil工程文件所在目录下(/Project目录下)
|
||||
:: 在keil 魔法棒USER里填写
|
||||
:: .\Out.bat $K !P @P
|
||||
:: $K hextobin转换工具位置 !P 工程名 @P 工程目录
|
||||
:: .\HEXBIN.bat .\Objects\hex2bin_TP.exe mcu \Objects\
|
||||
|
||||
|
||||
::关闭显示
|
||||
@echo off
|
||||
::获取时间
|
||||
set year=%date:~0,4%
|
||||
set month=%date:~5,2%
|
||||
set day=%date:~8,2%
|
||||
set hour=%time:~0,2%
|
||||
set min=%time:~3,2%
|
||||
set sec=%time:~6,2%
|
||||
::创建输出文件夹 Out
|
||||
if exist .\..\Out (
|
||||
echo Out file exist
|
||||
) else (
|
||||
mkdir .\..\Out
|
||||
)
|
||||
|
||||
::设置hex2bin_TP.exe位置 ,\Objects\hex2bin_TP.exe
|
||||
set exe_location=%1
|
||||
::获取工程名 mcu.hex
|
||||
set project_name=%2
|
||||
::设置.hex文件所在目录路径\Objects\
|
||||
set obj_path=%3
|
||||
::设置输出后的文件名
|
||||
set output_nameTmp=SY8833A_EVB_%project_name%_V01_%date:~0,4%_%date:~5,2%_%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%
|
||||
::如果hour小于10,会有空格,下面这句话可以除去字符串中的空格,并用0代替。
|
||||
set output_name=%output_nameTmp: =0%
|
||||
|
||||
::将bin文件生成到HEXBIN文件夹 >nul屏蔽成功命令 .\Objects\hex2bin_TP.exe .\Objects\mcu.hex .\Objects\bin.bin 3 0
|
||||
%exe_location% .%obj_path%%project_name%.hex .%obj_path%%output_name%.bin 3 0 >nul
|
||||
::将hex文件重命名
|
||||
ren .%obj_path%%project_name%.hex %output_name%.hex >nul
|
||||
|
||||
ECHO Add CRC16 At the end of the .bin file
|
||||
ECHO -------------------------------------
|
||||
|
||||
SET SREC_PATH=D:\Keil_v5\SREC
|
||||
|
||||
for /f %%i in ('dir /s /b .%obj_path%%output_name%.bin') do (
|
||||
set indexdx=%%~zi
|
||||
)
|
||||
|
||||
ECHO --- size= %indexdx% Bytes ---
|
||||
|
||||
ECHO %SREC_PATH%\srec_cat.exe .%obj_path%%output_name%.bin -Binary -crop 0 %indexdx% -CRC16_Big_Endian %indexdx% -XMODEM -o .%obj_path%%output_name%_crc.bin -Binary
|
||||
%SREC_PATH%\srec_cat.exe .%obj_path%%output_name%.bin -Binary -crop 0 %indexdx% -CRC16_Big_Endian %indexdx% -XMODEM -o .%obj_path%%output_name%_crc.bin -Binary
|
||||
|
||||
del /q ..\Out\*.*
|
||||
::将hex文件复制到HEXBIN文件夹
|
||||
move .%obj_path%%output_name%.hex .\..\Out >nul
|
||||
move .%obj_path%%output_name%.bin .\..\Out >nul
|
||||
move .%obj_path%%output_name%_crc.bin .\..\Out >nul
|
BIN
UsrDoc/SY883X软件开发说明文档.doc
Normal file
BIN
UsrDoc/SY883X软件开发说明文档.doc
Normal file
Binary file not shown.
BIN
UsrDoc/Vox耳机相关功能状态.png
Normal file
BIN
UsrDoc/Vox耳机相关功能状态.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 642 KiB |
BIN
UsrDoc/Vox耳机相关功能状态思维导图.pdf
Normal file
BIN
UsrDoc/Vox耳机相关功能状态思维导图.pdf
Normal file
Binary file not shown.
BIN
UsrDoc/Vox耳机相关功能状态思维导图.xmind
Normal file
BIN
UsrDoc/Vox耳机相关功能状态思维导图.xmind
Normal file
Binary file not shown.
8
UsrDoc/readme.txt
Normal file
8
UsrDoc/readme.txt
Normal file
@ -0,0 +1,8 @@
|
||||
工程文件应包含以下全部或部分文件夹:
|
||||
UsrSrc:用户源文件,用来存放.c文件和其它源文件。main.c应放在这里;
|
||||
UsrInc:用户头文件,用来存放.h文件;
|
||||
UsrDoc:用户说明文档,用来存放用户在开发过程中书协的文档,包括软件开发说明、指令说明、版本更改说明等;
|
||||
Src:引用库的源文件;
|
||||
Inc:应用库的头文件;
|
||||
Lib:应用的库文件。
|
||||
Out:编译生成的烧写程序(烧录到芯片中的firmware)。
|
BIN
UsrDoc/功能测试/SY8833A Demo软件问题记录.xlsx
Normal file
BIN
UsrDoc/功能测试/SY8833A Demo软件问题记录.xlsx
Normal file
Binary file not shown.
BIN
UsrDoc/功能测试/SY8833A测试说明20230713).doc
Normal file
BIN
UsrDoc/功能测试/SY8833A测试说明20230713).doc
Normal file
Binary file not shown.
BIN
UsrDoc/程序流程图/VOX耳机识别流程图.vsdx
Normal file
BIN
UsrDoc/程序流程图/VOX耳机识别流程图.vsdx
Normal file
Binary file not shown.
BIN
UsrDoc/软件各个功能模块占用内存大小.xls
Normal file
BIN
UsrDoc/软件各个功能模块占用内存大小.xls
Normal file
Binary file not shown.
60
UsrInc/adc/adc.h
Normal file
60
UsrInc/adc/adc.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file adc.h
|
||||
* @brief adc module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __ADC_H__
|
||||
#define __ADC_H__
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "define.h"
|
||||
|
||||
#if ADC_ENABLE
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
#define VREF 1000
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
extern idata uint16_t Vbat_Adc;
|
||||
|
||||
typedef enum {
|
||||
ADC_CH0 = 0x00,
|
||||
ADC_CH1,
|
||||
ADC_CH2,
|
||||
ADC_CH3,
|
||||
ADC_CH4,
|
||||
ADC_BAT,
|
||||
ADC_VREF,
|
||||
}ADC_CHANNELS_E;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
extern uint16_t Vbat_Value(void);
|
||||
|
||||
extern uint16_t ADC_NTC_Value(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
50
UsrInc/bat/bat.h
Normal file
50
UsrInc/bat/bat.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file bat.h
|
||||
* @brief bat module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __BAT_H__
|
||||
#define __BAT_H__
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "define.h"
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
extern idata uint8_t bat_level;
|
||||
extern bit F_batlevel_low; //µç³ØµÍѹ
|
||||
extern bit F_batlevel_protect; //µÍµç±£»¤
|
||||
|
||||
#if BAT_VALUE
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
extern void check_bat_level(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
66
UsrInc/charger/charger_module.h
Normal file
66
UsrInc/charger/charger_module.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file Charger_module.h
|
||||
* @brief charger module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __CHARGER_MODULE_H__
|
||||
#define __CHARGER_MODULE_H__
|
||||
|
||||
#include "define.h"
|
||||
#if 0
|
||||
// 充电状态定义
|
||||
typedef enum
|
||||
{
|
||||
CHG_STA_ING, // 充电中
|
||||
CHG_STA_COMPLETED, // 充电完成
|
||||
CHG_STA_PULLOUT, // 充电器拔出
|
||||
} TE_CHG_STA;
|
||||
|
||||
|
||||
extern idata TE_CHG_STA ChgStatus; // 系统状态定义
|
||||
#endif
|
||||
|
||||
extern bit Charger_Done;
|
||||
|
||||
#if CHARGER_ENABLE
|
||||
/*充电电流设置,在系统初始化时通过配置寄存器REG_CHG1配置。
|
||||
|
||||
REG_CHG1 = CHG_CURRENT_300MA;
|
||||
|
||||
*/
|
||||
#define CHG_CURRENT_100MA 0x00
|
||||
#define CHG_CURRENT_200MA 0x01
|
||||
#define CHG_CURRENT_250MA 0x02
|
||||
#define CHG_CURRENT_300MA 0x03
|
||||
#define CHG_CURRENT_350MA 0x04
|
||||
#define CHG_CURRENT_400MA 0x05
|
||||
#define CHG_CURRENT_450MA 0x06
|
||||
#define CHG_CURRENT_500MA 0x07
|
||||
|
||||
|
||||
#define CHG_CONSTANT_CUR_TIM 1
|
||||
|
||||
#define DIE_OT_RECOVER_TIM 25 //NTC保护后,恢复正常后等待250ms重新开启充电
|
||||
|
||||
extern void Charger_Handler(void);
|
||||
extern uint8_t PMU_NTC_Control(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
42
UsrInc/discharge/discharge_module.h
Normal file
42
UsrInc/discharge/discharge_module.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file discharge_module.h
|
||||
* @brief discharge module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __DISCHARGE_MODULE_H__
|
||||
#define __DISCHARGE_MODULE_H__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
extern bit gBoost_Prepared_Flag; //BoostÂú×㿪ÆôÌõ¼þ¡£
|
||||
|
||||
#if DISCHARGE_ENABLE
|
||||
|
||||
#define BOOST_OPEN_TIM 10
|
||||
|
||||
#if 0
|
||||
extern void DisCharge_Boost_Open(void);
|
||||
extern void DisCharge_Boost_Close(void);
|
||||
#endif
|
||||
|
||||
extern void DisCharge_Handler(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
33
UsrInc/gpio/gpio.h
Normal file
33
UsrInc/gpio/gpio.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file gpio.h
|
||||
* @brief gpio module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __GPIO_H__
|
||||
#define __GPIO_H__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
|
||||
//extern void GPIO_Init(void);
|
||||
//extern void Enter_ShipMode(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
67
UsrInc/gpio_comm/gpio_comm.h
Normal file
67
UsrInc/gpio_comm/gpio_comm.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file gpio_comm.h
|
||||
* @brief gpio_comm module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2024/07/18 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2024/07/18 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __GPIO_COMM_H__
|
||||
#define __GPIO_COMM_H__
|
||||
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "define.h"
|
||||
|
||||
#if VOX_TX_PATTERN
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
sbit PATTERN_TX = P0^1;
|
||||
|
||||
#define PATTERN_TX_ON() COM_CTRL = 1
|
||||
#define PATTERN_TX_OFF() COM_CTRL = 0
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
extern bit Pattern_TX_Start;
|
||||
|
||||
extern uint16_t Pattern_TX_Data;
|
||||
|
||||
typedef enum {
|
||||
GPIO_TX_STEPS_NONE = 0,
|
||||
GPIO_TX_STEPS_START,
|
||||
GPIO_TX_STEPS_BIT_SYC,
|
||||
GPIO_TX_STEPS_DATA,
|
||||
GPIO_TX_STEPS_STOP,
|
||||
}e_Gpio_Comm_Step;
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
extern void Gpio_Comm(uint16_t Data);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
61
UsrInc/hall/hall.h
Normal file
61
UsrInc/hall/hall.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file hall.h
|
||||
* @brief hall module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __HALL_H__
|
||||
#define __HALL_H__
|
||||
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "define.h"
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
typedef enum{
|
||||
|
||||
CLOSE = 0,
|
||||
OPEN = !CLOSE
|
||||
|
||||
} CoverStatus_E;
|
||||
|
||||
extern CoverStatus_E CoverStatus;
|
||||
|
||||
extern bit CoverEvent_Flg;
|
||||
extern bit CoverEvent_Flg_led;
|
||||
extern uint8_t Hall_Sta_bk;
|
||||
|
||||
#if HALL_ENABLE
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
//extern void Hall_Init(void);
|
||||
extern void Hall_Handler(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
94
UsrInc/inc/config.h
Normal file
94
UsrInc/inc/config.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file Config.h
|
||||
* @brief Config module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/07/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __CONFIG_H__
|
||||
#define __CONFIG_H__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
/*Charger Module Config Para Setting*/
|
||||
|
||||
#define BAT_CV 4200 //电池CV电压设置:4.20V
|
||||
#define BAT_PRE 3000 //电池涓流充电电压:3.0v
|
||||
#define BAT_RECHARG 4075 //电池复充电压:4200mv - 135mv = 4075mv
|
||||
|
||||
|
||||
#define CHG_CURRENT_400MA 0x05
|
||||
|
||||
/*20uA 电流源下接 104K NTC 电阻并联一个82K电阻后得到的电压值*/
|
||||
#define T_N20C 1530 //-20℃(76.5KΩ * 20uA) NTC:1151K
|
||||
|
||||
#define T_N15C 1495 //-15℃ 迟滞温度
|
||||
|
||||
#define T_N10C 1440 //-10℃(72KΩ * 20uA) NTC:629K
|
||||
|
||||
#define T_0C 1334 //0℃(66.7KΩ * 20uA) NTC:357K
|
||||
|
||||
#define T_3C 1300
|
||||
|
||||
#define T_8C 1200
|
||||
|
||||
#define T_10C 1178 //10℃(58.9KΩ * 20uA) NTC:209.7K
|
||||
|
||||
#define T_12C 1100
|
||||
|
||||
#define T_15C 1050
|
||||
|
||||
#define T_18C 996
|
||||
|
||||
#define T_42C 580
|
||||
|
||||
#define T_45C 546 //45℃(27.3KΩ * 20uA) NTC:40.9K
|
||||
|
||||
#define T_47C 500
|
||||
|
||||
#define T_57C 370
|
||||
|
||||
#define T_60C 350 //60℃(17.5KΩ * 20uA) NTC:22.2K
|
||||
|
||||
#define T_75C 250
|
||||
|
||||
#define T_80C 188 //80℃(9.4KΩ * 20uA) NTC:10.6K
|
||||
|
||||
/*Boost Module Config Para Setting*/
|
||||
#define OPEN_BOOST_VIN 3600 //Boost 发生uvlo保护后,在有VIN条件下,Boost再次恢复开启的电压(3.6V)。
|
||||
#define OPEN_BOOST_NOVIN 3300 //Boost 发生uvlo保护后,在无VIN条件下,Boost再次恢复开启的电压(3.3V)。
|
||||
|
||||
/*KEY And Hall Module Setting*/
|
||||
#define HALL_OPEN_LEV_SET 1 //配置是高电平为开盖还是低电平为开盖。1:高电平为开盖;0:低电平为开盖
|
||||
|
||||
/*Sleep Module Setting*/
|
||||
/*Enter Sleep Time Debounce*/
|
||||
#define ENTER_STANDBYMODE_CNT 10 //进入Standby Mode 延迟时间,单位:秒
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
UserCfg.Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
#endif
|
||||
|
136
UsrInc/inc/define.h
Normal file
136
UsrInc/inc/define.h
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file define.h
|
||||
* @brief define module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/07/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __DEFINE_H__
|
||||
#define __DEFINE_H__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/*程序版本,第一个数代表在硬件存在改动不能兼容之前版本时加1,
|
||||
第二个数在功能存在改动时加1,第三个数在软件调试出现不同的
|
||||
测试版本时改动;高位数字变动时,低位数字清零。*/
|
||||
|
||||
#define FW_VER0 0x01 //程序版本0:代表在硬件存在改动不能兼容之前版本时加1
|
||||
#define FW_VER1 0x01 //程序版本1:代表在功能存在改动时加1
|
||||
#define FW_VER2 0x01 //程序版本2:代表在软件调试出现不同的测试版本时改动时加1
|
||||
|
||||
/*Function Select,功能选择宏定义*/
|
||||
|
||||
#define TIMER1_ENABLE 1 //Timer1 定时周期1ms
|
||||
|
||||
#if TIMER1_ENABLE
|
||||
#define BREATHING_LIGHT //呼吸灯功能,驱动函数置于Timer1中断处理函数中,调用周期100us。(243Bytes)
|
||||
#endif
|
||||
|
||||
#define UART0_ENABLE 1 //UART0功能,用于程序调试。(153Bytes)
|
||||
|
||||
#define WTG_ENABLE 1 //看门狗功能使能(7Bytes)
|
||||
|
||||
#define LED_DISPLAY //LED显示 ,1个灯显示 (348Bytes)
|
||||
|
||||
#define HALL_ENABLE 1 //Hall功能。(Hall 46Bytes)
|
||||
|
||||
#define KEY_ENABLE 1 //Key功能(262Bytes)
|
||||
|
||||
#define VOX_ENABLE 1 //304Bytes
|
||||
|
||||
#define VOX_TX //587Bytes
|
||||
|
||||
#define VOX_TX_PATTERN 0 //GPIO Pattern (118Bytes)
|
||||
|
||||
#define VOX_FOLLOW_CHG 0
|
||||
|
||||
//#define VOX_RX //405Bytes
|
||||
|
||||
#define CHARGER_ENABLE 1 //225Bytes
|
||||
|
||||
#define DISCHARGE_ENABLE 1 //75Bytes
|
||||
|
||||
#define SLEEP_ENABLE 1 //82Bytes
|
||||
|
||||
#define ADC_ENABLE 1 //561Bytes
|
||||
|
||||
#if ADC_ENABLE
|
||||
#define NTC_ENABLE 1
|
||||
#endif
|
||||
|
||||
#define BAT_VALUE 1 //147Bytes
|
||||
|
||||
//#define _DEBUG_ALL //打开打印功能
|
||||
|
||||
#ifdef _DEBUG_ALL
|
||||
|
||||
#define _DEBUG_MAIN
|
||||
// #define _DEBUG_KEY
|
||||
// #define _DEBUG_VOX
|
||||
// #define _DEBUG_HALL
|
||||
// #define _DEBUG_ADC
|
||||
// #define _DEBUG_DISCHARGE
|
||||
// #define _DEBUG_CHARGER
|
||||
// #define _DEBUG_SLEEP
|
||||
// #define _DEBUG_BAT
|
||||
|
||||
//#define TEST_MODE
|
||||
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
|
||||
#endif
|
||||
|
||||
#define HIBYTE(v1) ((uint8_t)((v1)>>8)) //v1 is uint16_t
|
||||
#define LOBYTE(v1) ((uint8_t)((v1)&0xFF))
|
||||
|
||||
typedef bit BIT;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned int uint16_t;
|
||||
typedef unsigned long uint32_t;
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned int uint16;
|
||||
typedef unsigned long uint32;
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef signed int int16_t;
|
||||
typedef signed long int32_t;
|
||||
|
||||
typedef signed char int8;
|
||||
typedef signed int int16;
|
||||
typedef signed long int32;
|
||||
|
||||
typedef signed char s8;
|
||||
typedef unsigned char u8;
|
||||
typedef signed short int s16;
|
||||
typedef unsigned short int u16;
|
||||
typedef signed long int s32;
|
||||
typedef unsigned long int u32;
|
||||
|
||||
typedef enum{false = 0, true = !false} bool;
|
||||
|
||||
#define FALSE false
|
||||
#define TRUE true
|
||||
#define ON true
|
||||
#define OFF false
|
||||
|
||||
#include "reg3310.h"
|
||||
#if UART0_ENABLE
|
||||
#include "uart.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
277
UsrInc/inc/reg3310.h
Normal file
277
UsrInc/inc/reg3310.h
Normal file
@ -0,0 +1,277 @@
|
||||
/*---------------------------------------------------------------------
|
||||
REG3310.H
|
||||
|
||||
Header file for TP3310 microcontroller.
|
||||
|
||||
Initial Released by zheng, 2023-12-01.
|
||||
|
||||
Thinkplus Semiconductor co., ltd, All Rights Reserved!
|
||||
----------------------------------------------------------------------*/
|
||||
#ifndef __REG3310_H__ //给客户的头文件名里的所有内部项目编号需改成实际产品编号!!!
|
||||
#define __REG3310_H__
|
||||
|
||||
//------------------------ Ext SFR Registers -------------------------
|
||||
/*------ GPIO/MFP Registers ------*/
|
||||
#define P0_PU 0x00
|
||||
#define P0_PD 0x01
|
||||
#define P0_OD 0x02
|
||||
#define P0_DRV 0x03
|
||||
#define P0_IE 0x05
|
||||
#define P0_OE 0x06
|
||||
//#define P1_PU 0x07
|
||||
//#define P1_PD 0x08
|
||||
//#define P1_OD 0x09
|
||||
//#define P1_IE 0x0C
|
||||
#define P1_OE 0x0D
|
||||
#define MFP_CTL0 0x0E
|
||||
#define MFP_CTL1 0x0F
|
||||
#define GPIO_TEST 0x9B
|
||||
|
||||
/*----- IRQ Enable Registers ----*/
|
||||
#define IRQ_EN0 0x14 // Abnormal interrupt enable
|
||||
#define IRQ_EN1 0x15 // EXTI interrupt enable 0
|
||||
#define IRQ_EN2 0x16 // EXTI interrupt enable 1
|
||||
#define IRQ_EN3 0x17 // VOL/R LOADIN/ON interrupt enable
|
||||
#define IRQ_EN4 0x18 // VOL/R Recharge and IOFF interrupt enable
|
||||
#define IRQ_EN7 0x1B // KEY/PWM interrupt enable
|
||||
#define IRQ_EN9 0x1D // Charger interrupt enable
|
||||
#define IRQ_EN10 0x1E // VBUS/COMP/HALL/STBTMR/ADC_DATA_RDY interrupt enable
|
||||
|
||||
/*--- Wakeup Enable Registers ---*/
|
||||
#define WKUP_EN0 0x21 // BOOST/HALL/KEY/VBUS Wakeup enable
|
||||
#define WKUP_EN1 0x22 // EXTI and VOL/R Short Wakeup enable
|
||||
#define WKUP_EN3 0x24 // BAT_LOW/TMR/VOX LOADIN/ON Wakeup enable
|
||||
|
||||
/*-------- ADC Registers --------*/
|
||||
#define ADC_CTL0 0x29
|
||||
#define ADC00 0x2D
|
||||
#define ADCCS_CTL0 0x4F
|
||||
|
||||
/*---- OTP KEY Registers ----*/
|
||||
#define OTP_KEY 0x8F
|
||||
|
||||
/*------ VOL/R Registers -----*/
|
||||
#define VOL_IOFF_TRIM 0x69
|
||||
#define VOX_CON0 0x6A
|
||||
#define VOX_CON1 0x6B
|
||||
#define VOX_CON2 0x6C
|
||||
#define VOR_IOFF_TRIM 0x6D
|
||||
#define ST_VOX 0x6E
|
||||
|
||||
/*------ CHG Registers ------*/
|
||||
#define REG_CHG0 0x70
|
||||
#define REG_CHG3 0x9D
|
||||
#define OTP_CHG0 0x71
|
||||
#define OTP_CHG1 0x72
|
||||
|
||||
/*----- BOOST Registers -----*/
|
||||
#define BST_CTL0 0x78
|
||||
#define BST_CTL1 0x79
|
||||
|
||||
/*------ PMU Registers ------*/
|
||||
#define PMU_CTL0 0x80
|
||||
#define PMU_CTL1 0x81
|
||||
#define PMU_CTL3 0x83
|
||||
#define PMU_CTL6 0x86
|
||||
#define PMU_CTL7 0x87
|
||||
#define PMU_CTL8 0x88
|
||||
#define PMU_CTL9 0x89
|
||||
|
||||
/*------ CMU Registers ------*/
|
||||
#define HOSC_CTL 0x8B
|
||||
|
||||
/*------ Misc Registers -----*/
|
||||
#define CHIP_ID 0x8D
|
||||
#define CHIP_VER 0x8E
|
||||
|
||||
|
||||
//------------------------- SFR Registers ----------------------------
|
||||
/*--- BYTE Register ---*/
|
||||
sfr P0 = 0x80;
|
||||
sfr P1 = 0x90;
|
||||
sfr P2 = 0xA0;
|
||||
sfr P3 = 0xB0;
|
||||
sfr PSW = 0xD0;
|
||||
sfr ACC = 0xE0;
|
||||
sfr B = 0xF0;
|
||||
|
||||
sfr SP = 0x81;
|
||||
sfr DPL = 0x82;
|
||||
sfr DPH = 0x83;
|
||||
sfr DPL1 = 0x84;
|
||||
sfr DPH1 = 0x85;
|
||||
sfr WDTREL = 0x86;
|
||||
sfr PCON = 0x87;
|
||||
sfr TCON = 0x88;
|
||||
sfr TMOD = 0x89;
|
||||
sfr TL0 = 0x8A;
|
||||
sfr TL1 = 0x8B;
|
||||
sfr TH0 = 0x8C;
|
||||
sfr TH1 = 0x8D;
|
||||
sfr CKCON = 0x8E;
|
||||
sfr DPSEL = 0x92;
|
||||
sfr ASKCTL0 = 0x96;
|
||||
sfr ASKDATA = 0x97;
|
||||
sfr S0CON = 0x98;
|
||||
sfr S0BUF = 0x99;
|
||||
sfr IEN2 = 0x9A;
|
||||
sfr S1CON = 0x9B;
|
||||
sfr S1BUF = 0x9C;
|
||||
sfr S1RELL = 0x9D;
|
||||
|
||||
sfr16 ADC_DAT = 0xA1;
|
||||
sfr ADC_DATL = 0xA1;
|
||||
sfr ADC_DATH = 0xA2;
|
||||
sfr ADC_OFFSET = 0xA3;
|
||||
sfr ADC_CTL1 = 0xA5;
|
||||
|
||||
sfr IEN0 = 0xA8;
|
||||
sfr IP0 = 0xA9;
|
||||
sfr S0RELL = 0xAA;
|
||||
|
||||
sfr REG_CHG1 = 0xB1;
|
||||
sfr REG_CHG2 = 0xB2;
|
||||
sfr CHG_CTL = 0xB3;
|
||||
|
||||
sfr BST_EN = 0xB5;
|
||||
|
||||
sfr VOX_CTL0 = 0xB7;
|
||||
|
||||
sfr IEN1 = 0xB8;
|
||||
sfr IP1 = 0xB9;
|
||||
sfr S0RELH = 0xBA;
|
||||
sfr S1RELH = 0xBB;
|
||||
sfr IRCON2 = 0xBF;
|
||||
sfr IRCON = 0xC0;
|
||||
sfr CCEN = 0xC1;
|
||||
sfr CCL1 = 0xC2;
|
||||
sfr CCH1 = 0xC3;
|
||||
sfr CCL2 = 0xC4;
|
||||
sfr CCH2 = 0xC5;
|
||||
sfr CCL3 = 0xC6;
|
||||
sfr CCH3 = 0xC7;
|
||||
sfr T2CON = 0xC8;
|
||||
sfr CRCL = 0xCA;
|
||||
sfr CRCH = 0xCB;
|
||||
sfr TL2 = 0xCC;
|
||||
sfr TH2 = 0xCD;
|
||||
|
||||
sfr CLKPRE = 0xD2;
|
||||
sfr RSTCON = 0xD3;
|
||||
sfr KEY_CTL = 0xD7;
|
||||
|
||||
sfr ADCON = 0xD8;
|
||||
|
||||
sfr RST_FLAG = 0xE1;
|
||||
sfr CHIP_STA0 = 0xE2;
|
||||
sfr CHIP_STA1 = 0xE3;
|
||||
sfr CHIP_STA2 = 0xE4;
|
||||
sfr CHIP_STA3 = 0xE5;
|
||||
sfr CHIP_STA4 = 0xE6;
|
||||
|
||||
sfr IRQ_FLAG0 = 0xE8;
|
||||
sfr IRQ_FLAG1 = 0xE9;
|
||||
sfr IRQ_FLAG2 = 0xEA;
|
||||
sfr IRQ_FLAG3 = 0xEB;
|
||||
sfr IRQ_FLAG4 = 0xEC;
|
||||
sfr IRQ_FLAG7 = 0xEF;
|
||||
sfr IRQ_FLAG9 = 0xF2;
|
||||
sfr IRQ_FLAG10 = 0xF3;
|
||||
|
||||
sfr SRST = 0xF7;
|
||||
|
||||
sfr WKUP_FLAG0 = 0xF6;
|
||||
sfr WKUP_FLAG1 = 0xF8;
|
||||
sfr WKUP_FLAG3 = 0xFA;
|
||||
|
||||
sfr SFRADDR = 0xFE;
|
||||
sfr SFRDATA = 0xFF;
|
||||
|
||||
/*--- BIT Register ---*/
|
||||
/* PSW */
|
||||
sbit CY = 0xD7;
|
||||
sbit AC = 0xD6;
|
||||
sbit F0 = 0xD5;
|
||||
sbit RS1 = 0xD4;
|
||||
sbit RS0 = 0xD3;
|
||||
sbit OV = 0xD2;
|
||||
sbit P = 0xD0;
|
||||
|
||||
/* TCON */
|
||||
sbit TF1 = 0x8F;
|
||||
sbit TR1 = 0x8E;
|
||||
sbit TF0 = 0x8D;
|
||||
sbit TR0 = 0x8C;
|
||||
sbit IE1 = 0x8B;
|
||||
sbit IT1 = 0x8A;
|
||||
sbit IE0 = 0x89;
|
||||
sbit IT0 = 0x88;
|
||||
|
||||
/* T2CON */
|
||||
sbit T2PS = 0xCF;
|
||||
sbit I3FR = 0xCE;
|
||||
sbit I2FR = 0xCD;
|
||||
sbit T2R1 = 0xCC;
|
||||
sbit T2R0 = 0xCB;
|
||||
sbit T2CM = 0xCA;
|
||||
sbit T2I1 = 0xC9;
|
||||
sbit T2I0 = 0xC8;
|
||||
|
||||
/* S0CON */
|
||||
sbit SM0 = 0x9F;
|
||||
sbit SM1 = 0x9E;
|
||||
sbit SM20 = 0x9D;
|
||||
sbit REN0 = 0x9C;
|
||||
sbit TB80 = 0x9B;
|
||||
sbit RB80 = 0x9A;
|
||||
sbit TI0 = 0x99;
|
||||
sbit RI0 = 0x98;
|
||||
|
||||
/* IEN0 */
|
||||
sbit EAL = 0xAF;
|
||||
sbit WDT = 0xAE;
|
||||
sbit ET2 = 0xAD;
|
||||
sbit ES0 = 0xAC;
|
||||
sbit ET1 = 0xAB;
|
||||
sbit EX1 = 0xAA;
|
||||
sbit ET0 = 0xA9;
|
||||
sbit EX0 = 0xA8;
|
||||
|
||||
/* IEN1 */
|
||||
sbit EXEN2 = 0xBF;
|
||||
sbit SWDT = 0xBE;
|
||||
sbit EX6 = 0xBD;
|
||||
sbit EX5 = 0xBC;
|
||||
sbit EX4 = 0xBB;
|
||||
sbit EX3 = 0xBA;
|
||||
sbit EX2 = 0xB9;
|
||||
sbit EX7 = 0xB8;
|
||||
|
||||
/* IRCON */
|
||||
sbit EXF2 = 0xC7;
|
||||
sbit TF2 = 0xC6;
|
||||
sbit IEX6 = 0xC5;
|
||||
sbit IEX5 = 0xC4;
|
||||
sbit IEX4 = 0xC3;
|
||||
sbit IEX3 = 0xC2;
|
||||
sbit IEX2 = 0xC1;
|
||||
sbit IADC = 0xC0;
|
||||
|
||||
/* ADCON */
|
||||
sbit BD = 0xDF;
|
||||
|
||||
/* P0 */
|
||||
sbit P00 = P0^0;
|
||||
sbit P01 = P0^1;
|
||||
sbit P02 = P0^2;
|
||||
sbit P03 = P0^3;
|
||||
sbit P04 = P0^4;
|
||||
sbit P05 = P0^5;
|
||||
sbit P06 = P0^6;
|
||||
sbit P07 = P0^7;
|
||||
|
||||
/* P1 */
|
||||
sbit P10 = P1^0;
|
||||
|
||||
#endif
|
||||
|
62
UsrInc/key/key.h
Normal file
62
UsrInc/key/key.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file key.h
|
||||
* @brief key module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __KEY_H__
|
||||
#define __KEY_H__
|
||||
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "define.h"
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
#if KEY_ENABLE
|
||||
|
||||
extern bit Key_Press_short_irq;
|
||||
extern bit Key_Press_l_irq;
|
||||
extern bit Key_Press_ll_irq;
|
||||
|
||||
extern bit Key_l_Flag;
|
||||
|
||||
typedef enum {
|
||||
KEY_EVENT_Empty = 0x00,
|
||||
KEY_EVENT_SHORT, //Key short press(60ms-1s) interrupt flag
|
||||
KEY_EVENT_L_2S, //Key long press for 2/3s interrupt flag
|
||||
KEY_EVENT_LL_8S, //Key super long press for 8s interrupt flag
|
||||
}KEY_EVENT_E;
|
||||
|
||||
extern idata KEY_EVENT_E Event_key;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
extern void Key_Handler(void );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
95
UsrInc/led/led.h
Normal file
95
UsrInc/led/led.h
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file led.h
|
||||
* @brief led dispaly module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __LED_H__
|
||||
#define __LED_H__
|
||||
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "define.h"
|
||||
|
||||
#ifdef LED_DISPLAY
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
// LED端口定义
|
||||
#define LEDR_ON() pin_LED_1 = 1 //LED_1_ON() p03
|
||||
#define LEDR_OFF() pin_LED_1 = 0 //LED_1_OFF()
|
||||
#define LEDR_TOG() pin_LED_1 = !pin_LED_1 //LED_1_RUN()
|
||||
sbit pin_LED_1 = P0^4;
|
||||
|
||||
#define LEDG_ON() pin_LED_2 = 1 //LED_2_ON()
|
||||
#define LEDG_OFF() pin_LED_2 = 0 //LED_2_OFF()
|
||||
#define LEDG_TOG() pin_LED_2 = !pin_LED_2 //LED_2_RUN()
|
||||
sbit pin_LED_2 = P0^3;
|
||||
|
||||
/******************************************************************************\
|
||||
Typedef definitions
|
||||
\******************************************************************************/
|
||||
//LED名称重定义,顺序和上方的宏定义保持一致
|
||||
enum LED_ID
|
||||
{
|
||||
LED_R,
|
||||
LED_G,
|
||||
LED_ID_MAX
|
||||
};
|
||||
|
||||
#ifdef BREATHING_LIGHT
|
||||
|
||||
//LED呼吸灯控制结构体
|
||||
typedef struct{
|
||||
uint8_t Breathing_Light_On[LED_ID_MAX]; //呼吸灯使能标志位。
|
||||
uint8_t BL_On_Time[LED_ID_MAX]; //LED缓亮时间
|
||||
uint8_t BL_Flash_Duty[LED_ID_MAX]; //LED占空比,即点亮时间
|
||||
uint8_t BL_Timer[LED_ID_MAX]; //时间计数 100us计数一次
|
||||
uint8_t Flash_Duty_Rising[LED_ID_MAX]; //呼吸灯逐亮标志
|
||||
uint8_t Flash_Duty_Declining[LED_ID_MAX]; //呼吸灯逐暗标志
|
||||
|
||||
}BRTH_LED_INFO;
|
||||
|
||||
extern idata BRTH_LED_INFO BL_LED;
|
||||
|
||||
#define BL_DUTY_MAX 170
|
||||
#define BL_STEP 2
|
||||
|
||||
//LED改变最小时间周期单位
|
||||
#define LED_PLUS_TIME 1
|
||||
|
||||
/*
|
||||
* 函数名称 : LED_Breathing_Light
|
||||
* 功能描述 : LED呼吸灯驱动,需放在100us时间片中
|
||||
* 参 数 : NONE
|
||||
* 返回值 : NONE
|
||||
*/
|
||||
/******************************************************************************/
|
||||
extern void LED_Breathing_Light(void);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
47
UsrInc/sleep/sleep.h
Normal file
47
UsrInc/sleep/sleep.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file sleep.h
|
||||
* @brief sleep module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/07/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __SLEEP_H__
|
||||
#define __SLEEP_H__
|
||||
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "define.h"
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
#if SLEEP_ENABLE
|
||||
|
||||
extern uint8_t Decnt_SleepDelay;
|
||||
extern bit Enter_Sleep_Cnt_Restart_Flag;
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
extern bit Check_Require_Sleep(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
56
UsrInc/system/system.h
Normal file
56
UsrInc/system/system.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file system.h
|
||||
* @brief system module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __SYSTEM_H__
|
||||
#define __SYSTEM_H__
|
||||
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "define.h"
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
/*中断号计算方式:中断向量 = 中断号 * 8 + 3*/
|
||||
#define Interrupt_Vector_IE0 0 //0x03,TP3310 IE0 use for wakeup
|
||||
#define Interrupt_Vector_TF0 1 //0x0B,Timer 0 Overflow
|
||||
#define Interrupt_Vector_TF1 3 //0x1B,Timer 1 Overflow
|
||||
#define Interrupt_Vector_RI_TI 4 //0x23,Serial Port0 Interrupt
|
||||
#define Interrupt_Vector_IE7 8 //0x43,Charger Interrupt
|
||||
#define Interrupt_Vector_IE2 9 //0x4B,External Interrupr 2/VOX Interrupt
|
||||
#define Interrupt_Vector_IE3 10 //0x53,External Interrupr 3/系统异常中断、电源插拔中断
|
||||
#define Interrupt_Vector_IE4 11 //0x5B,External Interrupr 4/key和Hall中断
|
||||
#define Interrupt_Vector_IE5 12 //0x63,NA
|
||||
#define Interrupt_Vector_IE6 13 //0x6B,ADC中断
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
extern void System_Init(void);
|
||||
|
||||
#endif
|
||||
|
75
UsrInc/timer/sys_tim.h
Normal file
75
UsrInc/timer/sys_tim.h
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file sys_tim.h
|
||||
* @brief system timer module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __sys_tim_H__
|
||||
#define __sys_tim_H__
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "define.h"
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
//#define FOSC 11059200L
|
||||
|
||||
#define T1MS 1000
|
||||
#define T100uS 100
|
||||
#define T10MS 10000 //FOSC/12/100
|
||||
|
||||
#define T10MS_DEBOUNCE_1S 100 //10msÖÜÆÚ¶¨Ê±1s
|
||||
|
||||
#define C_TIM0_Reload (65535 - T1MS) //1ms (65535 - N) * 1/FOSC = Time -> (65535 - N) * 1/11.0592M = 1ms -> 65535 - N = 11059.2 -> N = 65535 - 11059.2
|
||||
|
||||
#if TIMER1_ENABLE
|
||||
|
||||
#define C_TIM1_Reload (65535 - T100uS)
|
||||
|
||||
#endif
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
extern bit F_sys_tim_10ms;
|
||||
extern bit F_sys_tim_250ms;
|
||||
extern bit F_sys_tim_100ms;
|
||||
extern bit F_sys_tim_1s;
|
||||
|
||||
#if TIMER1_ENABLE
|
||||
|
||||
extern bit F_sys_tim1_tick;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
extern void Sys_Tim_Handler(void );
|
||||
|
||||
extern void Delay15ms(void);
|
||||
|
||||
#if TIMER1_ENABLE
|
||||
|
||||
extern void Sys_Tim1_Init(void );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
69
UsrInc/uart/uart.h
Normal file
69
UsrInc/uart/uart.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uart.h
|
||||
* @brief uart module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __UART_H__
|
||||
#define __UART_H__
|
||||
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "define.h"
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
#define Baud_Rate0 115200//9600//19200//38400//93750
|
||||
#define S0REL_VALUE (1024-375000/Baud_Rate0)
|
||||
|
||||
#if UART0_ENABLE
|
||||
|
||||
|
||||
#define COM0_Data_Lenth 11
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
extern idata uint8_t RX0_Buffer[COM0_Data_Lenth]; //½ÓÊÕ»º³å
|
||||
|
||||
extern bit Uart0_RX_Finish_Flag;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
#ifdef _DEBUG_ALL
|
||||
|
||||
extern char putchar (char ch);
|
||||
|
||||
#endif
|
||||
|
||||
//extern void UART0_Init(void);
|
||||
|
||||
extern void Uart0SendData(uint8_t Txdata);
|
||||
|
||||
#ifdef VOX_TX
|
||||
extern void Uart0SendPacket(uint8_t Length,uint8_t *TransBuf);
|
||||
#endif
|
||||
|
||||
extern void HandleVoxCommMsg(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
51
UsrInc/userapp/userapp.h
Normal file
51
UsrInc/userapp/userapp.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file userapp.h
|
||||
* @brief userapp module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __USERAPP_H__
|
||||
#define __USERAPP_H__
|
||||
|
||||
#include "define.h"
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
#define BAT_LEVEL_LOW 20 //电池电量低报警值
|
||||
|
||||
#define LED_OFF_CNT 2
|
||||
|
||||
#define LED_ON_CNT 50 //5s
|
||||
|
||||
#define LED_HUXI_ON_CNT 85
|
||||
|
||||
#define LED_CHG_ON_CNT 200 //200s
|
||||
|
||||
/******************************************************************************\
|
||||
Typedef definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Global variables and functions
|
||||
\******************************************************************************/
|
||||
|
||||
extern uint8_t LED_On_Timer; //led亮时间计时
|
||||
|
||||
extern void UserAPP(void);
|
||||
|
||||
#endif
|
||||
|
126
UsrInc/vox/vox_module.h
Normal file
126
UsrInc/vox/vox_module.h
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file VOX_Module.h
|
||||
* @brief VOL/R module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/07/18 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/07/18 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __VOX_MODULE_H__
|
||||
#define __VOX_MODULE_H__
|
||||
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "define.h"
|
||||
|
||||
extern bit Vox_Vout_Enable;
|
||||
sbit COM_CTRL = P0^2;
|
||||
|
||||
extern uint8_t Vox_TX_Timer; //VOX发送指令持续时间计数,在Hall_Handler检测中清0.
|
||||
extern bit Earphone_Chg_Flag; //耳机出入盒标志位
|
||||
|
||||
#if VOX_ENABLE
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
/*
|
||||
VOX过流档位设置,在系统初始化中(Vox_init())通过配置VOX_CON0,
|
||||
|
||||
SFRADDR = VOX_CON0; //设置VOX输出500mA,负载识别电流2.5uA。
|
||||
SFRDATA &= 0xE0;
|
||||
SFRDATA |= (VOX_IOUT_500MA << 3) | VOX_ADT_Cur_2_5UA;
|
||||
|
||||
*/
|
||||
#define VOX_IOUT_200MA 0x00
|
||||
#define VOX_IOUT_300MA 0x01
|
||||
#define VOX_IOUT_400MA 0x02
|
||||
#define VOX_IOUT_500MA 0x03
|
||||
|
||||
#define VOX_ADT_Cur_0_5UA 0x00
|
||||
#define VOX_ADT_Cur_1_5UA 0x01
|
||||
#define VOX_ADT_Cur_2_5UA 0x02
|
||||
#define VOX_ADT_Cur_3_5UA 0x03
|
||||
#define VOX_ADT_Cur_4_5UA 0x04
|
||||
#define VOX_ADT_Cur_5_5UA 0x05
|
||||
#define VOX_ADT_Cur_6_5UA 0x06
|
||||
#define VOX_ADT_Cur_7_5UA 0x07
|
||||
|
||||
#define HEADER 0x55AA //VOX通讯数据包头
|
||||
|
||||
#define BOX_FAC_HEADER 0xFB04 //VOX通讯仓->产测上位机数据包头
|
||||
#define BESHEADER 0xA5 //VOX通讯耳机->仓数据包头
|
||||
|
||||
#define TIM_SHUTDOWN_DEBOUNCE 600 //关机前debounce时间
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
/*耳机通道选择*/
|
||||
typedef enum {
|
||||
VOL_CHAN = 0,
|
||||
VOR_CHAN,
|
||||
VOX_BOTH,
|
||||
}e_Vox_Chan;
|
||||
|
||||
#if 1
|
||||
/*耳机配对状态*/
|
||||
typedef enum {
|
||||
VOX_PAIR_NONE = 0, //无效
|
||||
VOX_PAIR_ING, //配对中
|
||||
VOX_PAIR_OK, //配对完成
|
||||
VOX_PAIR_KEEP, //不处理,保持当前状态
|
||||
}e_Vox_Pairing_State;
|
||||
|
||||
/*耳机配对记录*/
|
||||
typedef enum {
|
||||
VOX_PAIRED_NONE = 0, //无配对过
|
||||
VOX_PAIRED_OK, //有配对记录
|
||||
}e_Vox_Paired_State;
|
||||
#endif
|
||||
/*耳机和充电仓进行双向通讯的协议命令ID。*/
|
||||
typedef enum _VOX_FAC_COMMAND_E
|
||||
{
|
||||
CMD_FAC_START = 0xB0, //产测开始指令
|
||||
CMD_FAC_HALL = 0xB1, //Hall测试指令
|
||||
CMD_FAC_GUAGE = 0xB2, //电量管控设置
|
||||
CMD_FAC_LED = 0xB3, //LED测试指令
|
||||
CMD_FAC_SHUTDOWN = 0xB4, //关机模式
|
||||
CMD_FAC_GET_DAUGE = 0xB5, //获取电量指令
|
||||
CMD_FAC_GET_NTC = 0xB6, //获取NTC指令
|
||||
CMD_FAC_GET_FWVER = 0xB7, //获取固件版本指令
|
||||
CMD_FAC_SET_VOX_5V = 0xB8, //充电盒进入5V升压
|
||||
|
||||
}VOX_FAC_COMMAND_E;
|
||||
|
||||
/* VOL Enable Type */
|
||||
typedef enum {
|
||||
|
||||
VOX_VOUT_Mode = 0x00, //VOx 5V 输出使能
|
||||
VOX_ADT_Mode, //VOx 负载接入、存在识别功能使能,负载自动识别
|
||||
|
||||
} VOX_Enable_Mode_e;
|
||||
|
||||
extern bit Cover_Open_Flag;
|
||||
|
||||
/******************************************************************************\
|
||||
UserCfg.Functions definitions
|
||||
\******************************************************************************/
|
||||
extern void Vox_TX_Machine(void);
|
||||
|
||||
extern void Vox_Det_Machine(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
51
UsrInc/watchdog/watchdog.h
Normal file
51
UsrInc/watchdog/watchdog.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file watchdog.h
|
||||
* @brief watchdog module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/05/12 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __WATCHDOG_H__
|
||||
#define __WATCHDOG_H__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
#if 0
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
#define _WDT_TIME_65ms_ 0
|
||||
#define _WDT_TIME_1s_ 1
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
UserCfg.Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
extern void Watchdog_Clear(void);
|
||||
extern void Watchdog_Init(uint8_t watchdog_time );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
30
UsrSrc/InitVars.c
Normal file
30
UsrSrc/InitVars.c
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file adc.c
|
||||
* @brief adc module
|
||||
* @ic TP3102
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2024/07/03 15:00:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2024/07/03 Alex build this file
|
||||
******************************************************************************/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
#include "define.h"
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
char code Version_Addr[3] = {FW_VER0,FW_VER1,FW_VER2}; //设置ROM绝对地址存放软版本,两个参数存于ROM的3070、3071、3072位置处,小端模式存储。
|
||||
|
165
UsrSrc/adc/adc.c
Normal file
165
UsrSrc/adc/adc.c
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file adc.c
|
||||
* @brief adc module
|
||||
* @ic TP3102
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2024/03/26 15:00:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/08/04 Alex build this file
|
||||
******************************************************************************/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "adc.h"
|
||||
#include "system.h"
|
||||
#include "sys_tim.h"
|
||||
|
||||
#if ADC_ENABLE
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
idata uint16_t Vbat_Adc = 0;
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* uint16_t ADC_Chn_Data(ADC_CHANNELS_E adc_chn)
|
||||
*
|
||||
* Description : 获取相应通道的电压ADC值。
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : adc Value (mV)
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
uint16_t ADC_Chn_Data(ADC_CHANNELS_E adc_chn)
|
||||
{
|
||||
uint8_t index = 0;
|
||||
uint16_t adc_data = 0;
|
||||
uint16_t adc_plus_data = 0;
|
||||
|
||||
SFRADDR = ADC_CTL0;
|
||||
SFRDATA = 0x8B; //0x8B--ADC EN; Single mode; ADC CLK divided by 24=460k
|
||||
|
||||
for(index=0; index<8; index++)
|
||||
{
|
||||
ADC_CTL1 = (adc_chn << 4) | 0x01; //Channel set and Start conversion
|
||||
|
||||
while(ADC_CTL1 & 0x01); //Wait for conversion complete
|
||||
|
||||
adc_data = ADC_DATL; //Read low byte first! Lock ADC Value.
|
||||
|
||||
adc_data |= (uint16_t)(ADC_DATH << 8);
|
||||
|
||||
adc_plus_data += adc_data;
|
||||
#ifdef _DEBUG_ADC
|
||||
printf("adc4:%d,plus:%d.\r\n",(uint16_t)adc_data,(uint16_t)adc_plus_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
adc_data = adc_plus_data >> 3;
|
||||
|
||||
#ifdef _DEBUG_ADC
|
||||
printf("adc_chn1:%d.\r\n",(uint16_t)adc_data);
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG_ADC
|
||||
printf("Adc,Vadc:%d,Vref:%d.\r\n", (uint16_t)adc_data, (uint16_t)adc_plus_data);
|
||||
#endif
|
||||
|
||||
return adc_data;
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* uint16_t Vbat_Value(void)
|
||||
*
|
||||
* Description : Vbat Value.获取电池电压。
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : Vbat Value (mV)
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
uint16_t Vbat_Value(void)
|
||||
{
|
||||
uint16_t n_Vbat_Data = 0;
|
||||
|
||||
n_Vbat_Data = ADC_Chn_Data(ADC_BAT);
|
||||
|
||||
#ifdef _DEBUG_ADC
|
||||
printf("bat_Vbat1:%d.\r\n",(uint16_t)n_Vbat_Data);
|
||||
#endif
|
||||
|
||||
n_Vbat_Data = (uint32_t)(n_Vbat_Data) * VREF * 2 / ADC_Chn_Data(ADC_VREF); //Vadx = VREF*DATAadx/DATAvref
|
||||
|
||||
#ifdef _DEBUG_ADC
|
||||
printf("bat,Vbat:%d.\r\n",(uint16_t)n_Vbat_Data);
|
||||
#endif
|
||||
|
||||
return n_Vbat_Data;
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* uint16_t ADC_NTC_Value(void)
|
||||
*
|
||||
* Description : 获取NTC采样电压
|
||||
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : ADC Value (mV)
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
uint16_t ADC_NTC_Value(void)
|
||||
{
|
||||
uint16_t adc_data = 0;
|
||||
|
||||
adc_data = ADC_Chn_Data(ADC_CH4);
|
||||
|
||||
#ifdef _DEBUG_ADC
|
||||
printf("adc_chn1:%d.\r\n",(uint16_t)adc_data);
|
||||
#endif
|
||||
|
||||
adc_data = (uint32_t)(adc_data) * VREF / ADC_Chn_Data(ADC_VREF); //Vadx = VREF*DATAadx/DATAvref
|
||||
|
||||
#ifdef _DEBUG_ADC
|
||||
printf("Adc,Vadc:%d.\r\n", (uint16_t)adc_data);
|
||||
#endif
|
||||
|
||||
return adc_data;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
104
UsrSrc/bat/bat.c
Normal file
104
UsrSrc/bat/bat.c
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file bat.c
|
||||
* @brief Voltage-based RC model gauge algorithm
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/02/20 17:35:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/02/20 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "bat.h"
|
||||
#include "adc.h"
|
||||
|
||||
idata uint8_t bat_level = 0;
|
||||
bit F_batlevel_low = 0; //电池低压
|
||||
|
||||
#if BAT_VALUE
|
||||
|
||||
#define C_offset_bat_level_MAX 50
|
||||
#define C_offset_bat_level_MIN 10
|
||||
|
||||
#define C_bat_level_protect 0
|
||||
#define C_bat_level_lowpower 1
|
||||
|
||||
bit F_batlevel_protect = 0; //低电保护
|
||||
idata uint8_t offset_bat_level = ( C_offset_bat_level_MAX + C_offset_bat_level_MIN ) / 2;
|
||||
|
||||
#define C_batLevel_SetMax 10
|
||||
|
||||
/*充电电池电压会浮高,具体电压需要测试。*/
|
||||
const uint16_t Boost_batlevel_Threshold[C_batLevel_SetMax] =
|
||||
{
|
||||
3200, //1
|
||||
3300, //2
|
||||
3400, //3
|
||||
3660, //4
|
||||
3730, //5
|
||||
3800, //6
|
||||
3900, //7
|
||||
3980, //8
|
||||
4050, //9
|
||||
4200 //10
|
||||
};
|
||||
|
||||
void check_bat_level(void)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
//get bat level
|
||||
#if ADC_ENABLE
|
||||
for(i=0; i < C_batLevel_SetMax; i++)
|
||||
{
|
||||
if( Vbat_Adc < Boost_batlevel_Threshold[i] )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( i > bat_level )
|
||||
{
|
||||
offset_bat_level++;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset_bat_level--;
|
||||
}
|
||||
|
||||
//debounce
|
||||
if( (offset_bat_level > C_offset_bat_level_MAX) || (offset_bat_level < C_offset_bat_level_MIN) )
|
||||
{
|
||||
//update
|
||||
bat_level = i;
|
||||
offset_bat_level = ( C_offset_bat_level_MAX + C_offset_bat_level_MIN ) / 2;
|
||||
}
|
||||
#if 0
|
||||
if( bat_level <= C_bat_level_protect )
|
||||
{
|
||||
F_batlevel_protect = 1;
|
||||
}
|
||||
else if( bat_level > ( C_bat_level_protect + 1 ) )
|
||||
{
|
||||
F_batlevel_protect = 0;
|
||||
}
|
||||
#endif
|
||||
if( bat_level <= C_bat_level_lowpower )
|
||||
{
|
||||
F_batlevel_low = 1;
|
||||
}
|
||||
else if( bat_level > (C_bat_level_lowpower + 1) )
|
||||
{
|
||||
F_batlevel_low = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
289
UsrSrc/charger/charger_module.c
Normal file
289
UsrSrc/charger/charger_module.c
Normal file
@ -0,0 +1,289 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file charger_module.c
|
||||
* @brief charger module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/07/12 17:35:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
#include "charger_module.h"
|
||||
#include "adc.h"
|
||||
#include "sys_tim.h"
|
||||
#include "discharge_module.h"
|
||||
#include "system.h"
|
||||
#include "vox_module.h"
|
||||
#include "led.h"
|
||||
|
||||
bit Charger_Done = 0;
|
||||
|
||||
#if CHARGER_ENABLE
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
#define NTC_PRO_DEBOUNCE_TIM 10
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
//idata TE_CHG_STA ChgStatus; // 系统状态定义
|
||||
|
||||
|
||||
//bit NTC_Low_Pro_Flag = 0;
|
||||
//bit NTC_High_Pro_Flag = 0;
|
||||
//bit NTC_CHG_02C_Flag = 0;
|
||||
//bit NTC_CHG_1C_Flag = 0;
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Charger_init(void)
|
||||
*
|
||||
* Description : Charger Initialization
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#if 0
|
||||
void Charger_Init(void)
|
||||
{
|
||||
SFRADDR = PMU_CTL1;
|
||||
SFRDATA |= 0x07; //电池低压检测 enable 信号;电池低压检测档位选择:3.3V
|
||||
/* Setting CV */
|
||||
REG_CHG2 = 0x00; //0:4.20V;1:4.35V
|
||||
/* Setting CHG Current */
|
||||
REG_CHG1 = 0x03; //000:100mA;001:200mA;010:250mA;011:300mA;100:350mA;101:400mA;110:450mA;111:500mA
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Charger_Current_Set(void)
|
||||
*
|
||||
* Description : Charger Initialization
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#if 0
|
||||
void Charger_Current_Set(void)
|
||||
{
|
||||
uint16_t Charger_CurADC_Value = 0;
|
||||
/* 通过外部电阻ADC1值设置充电电流值 */
|
||||
Charger_CurADC_Value = ADC_Chn_Value(ADC_CH1);
|
||||
|
||||
|
||||
/* Setting CV */
|
||||
REG_CHG2 = 0x00; //0:4.20V;1:4.35V
|
||||
/* Setting CHG Current */
|
||||
REG_CHG1 = 0x03; //000:100mA;001:200mA;010:250mA;011:300mA;100:350mA;101:400mA;110:450mA;111:500mA
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* uint8_t Charger_NTC_Control(uint8_t Charge_sta)
|
||||
*
|
||||
* Description : Charger NTC Control
|
||||
* NTC 支持 103 和 104 电阻,NTC 温度检测由软件通过 ADC 采集 NTC 引脚电压。
|
||||
* 如果支持电量计温度检测线性化,支持电量计方案 103 的 NTC 需要并一个 8.2k
|
||||
|
||||
* 电阻(20uA 电流,103 NTC 需要串联 10k 电阻),104 的 NTC 并联 82k 电阻。
|
||||
* 在使能充电前,软件先检测NTC 温度,如果 NTC 浮空,屏蔽 NTC 功能,
|
||||
* 并锁定;如果 NTC 下拉到 0V,关闭充电和放电。NTC 保护后,软件关闭充电,
|
||||
* 温度恢复正常并持续 100ms,再继续充电。
|
||||
*
|
||||
* Arguments : NTC_Protect_Type_e NTC_Type:Shield 、JEITA or IEC;Charge_sta:Charge or not
|
||||
|
||||
* Returns :NTC_Flag (0:Shield; 1:JEITA; 2:IEC)
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#if NTC_ENABLE
|
||||
uint8_t PMU_NTC_Control(void)
|
||||
{
|
||||
uint16_t NTC_Adc = 0;
|
||||
uint8_t nNTC_Pro_Flag = 0;
|
||||
|
||||
static bit NTC_Low_Pro_Flag;
|
||||
static bit NTC_High_Pro_Flag;
|
||||
|
||||
#if NTC_ENABLE
|
||||
|
||||
NTC_Adc = ADC_NTC_Value();
|
||||
|
||||
#endif
|
||||
|
||||
if(NTC_Adc >= 2000) ////屏蔽NTC功能,NTC浮空,屏蔽 NTC 功能,并锁定。
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(NTC_Adc <= T_0C && NTC_Adc > T_45C) //NTC正常
|
||||
{
|
||||
if(NTC_Low_Pro_Flag)
|
||||
{
|
||||
if( NTC_Adc < T_3C )
|
||||
{
|
||||
NTC_Low_Pro_Flag = 0;
|
||||
nNTC_Pro_Flag = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nNTC_Pro_Flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(NTC_High_Pro_Flag)
|
||||
{
|
||||
if( NTC_Adc > T_42C )
|
||||
{
|
||||
NTC_High_Pro_Flag = 0;
|
||||
nNTC_Pro_Flag = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nNTC_Pro_Flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else //异常不充电
|
||||
{
|
||||
|
||||
if(NTC_Adc > T_0C)
|
||||
{
|
||||
NTC_Low_Pro_Flag = 1;
|
||||
}
|
||||
else
|
||||
if(NTC_Adc < T_45C)
|
||||
{
|
||||
NTC_High_Pro_Flag = 1;
|
||||
}
|
||||
|
||||
nNTC_Pro_Flag = 1;
|
||||
}
|
||||
|
||||
return nNTC_Pro_Flag;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Charger_Handler(void)
|
||||
*
|
||||
* Description : Charger Handle. ---- 充电过程除了根据 NTC 动态调节充电电流和截止电压外,其他由硬件控制。充电过程
|
||||
发生异常,硬件进行相应处理,并发送标志位,软件可以进行相应处理。
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*
|
||||
1、充电超时:充电超时后,软件关闭充电使能,等待VIN拔出。
|
||||
*/
|
||||
void Charger_Handler(void)
|
||||
{
|
||||
if( !(CHIP_STA4 & 0x80) ) //未检测到Power good,则关闭Charger使能后返回。
|
||||
{
|
||||
CHG_CTL &= ~0x01; //Disable Charger
|
||||
IRQ_FLAG9 = 0x10; //未充电,需清Charg complete interrupt中断
|
||||
Charger_Done = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/*各项保护都无需软件处理,只处理充电超时,超时后需要等VBUS重新插拔后才重新开始Charger流程。*/
|
||||
if ( IRQ_FLAG9 & 0x0C ) //充电超时,Tricle charg and Fast charge timeout
|
||||
{
|
||||
CHG_CTL &= ~0x01; //Disable Charger
|
||||
if ( IRQ_FLAG10 & 0xC0 ) //Plugin\Plugout interrupt
|
||||
{
|
||||
IRQ_FLAG9 = 0x0C;
|
||||
IRQ_FLAG10 = 0xC0; //Clear Plugin\Plugout interrupt
|
||||
}
|
||||
return;
|
||||
}
|
||||
else /*充电未超时,存在Plug则清Plugin\Plugout int*/
|
||||
{
|
||||
if( IRQ_FLAG10 & 0xC0 )
|
||||
{
|
||||
IRQ_FLAG10 = 0xC0; //Clear Plugin\Plugout interrupt
|
||||
}
|
||||
}
|
||||
|
||||
#if NTC_ENABLE
|
||||
/*NTC Handle*/ //使能Charger前先检测NTC温度,异常就不开充电。(CHIP_STA4 & 0x80):PG
|
||||
if( PMU_NTC_Control() ) //NTC保护,不充电。
|
||||
{
|
||||
CHG_CTL &= ~0x01; //Disable Charger.
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( IRQ_FLAG9 & 0x10 ) //Charg complete interrupt
|
||||
{
|
||||
#if ADC_ENABLE
|
||||
|
||||
#ifdef _DEBUG_CHARGER
|
||||
printf("Chg Done\r\n");
|
||||
#endif
|
||||
if( Vbat_Adc < BAT_RECHARG )
|
||||
{
|
||||
//CHG_CTL |= 0x01; //Enable Charger
|
||||
IRQ_FLAG9 = 0x10;
|
||||
#ifdef _DEBUG_CHARGER
|
||||
printf("En Chg\r\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
CHG_CTL &= ~0x01; //Disable Charger
|
||||
#ifdef _DEBUG_CHARGER
|
||||
printf("Dis Chg\r\n");
|
||||
#endif
|
||||
}
|
||||
Charger_Done = 1;
|
||||
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
CHG_CTL |= 0x01; //Enable Charger
|
||||
Charger_Done = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
208
UsrSrc/discharge/discharge_module.c
Normal file
208
UsrSrc/discharge/discharge_module.c
Normal file
@ -0,0 +1,208 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file discharge_module.c
|
||||
* @brief discharge module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/07/12 17:35:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "discharge_module.h"
|
||||
#include "vox_module.h"
|
||||
#include "adc.h"
|
||||
#include "charger_module.h"
|
||||
#include "sys_tim.h"
|
||||
#include "system.h"
|
||||
#include "led.h"
|
||||
#include "bat.h"
|
||||
|
||||
bit gBoost_Prepared_Flag = 0; //Boost满足开启条件。
|
||||
|
||||
#if DISCHARGE_ENABLE
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
|
||||
bit gBoost_UVLO_Flag = 0;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
#if 0
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void DisCharge_Boost_Open(void)
|
||||
*
|
||||
* Description : Boost Open
|
||||
* VIN 存在时,Boost 在电池电压高于 UVLO(硬件关闭 2.8/3.0V,硬件清 boost 使能。开
|
||||
* 软件实现,有 VIN,3.6V,无 VIN,3.3V)和电池存在的情况下才能开启。
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void DisCharge_Boost_Open(void)
|
||||
{
|
||||
if( gBoost_Prepared_Flag ) //Boost需满足开启条件
|
||||
{
|
||||
BST_EN = 1; //Boost Enable;异常时由硬件主动关闭。
|
||||
|
||||
#ifdef _DEBUG_DISCHARGE
|
||||
printf("Bst Open\r\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void DisCharge_Boost_Close(void)
|
||||
*
|
||||
* Description : Boost Close;主要是出现异常时由硬件主动关闭,软件在电池LOW电量状态下,是否需要关闭boost输出?
|
||||
*
|
||||
* Arguments :
|
||||
|
||||
* Returns :
|
||||
|
||||
* Notes :
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void DisCharge_Boost_Close(void)
|
||||
{
|
||||
if( (BST_EN & 0x01) && gBoost_Prepared_Flag )
|
||||
{
|
||||
BST_EN = 0; //Boost Disable
|
||||
gBoost_Prepared_Flag = 0;
|
||||
|
||||
#ifdef _DEBUG_DISCHARGE
|
||||
printf("Bst Close\r\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void DisCharge_Handler(void)
|
||||
*
|
||||
* Description : Boost放电的保护功能包括:输出短路保护,电池 UVLO 保护,放电过流保护,过温保护。
|
||||
*
|
||||
* Arguments :
|
||||
|
||||
* Returns :
|
||||
|
||||
* Notes :
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void DisCharge_Handler(void)
|
||||
{
|
||||
/*放电过流保护 --- 硬件实现*/
|
||||
#if 0
|
||||
gBoost_Prepared_Flag = 1;
|
||||
#else
|
||||
/*过温保护 --- 硬件实现*/
|
||||
if( CHIP_STA3 & 0x02 )
|
||||
{
|
||||
gBoost_Prepared_Flag = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/*Boost Input UVLO 硬件实现*/
|
||||
if( (CHIP_STA0 & 0x80) ) //用于清软件标志位。
|
||||
{
|
||||
gBoost_Prepared_Flag = 0;
|
||||
gBoost_UVLO_Flag = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
/*输出短路保护 (使用中断标志位,Boost短路中断发生后会锁存,需要写1清零。)-- 短路保护后一直打嗝或者打嗝BOOST_HICCUP_TIM次之后disable boost,打嗝时间 250ms(软件实现)。*/
|
||||
if( IRQ_FLAG0 & 0x01 )
|
||||
{
|
||||
#ifdef _DEBUG_DISCHARGE
|
||||
printf("Boost Pro Output Short!\r\n");
|
||||
#endif
|
||||
gBoost_Prepared_Flag = 0;
|
||||
|
||||
//一直打嗝
|
||||
if( F_sys_tim_250ms )
|
||||
{
|
||||
F_sys_tim_250ms = 0;
|
||||
IRQ_FLAG0 = 0x01;
|
||||
|
||||
BST_EN = 1; //250ms定时开一次Boost
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#if NTC_ENABLE
|
||||
/*NTC Handle*/ //使能Boost前先检测NTC温度,异常就不开放电。
|
||||
if( PMU_NTC_Control() ) //NTC保护,不放电。
|
||||
{
|
||||
gBoost_Prepared_Flag = 0;
|
||||
BST_EN = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
/*电池低电保护*/
|
||||
if( F_batlevel_protect )
|
||||
{
|
||||
gBoost_Prepared_Flag = 0;
|
||||
BST_EN = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
gBoost_Prepared_Flag = 1;
|
||||
|
||||
#if ADC_ENABLE
|
||||
/*
|
||||
VIN 存在时,Boost 在电池电压高于 UVLO(硬件关闭 2.8/3.0V,硬件清 boost 使能。开
|
||||
软件实现,有 VIN,3.6V,无 VIN,3.3V)和电池存在的情况下才能开启。
|
||||
软件上只作有 VIN,3.6V开boost,无 VIN,3.3V开boost逻辑。
|
||||
只关注VIN存在时的UVLO恢复Boost情况。无VIN情况下由硬件处理。
|
||||
*/
|
||||
if ( gBoost_UVLO_Flag )
|
||||
{
|
||||
if( CHIP_STA4 & 0x80 ) //Power GOOD
|
||||
{
|
||||
if( Vbat_Adc >= OPEN_BOOST_VIN )
|
||||
{
|
||||
gBoost_Prepared_Flag = 1;
|
||||
gBoost_UVLO_Flag = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
BST_EN = 0; //Boost Disable
|
||||
gBoost_Prepared_Flag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
66
UsrSrc/gpio/gpio.c
Normal file
66
UsrSrc/gpio/gpio.c
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file gpio.c
|
||||
* @brief gpio module
|
||||
* @ic TP3102
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/08/05 15:00:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/08/05 Alex build this file
|
||||
******************************************************************************/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
#include "gpio.h"
|
||||
#include "sleep.h"
|
||||
#include "userapp.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
//uint8_t System_Rst_Cnt = 0; //系统软复位定时器
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Gpio_Init(void)
|
||||
*
|
||||
* Description : gpio Initialization. --- 系统初始化调用。
|
||||
*
|
||||
* Arguments :
|
||||
|
||||
* Returns :
|
||||
|
||||
* Notes :
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#if 0
|
||||
void GPIO_Init(void)
|
||||
{
|
||||
/* GPIO */
|
||||
|
||||
// SFRADDR = P0_OE;
|
||||
// SFRDATA |= 0x1C; //P02,P03,P04设置成输出模式
|
||||
|
||||
SFRADDR = P1_OE;
|
||||
SFRDATA = 0x01;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
161
UsrSrc/gpio_comm/gpio_comm.c
Normal file
161
UsrSrc/gpio_comm/gpio_comm.c
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file VOX_Module.c
|
||||
* @brief VOL/R module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/07/18 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/07/18 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "gpio_comm.h"
|
||||
#include "vox_module.h"
|
||||
|
||||
#if VOX_TX_PATTERN
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
uint8_t Gpio_TX_Comm_Cnt = 0;
|
||||
uint8_t Gpio_TX_Steps = GPIO_TX_STEPS_START;
|
||||
|
||||
uint8_t Bit_Cnt = 16;
|
||||
uint8_t Pin_Status = 0;
|
||||
|
||||
#define START_LOW_TIM 10
|
||||
#define START_HIGH_TIM 1
|
||||
|
||||
|
||||
uint16_t Pattern_TX_Data = 0; //需要通过VOX发送的数据:高8位:盒子电量;低8位版本号
|
||||
|
||||
bit Pattern_TX_Start = 0;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Gpio_Comm(uint8_t data)
|
||||
*
|
||||
* Description : gpio TX Communicate 1ms调用周期
|
||||
|
||||
* Arguments : uint8_t data
|
||||
|
||||
* Returns :
|
||||
|
||||
* Notes :
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void Gpio_Comm(uint16_t Data)
|
||||
{
|
||||
/*起始帧:10ms低电平 + 1ms高电平 + 10ms低电平。*/
|
||||
if( Pattern_TX_Start )
|
||||
{
|
||||
Gpio_TX_Comm_Cnt++;
|
||||
|
||||
if( Gpio_TX_Steps == GPIO_TX_STEPS_START )
|
||||
{
|
||||
if( Gpio_TX_Comm_Cnt <= START_LOW_TIM )
|
||||
{
|
||||
PATTERN_TX_OFF();
|
||||
}
|
||||
else
|
||||
if( Gpio_TX_Comm_Cnt <= (START_LOW_TIM + START_HIGH_TIM) )
|
||||
{
|
||||
PATTERN_TX_ON();
|
||||
}
|
||||
else
|
||||
if( Gpio_TX_Comm_Cnt <= 22 )
|
||||
{
|
||||
PATTERN_TX_OFF();
|
||||
if( Gpio_TX_Comm_Cnt == 22 )
|
||||
{
|
||||
Gpio_TX_Steps = GPIO_TX_STEPS_BIT_SYC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( Gpio_TX_Steps == GPIO_TX_STEPS_BIT_SYC )
|
||||
{
|
||||
Bit_Cnt--;
|
||||
if(Bit_Cnt > 15)
|
||||
{
|
||||
Bit_Cnt = 16;
|
||||
Gpio_TX_Steps = GPIO_TX_STEPS_STOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
Gpio_TX_Steps = GPIO_TX_STEPS_DATA;
|
||||
}
|
||||
Pin_Status = (Data>>Bit_Cnt)&0x01;
|
||||
Gpio_TX_Comm_Cnt = 0;
|
||||
}
|
||||
|
||||
if( Gpio_TX_Steps == GPIO_TX_STEPS_DATA )
|
||||
{
|
||||
if( Pin_Status ) //bit high
|
||||
{
|
||||
if( Gpio_TX_Comm_Cnt <= 2 )
|
||||
{
|
||||
PATTERN_TX_ON();
|
||||
}
|
||||
else
|
||||
if( Gpio_TX_Comm_Cnt <= 3 )
|
||||
{
|
||||
PATTERN_TX_OFF();
|
||||
Gpio_TX_Steps = GPIO_TX_STEPS_BIT_SYC;
|
||||
}
|
||||
}
|
||||
else //bit low
|
||||
{
|
||||
if( Gpio_TX_Comm_Cnt < 1 )
|
||||
{
|
||||
PATTERN_TX_ON();
|
||||
}
|
||||
else
|
||||
if( Gpio_TX_Comm_Cnt <= 1 )
|
||||
{
|
||||
PATTERN_TX_OFF();
|
||||
Gpio_TX_Steps = GPIO_TX_STEPS_BIT_SYC;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if( Gpio_TX_Steps == GPIO_TX_STEPS_STOP ) //stop帧
|
||||
{
|
||||
if( Gpio_TX_Comm_Cnt < START_LOW_TIM )
|
||||
{
|
||||
PATTERN_TX_OFF();
|
||||
BST_EN = 0;
|
||||
VOX_CTL0 &= ~0x30; //打开VOX负端MOS
|
||||
}
|
||||
else
|
||||
{
|
||||
// PATTERN_TX_ON();
|
||||
PATTERN_TX = ON;
|
||||
Gpio_TX_Comm_Cnt = 0;
|
||||
Pattern_TX_Start = 0;
|
||||
Gpio_TX_Steps = GPIO_TX_STEPS_START;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
101
UsrSrc/hall/hall.c
Normal file
101
UsrSrc/hall/hall.c
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file hall.c
|
||||
* @brief hall module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/08/04 15:00:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/08/04 Alex build this file
|
||||
******************************************************************************/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
#include "hall.h"
|
||||
#include "key.h"
|
||||
#include "led.h"
|
||||
#include "vox_module.h"
|
||||
#include "userapp.h"
|
||||
#include "charger_module.h"
|
||||
#include "sleep.h"
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
CoverStatus_E CoverStatus;
|
||||
|
||||
bit CoverEvent_Flg = 0; //Hall开关触发事件标志位
|
||||
bit CoverEvent_Flg_led = 0;
|
||||
|
||||
#if HALL_ENABLE
|
||||
|
||||
uint8_t Hall_Sta_bk = 0xff;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Hall_Handle(void)
|
||||
*
|
||||
* Description : Hall Handle --- 主循环中调用,调用周期10ms。CoverStatus --- 充电仓盖子状态。
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void Hall_Handler(void)
|
||||
{
|
||||
uint8_t Hall_Sta = 0;
|
||||
|
||||
Hall_Sta = CHIP_STA0 & 0x08;
|
||||
|
||||
if( Hall_Sta != Hall_Sta_bk)
|
||||
{
|
||||
if(CHIP_STA0 & 0x08) //Hall 高电平
|
||||
{
|
||||
#if HALL_OPEN_LEV_SET
|
||||
CoverStatus = OPEN;
|
||||
#else
|
||||
CoverStatus = CLOSE;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if HALL_OPEN_LEV_SET
|
||||
CoverStatus = CLOSE;
|
||||
#else
|
||||
CoverStatus = OPEN;
|
||||
#endif
|
||||
}
|
||||
|
||||
CoverEvent_Flg = 1;
|
||||
CoverEvent_Flg_led = 1;
|
||||
LED_On_Timer = 0;
|
||||
Vox_TX_Timer = 0;
|
||||
Hall_Sta_bk = Hall_Sta;
|
||||
Enter_Sleep_Cnt_Restart_Flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
122
UsrSrc/key/key.c
Normal file
122
UsrSrc/key/key.c
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file key.c
|
||||
* @brief key module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/08/04 15:00:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/08/04 Alex build this file
|
||||
******************************************************************************/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
#include "key.h"
|
||||
#include "system.h"
|
||||
#include "led.h"
|
||||
#include "sleep.h"
|
||||
#include "adc.h"
|
||||
#include "bat.h"
|
||||
#include "vox_module.h"
|
||||
|
||||
#if KEY_ENABLE
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
bit Key_Press_short_irq = 0;
|
||||
bit Key_Press_l_irq = 0;
|
||||
bit Key_Press_ll_irq = 0;
|
||||
|
||||
bit Key_l_Flag = 0;
|
||||
|
||||
idata KEY_EVENT_E Event_key = 0;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Key_Handler(void)
|
||||
*
|
||||
* Description : Key Handler --- 主循环中调用,调用周期5ms。其中长按(按键时间大于2s)需要判断抬键动作才触发。
|
||||
CoverStatus --- 充电仓盖子状态。(本函数提供对应Key事件标志位,后续应用待定)
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void Key_Handler(void)
|
||||
{
|
||||
#if 1
|
||||
|
||||
if( IRQ_FLAG7 ) //有按键触发
|
||||
{
|
||||
if( IRQ_FLAG7 & 0x40 ) //key super long press for 8s interrupt flag
|
||||
{
|
||||
Key_Press_ll_irq = 1;
|
||||
Event_key = KEY_EVENT_LL_8S;
|
||||
}
|
||||
IRQ_FLAG7 = 0xFF; //Clear Key Interrupt Flag
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
if( Key_l_Flag )
|
||||
{
|
||||
Key_Press_l_irq = 0;
|
||||
Key_l_Flag = 0;
|
||||
/*todo*/
|
||||
Event_key = KEY_EVENT_L_2S;
|
||||
/*耳机配对*/
|
||||
|
||||
#ifdef _DEBUG_KEY
|
||||
printf("long press\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if( Key_Press_ll_irq )
|
||||
{
|
||||
Key_Press_ll_irq = 0;
|
||||
/*todo*/
|
||||
Event_key = KEY_EVENT_LL_8S;
|
||||
|
||||
#ifdef _DEBUG_KEY
|
||||
printf("supper long press\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if( Key_Press_short_irq )
|
||||
{
|
||||
Key_Press_short_irq = 0;
|
||||
/*todo*/
|
||||
Event_key = KEY_EVENT_SHORT;
|
||||
|
||||
#ifdef _DEBUG_KEY
|
||||
printf("short press\r\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
158
UsrSrc/led/led.c
Normal file
158
UsrSrc/led/led.c
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file led.c
|
||||
* @brief led module
|
||||
* @ic TP3102
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/08/04 15:00:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/08/04 Alex build this file
|
||||
******************************************************************************/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "led.h"
|
||||
|
||||
|
||||
#ifdef LED_DISPLAY
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/*
|
||||
* 函数名称 : LED_On
|
||||
* 功能描述 : 点亮LED
|
||||
* 参 数 : LED的ID
|
||||
* 返回值 : NONE
|
||||
*/
|
||||
/******************************************************************************/
|
||||
static void LED_On(uint8_t LedId)
|
||||
/******************************************************************************/
|
||||
{
|
||||
switch(LedId)
|
||||
{
|
||||
case LED_R:
|
||||
LEDR_ON();
|
||||
break;
|
||||
|
||||
case LED_G:
|
||||
LEDG_ON();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数名称 : LED_Off
|
||||
* 功能描述 : 熄灭LED
|
||||
* 参 数 : LED的ID
|
||||
* 返回值 : NONE
|
||||
*/
|
||||
/******************************************************************************/
|
||||
static void LED_Off(uint8_t LedId)
|
||||
/******************************************************************************/
|
||||
{
|
||||
switch(LedId)
|
||||
{
|
||||
case LED_R:
|
||||
LEDR_OFF();
|
||||
break;
|
||||
|
||||
case LED_G:
|
||||
LEDG_OFF();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BREATHING_LIGHT
|
||||
|
||||
idata BRTH_LED_INFO BL_LED;
|
||||
|
||||
/*
|
||||
* 函数名称 : LED_Breathing_Light
|
||||
* 功能描述 : LED呼吸灯驱动,需放在100us时间片中,每20ms改变一次占空比。
|
||||
模拟人体呼吸,吸气和呼气各占1.5s,人眼的图像滞留时间0.04s(1/24帧画面)
|
||||
按最快0.04s(40ms)。亮20ms,灭20ms,人眼看到的应该是一直亮。
|
||||
呼吸灯,就是改变这40ms中,亮和灭所占用的百分百。
|
||||
1500/20=75个周期,40ms/75=266us。75个变化周期中,每个周期增长1个单位266us,
|
||||
|
||||
75个周期刚好是40ms,这样就能达到全亮,反之全灭。
|
||||
* 参 数 : NONE
|
||||
* 返回值 : NONE
|
||||
*/
|
||||
/******************************************************************************/
|
||||
void LED_Breathing_Light(void)
|
||||
/******************************************************************************/
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0;i < LED_ID_MAX;i++)
|
||||
{
|
||||
if ( BL_LED.Breathing_Light_On[i] )
|
||||
{
|
||||
if( BL_LED.BL_Timer[i] <= BL_LED.BL_Flash_Duty[i] )
|
||||
{
|
||||
LED_On(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
LED_Off(i);
|
||||
}
|
||||
|
||||
if( BL_LED.BL_Timer[i] >= BL_DUTY_MAX )
|
||||
{
|
||||
BL_LED.BL_Timer[i] = 0;
|
||||
|
||||
if(BL_LED.Flash_Duty_Declining[i])
|
||||
{
|
||||
BL_LED.BL_Flash_Duty[i] -= BL_STEP;
|
||||
}
|
||||
else
|
||||
if(BL_LED.Flash_Duty_Rising[i])
|
||||
{
|
||||
BL_LED.BL_Flash_Duty[i] += BL_STEP;
|
||||
}
|
||||
}
|
||||
|
||||
if( BL_DUTY_MAX <= BL_LED.BL_Flash_Duty[i] )
|
||||
{
|
||||
BL_LED.Flash_Duty_Declining[i] = 1;
|
||||
BL_LED.Flash_Duty_Rising[i] = 0;
|
||||
}
|
||||
else
|
||||
if( BL_LED.BL_Flash_Duty[i] <= 1 )
|
||||
{
|
||||
BL_LED.Flash_Duty_Rising[i] = 1;
|
||||
BL_LED.Flash_Duty_Declining[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
BL_LED.BL_Timer[i] += LED_PLUS_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
67
UsrSrc/main.c
Normal file
67
UsrSrc/main.c
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file main.c
|
||||
* @brief main module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/07/12 17:35:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/07/12 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
#include "define.h"
|
||||
#include "userapp.h"
|
||||
#include "watchdog.h"
|
||||
#include "sys_tim.h"
|
||||
#include "system.h"
|
||||
#include "led.h"
|
||||
#include "charger_module.h"
|
||||
#include "adc.h"
|
||||
#include "vox_module.h"
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
extern char code Version_Addr[3];
|
||||
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
void main(void )
|
||||
{
|
||||
System_Init(); //ϵͳ³õʼ»¯
|
||||
|
||||
#ifdef _DEBUG_MAIN
|
||||
printf("System Init(Ver:%d%d%d)\r\n",Version_Addr[0],Version_Addr[1],Version_Addr[2]);
|
||||
|
||||
#endif
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
#if WTG_ENABLE
|
||||
WDT = 1;
|
||||
SWDT = 1;
|
||||
#endif
|
||||
Sys_Tim_Handler(); //¶¨Ê±Æ÷
|
||||
|
||||
UserAPP();
|
||||
}
|
||||
}
|
73
UsrSrc/sleep/sleep.c
Normal file
73
UsrSrc/sleep/sleep.c
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file sleep.c
|
||||
* @brief sleep module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/03/22 17:35:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/03/22 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "sleep.h"
|
||||
#include "system.h"
|
||||
#include "vox_module.h"
|
||||
|
||||
#if SLEEP_ENABLE
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
uint8_t Decnt_SleepDelay = ENTER_STANDBYMODE_CNT;
|
||||
|
||||
bit Enter_Sleep_Cnt_Restart_Flag = 0;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* bool Check_Require_Sleep(void )
|
||||
*
|
||||
* Description : 查询休眠唤醒源标志位函数。
|
||||
*
|
||||
* Arguments : None
|
||||
|
||||
* Returns : None
|
||||
|
||||
* Notes : bool Flag
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
bit Check_Require_Sleep(void )
|
||||
{
|
||||
if( ( CHIP_STA4 & 0x80 ) || ( ON == Vox_Vout_Enable ) || Enter_Sleep_Cnt_Restart_Flag ) /*VBUS Power Good存在、有中断、耳机处于充电状态情况下,Boost重载输出,系统不进休眠模式。 */
|
||||
{
|
||||
#ifdef _DEBUG_SLEEP
|
||||
printf("Protect\r\n");
|
||||
#endif
|
||||
Enter_Sleep_Cnt_Restart_Flag = 0;
|
||||
/*处理对应的保护和中断唤醒事件。*/
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
273
UsrSrc/system/system.c
Normal file
273
UsrSrc/system/system.c
Normal file
@ -0,0 +1,273 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file system.c
|
||||
* @brief system module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/08/04 15:00:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/08/15 Alex build this file
|
||||
* Attention:1、由于同一个Byte的中断标志位,会分配在不同的中断中,对于清中断标志位(写1清),不能用 |= ,需要用 = ;
|
||||
例如:IRQ_FLAG10 = 0x02; //Clear bit0,bit1 interrupt flag
|
||||
2、外部中断0,主要是用于系统唤醒功能,中断处理函数中无需作逻辑功能处理,必需预留接口!
|
||||
******************************************************************************/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "system.h"
|
||||
#include "gpio.h"
|
||||
#include "adc.h"
|
||||
#include "hall.h"
|
||||
#include "key.h"
|
||||
#include "sleep.h"
|
||||
#include "uart.h"
|
||||
#include "bat.h"
|
||||
#include "sys_tim.h"
|
||||
#include "charger_module.h"
|
||||
#include "discharge_module.h"
|
||||
#include "led.h"
|
||||
#include "vox_module.h"
|
||||
#include "watchdog.h"
|
||||
#include "userapp.h"
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void System_Init(void)
|
||||
*
|
||||
* Description : System Initialization
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void System_Init(void)
|
||||
{
|
||||
SFRADDR = PMU_CTL0; //芯片硬件需求,固定
|
||||
SFRDATA |= 0x30;
|
||||
|
||||
/*test*/
|
||||
SFRADDR = P0_PD;
|
||||
SFRDATA &= ~0x03;
|
||||
|
||||
#if UART0_ENABLE
|
||||
|
||||
//SFRADDR = P0_PU;
|
||||
//SFRDATA = 0x03;
|
||||
|
||||
SFRADDR = MFP_CTL0;
|
||||
SFRDATA = 0x05; //P01 as UART's TX,P00 as UART's RX
|
||||
|
||||
BD = 1; //Select additional Baudrate generator
|
||||
PCON |= 0x80; //Baudrate double enable
|
||||
|
||||
//baudrate set
|
||||
S0RELH = HIBYTE(S0REL_VALUE);
|
||||
S0RELL = LOBYTE(S0REL_VALUE);//s0rel=1023, baudrate = fclk/32 = 187.5k
|
||||
|
||||
S0CON = 0xD0; //SCON: MODE 3, 9-bit UART, RI enable, EVEN Parity
|
||||
|
||||
TI0 = 1;
|
||||
RI0 = 1;
|
||||
ES0 = 1; //Enable UART0 IRQ
|
||||
|
||||
#endif
|
||||
|
||||
#if VOX_ENABLE
|
||||
|
||||
VOX_CTL0 = 0xC3; //VOX 负载接入、存在识别功能使能,负载自动识别。打开Vox vds钳压环使能(主要用于VOX 5V输出)。
|
||||
|
||||
SFRADDR = VOX_CON0; //设置VOX输出过流200mA。
|
||||
SFRDATA &= ~0x1F;
|
||||
SFRDATA |= (VOX_IOUT_200MA << 3) | VOX_ADT_Cur_4_5UA;
|
||||
|
||||
#endif
|
||||
|
||||
TMOD = 0x01; //mode 1, 16bit timer
|
||||
|
||||
TH0 = C_TIM0_Reload >> 8;
|
||||
TL0 = C_TIM0_Reload & 0xFF;
|
||||
|
||||
ET0 = 1; //enable time0 interrupt
|
||||
TR0 = 1; //time0 run
|
||||
|
||||
#if TIMER1_ENABLE
|
||||
|
||||
TMOD |= 0x10; //mode 1, 16bit timer
|
||||
|
||||
TH1 = C_TIM1_Reload >> 8;
|
||||
TL1 = C_TIM1_Reload & 0xFF;
|
||||
|
||||
ET1 = 1; //enable time1 interrupt
|
||||
TR1 = 1; //time1 run
|
||||
|
||||
#endif
|
||||
|
||||
/*GPIO Set*/
|
||||
SFRADDR = P0_OE;
|
||||
SFRDATA = 0x1C; //COM_CTRL(P02)、LED1(P03)、LED2(P04)配置为GPIO输出
|
||||
|
||||
#ifdef LED_DISPLAY
|
||||
|
||||
SFRADDR = P0_DRV; //P03、P04限流开,限流电阻为400Ω
|
||||
SFRDATA = 0x3C;
|
||||
|
||||
pin_LED_1 = 0;
|
||||
pin_LED_2 = 0;
|
||||
|
||||
#endif
|
||||
|
||||
#if WTG_ENABLE
|
||||
/* 65ms */
|
||||
WDTREL = 0x00; //WDTPS = 0,wdt_f = wdt_f1/2;WDTPS = 1,wdt_f = wdt_f1/32;
|
||||
/* 1s */
|
||||
// WDTREL = 0x80; //WDTPS = 0,wdt_f = wdt_f1/2;WDTPS = 1,wdt_f = wdt_f1/32;
|
||||
#endif
|
||||
|
||||
#if ADC_ENABLE
|
||||
|
||||
SFRADDR = MFP_CTL1; //Set P07 Pinmux As AD4 Function
|
||||
SFRDATA |= 0x80;
|
||||
|
||||
SFRADDR = ADCCS_CTL0; //AD0~AD4 GPIO constant 20uA current source enable.
|
||||
SFRDATA = 0x10;
|
||||
|
||||
#endif
|
||||
|
||||
/* Interrupt Enable 根据应用选择必要的中断 */
|
||||
SFRADDR = IRQ_EN3; //INT2 --- VOX EDGE LOADON
|
||||
SFRDATA = 0x3C;
|
||||
|
||||
//SFRADDR = IRQ_EN10; //INT4 --- Hall interrupt enable.
|
||||
//SFRDATA = 0x0C;
|
||||
|
||||
/* 开外部中断使能 */
|
||||
EX0 = 1;
|
||||
EX2 = 1;
|
||||
//EX4 = 1;
|
||||
|
||||
EAL = 1; //开总中断。
|
||||
|
||||
IRQ_FLAG9 = 0x1C; //清 Charge complete Int、Tricle/Fast Charge Time expire Int
|
||||
IRQ_FLAG10 = 0xC0; //清 VBUS Plugin\Plugout Int
|
||||
IRQ_FLAG0 = 0x0C; //Vox短路保护
|
||||
|
||||
#if CHARGER_ENABLE
|
||||
|
||||
#ifdef SY8836 //合封芯片关闭VBUS OV检测使能
|
||||
SFRADDR = PMU_CTL7;
|
||||
SFRDATA &= ~0x20;
|
||||
|
||||
SFRADDR = REG_CHG0;
|
||||
SFRDATA |= 0x04; //关VDPM环
|
||||
#endif
|
||||
|
||||
CHG_CTL |= 0x10; //开启充电超时使能
|
||||
|
||||
// REG_CHG1 = CHG_CURRENT_400MA; //充电电流400mA。
|
||||
|
||||
//REG_CHG2 = 0x01; //CV电压4.35V
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void EX0_isr(void ) interrupt Interrupt_Vector_IE0
|
||||
*
|
||||
* Description : System External Intterupt 0
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void EX0_isr(void) interrupt Interrupt_Vector_IE0
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void EX2_isr(void) interrupt Interrupt_Vector_IE2
|
||||
*
|
||||
* Description : System External Intterupt 2
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void EX2_isr(void) interrupt Interrupt_Vector_IE2
|
||||
{
|
||||
IRQ_FLAG3 = 0x3C;
|
||||
|
||||
#if SLEEP_ENABLE
|
||||
// if( !Enter_Sleep_Cnt_Restart_Flag )
|
||||
{
|
||||
Enter_Sleep_Cnt_Restart_Flag = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void EX4_isr(void) interrupt Interrupt_Vector_IE4
|
||||
*
|
||||
* Description : System External Intterupt 4
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#if 0
|
||||
void EX4_isr(void) interrupt Interrupt_Vector_IE4
|
||||
{
|
||||
|
||||
IRQ_FLAG10 = 0x0C;
|
||||
|
||||
#if SLEEP_ENABLE
|
||||
|
||||
//if( !Enter_Sleep_Cnt_Restart_Flag )
|
||||
{
|
||||
Enter_Sleep_Cnt_Restart_Flag = 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
#endif
|
245
UsrSrc/timer/sys_tim.c
Normal file
245
UsrSrc/timer/sys_tim.c
Normal file
@ -0,0 +1,245 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file sys_tim.c
|
||||
* @brief Timer module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/09/05 15:00:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/09/05 Alex build this file
|
||||
******************************************************************************/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "sys_tim.h"
|
||||
#include "vox_module.h"
|
||||
#include "system.h"
|
||||
#include "charger_module.h"
|
||||
#include "led.h"
|
||||
#include "gpio_comm.h"
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
uint8_t cnt_sys_tim_10ms = 0;
|
||||
uint8_t cnt_sys_tim_250ms = 0;
|
||||
uint8_t cnt_sys_tim_100ms = 0;
|
||||
uint8_t cnt_sys_tim_1s = 0;
|
||||
|
||||
bit F_sys_tim_10ms = 0;
|
||||
bit F_sys_tim_250ms = 0;
|
||||
bit F_sys_tim_100ms = 0;
|
||||
bit F_sys_tim_1s = 0;
|
||||
|
||||
uint8_t F_sys_tim0_tick = 0;
|
||||
|
||||
uint8_t cnt_sys_tim0_5ms = 0;
|
||||
bit BES_Puls_Start = 0; //开启BES Reset脉冲信号
|
||||
|
||||
#if TIMER1_ENABLE
|
||||
bit F_sys_tim1_tick = 0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Sys_Tim_Handler(void )
|
||||
*
|
||||
* Description : Timer Handle
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void Sys_Tim_Handler(void)
|
||||
{
|
||||
if(F_sys_tim0_tick == 0)
|
||||
return;
|
||||
F_sys_tim0_tick = 0;
|
||||
//system tick
|
||||
#if 1
|
||||
//---------------10ms----------------------------------------
|
||||
cnt_sys_tim_10ms++;
|
||||
if(cnt_sys_tim_10ms >= 10)
|
||||
{
|
||||
cnt_sys_tim_10ms = 0;
|
||||
F_sys_tim_10ms = 1;
|
||||
}
|
||||
#endif
|
||||
//---------------100ms----------------------------------------
|
||||
cnt_sys_tim_100ms++;
|
||||
if(cnt_sys_tim_100ms >= 100)
|
||||
{
|
||||
cnt_sys_tim_100ms = 0;
|
||||
F_sys_tim_100ms = 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
cnt_sys_tim_250ms++;
|
||||
if(cnt_sys_tim_250ms>=250)
|
||||
{
|
||||
cnt_sys_tim_250ms = 0;
|
||||
F_sys_tim_250ms = 1;
|
||||
//-----------------250ms-------------------------
|
||||
cnt_sys_tim_1s++;
|
||||
if(cnt_sys_tim_1s >= 4)
|
||||
{
|
||||
cnt_sys_tim_1s = 0;
|
||||
F_sys_tim_1s = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Delay10ms(void) //@11.0592MHz
|
||||
*
|
||||
* Description : 10ms软定时函数
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#if 0
|
||||
void Delay15ms(void) //@11.0592MHz
|
||||
{
|
||||
unsigned char i, j;
|
||||
|
||||
i = 36;
|
||||
j = 140;
|
||||
do
|
||||
{
|
||||
while (--j);
|
||||
} while (--i);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @brief This function handles sys_tim Handler.
|
||||
* @param None
|
||||
* @retval None
|
||||
* 1ms
|
||||
*/
|
||||
#define PATTERN_HIGH_CNT 160 //高电平时间
|
||||
#define PATTERN_LOW_CNT 2 //低电平时间
|
||||
#define PATTERN_TIM 162 //8s + 100ms
|
||||
|
||||
void tim0_Interrupt(void) interrupt Interrupt_Vector_TF0 //interrupt address is 0x000B
|
||||
{
|
||||
//1ms
|
||||
TH0 += C_TIM0_Reload >> 8;
|
||||
TL0 += C_TIM0_Reload & 0xFF;
|
||||
|
||||
F_sys_tim0_tick = 1;
|
||||
|
||||
#if VOX_TX_PATTERN
|
||||
Gpio_Comm(Pattern_TX_Data);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Sys_Tim0_Init(void)
|
||||
*
|
||||
* Description : TImer0 Mode1 16bit timer Initialization
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#if 0
|
||||
void Sys_Tim0_Init(void)
|
||||
{
|
||||
TMOD &= 0xF0;
|
||||
TMOD |= 0x01; //mode 1, 16bit timer
|
||||
|
||||
TH0 = C_TIM0_Reload >> 8;
|
||||
TL0 = C_TIM0_Reload & 0xFF;
|
||||
|
||||
ET0 = 1; //enable time0 interrupt
|
||||
TR0 = 1; //time0 run
|
||||
}
|
||||
#endif
|
||||
#if TIMER1_ENABLE
|
||||
|
||||
/**
|
||||
* @brief This function handles sys_tim Handler.
|
||||
* @param None
|
||||
* @retval None
|
||||
* 1ms
|
||||
*/
|
||||
void tim1_Interrupt(void) interrupt Interrupt_Vector_TF1//interrupt address is 0x000B
|
||||
{
|
||||
//1ms
|
||||
TF1 = 0;
|
||||
|
||||
TH1 += C_TIM1_Reload >> 8;
|
||||
TL1 += C_TIM1_Reload & 0xFF;
|
||||
#ifdef LED_DISPLAY
|
||||
#ifdef BREATHING_LIGHT
|
||||
/*todo*/
|
||||
LED_Breathing_Light();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
F_sys_tim1_tick = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Sys_Tim1_Init(void)
|
||||
*
|
||||
* Description : TImer1 Mode1 16bit timer Initialization
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#if 0
|
||||
void Sys_Tim1_Init(void)
|
||||
{
|
||||
TMOD &= 0x0F;
|
||||
TMOD |= 0x10; //mode 1, 16bit timer
|
||||
|
||||
TH1 = C_TIM1_Reload >> 8;
|
||||
TL1 = C_TIM1_Reload & 0xFF;
|
||||
|
||||
ET1 = 1; //enable time1 interrupt
|
||||
TR1 = 1; //time1 run
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
301
UsrSrc/uart/uart.c
Normal file
301
UsrSrc/uart/uart.c
Normal file
@ -0,0 +1,301 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uart.c
|
||||
* @brief uart module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/12/14 15:00:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/12/14 Alex build this file
|
||||
******************************************************************************/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
#include "uart.h"
|
||||
#include "system.h"
|
||||
#include "vox_module.h"
|
||||
#include "sleep.h"
|
||||
|
||||
|
||||
#if UART0_ENABLE
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
#define NONE_PARITY 0 //无校验
|
||||
#define ODD_PARITY 1 //奇校验
|
||||
#define EVEN_PARITY 2 //偶校验
|
||||
#define MARK_PARITY 3 //标记校验
|
||||
#define SPACE_PARITY 4 //空白校验
|
||||
|
||||
#define PARITYBIT EVEN_PARITY //定义校验位
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
bit busy0;
|
||||
|
||||
idata uint8_t RX0_Buffer[COM0_Data_Lenth] = 0; //接收缓冲
|
||||
bit Uart0_RX_Finish_Flag = 0;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG_ALL
|
||||
|
||||
char putchar(char c)
|
||||
{
|
||||
|
||||
while(!TI0);
|
||||
TI0 = 0;
|
||||
return (S0BUF = c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if UART0_ENABLE
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Uart0SendPacket(uint8_t Length,uint8_t *TransBuf)
|
||||
*
|
||||
* Description : UART0 Send Packet
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifdef VOX_TX
|
||||
|
||||
void Uart0SendPacket(uint8_t Length,uint8_t *TransBuf)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
for(i=0;i<Length;i++)
|
||||
{
|
||||
while(busy0);
|
||||
ACC = *TransBuf++;
|
||||
busy0 = 1;
|
||||
S0BUF = ACC;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if UART0_ENABLE
|
||||
|
||||
#ifdef VOX_RX
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void HandleRxCommand(ACK_TYPE_E RxCommand)
|
||||
*
|
||||
* Description : 耳机端发送的数据包的解析及处理
|
||||
* Ack payload:
|
||||
* Header checksum side cmd len Data
|
||||
* 1bytes 1byte 1byte 1byte 1byte Len bytes
|
||||
*
|
||||
* Arguments : ACK_TYPE_E RxCommand:
|
||||
|
||||
* Returns :
|
||||
*
|
||||
* Notes :
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void HandleRxMsg(VOX_FAC_COMMAND_E RxCommand)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
switch(RxCommand)
|
||||
{
|
||||
case CMD_FAC_START:
|
||||
|
||||
break;
|
||||
|
||||
case CMD_FAC_HALL:
|
||||
|
||||
break;
|
||||
|
||||
case CMD_FAC_GUAGE:
|
||||
|
||||
break;
|
||||
|
||||
case CMD_FAC_LED:
|
||||
|
||||
|
||||
break;
|
||||
case CMD_FAC_SHUTDOWN:
|
||||
|
||||
|
||||
break;
|
||||
case CMD_FAC_GET_DAUGE:
|
||||
|
||||
|
||||
break;
|
||||
case CMD_FAC_GET_NTC:
|
||||
|
||||
|
||||
break;
|
||||
case CMD_FAC_GET_FWVER:
|
||||
|
||||
|
||||
break;
|
||||
case CMD_FAC_SET_VOX_5V:
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void HandleVoxCommMsg(void)
|
||||
*
|
||||
* Description : Vox 通讯功能处理函数,100ms定时调用。由于和耳机通信前需要打开耳机端的TRX功能,并且每次通信只能一只耳机。通过切换VOL/VOR通信开关进行通信
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void HandleVoxCommMsg(void)
|
||||
{
|
||||
uint8_t CrcCheckSum = 0;
|
||||
uint8_t i = 0;
|
||||
|
||||
/*RX数据处理*/
|
||||
if( Uart0_RX_Finish_Flag )
|
||||
{
|
||||
Uart0_RX_Finish_Flag = 0;
|
||||
|
||||
if( CrcCheckSum == RX0_Buffer[1] )
|
||||
{
|
||||
HandleRxMsg((VOX_FAC_COMMAND_E)RX0_Buffer[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define Vox_Comm_Data_Len 5
|
||||
#define Vox_R_W_FLAG 4
|
||||
|
||||
/*uart0中断处理函数*/
|
||||
void uart0_Interrupt(void) interrupt Interrupt_Vector_RI_TI
|
||||
{
|
||||
#ifdef VOX_RX
|
||||
|
||||
static uint8_t Rx0Status;
|
||||
static uint8_t RX0_Cnt;
|
||||
static uint8_t RX0DataLen;
|
||||
|
||||
#endif
|
||||
/*处理UART0发送中断*/
|
||||
if(TI0)
|
||||
{
|
||||
TI0 = 0;
|
||||
busy0 = 0;
|
||||
}
|
||||
|
||||
/*处理UART0接收中断*/
|
||||
if(RI0)
|
||||
{
|
||||
RI0 = 0;
|
||||
|
||||
#if SLEEP_ENABLE
|
||||
Enter_Sleep_Cnt_Restart_Flag = 1;
|
||||
#endif
|
||||
|
||||
#ifdef VOX_RX
|
||||
|
||||
switch(Rx0Status)
|
||||
{
|
||||
case 0:
|
||||
if( S0BUF == 0x04 )
|
||||
{
|
||||
Rx0Status = 1;
|
||||
RX0_Buffer[0] = S0BUF;
|
||||
}
|
||||
else
|
||||
{
|
||||
Rx0Status = 0;
|
||||
|
||||
RX0_Cnt = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if( S0BUF == 0xFB )
|
||||
{
|
||||
Rx0Status = 2;
|
||||
RX0_Cnt = 1;
|
||||
RX0_Buffer[RX0_Cnt] = S0BUF;
|
||||
RX0_Cnt++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Rx0Status = 0;
|
||||
|
||||
RX0_Cnt = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
|
||||
RX0_Buffer[RX0_Cnt] = S0BUF;
|
||||
RX0_Cnt++;
|
||||
|
||||
|
||||
if( (RX0_Buffer[3] == 1) || (RX0_Buffer[4] == 0) ) //读操作或写数据长度为0,则不带4字节CRC校验和
|
||||
{
|
||||
RX0_Cnt = 0;
|
||||
Rx0Status = 0;
|
||||
Uart0_RX_Finish_Flag = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if( RX0_Cnt == Vox_Comm_Data_Len )
|
||||
{
|
||||
RX0DataLen = RX0_Buffer[4] + 9; //获取数据长度:Header(2Bytes) + CMD(1Bytes) + W Flag(1Bytes) + Datalen(1Bytes) + Data + CRC(4Bytes)
|
||||
}
|
||||
|
||||
|
||||
if( (RX0DataLen == RX0_Cnt) || (RX0_Cnt > COM0_Data_Lenth) ) //当接收到的data个数等于RX0DataLen,这结束本次传输。
|
||||
{
|
||||
RX0_Cnt = 0;
|
||||
Rx0Status = 0;
|
||||
Uart0_RX_Finish_Flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
344
UsrSrc/userapp/userapp.c
Normal file
344
UsrSrc/userapp/userapp.c
Normal file
@ -0,0 +1,344 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file UserApp.c
|
||||
* @brief UserApp module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2023/03/27 15:00:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2023/03/27 Alex build this file
|
||||
******************************************************************************/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
|
||||
#include "userapp.h"
|
||||
#include "gpio.h"
|
||||
#include "adc.h"
|
||||
#include "hall.h"
|
||||
#include "key.h"
|
||||
#include "sleep.h"
|
||||
#include "system.h"
|
||||
#include "bat.h"
|
||||
#include "sys_tim.h"
|
||||
#include "charger_module.h"
|
||||
#include "discharge_module.h"
|
||||
#include "led.h"
|
||||
#include "vox_module.h"
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
uint8_t LED_On_Timer = 0; //led亮时间计时
|
||||
bit LED_On_Flag = 0;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Function : void LED_Display_App(void)
|
||||
* Description : 5ms调用周期
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : None
|
||||
* Note : None
|
||||
*****************************************************************************/
|
||||
/*
|
||||
充电:
|
||||
1、充电中,无其它行为打断时,开关盒状态下都显示充电常亮灯效(1Hz闪烁);
|
||||
2、充满,常亮;可被其它灯效打断;
|
||||
|
||||
非充电:
|
||||
1、首次使用开盖灯效:①高电:亮4s后灭;②低电:1Hz闪4s后灭;
|
||||
2、非首次使用开盖灯效:①耳机在盒:亮4s后灭;②耳机不在盒:????
|
||||
③充电中,开盖闪一下,如何闪?亮多久后灭?
|
||||
3、关盖灯效,高电:亮4s后灭;低电:1Hz闪4s后灭;
|
||||
4、关盒状态下无灯效显示;
|
||||
|
||||
*/
|
||||
#ifdef LED_DISPLAY
|
||||
|
||||
void LED_Display_App(void)
|
||||
{
|
||||
if( Earphone_Chg_Flag ) //耳机出入仓呼吸灯循环3次。
|
||||
{
|
||||
if( LED_On_Timer < LED_OFF_CNT )
|
||||
{
|
||||
LEDR_OFF();
|
||||
LEDG_OFF();
|
||||
|
||||
LED_On_Timer++;
|
||||
}
|
||||
else
|
||||
if( LED_On_Timer < LED_HUXI_ON_CNT ) //红色LED亮5s后灭。
|
||||
{
|
||||
LED_On_Timer++;
|
||||
|
||||
if( F_batlevel_low )
|
||||
{
|
||||
#ifdef BREATHING_LIGHT
|
||||
BL_LED.Breathing_Light_On[LED_R] = 1;
|
||||
BL_LED.Breathing_Light_On[LED_G] = 0;
|
||||
#endif
|
||||
LEDG_OFF();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BREATHING_LIGHT
|
||||
BL_LED.Breathing_Light_On[LED_R] = 0;
|
||||
BL_LED.Breathing_Light_On[LED_G] = 1;
|
||||
#endif
|
||||
LEDR_OFF();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BREATHING_LIGHT
|
||||
BL_LED.Breathing_Light_On[LED_R] = 0;
|
||||
BL_LED.Breathing_Light_On[LED_G] = 0;
|
||||
BL_LED.BL_Timer[LED_R] = BL_DUTY_MAX;
|
||||
BL_LED.BL_Timer[LED_G] = BL_DUTY_MAX;
|
||||
#endif
|
||||
LEDR_OFF();
|
||||
LEDG_OFF();
|
||||
|
||||
Earphone_Chg_Flag = 0;
|
||||
CoverEvent_Flg_led = 0;
|
||||
LED_On_Timer = 0;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( CHIP_STA4 & 0x80 ) //充电中
|
||||
{
|
||||
if ( Charger_Done ) // 充电完成,LED绿灯常亮
|
||||
{
|
||||
LEDG_ON();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( LED_On_Timer < LED_OFF_CNT )
|
||||
{
|
||||
LEDR_OFF();
|
||||
LEDG_OFF();
|
||||
LED_On_Timer++;
|
||||
}
|
||||
else
|
||||
if( LED_On_Timer < LED_CHG_ON_CNT ) //红色LED亮20s后灭。
|
||||
{
|
||||
LED_On_Timer++;
|
||||
LEDR_ON();
|
||||
}
|
||||
else
|
||||
{
|
||||
LEDR_OFF();
|
||||
}
|
||||
}
|
||||
|
||||
CoverEvent_Flg_led = 0;
|
||||
LED_On_Flag = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( LED_On_Flag )
|
||||
{
|
||||
LEDR_OFF();
|
||||
LEDG_OFF();
|
||||
LED_On_Timer = 0;
|
||||
LED_On_Flag = 0;
|
||||
}
|
||||
|
||||
if ( CoverEvent_Flg_led ) //开关盖,低电橙灯亮5s,非低电绿灯亮5s。
|
||||
{
|
||||
if( F_batlevel_low )
|
||||
{
|
||||
if( LED_On_Timer < LED_OFF_CNT )
|
||||
{
|
||||
LEDR_OFF();
|
||||
LEDG_OFF();
|
||||
LED_On_Timer++;
|
||||
}
|
||||
else
|
||||
if( LED_On_Timer < LED_ON_CNT ) //开关盖,盒子低电,红色LED亮5s后灭。
|
||||
{
|
||||
LED_On_Timer++;
|
||||
LEDR_ON();
|
||||
}
|
||||
else
|
||||
{
|
||||
LEDR_OFF();
|
||||
CoverEvent_Flg_led = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LEDR_OFF();
|
||||
if( LED_On_Timer < LED_OFF_CNT )
|
||||
{
|
||||
LEDG_OFF();
|
||||
LED_On_Timer++;
|
||||
}
|
||||
else
|
||||
if( LED_On_Timer < LED_ON_CNT ) //开关盖,盒子非低电,绿色LED亮3s后灭。
|
||||
{
|
||||
LED_On_Timer++;
|
||||
LEDG_ON();
|
||||
}
|
||||
else
|
||||
{
|
||||
LEDG_OFF();
|
||||
CoverEvent_Flg_led = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* Function : UserAPP
|
||||
* Description : 5ms调用周期
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : None
|
||||
* Note : None
|
||||
*****************************************************************************/
|
||||
void UserAPP(void)
|
||||
{
|
||||
if( F_sys_tim_100ms )
|
||||
{
|
||||
F_sys_tim_100ms = 0;
|
||||
#if ADC_ENABLE
|
||||
Vbat_Adc = Vbat_Value(); //获取Bat电压
|
||||
#endif
|
||||
|
||||
#if HALL_ENABLE
|
||||
Hall_Handler(); //开关盖检测
|
||||
#endif
|
||||
|
||||
#if KEY_ENABLE
|
||||
Key_Handler(); //按键检测
|
||||
#endif
|
||||
|
||||
#if DISCHARGE_ENABLE
|
||||
DisCharge_Handler(); //放电boost功能
|
||||
#endif
|
||||
|
||||
#if CHARGER_ENABLE
|
||||
Charger_Handler(); //充电功能
|
||||
#endif
|
||||
|
||||
#if VOX_ENABLE
|
||||
Vox_Det_Machine(); //开关盖盒子功能逻辑。
|
||||
#endif
|
||||
|
||||
#ifdef LED_DISPLAY
|
||||
LED_Display_App(); //LED 灯效
|
||||
#endif
|
||||
|
||||
#if BAT_VALUE
|
||||
check_bat_level(); //电量计
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if( F_sys_tim_1s )
|
||||
{
|
||||
F_sys_tim_1s = 0;
|
||||
|
||||
#if SLEEP_ENABLE
|
||||
|
||||
/*1、唤醒后工作Ns后进入Sleep Mode。
|
||||
2、有VIN存在的情况下,系不会进入sleep mode。
|
||||
*/
|
||||
|
||||
if( Decnt_SleepDelay > 0 ) /*能否在数字中实现此功能?*/
|
||||
{
|
||||
Decnt_SleepDelay--;
|
||||
|
||||
/*倒数进Sleep Mode过程中出现了KEY\HALL\Loadon\IOFF中断,则重新计时。*/
|
||||
if( Enter_Sleep_Cnt_Restart_Flag )
|
||||
{
|
||||
Enter_Sleep_Cnt_Restart_Flag = 0;
|
||||
Decnt_SleepDelay = ENTER_STANDBYMODE_CNT;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( Check_Require_Sleep() )
|
||||
{
|
||||
/* 唤醒中断使能设置 */
|
||||
SFRADDR = WKUP_EN3; //vox loadon wake up enable
|
||||
SFRDATA |= 0x3C;
|
||||
/* Enter Sleep */
|
||||
/* InSleep Handler */ //Disable All IRQ
|
||||
#if UART0_ENABLE
|
||||
ES0 = 0; //UART0 IRQ Disable
|
||||
#endif
|
||||
//EX4 = 0;
|
||||
EX2 = 0;
|
||||
ET0 = 0; //timer0 IRQ Disable
|
||||
#if TIMER1_ENABLE
|
||||
ET1 = 0; //timer1 IRQ Disable
|
||||
#endif
|
||||
|
||||
VOX_CTL0 &= ~0x30; //VOX 5v Off
|
||||
|
||||
#if DISCHARGE_ENABLE
|
||||
BST_EN = 0; //Boost Disable
|
||||
#endif
|
||||
|
||||
#if ADC_ENABLE
|
||||
SFRADDR = ADC_CTL0;
|
||||
SFRDATA &= ~0x80; //ADC Disable.
|
||||
|
||||
SFRADDR = ADCCS_CTL0; //AD0~AD4 GPIO constant 20uA current source disable.
|
||||
SFRDATA = 0x00;
|
||||
#endif
|
||||
SFRADDR = PMU_CTL0; //芯片硬件需求,固定
|
||||
SFRDATA &= ~0x30;
|
||||
|
||||
PCON |= 0x02; //Enter StandbyMode, Only int0 or int1 can wake up system
|
||||
|
||||
/* OutSleep Handler */ //Enable IRQ
|
||||
|
||||
SFRADDR = PMU_CTL0; //芯片硬件需求,固定
|
||||
SFRDATA |= 0x30;
|
||||
|
||||
SFRADDR = ADCCS_CTL0; //AD0~AD4 GPIO constant 20uA current source enable.
|
||||
SFRDATA = 0x10;
|
||||
|
||||
#if UART0_ENABLE
|
||||
ES0 = 1; //UART0 IRQ
|
||||
#endif
|
||||
//EX4 = 1;
|
||||
EX2 = 1;
|
||||
ET0 = 1; //timer0 IRQ
|
||||
#if TIMER1_ENABLE
|
||||
ET1 = 1; //timer1 IRQ
|
||||
#endif
|
||||
Decnt_SleepDelay = ENTER_STANDBYMODE_CNT;
|
||||
}
|
||||
else
|
||||
{
|
||||
Decnt_SleepDelay = ENTER_STANDBYMODE_CNT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
440
UsrSrc/vox/vox_module.c
Normal file
440
UsrSrc/vox/vox_module.c
Normal file
@ -0,0 +1,440 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file VOX_Module.c
|
||||
* @brief VOL/R module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/07/18 09:59:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/07/18 Alex build this file
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "vox_module.h"
|
||||
#include "led.h"
|
||||
#include "system.h"
|
||||
#include "discharge_module.h"
|
||||
#include "sleep.h"
|
||||
#include "bat.h"
|
||||
#include "hall.h"
|
||||
#include "key.h"
|
||||
#include "sys_tim.h"
|
||||
#include "adc.h"
|
||||
#include "gpio_comm.h"
|
||||
#include "userapp.h"
|
||||
#include "key.h"
|
||||
|
||||
bit Vox_Vout_Enable = OFF; //Vox功率输出标志位
|
||||
bit Earphone_Chg_Flag = 0; //耳机出入盒标志位
|
||||
uint8_t Vox_TX_Timer = 0; //VOX发送指令持续时间计数,在Hall_Handler检测中清0.
|
||||
|
||||
#if VOX_ENABLE
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
/*100ms调用周期*/
|
||||
#define VOX_OUTPUT_SHORT_CNT 2
|
||||
#define VOX_LOW_BAT_CNT 25 //关盖前,盒子低电保护,Vox 5V持续2.5s
|
||||
#define VOX_VOUT_5V_LEAST_CNT 50
|
||||
|
||||
#define VOX_VOUT_5V_DEBOUNCE 5
|
||||
#define VOX_ADT_HOLD_CNT 3
|
||||
#define Vox_TX_Pattern_Cnt 3
|
||||
|
||||
#define BOOST_VOUT_MAX 2 //跟随充Boost输出电压上限值:0:4.6V,1:4.7V,2:4.8V,3:5.05V.
|
||||
|
||||
#define Vox_TX_Interval 2 //Vox定时发送指令时间间隔
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
uint8_t Vox_Vol_Hold_Timer = 0;
|
||||
|
||||
bit Cover_Close_Flag = 0;
|
||||
bit Cover_Close_Flag1 = 0;
|
||||
|
||||
bit Cover_Open_Flag = 0;
|
||||
bit Vox_Vout_5V_Flag = 0;
|
||||
|
||||
uint8_t Vox_Output_Debounce = 0;
|
||||
|
||||
bit Get_CHIP_STA1_Flag = 0;
|
||||
|
||||
bit Pattern_TX_Over_Flag = 0;
|
||||
|
||||
uint8_t CHIP_STA1_BK = 0;
|
||||
|
||||
bit Cover_Open_5V_Flag = 0;
|
||||
|
||||
#if VOX_FOLLOW_CHG
|
||||
|
||||
bit Boost_VoxVout_Follow_Flag = 0;
|
||||
int8 Boost_Vout_Value = 0;
|
||||
bit Boost_Up_Flag = 0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void VOX_EN_Type(VOR_Enable_Type_e VOR_Enable_Type)
|
||||
*
|
||||
* Description : VOL Open(EN_VO)
|
||||
|
||||
* Arguments :
|
||||
|
||||
* Returns :
|
||||
|
||||
* Notes :
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void VOX_EN_Type(VOX_Enable_Mode_e VOX_Enable_Mode)
|
||||
{
|
||||
COM_CTRL = ON;
|
||||
|
||||
if( VOX_Enable_Mode == VOX_VOUT_Mode)
|
||||
{
|
||||
VOX_CTL0 &= ~0x30; //VOX Disable 5V And Disable VOX ADT
|
||||
|
||||
VOX_CTL0 |= 0x30; //VOX Enable 5V
|
||||
}
|
||||
else
|
||||
{
|
||||
VOX_CTL0 &= ~0x30; //VOX 5v Off
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Vox_Det_Machine(void)
|
||||
*
|
||||
* Description : Vox Detect:耳机识别。 (100ms调用周期)
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void Vox_Det_Machine(void)
|
||||
{
|
||||
/*Vox 过流保护,两只耳机都每隔200ms打嗝一次*/
|
||||
if( IRQ_FLAG0 & 0x0C )
|
||||
{
|
||||
Vox_Output_Debounce++;
|
||||
if( Vox_Output_Debounce >= VOX_OUTPUT_SHORT_CNT ) //Vox短路保护200ms后,重新开启Vox 5V。
|
||||
{
|
||||
Vox_Output_Debounce = 0;
|
||||
IRQ_FLAG0 = 0x0C;
|
||||
VOX_EN_Type(VOX_VOUT_Mode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( CoverEvent_Flg ) //Hall事件触发。
|
||||
{
|
||||
if( gBoost_Prepared_Flag )
|
||||
{
|
||||
COM_CTRL = ON;
|
||||
|
||||
if( !F_batlevel_low ) //电压低于3.3V不升压,但需要走开关盖逻辑,用于灯效显示。
|
||||
{
|
||||
if( !BST_EN )
|
||||
{
|
||||
BST_EN = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
VOX_EN_Type(VOX_VOUT_Mode); //VOX Enable 5V,开启VOX端的NMOS
|
||||
}
|
||||
|
||||
if( CoverStatus == CLOSE ) //1、关盖关闭COM_CTRL;显示灯效。(无需查询Loadon、IOFF状态,无论耳机是否在仓,Vox 5V输出。)
|
||||
{
|
||||
#if VOX_FOLLOW_CHG
|
||||
|
||||
if( BST_EN )
|
||||
{
|
||||
/*跟随充逻辑*/
|
||||
SFRADDR = BST_CTL0; //Boost 5V输出
|
||||
SFRDATA |= 0x03;
|
||||
Boost_Vout_Value = 0x03;
|
||||
Boost_Up_Flag = 0;
|
||||
|
||||
SFRADDR = VOX_CON0; //IOFF选择高电流档10/15/20/25mA
|
||||
SFRDATA |= 0x20;
|
||||
|
||||
SFRADDR = VOX_CON2;
|
||||
SFRDATA &= ~0xC0;
|
||||
SFRDATA |= 0x80; //IOFF 20mA
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Cover_Close_Flag = 1;
|
||||
|
||||
CoverEvent_Flg = 0;
|
||||
|
||||
Vox_Vout_Enable = ON;
|
||||
|
||||
Cover_Open_Flag = 0;
|
||||
|
||||
Vox_Vol_Hold_Timer = 0; //关盖清0,开盖使用
|
||||
|
||||
#if VOX_FOLLOW_CHG
|
||||
Boost_VoxVout_Follow_Flag = 1;
|
||||
#endif
|
||||
|
||||
//VOX_EN_Type(VOX_VOUT_Mode); //VOX Enable 5V,开启VOX端的NMOS
|
||||
}
|
||||
else //2、开盖处理:5v 500ms 转0V 500ms,后转ADT模式。
|
||||
{
|
||||
|
||||
Cover_Close_Flag = 0;
|
||||
|
||||
Vox_Vol_Hold_Timer = 0;
|
||||
|
||||
Cover_Open_Flag = 1;
|
||||
|
||||
Get_CHIP_STA1_Flag = 0;
|
||||
|
||||
CoverEvent_Flg = 0;
|
||||
|
||||
Cover_Open_5V_Flag = 0;
|
||||
|
||||
Vox_Output_Debounce = 0;
|
||||
|
||||
// VOX_EN_Type(VOX_VOUT_Mode); //VOX Enable 5V,开启VOX端的NMOS
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
VOX_EN_Type(VOX_ADT_Mode);
|
||||
|
||||
Vox_Vout_Enable = OFF;
|
||||
|
||||
CoverEvent_Flg = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* 发送开盖指令*/
|
||||
if( Cover_Open_Flag ) /*开盖后,5V持续500ms后0V持续500ms,Vox转入adt模式,等待耳机出入盒,并显示相应的灯效。*/
|
||||
{
|
||||
if( Vox_Vol_Hold_Timer < VOX_VOUT_5V_DEBOUNCE ) //开盖后5V 500ms。
|
||||
{
|
||||
Vox_Vol_Hold_Timer++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( Vox_TX_Timer < VOX_VOUT_5V_DEBOUNCE ) //转0V 500ms
|
||||
{
|
||||
COM_CTRL = OFF;
|
||||
|
||||
BST_EN = 0;
|
||||
|
||||
Vox_TX_Timer++;
|
||||
|
||||
Pattern_TX_Over_Flag = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Pattern_TX_Over_Flag ) //转adt模式,用于后续识别耳机出入仓检测
|
||||
{
|
||||
Pattern_TX_Over_Flag = 0;
|
||||
|
||||
COM_CTRL = ON;
|
||||
|
||||
Vox_Vout_Enable = OFF;
|
||||
|
||||
VOX_EN_Type(VOX_ADT_Mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !Get_CHIP_STA1_Flag )
|
||||
{
|
||||
Get_CHIP_STA1_Flag = 1;
|
||||
|
||||
CHIP_STA1_BK = CHIP_STA1 & 0xA0; //获取耳机loadon状态
|
||||
}
|
||||
}
|
||||
|
||||
if( Get_CHIP_STA1_Flag )
|
||||
{
|
||||
/*耳机出入盒判断*/
|
||||
if( CHIP_STA1_BK != (CHIP_STA1 & 0xA0) ) //查询耳机loadon状态,loadon状态改变,则说明有耳机出入盒。
|
||||
{
|
||||
Earphone_Chg_Flag = 1;
|
||||
|
||||
LED_On_Timer = 0;
|
||||
|
||||
CHIP_STA1_BK = CHIP_STA1 & 0xA0;
|
||||
}
|
||||
|
||||
#if KEY_ENABLE
|
||||
/*开盖状态下,长按按键8s,则VOX发送数据:55 AA 02 06 DD BA*/
|
||||
if( Key_Press_ll_irq )
|
||||
{
|
||||
if( Vox_Output_Debounce < 10 )
|
||||
{
|
||||
if( (Vox_Output_Debounce % Vox_TX_Interval == 0) )
|
||||
{
|
||||
Vox_TX_Machine();
|
||||
}
|
||||
|
||||
Vox_Output_Debounce++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Key_Press_ll_irq = 0;
|
||||
|
||||
Vox_Output_Debounce = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( Cover_Close_Flag )
|
||||
{
|
||||
/*跟随充说明:
|
||||
1、关盖后初始化Boost输出5V,IOFF 20mA;
|
||||
*/
|
||||
#if VOX_FOLLOW_CHG
|
||||
|
||||
if( Boost_VoxVout_Follow_Flag )
|
||||
{
|
||||
if ( CHIP_STA1 & 0x0C ) //是否存在IOFF标志,存在,则Boost上升一个step,否则,Boost下降一个step。
|
||||
{
|
||||
Boost_Vout_Value += 1; //Boost 输出上升一个step
|
||||
|
||||
Boost_Up_Flag = 1;
|
||||
|
||||
if( Boost_Vout_Value >= BOOST_VOUT_MAX ) //Boost输出达到电压上限值,则结束跟随充。
|
||||
{
|
||||
Boost_Vout_Value = BOOST_VOUT_MAX;
|
||||
|
||||
Boost_VoxVout_Follow_Flag = 0;
|
||||
|
||||
SFRADDR = VOX_CON0; //IOFF选择低电流档2/3/4/5mA
|
||||
SFRDATA &= ~0x20;
|
||||
|
||||
SFRADDR = VOX_CON2;
|
||||
SFRDATA &= ~0xC0;
|
||||
SFRDATA |= 0x40; //IOFF 3mA
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !Boost_Up_Flag ) //只在初始化找最低轻载电压时执行
|
||||
{
|
||||
Boost_Vout_Value -= 1; //Boost 输出下降一个step
|
||||
if( Boost_Vout_Value <= 0 )
|
||||
{
|
||||
Boost_Vout_Value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SFRADDR = BST_CTL0; //Boost 输出
|
||||
SFRDATA |= Boost_Vout_Value;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
if( ( (CHIP_STA1 & 0xAC) == 0xAC ) || F_batlevel_low ) //耳机充满或盒子低电,则关闭Vout输出通路,关闭Boost。
|
||||
{
|
||||
if( Vox_Vol_Hold_Timer < VOX_VOUT_5V_LEAST_CNT ) //重载转轻载延时5s后关闭Boost输出。
|
||||
{
|
||||
Vox_Vol_Hold_Timer++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
BST_EN = 0;
|
||||
|
||||
VOX_EN_Type(VOX_ADT_Mode);
|
||||
|
||||
Vox_Vout_Enable = OFF;
|
||||
|
||||
COM_CTRL = OFF; //关MOS管,节省功耗。
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VOX_TX
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Vox_TX_Machine(void)
|
||||
*
|
||||
* Description : Vor Detect:耳机识别。 (100ms调用周期)
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void Vox_TX_Machine(void)
|
||||
{
|
||||
uint8_t tx_pData[7] = 0;
|
||||
|
||||
tx_pData[0] = 0x55;
|
||||
|
||||
tx_pData[1] = 0xAA;
|
||||
|
||||
tx_pData[2] = 0x02;
|
||||
|
||||
tx_pData[3] = 0x06;
|
||||
|
||||
tx_pData[4] = 0xDD;
|
||||
|
||||
tx_pData[5] = 0xBA;
|
||||
|
||||
COM_CTRL = OFF; //VOX切换到通讯TX功能模式(3.3V)。
|
||||
|
||||
SFRADDR = P0_PU;
|
||||
SFRDATA = 0x03;
|
||||
|
||||
SFRADDR = MFP_CTL0;
|
||||
SFRDATA |= 0x04; //P01 as UART's TX
|
||||
|
||||
Uart0SendPacket(7, tx_pData); //多加一个字节发送,后面要设置TX为GPIO,会导致最后一个字节没来得及发出去。
|
||||
|
||||
SFRADDR = MFP_CTL0; //Set P01 Pinmux As GPIO Function
|
||||
SFRDATA &= ~0x0C;
|
||||
|
||||
SFRADDR = P0_PD;
|
||||
SFRDATA &= ~0x03;
|
||||
|
||||
COM_CTRL = ON;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
96
UsrSrc/watchdog/watchdog.c
Normal file
96
UsrSrc/watchdog/watchdog.c
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @file watchdog.c
|
||||
* @brief watchdog module
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @date 2022/08/04 15:00:40
|
||||
* @author Alex Xu
|
||||
*
|
||||
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
|
||||
* All Rights Reserved
|
||||
*
|
||||
* History:
|
||||
* Revision Date Author Desc
|
||||
* 1.0.0 2022/08/04 Alex build this file
|
||||
******************************************************************************/
|
||||
/*_____ I N C L U D E S ____________________________________________________*/
|
||||
#include "watchdog.h"
|
||||
#if 0
|
||||
/*_____ D E F I N I T I O N S ______________________________________________*/
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
/*_____ F U N C T I O N S __________________________________________________*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Watchdog_Init(uint8_t watchdog_time)
|
||||
*
|
||||
* Description : watchdog Initialization. WDT_TM = 0,则看门狗时钟为系统时钟的12分频,否则为系统时钟。
|
||||
wdtrel.7=1 则看门狗计数器时钟为Sys_Fre/12*32,wdtrel.7=0 则看门狗计数器时钟为Sys_Fre/12*2.
|
||||
Sys_Fre = 12MHz,wdtrel.7=0时,定时器范围:
|
||||
(1/Sys_Fre)*12*2*256~(1/Sys_Fre)*12*2*256*128 = 5ms~65ms
|
||||
|
||||
Sys_Fre = 12MHz,wdtrel.7=1时,定时器范围:
|
||||
(1/Sys_Fre)*12*32*256~(1/Sys_Fre)*12*32*256*128 = 80ms~1s
|
||||
*
|
||||
* Arguments :
|
||||
|
||||
* Returns :
|
||||
|
||||
* Notes :
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void Watchdog_Init(uint8_t watchdog_time)
|
||||
{
|
||||
switch(watchdog_time)
|
||||
{
|
||||
case _WDT_TIME_65ms_:
|
||||
WDTREL = 0x00; //WDTPS = 0,wdt_f = wdt_f1/2;WDTPS = 1,wdt_f = wdt_f1/32;
|
||||
break;
|
||||
case _WDT_TIME_1s_:
|
||||
WDTREL = 0x80; //WDTPS = 0,wdt_f = wdt_f1/2;WDTPS = 1,wdt_f = wdt_f1/32;
|
||||
break;
|
||||
}
|
||||
SWDT = 1; //Watchdog Start
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Watchdog_Clear(void)
|
||||
*
|
||||
* Description : Feed watchdog 在系统初始化时未进行看门狗初始化,则不能在程序中进行喂狗操作!!!
|
||||
*
|
||||
* Arguments :
|
||||
|
||||
* Returns :
|
||||
|
||||
* Notes :
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void Watchdog_Clear(void)
|
||||
{
|
||||
WDT = 1;
|
||||
SWDT = 1;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user