SY8834 JLAB客户JS07项目源代码。
This commit is contained in:
commit
78a6b66c00
BIN
Out/SY883X_EVB_mcu_2024_11_27_194401.bin
Normal file
BIN
Out/SY883X_EVB_mcu_2024_11_27_194401.bin
Normal file
Binary file not shown.
203
Out/SY883X_EVB_mcu_2024_11_27_194401.hex
Normal file
203
Out/SY883X_EVB_mcu_2024_11_27_194401.hex
Normal file
@ -0,0 +1,203 @@
|
||||
:0300000002057185
|
||||
:10057100758E3075D20078FFE4F6D8FD758154028E
|
||||
:0205810005BEB5
|
||||
:0C000E00120841D2AED2BE1204DD80F711
|
||||
:08060300021600000214013789
|
||||
:0C003D00AE14AF15AB07AA06E4F9F822D8
|
||||
:0207E100AD0762
|
||||
:1007E300E4FCFBFAF51CF51D75FE2975FF8BBD06B0
|
||||
:1007F3001775FE0143FF8075A541E5A520E0FB7554
|
||||
:10080300A56175FE0153FF7FE4FCEDC454F0440180
|
||||
:10081300F5A5E5A520E0FBAFA1AB07AFA2EFFEEE88
|
||||
:10082300FAEB251DF51DEA351CF51C0CBC08DBE5B0
|
||||
:0D0833001DAE1C7803CEC313CE13D8F9FF01
|
||||
:010840002295
|
||||
:100A1C00E4FE7F051207E17C077DD012032CC00693
|
||||
:0C0A2C00C00712003DD007D00602029A5D
|
||||
:100A3800E4FE7F041207E17C037DE812032CC00664
|
||||
:0C0A4800C00712003DD007D00602029A41
|
||||
:04060B00C120C12128
|
||||
:10077600E4FFFEF51B120A38C3EF94D0EE9407404F
|
||||
:10078600037F0022D3EF942EEE94065030EF94129E
|
||||
:10079600EE94024028301E12EF9406EE940650079F
|
||||
:1007A600C21EE4F51B8003751B01301F2BD3EF948B
|
||||
:1007B60033EE9402401FC21FE4F51B801BD3EF9457
|
||||
:1007C6002EEE94064004D21E800BC3EF9412EE94D4
|
||||
:0A07D600025002D21F751B01AF1B79
|
||||
:0107E00022F6
|
||||
:10089F00E5E620E70953B3FE75F210C22022E5F218
|
||||
:1008AF00540C601053B3FEE5F354C0603A75F20C6C
|
||||
:1008BF0075F3C02275F3C030210453B3FE22E5F265
|
||||
:1008CF0030E416C3E51794D2E516940F500575F270
|
||||
:1008DF0010800353B3FED2202243B311E534D394D7
|
||||
:0808EF00014002C22AC22022CE
|
||||
:04060F00C125C1261A
|
||||
:10094D00E5E530E103C22522E5E230E705C225D217
|
||||
:10095D002622302A02802FE5E830E009C22575E80D
|
||||
:10096D000175B50122302106C225E4F5B522D22547
|
||||
:10097D00302618E5E630E713C3E5179410E5169415
|
||||
:0C098D000E4003C22622E4F5B5C225226C
|
||||
:07061300011FFFC127C128F0
|
||||
:10001E00E5E25408FF651F6015E5E230E305751E45
|
||||
:0E002E00018003E4F51ED227D228D21D8F1FB9
|
||||
:01003C0022A1
|
||||
:06061A00C117C118C11652
|
||||
:10068900E5E220E12D054BE54BC3941E40102013F4
|
||||
:100699001DD213D212301016D216D21D8010E54B7E
|
||||
:1006A900C3940F4009201406D21CD218D214D215B3
|
||||
:1006B9008019301513C215C213C214C218E54BC3F1
|
||||
:1006C90094055004D217D21DE4F54B30122FE54C96
|
||||
:1006D900D394185019E54C75F00584E5F0700C3089
|
||||
:1006E9001009D22BF512751305D22C054C22C21212
|
||||
:0D06F900754C01E51EB401057F01120A5485
|
||||
:0107060022D0
|
||||
:1008F7007850E6604D7852E6FFD318965004D284BC
|
||||
:100907008002C284EFC394AA4018E47852F6785460
|
||||
:10091700E660067851161680097853E66004785128
|
||||
:1009270006067851E6FF74AAD39F500978547601DA
|
||||
:10093700E418F6800DEFD39401500778537601E45D
|
||||
:0609470008F678520622BA
|
||||
:05062000014F0AC12D8D
|
||||
:100A8100E5E220E006201103302D04C22DC322D35C
|
||||
:010A91002242
|
||||
:1008410075FE8043FF3075FE0153FFFCD28175FEBA
|
||||
:100851000643FF1AD21D75B7C375FE6A75FF04758D
|
||||
:10086100FE6C43FF0A758901758CFC758A66D2A9F5
|
||||
:10087100D28C438910758DFF758BA4D2ABD28E7546
|
||||
:10088100868075FE0F43FF8075FE4F75FF1075FE64
|
||||
:0E0891001775FF3CD2A8D2B9D2AF75B10222C2
|
||||
:03000300020006F2
|
||||
:0100060032C7
|
||||
:03004B00020A9D09
|
||||
:060A9D0075EB3CD22D3286
|
||||
:04062500C11DC11C16
|
||||
:0B0A9200E47850F6C283C284D22D220B
|
||||
:10035900202103300A21201907D219120A92801488
|
||||
:10036900E54DD39428500B054DE54D20E006B283A9
|
||||
:100379008002C283D22D2230190DC219120A92C2EB
|
||||
:100389001AC21BD21DD21CE5E630E72830200C200A
|
||||
:100399001B05D21B120A92D2848010201A09D21A84
|
||||
:1003A900C21B120A92800478507601C217C216C283
|
||||
:1003B90028C21D22301A08C21AC21BD21DD21C30F3
|
||||
:1003C9001D08E4F54DC21D120A92302A02804D2003
|
||||
:1003D9000B0920170620160330284B301605754ED9
|
||||
:1003E9002B8003754E23E54DC394055003054D221B
|
||||
:1003F900E54DC3954E5025054D30160DE54D75F06B
|
||||
:100409000584E5F07020B2842230290DE54D75F0A0
|
||||
:100419000584E5F07010B28322D28422C217C21675
|
||||
:06042900C228C20BD21D27
|
||||
:01042F0022AA
|
||||
:1004DD00302305C22312043030222FC22212001EF7
|
||||
:1004ED0012094D12089F120689120A1C8E168F17BB
|
||||
:1004FD00120776EF24FF92217F061207E18E148FEB
|
||||
:10050D001512004E120707120359302456C224E566
|
||||
:10051D004FD394004009154F302D48C22D80411204
|
||||
:10052D000A81503CE5E230E70875FE2453FFC38095
|
||||
:10053D000675FE2443FF3CC2ABC2B9C2A953B7CF67
|
||||
:10054D00E4F5B575FE2953FF7F75FE8053FFCF434C
|
||||
:10055D00870275FE8043FF30D2B9D2A9D2AB80009D
|
||||
:04056D00754F0A229A
|
||||
:10062900C111C10BC10AC110C10FC10EC10D010D0C
|
||||
:0306390000C10CF1
|
||||
:100A5400E4F5B5EF24FF928175FE0653FFFB43FFD7
|
||||
:080A640002BF010353B7CF22CA
|
||||
:100A6C0075FE0643FF0453FFFDC28275B501BF013D
|
||||
:050A7C000343B7302226
|
||||
:10004E00E5E8540C600C75E80C53B7CF43B730D2CB
|
||||
:10005E000A22C20A202503020249302737E5B5706D
|
||||
:10006E000302019C43B730E4F50CF509F50AF50BD4
|
||||
:10007E00C200C210E51E7014C20BD201D205D20608
|
||||
:10008E00D211C202C209C208C20D8006C201D2023A
|
||||
:10009E00C204C22720020302014BE509C394025099
|
||||
:1000AE0003050922E50AC39402500AE4FF120A541A
|
||||
:1000BE00050A02014B301C11E5B5700302019CC20A
|
||||
:1000CE0000E4F50B43B730C21C200041E50CD3947D
|
||||
:1000DE00185023E50C75F00584E5F07015E5E35432
|
||||
:1000EE00A0FFBFA00DD22BC22CE53344C475120065
|
||||
:1000FE00F513050C8047E50BC394035003050B2243
|
||||
:10010E00D2007F01120A54D203C21180303003157F
|
||||
:10011E00C203E4F50BE5E354ACFFBFA004D210809C
|
||||
:10012E0016C2108012E5E354A065086010E5E35492
|
||||
:10013E00A06004D20BD21DE5E354A0F50820010304
|
||||
:10014E00020246301C18E5B5700FFF120A6CC2058C
|
||||
:10015E00C200F50AF509C2082243B730C21CE50AEF
|
||||
:10016E00C3940A5003050A222005097F01120A547E
|
||||
:10017E00D2058013200010E5E354ACFFBFA004D2DB
|
||||
:10018E00108002C210D20020060DE5B57004FF02E9
|
||||
:10019E000A6C43B730D206300903020228200D192B
|
||||
:1001AE00750D03C20C75FE6A43FF2075FE6C53FF7E
|
||||
:1001BE003F43FF80D20D020246E509C3940A500365
|
||||
:1001CE00050922E4F509E5E3540C6025050DD20C72
|
||||
:1001DE00C3E50D648094824029750D02C20DD209CB
|
||||
:1001EE0075FE6A53FFDF75FE6C53FF3F43FF408081
|
||||
:1001FE0011200C0E150DD3E50D648094805003E490
|
||||
:10020E00F50D75FE8F75FF6975FE7853FFFCE50DD4
|
||||
:10021E0042FF75FE8F75FF01801E20081BE5E3541B
|
||||
:10022E00ACFFBFAC13E509C394325003050922D2CB
|
||||
:10023E0008C2117F01120A54C20722200711D207E9
|
||||
:0F024E00C2117F01120A54E5E354A0F508D21C37
|
||||
:01025D00227E
|
||||
:10063C00013400013300C129C12A01326416350C82
|
||||
:10064C00800DAC0E100E740ED80F3C0F6E0FA01058
|
||||
:10065C0004103610680B270A181A202228292A3071
|
||||
:02066C00313229
|
||||
:10070700E4FFEF25E02435F8E6FC08E6FDC3E5172E
|
||||
:100717009DE5169C40040FBF0BE8E5E16005E4F595
|
||||
:10072700E18F34EFD395344004053280021532E56A
|
||||
:1007370032D394BE5007E532C3940A50158F34E57F
|
||||
:10074700266534600A74272FF8E6F5338534267555
|
||||
:100757003264E534D394005002D22AE534D39402AC
|
||||
:0E0767005003D22922E534D394044002C22963
|
||||
:010775002261
|
||||
:0F066E00011900011800011A00C123C122C12483
|
||||
:03000B000209DE09
|
||||
:1009DE00C0E0C0D074FC258CF58C7466258AF58A2F
|
||||
:1009EE00D2230518E518C394644005751800D22269
|
||||
:1009FE000519E519C394FA4010751900051AE51A80
|
||||
:0E0A0E0094044005751A00D224D0D0D0E032F6
|
||||
:03001B000209993E
|
||||
:10099900C0E0C0F0C083C082C0D075D000C000C024
|
||||
:1009A90001C002C003C004C005C006C007C28F153C
|
||||
:1009B9008D74A4258BF58B1208F7D007D006D005C6
|
||||
:1009C900D004D003D002D001D000D0D0D082D083BF
|
||||
:0509D900D0F0D0E03277
|
||||
:030BFD00010102F1
|
||||
:0B067D00C12B01110002120000C12C73
|
||||
:10043000202B030204DC0510E511702EE510D39487
|
||||
:100440003750028015E510D3944B50077F01120AF4
|
||||
:100450006C8017E510C3945F5007E4FF120A5480C4
|
||||
:1004600009751101302C03750E04E511B4012B152B
|
||||
:100470000EE50ED394074008750E0875110380032E
|
||||
:10048000751102E513AE12A80E088005CEC313CE77
|
||||
:1004900013D8F95401F50FE4F510E511B40211E594
|
||||
:1004A00010C394145006E50F601F801175110122CE
|
||||
:1004B000E51164037026E510C3941450057F010212
|
||||
:1004C0000A6CE510C394285005E4FF020A547F012A
|
||||
:0C04D000120A6CE4F510C22BC22CF511CE
|
||||
:0104DC0022FD
|
||||
:1005830002000EE493A3F8E493A34003F68001F280
|
||||
:1005930008DFF48029E493A3F85407240CC8C33379
|
||||
:1005A300C4540F4420C8834004F456800146F6DF48
|
||||
:1005B300E4800B0102040810204080900603E47ECF
|
||||
:1005C300019360BCA3FF543F30E509541FFEE4933D
|
||||
:1005D300A360010ECF54C025E060A840B8E493A304
|
||||
:1005E300FAE493A3F8E493A3C8C582C8CAC583CA2F
|
||||
:1005F300F0A3C8C582C8CAC583CADFE9DEE780BEE7
|
||||
:010688000071
|
||||
:10025E0075F008758200EF2FFFEE33FECD33CDCC57
|
||||
:10026E0033CCC58233C5829BED9AEC99E5829840DA
|
||||
:10027E000CF582EE9BFEED9AFDEC99FC0FD5F0D6B7
|
||||
:10028E00E4CEFBE4CDFAE4CCF9A88222B800C1B9E1
|
||||
:10029E000059BA002DEC8BF084CFCECDFCE5F0CB1F
|
||||
:1002AE00F97818EF2FFFEE33FEED33FDEC33FCEB58
|
||||
:1002BE0033FB10D703994004EB99FB0FD8E5E4F913
|
||||
:1002CE00FA227818EF2FFFEE33FEED33FDEC33FC00
|
||||
:1002DE00C933C910D7059BE99A4007EC9BFCE99AF4
|
||||
:1002EE00F90FD8E0E4C9FAE4CCFB2275F010EF2F39
|
||||
:1002FE00FFEE33FEED33FDCC33CCC833C810D70739
|
||||
:10030E009BEC9AE899400AED9BFDEC9AFCE899F873
|
||||
:0E031E000FD5F0DAE4CDFBE4CCFAE4C8F92206
|
||||
:10032C00EC8EF0A4CCC5F0CCCDF8EFA4CEC5F02D5E
|
||||
:10033C00FDE43CFCE8A42EC8C5F03DFDE43CFCEF1C
|
||||
:0D034C00A4FFE5F028FEE43DFDE43CFC22AA
|
||||
:00000001FF
|
BIN
Out/SY883X_EVB_mcu_2024_11_27_194401_crc(8a94)_V010102.bin
Normal file
BIN
Out/SY883X_EVB_mcu_2024_11_27_194401_crc(8a94)_V010102.bin
Normal file
Binary file not shown.
1878
Project/TP3102_Demo.uvgui.Alex-xu
Normal file
1878
Project/TP3102_Demo.uvgui.Alex-xu
Normal file
File diff suppressed because one or more lines are too long
3655
Project/TP3102_Demo.uvgui.GH
Normal file
3655
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
478
Project/TP3102_Demo.uvopt
Normal file
478
Project/TP3102_Demo.uvopt
Normal file
@ -0,0 +1,478 @@
|
||||
<?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>1</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>
|
||||
<Ww>
|
||||
<count>5</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>F_sys_tim_250ms</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>0</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>1</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>2</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
|
10
TP3310_Demo.si4project/TP3310_Demo.SearchResults
Normal file
10
TP3310_Demo.si4project/TP3310_Demo.SearchResults
Normal file
@ -0,0 +1,10 @@
|
||||
---- Key_Press_ll_irq_led Matches (9 in 3 files) ----
|
||||
key.c (UsrSrc\key) line 35 : bit Key_Press_ll_irq_led = 0;
|
||||
Key_Handler in key.c (UsrSrc\key) : Key_Press_ll_irq_led = 1;
|
||||
key.h (UsrInc\key) line 28 : extern bit Key_Press_ll_irq_led;
|
||||
LED_Display_App in userapp.c (UsrSrc\userapp) : Key_Press_ll_irq_led = 0;
|
||||
LED_Display_App in userapp.c (UsrSrc\userapp) : Key_Press_ll_irq_led = 0;
|
||||
LED_Display_App in userapp.c (UsrSrc\userapp) : if( (Earphone_Chg_Flag || Key_Press_irq || Key_Press_ll_irq_led || CoverEvent_Flg_led) ) //耳机出入盒、按键触发,显示灯效
|
||||
LED_Display_App in userapp.c (UsrSrc\userapp) : if( Key_Press_ll_irq_led )
|
||||
LED_Display_App in userapp.c (UsrSrc\userapp) : if( Key_Press_ll_irq_led )
|
||||
LED_Display_App in userapp.c (UsrSrc\userapp) : Key_Press_ll_irq_led = 0;
|
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.
72
UsrDoc/HEXBIN.bat
Normal file
72
UsrDoc/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
UsrDoc/KEIL5环境配置说明.doc
Normal file
BIN
UsrDoc/KEIL5环境配置说明.doc
Normal file
Binary file not shown.
BIN
UsrDoc/SY883XA嵌入式系统开发说明(徐少辉)202408-pm.pptx
Normal file
BIN
UsrDoc/SY883XA嵌入式系统开发说明(徐少辉)202408-pm.pptx
Normal file
Binary file not shown.
BIN
UsrDoc/SY883X软件开发说明文档.doc
Normal file
BIN
UsrDoc/SY883X软件开发说明文档.doc
Normal file
Binary file not shown.
BIN
UsrDoc/SY883x项目软件开发功能需求表V1.0_20240826.xlsx
Normal file
BIN
UsrDoc/SY883x项目软件开发功能需求表V1.0_20240826.xlsx
Normal file
Binary file not shown.
BIN
UsrDoc/TP3310DEMO_UI.docx
Normal file
BIN
UsrDoc/TP3310DEMO_UI.docx
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/上位机/DownLoad_Tools(v4.0)-20240718(pm).exe
Normal file
BIN
UsrDoc/上位机/DownLoad_Tools(v4.0)-20240718(pm).exe
Normal file
Binary file not shown.
BIN
UsrDoc/上位机/驱动/CH340驱动/ch341ser.exe
Normal file
BIN
UsrDoc/上位机/驱动/CH340驱动/ch341ser.exe
Normal file
Binary file not shown.
BIN
UsrDoc/上位机/驱动/NI-VISA/ni-visa_19.5_online_repack(1).exe
Normal file
BIN
UsrDoc/上位机/驱动/NI-VISA/ni-visa_19.5_online_repack(1).exe
Normal file
Binary file not shown.
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/数码管/188.docx
Normal file
BIN
UsrDoc/数码管/188.docx
Normal file
Binary file not shown.
BIN
UsrDoc/数码管/SD-35C03BW-10.28 共阳(1).pdf
Normal file
BIN
UsrDoc/数码管/SD-35C03BW-10.28 共阳(1).pdf
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.
54
UsrInc/adc/adc.h
Normal file
54
UsrInc/adc/adc.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
#if ADC_ENABLE
|
||||
|
||||
#define VREF 1000
|
||||
|
||||
extern uint16_t Vbat_Adc;
|
||||
extern uint16_t Vref_Adc;
|
||||
|
||||
extern uint16_t Vbat_Value(void);
|
||||
|
||||
typedef enum {
|
||||
ADC_CH0 = 0x00,
|
||||
ADC_CH1,
|
||||
ADC_CH2,
|
||||
ADC_CH3,
|
||||
ADC_CH4,
|
||||
ADC_BAT,
|
||||
ADC_VREF,
|
||||
}ADC_CHANNELS_E;
|
||||
|
||||
#ifdef NTC_ENABLE
|
||||
extern uint16_t ADC_NTC_Value(void);
|
||||
#endif
|
||||
|
||||
extern uint16_t ADC_Chn_Data(ADC_CHANNELS_E adc_chn);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
55
UsrInc/bat/bat.h
Normal file
55
UsrInc/bat/bat.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
#define C_bat_level_protect 0
|
||||
#define C_bat_level_lowpower 2
|
||||
|
||||
|
||||
extern uint8_t bat_level;
|
||||
extern uint8_t bat_level_pdata;
|
||||
|
||||
extern bit F_batlevel_low; //电池低压
|
||||
|
||||
#if BAT_VALUE
|
||||
|
||||
#if LED_DISPLAY
|
||||
|
||||
/*电池电量档位:25%一个档位。*/
|
||||
|
||||
#define BAT_LEVEL_25 3
|
||||
#define BAT_LEVEL_50 4
|
||||
#define BAT_LEVEL_75 5
|
||||
#define BAT_LEVEL_100 6
|
||||
#endif
|
||||
|
||||
extern bit F_batlevel_protect; //低电保护
|
||||
|
||||
|
||||
extern void check_bat_level(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
57
UsrInc/charger/charger_module.h
Normal file
57
UsrInc/charger/charger_module.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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"
|
||||
|
||||
extern bit Charger_Done;
|
||||
|
||||
//#ifdef NTC_ENABLE
|
||||
extern bit NTC_Pro_Flag;
|
||||
//#endif
|
||||
#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
|
||||
|
46
UsrInc/discharge/discharge_module.h
Normal file
46
UsrInc/discharge/discharge_module.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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
|
||||
|
||||
extern bit gBoost_Opened_Flag; //Boost已正常开启。
|
||||
|
||||
#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
|
||||
|
||||
|
77
UsrInc/gpio_comm/gpio_comm.h
Normal file
77
UsrInc/gpio_comm/gpio_comm.h
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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"
|
||||
|
||||
extern bit Pattern_TX_Start;
|
||||
|
||||
#if VOX_TX_PATTERN
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
sbit PATTERN_TX = P0^1;
|
||||
|
||||
#define START_LOW_55MS_TIM 55
|
||||
#define START_HIGH_20MS_TIM 20
|
||||
#define START_LOW_20MS_TIM 20
|
||||
|
||||
//#define PATTERN_TX_ON() COM_CTRL_ON()
|
||||
//#define PATTERN_TX_OFF() COM_CTRL_OFF()
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
|
||||
extern uint16_t Pattern_TX_Data;
|
||||
|
||||
extern uint8_t Gpio_TX_Steps;
|
||||
|
||||
extern bit g_Key_Type;
|
||||
|
||||
typedef enum {
|
||||
//GPIO_TX_STEPS_NONE = 0,
|
||||
GPIO_TX_STEPS_START = 0,
|
||||
GPIO_TX_STEPS_BIT_SYC,
|
||||
GPIO_TX_STEPS_DATA,
|
||||
GPIO_TX_STEPS_STOP,
|
||||
}e_Gpio_Comm_Step;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
extern void Vout_Ctrl_OFF(uint8_t Type);
|
||||
|
||||
extern void Vout_Ctrl_ON(uint8_t Type);
|
||||
|
||||
extern void Gpio_Comm(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
45
UsrInc/hall/hall.h
Normal file
45
UsrInc/hall/hall.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
#ifdef HALL_ENABLE
|
||||
|
||||
typedef enum{
|
||||
|
||||
CLOSE = 0,
|
||||
OPEN = !CLOSE
|
||||
|
||||
} CoverStatus_E;
|
||||
|
||||
extern CoverStatus_E CoverStatus;
|
||||
|
||||
extern bit CoverEvent_Flg;
|
||||
extern bit CoverEvent_Flg_led;
|
||||
|
||||
extern void Hall_Handler(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
187
UsrInc/inc/config.h
Normal file
187
UsrInc/inc/config.h
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 4050 //电池复充电压:4200mv - 135mv = 4075mv
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
/*20uA 电流源下接 104K NTC(4250K) 电阻并联一个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_5C 1260
|
||||
|
||||
#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
|
||||
#else
|
||||
/*20uA 电流源下接 104K NTC(4250K) 电阻并联一个100K电阻后得到的电压值*/
|
||||
#define T_N20C 1840 //-20℃(92KΩ * 20uA) NTC:1151K
|
||||
|
||||
#define T_N15C 1788 //-15℃(89.4KΩ * 20uA) NTC:846K
|
||||
|
||||
#define T_N10C 1724 //-10℃(86.2KΩ * 20uA) NTC:629K
|
||||
|
||||
#define T_N1C 1582
|
||||
|
||||
#define T_0C 1562 //-0℃(78.1KΩ * 20uA) NTC:357K
|
||||
|
||||
#define T_2C 1542
|
||||
|
||||
#define T_3C 1502 //3℃(75.1KΩ * 20uA) NTC:303K
|
||||
|
||||
#define T_4C 1582
|
||||
|
||||
#define T_5C 1462 //5℃(73.1KΩ * 20uA) NTC:272K
|
||||
|
||||
#define T_8C 1396 //8℃(69.8KΩ * 20uA) NTC:232K
|
||||
|
||||
#define T_10C 1354 //10℃(67.7KΩ * 20uA) NTC:209.7K
|
||||
|
||||
#define T_12C 1308 //12℃(65.4KΩ * 20uA) NTC:189K
|
||||
|
||||
#define T_15C 1236 //15℃(61.8KΩ * 20uA) NTC:162K
|
||||
|
||||
#define T_18C 1166 //15℃(58.3KΩ * 20uA) NTC:140K
|
||||
|
||||
#define T_42C 634 //42℃(31.7KΩ * 20uA) NTC:46.5K
|
||||
|
||||
#define T_45C 580 //45℃(29 KΩ * 20uA) NTC:40.9K
|
||||
|
||||
#define T_46C 563
|
||||
|
||||
#define T_47C 546 //47℃(27.3KΩ * 20uA) NTC:37.6K
|
||||
|
||||
#define T_48C 530
|
||||
|
||||
#define T_57C 400 //57℃(20 KΩ * 20uA) NTC:25K
|
||||
|
||||
#define T_60C 362 //60℃(18.1KΩ * 20uA) NTC:22.2K
|
||||
|
||||
#define T_75C 222 //75℃(11.1KΩ * 20uA) NTC:12.6K
|
||||
|
||||
#define T_80C 192 //80℃(9.6KΩ * 20uA) NTC:10.6K
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
/*20uA 电流源下接 104K NTC(3950K) 电阻并联一个82K电阻后得到的电压值*/
|
||||
#define T_N20C 1500 //-20℃(75.5KΩ * 20uA) NTC:953K
|
||||
|
||||
#define T_N17C 1488 //-17℃(74.4KΩ * 20uA) NTC:804K
|
||||
|
||||
#define T_N15C 1495 //-15℃(73.6KΩ * 20uA) NTC:719K
|
||||
|
||||
#define T_N13C 1454 //-13℃(72.7KΩ * 20uA) NTC:644K
|
||||
|
||||
#define T_N10C 1420 //-10℃(71KΩ * 20uA) NTC:547K
|
||||
|
||||
#define T_0C 1308 //-0℃(65.4KΩ * 20uA) NTC:325K
|
||||
|
||||
#define T_3C 1282 //3℃(64.1KΩ * 20uA) NTC:293K
|
||||
|
||||
#define T_5C 1238 //5℃(61.9KΩ * 20uA) NTC:253K
|
||||
|
||||
#define T_8C 1192 //8℃(59.6KΩ * 20uA) NTC:218K
|
||||
|
||||
#define T_10C 1158 //10℃(57.9KΩ * 20uA) NTC:198K
|
||||
|
||||
#define T_12C 1126 //12℃(56.3KΩ * 20uA) NTC:180K
|
||||
|
||||
#define T_15C 1076 //15℃(53.8KΩ * 20uA) NTC:157K
|
||||
|
||||
#define T_18C 1026 //18℃(51.3KΩ * 20uA) NTC:137K
|
||||
|
||||
#define T_42C 612 //42℃(30.6KΩ * 20uA) NTC:49K
|
||||
|
||||
#define T_45C 568 //45℃(28.4KΩ * 20uA) NTC:43.6K
|
||||
|
||||
#define T_47C 538 //47℃(26.9KΩ * 20uA) NTC:40K
|
||||
|
||||
#define T_57C 412 //57℃(20.6KΩ * 20uA) NTC:27.6K
|
||||
|
||||
#define T_60C 380 //60℃(19KΩ * 20uA) NTC:24.7K
|
||||
|
||||
#define T_75C 248 //75℃(12.4KΩ * 20uA) NTC:14.6K
|
||||
|
||||
#define T_80C 216 //80℃(10.8KΩ * 20uA) NTC:12.4K
|
||||
|
||||
#endif
|
||||
/*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
|
||||
|
149
UsrInc/inc/define.h
Normal file
149
UsrInc/inc/define.h
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 0x02 //程序版本2:代表在软件调试出现不同的测试版本时改动时加1
|
||||
|
||||
/* 芯片类型选择:SY8836合封OVP芯片 */
|
||||
//#define SY8836
|
||||
|
||||
/*Function Select,功能选择宏定义*/
|
||||
|
||||
/*VOX充放电功能选择:1、开关盖VOX充放电;2、Vox耳机插拔自适应充放电。二者只能选一。*/
|
||||
|
||||
#define VOX_ADT_ENABLE 1 //Vox自适应充放电,不带Hall(自选)(禁用KEY、HALL功能)486Bytes
|
||||
|
||||
/* 灯效功能选择;1、188数码管;2、4颗LED;3、呼吸灯 三者只能选一。选择LED显示,不需要Timer1。*/
|
||||
|
||||
#define LED_DISPLAY 1 //LED显示,3个灯显示,带呼吸 (814Bytes),具体灯个数和灯效需要在对应源码中选择更改。
|
||||
|
||||
/*呼吸灯功能,需要使用Timer1。*/
|
||||
|
||||
#if LED_DISPLAY
|
||||
|
||||
#define TIMER1_ENABLE
|
||||
|
||||
#define BREATHING_LIGHT //呼吸灯功能(自选),驱动函数置于Timer1中断处理函数中,调用周期100us,具体灯个数和灯效需要在对应源码中选择更改。
|
||||
|
||||
#endif
|
||||
|
||||
/* 公共功能选择宏定义,其中自选部分根据需求选择,必选部分勿动。 (其中需要调整参数的可在System_Init()中进行配置。)*/
|
||||
|
||||
#define VOX_ENABLE 1 //Vox功能配置(必选)
|
||||
|
||||
//#define VOX_TX //Vox发码功能(545Bytes)
|
||||
|
||||
#define UART0_ENABLE 0 //UART0功能,用于程序调试(自选)。(85Bytes)
|
||||
|
||||
#define WTG_ENABLE 1 //看门狗功能使能(必选)(7Bytes)
|
||||
|
||||
#define HALL_ENABLE //Hall功能(自选)(35Bytes)
|
||||
|
||||
#define KEY_ENABLE //Key功能(自选)(78Bytes)
|
||||
|
||||
#define CHARGER_ENABLE 1 //Charger功能(必选) 231Bytes
|
||||
|
||||
#define DISCHARGE_ENABLE 1 //Boost放电功能(必选)93Bytes
|
||||
|
||||
#define VOX_TX_PATTERN 1 //GPIO Pattern (227Bytes)
|
||||
|
||||
#define VOX_FOLLOW_CHG 1 //VOX跟随充(自选)ADT:356Bytes,HALL:165Bytes
|
||||
|
||||
#define SLEEP_ENABLE 1 //休眠功能(必选)91Bytes
|
||||
|
||||
#define ADC_ENABLE 1 //ADC功能(必选)476Bytes
|
||||
|
||||
#if ADC_ENABLE
|
||||
#define NTC_ENABLE //NTC保护功能(自选)298Bytes
|
||||
#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
|
||||
|
64
UsrInc/key/key.h
Normal file
64
UsrInc/key/key.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
extern bit Key_Press_irq;
|
||||
|
||||
extern bit Key_Press_ll_irq_led;
|
||||
|
||||
extern bit Key_Press_ll_irq;
|
||||
|
||||
extern bit Pattern_TX_Flag;
|
||||
|
||||
#define Vox_TX_Pattern_Tim 24
|
||||
|
||||
#define Vox_TX_Interval 5 //Vox¶¨Ê±·¢ËÍÖ¸Áîʱ¼ä¼ä¸ô
|
||||
|
||||
#ifdef KEY_ENABLE
|
||||
|
||||
//extern bit Key_Press_short_irq;
|
||||
//extern bit Key_Press_short_irq1;
|
||||
|
||||
//extern bit Key_Press_l_irq;
|
||||
//extern bit Key_Press_ll_irq;
|
||||
|
||||
//extern bit Key_l_Flag;
|
||||
|
||||
#if 0
|
||||
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;
|
||||
#endif
|
||||
extern void Key_Handler(void );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
94
UsrInc/led/led.h
Normal file
94
UsrInc/led/led.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
#if LED_DISPLAY
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
// LED端口定义
|
||||
sbit pin_LED_1 = P0^3;
|
||||
#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_3 = P0^4;
|
||||
#define LEDB_ON() pin_LED_3 = 1 //LED_3_ON()
|
||||
#define LEDB_OFF() pin_LED_3 = 0 //LED_3_OFF()
|
||||
#define LEDB_TOG() pin_LED_3 = !pin_LED_3 //LED_3_RUN()
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Typedef definitions
|
||||
\******************************************************************************/
|
||||
//LED名称重定义,顺序和上方的宏定义保持一致
|
||||
enum LED_ID
|
||||
{
|
||||
LED_R,
|
||||
LED_B,
|
||||
LED_ID_MAX
|
||||
};
|
||||
|
||||
#ifdef BREATHING_LIGHT
|
||||
|
||||
//LED呼吸灯控制结构体
|
||||
typedef struct{
|
||||
|
||||
uint8_t Breathing_Light_On; //呼吸灯使能标志位。
|
||||
uint8_t BL_Flash_Duty; //LED占空比,即点亮时间
|
||||
uint8_t BL_Timer; //时间计数 100us计数一次
|
||||
uint8_t Flash_Duty_Rising; //呼吸灯逐亮标志
|
||||
uint8_t Flash_Duty_Declining; //呼吸灯逐暗标志
|
||||
|
||||
}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
|
||||
|
35
UsrInc/sleep/sleep.h
Normal file
35
UsrInc/sleep/sleep.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
#if SLEEP_ENABLE
|
||||
|
||||
extern uint8_t Decnt_SleepDelay;
|
||||
extern bit Enter_Sleep_Cnt_Restart_Flag;
|
||||
|
||||
extern bit Check_Require_Sleep(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
42
UsrInc/system/system.h
Normal file
42
UsrInc/system/system.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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__
|
||||
|
||||
#include "define.h"
|
||||
/*中断号计算方式:中断向量 = 中断号 * 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中断
|
||||
|
||||
extern bit System_Init_Flag;
|
||||
|
||||
extern void System_Init(void);
|
||||
|
||||
#endif
|
||||
|
60
UsrInc/timer/sys_tim.h
Normal file
60
UsrInc/timer/sys_tim.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
//#define FOSC 11059200L
|
||||
|
||||
#define T1MS 921
|
||||
#define T100uS 91
|
||||
#define T200uS 183
|
||||
#define T300uS 275
|
||||
#define T400uS 368
|
||||
#define T500uS 460
|
||||
#define T600uS 552
|
||||
#define T800uS 736
|
||||
|
||||
#define T10MS 9215 //FOSC/12/100
|
||||
|
||||
#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
|
||||
|
||||
#ifdef TIMER1_ENABLE
|
||||
|
||||
#ifdef BREATHING_LIGHT
|
||||
|
||||
#define C_TIM1_Reload (65535 - T100uS) //100us
|
||||
|
||||
#endif
|
||||
extern bit F_sys_tim1_tick;
|
||||
extern void Sys_Tim1_Init(void );
|
||||
|
||||
#endif
|
||||
|
||||
extern bit F_sys_tim_1ms;
|
||||
extern bit F_sys_tim_250ms;
|
||||
|
||||
extern bit F_sys_tim_100ms;
|
||||
extern bit F_sys_tim_1s;
|
||||
|
||||
#endif
|
||||
|
50
UsrInc/uart/uart.h
Normal file
50
UsrInc/uart/uart.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
#define Baud_Rate0 9600//115200//19200//38400//93750
|
||||
#define S0REL_VALUE (1024-345600/Baud_Rate0)
|
||||
#define COM0_Data_Lenth 7
|
||||
|
||||
#ifdef _DEBUG_ALL
|
||||
|
||||
extern char putchar (char ch);
|
||||
|
||||
#endif
|
||||
|
||||
#if UART0_ENABLE
|
||||
|
||||
#ifdef VOX_RX
|
||||
|
||||
extern idata uint8_t RX0_Buffer[COM0_Data_Lenth]; //?¨®¨º??o3?
|
||||
|
||||
extern bit Uart0_RX_Finish_Flag;
|
||||
|
||||
#endif
|
||||
extern void Uart0SendPacket(uint8_t Length,uint8_t *TransBuf);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
39
UsrInc/userapp/userapp.h
Normal file
39
UsrInc/userapp/userapp.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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"
|
||||
|
||||
#define BAT_LEVEL_LOW 20 //电池电量低报警值
|
||||
|
||||
//extern uint8_t LED_On_Timer; //led亮时间计时
|
||||
|
||||
//extern bit Bat_Lev_LED_4s_Flag;
|
||||
extern bit Bat_Lev_Disp_Flag;
|
||||
extern bit Init_LED_Disp_Flag;
|
||||
extern bit LED_On_Flag;
|
||||
|
||||
extern bit Wkup_Earphone_Flag;
|
||||
extern void UserAPP(void);
|
||||
|
||||
#endif
|
||||
|
146
UsrInc/vox/vox_module.h
Normal file
146
UsrInc/vox/vox_module.h
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
sbit COM_CTRL = P0^2;
|
||||
|
||||
sbit COM_TX = P0^1;
|
||||
|
||||
//extern uint8_t Vox_TX_Timer; //VOX发送指令持续时间计数,在Hall_Handler检测中清0.
|
||||
extern bit Earphone_Chg_Flag; //耳机出入盒标志位
|
||||
extern bit Vox_Output_Short_Flag;
|
||||
extern bit Vox_Vout_Enable;
|
||||
extern bit Earphone_Num_2Inbox; //双耳机在盒标志位
|
||||
|
||||
#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 VOX_LIGHT_TO_HAVEY_1 0x00
|
||||
#define VOX_LIGHT_TO_HAVEY_8 0x01
|
||||
#define VOX_LIGHT_TO_HAVEY_128 0x02
|
||||
#define VOX_LIGHT_TO_HAVEY_256 0x03
|
||||
|
||||
#define VOX_HAVEY_TO_LIGHT_0_125 0x00
|
||||
#define VOX_HAVEY_TO_LIGHT_1 0x01
|
||||
#define VOX_HAVEY_TO_LIGHT_8 0x02
|
||||
#define VOX_HAVEY_TO_LIGHT_64 0x03
|
||||
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
extern bit Cover_Open_Flag;
|
||||
|
||||
/*耳机和充电仓进行双向通讯的协议命令ID。*/
|
||||
typedef enum _VOX_COMMAND_E
|
||||
{
|
||||
// CMD_CHG_FULL_CLOSE = 0x01, //充满关机指令
|
||||
|
||||
CMD_KEY_PRESS = 0x09, //按键发码指令
|
||||
|
||||
CMD_UPLOAD_BATLEV = 0x06, //电量上传指令
|
||||
|
||||
//CMD_VOX_LOW_CHG = 0x04, //低电指令
|
||||
|
||||
}VOX_COMMAND_E;
|
||||
|
||||
/******************************************************************************\
|
||||
UserCfg.Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
#if VOX_ADT_ENABLE
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
/* VOL Enable Type */
|
||||
typedef enum {
|
||||
|
||||
VOX_VOUT_Mode = 0x00, //VOx 5V 输出使能
|
||||
|
||||
VOX_ADT_Mode, //VOx 负载接入、存在识别功能使能,负载自动识别
|
||||
|
||||
} VOX_Enable_Mode_e;
|
||||
|
||||
typedef enum {
|
||||
|
||||
VOX_NONE_IN_BOX = 0, //空仓
|
||||
|
||||
VOX_GET_INTO_BOX, //耳机入仓
|
||||
|
||||
VOX_STAY_IN_BOX, //耳机在仓
|
||||
|
||||
//VOX_GET_OUTPUT_BOX, //耳机出仓
|
||||
|
||||
}Vox_State_e;
|
||||
|
||||
extern Vox_State_e Vol_State;
|
||||
extern Vox_State_e Vor_State;
|
||||
|
||||
extern bit Vor_Vout_Close_Flag;
|
||||
extern bit Vol_Vout_Close_Flag;
|
||||
|
||||
extern bit Vol_Bat_Full_Flag;
|
||||
extern bit Vor_Bat_Full_Flag;
|
||||
|
||||
/******************************************************************************\
|
||||
UserCfg.Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
extern void Vox_Det_Machine(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
32
UsrSrc/InitVars.c
Normal file
32
UsrSrc/InitVars.c
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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位置处,小端模式存储。
|
||||
|
||||
|
||||
|
183
UsrSrc/adc/adc.c
Normal file
183
UsrSrc/adc/adc.c
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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
|
||||
\******************************************************************************/
|
||||
|
||||
uint16_t Vbat_Adc = 0;
|
||||
|
||||
uint16_t Vref_Adc = 311;
|
||||
|
||||
/******************************************************************************\
|
||||
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
|
||||
|
||||
#if 1
|
||||
if( adc_chn == ADC_VREF ) //采VREF前,需要先拉低ADC4对应的IO口进行放电。
|
||||
{
|
||||
SFRADDR = P0_PD; //打开P07的下拉
|
||||
SFRDATA |= 0x80;
|
||||
|
||||
ADC_CTL1 = (ADC_CH4 << 4) | 0x01;
|
||||
|
||||
while(ADC_CTL1 & 0x01); //Wait for conversion complete
|
||||
|
||||
ADC_CTL1 = (ADC_VREF << 4) | 0x01;
|
||||
|
||||
SFRADDR = P0_PD; //取消P07的下拉
|
||||
SFRDATA &= ~0x80;
|
||||
|
||||
#ifdef _DEBUG_ADC
|
||||
printf("adc bug(vref:%d)\r\n",(uint16_t)adc_chn);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
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("adc:%d,plus:%d,index:%d.\r\n",(uint16_t)adc_data,(uint16_t)adc_plus_data,(uint16_t)index);
|
||||
#endif
|
||||
}
|
||||
|
||||
adc_data = adc_plus_data >> 3;
|
||||
|
||||
#ifdef _DEBUG_ADC
|
||||
printf("Adc,Vadc:%d,Vadc_plus:%d,adc_chn:%d.\r\n", (uint16_t)adc_data, (uint16_t)adc_plus_data,(uint16_t)adc_chn);
|
||||
#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);
|
||||
|
||||
n_Vbat_Data = (uint32_t)(n_Vbat_Data) * VREF * 2 / Vref_Adc;
|
||||
|
||||
#ifdef _DEBUG_ADC
|
||||
printf("bat,Vbat:%d.\r\n",(uint16_t)n_Vbat_Data);
|
||||
#endif
|
||||
|
||||
return n_Vbat_Data;
|
||||
}
|
||||
|
||||
#ifdef NTC_ENABLE
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* 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("NTC_adc,Vadc:%d.\r\n", (uint16_t)adc_data);
|
||||
#endif
|
||||
|
||||
adc_data = (uint32_t)(adc_data) * VREF / Vref_Adc;
|
||||
|
||||
#ifdef _DEBUG_ADC
|
||||
printf("NTC_V,Vadc:%d.\r\n", (uint16_t)adc_data);
|
||||
#endif
|
||||
|
||||
return adc_data;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
177
UsrSrc/bat/bat.c
Normal file
177
UsrSrc/bat/bat.c
Normal file
@ -0,0 +1,177 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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"
|
||||
#include "hall.h"
|
||||
#include "userapp.h"
|
||||
#include "system.h"
|
||||
#include "sleep.h"
|
||||
#include "led.h"
|
||||
#include "vox_module.h"
|
||||
|
||||
uint8_t bat_level = 0;
|
||||
|
||||
uint8_t bat_level_pdata = 0;
|
||||
|
||||
bit F_batlevel_low = 0; //电池低压
|
||||
|
||||
#if BAT_VALUE
|
||||
|
||||
#define C_offset_bat_level_MAX 190
|
||||
#define C_offset_bat_level_MIN 10
|
||||
|
||||
|
||||
bit F_batlevel_protect = 0; //低电保护
|
||||
|
||||
uint8_t offset_bat_level = ( C_offset_bat_level_MAX + C_offset_bat_level_MIN ) / 2;
|
||||
|
||||
/*充电电池电压会浮高,具体电压需要测试。*/
|
||||
|
||||
#define C_batLevel_SetMax 11
|
||||
|
||||
const uint16_t Boost_batlevel_Threshold[C_batLevel_SetMax] =
|
||||
{
|
||||
3200, //0
|
||||
|
||||
3500, //10%
|
||||
|
||||
3600, //20%
|
||||
|
||||
3700, //30%
|
||||
|
||||
3800, //40%
|
||||
|
||||
3900, //50%
|
||||
|
||||
3950, //60%
|
||||
|
||||
4000, //70%
|
||||
|
||||
4100, //80%
|
||||
|
||||
4150, //90%
|
||||
|
||||
4200 //100%
|
||||
};
|
||||
|
||||
const uint8_t batlev_data[C_batLevel_SetMax] =
|
||||
{
|
||||
0x0A, //0 0b001010
|
||||
|
||||
0x18, //10% 0b011000
|
||||
|
||||
0x1A, //20% 0b011010
|
||||
|
||||
0x20, //30% 0b100000
|
||||
|
||||
0x22, //40% 0b100010
|
||||
|
||||
0x28, //50% 0b101000
|
||||
|
||||
0x29, //60% 0b101001
|
||||
|
||||
0x2A, //70% 0b101010
|
||||
|
||||
0x30, //80% 0b110000
|
||||
|
||||
0x31, //90% 0b110001
|
||||
|
||||
0x32 //100% 0b110010
|
||||
};
|
||||
|
||||
//uint8_t bat_level_bk = 0;
|
||||
|
||||
void check_bat_level(void)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
//static uint8_t bat_level;
|
||||
static uint8_t bat_level_bk;
|
||||
//get bat level
|
||||
|
||||
#if ADC_ENABLE
|
||||
|
||||
for(i=0; i < C_batLevel_SetMax; i++)
|
||||
{
|
||||
if( Vbat_Adc < Boost_batlevel_Threshold[i] )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
|
||||
/*系统重启后,快速采集电量*/
|
||||
if( RST_FLAG )
|
||||
{
|
||||
RST_FLAG = 0;
|
||||
bat_level = i;
|
||||
}
|
||||
|
||||
#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;
|
||||
|
||||
if( bat_level_bk != bat_level )
|
||||
{
|
||||
bat_level_pdata = batlev_data[i];
|
||||
|
||||
bat_level_bk = bat_level;
|
||||
}
|
||||
|
||||
offset_bat_level = ( C_offset_bat_level_MAX + C_offset_bat_level_MIN ) / 2;
|
||||
}
|
||||
|
||||
if( bat_level <= C_bat_level_protect )
|
||||
{
|
||||
F_batlevel_protect = 1;
|
||||
}
|
||||
#if 0
|
||||
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 + 2) )
|
||||
{
|
||||
F_batlevel_low = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
241
UsrSrc/charger/charger_module.c
Normal file
241
UsrSrc/charger/charger_module.c
Normal file
@ -0,0 +1,241 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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"
|
||||
#include "userapp.h"
|
||||
#include "bat.h"
|
||||
|
||||
bit Charger_Done = 0;
|
||||
|
||||
//#ifdef NTC_ENABLE
|
||||
|
||||
bit NTC_Pro_Flag = 0;
|
||||
|
||||
//#endif
|
||||
|
||||
#if CHARGER_ENABLE
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
#define NTC_PRO_DEBOUNCE_TIM 10
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
#ifdef NTC_ENABLE
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* 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 保护后,软件关闭充电,
|
||||
* 温度恢复正常并持续 250ms,再继续充电。
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
uint8_t PMU_NTC_Control(void)
|
||||
{
|
||||
uint16_t NTC_Adc = 0;
|
||||
uint8_t NTC_Flag = FALSE;
|
||||
|
||||
static bit NTC_Low_Pro_Flag;
|
||||
static bit NTC_High_Pro_Flag;
|
||||
|
||||
// static bit NTC_CHG_02C_Flag;
|
||||
|
||||
#if ADC_ENABLE
|
||||
NTC_Adc = ADC_NTC_Value();
|
||||
#endif
|
||||
|
||||
if(NTC_Adc >= 2000) ////屏蔽NTC功能,NTC浮空,屏蔽 NTC 功能,并锁定。
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(NTC_Adc <= T_N1C && NTC_Adc > T_48C) //正常充电
|
||||
{
|
||||
if(NTC_Low_Pro_Flag)
|
||||
{
|
||||
if( NTC_Adc < T_2C )
|
||||
{
|
||||
NTC_Low_Pro_Flag = 0;
|
||||
|
||||
NTC_Flag = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
NTC_Flag = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(NTC_High_Pro_Flag)
|
||||
{
|
||||
if( NTC_Adc > T_46C )
|
||||
{
|
||||
NTC_High_Pro_Flag = 0;
|
||||
|
||||
NTC_Flag = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
NTC_Flag = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else //异常不充电
|
||||
{
|
||||
|
||||
if(NTC_Adc > T_N1C)
|
||||
{
|
||||
NTC_Low_Pro_Flag = 1;
|
||||
}
|
||||
else
|
||||
if(NTC_Adc < T_48C)
|
||||
{
|
||||
NTC_High_Pro_Flag = 1;
|
||||
}
|
||||
|
||||
NTC_Flag = TRUE;
|
||||
}
|
||||
|
||||
return NTC_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*/
|
||||
{
|
||||
IRQ_FLAG10 = 0xC0; //Clear Plugin\Plugout interrupt
|
||||
}
|
||||
|
||||
#ifdef NTC_ENABLE
|
||||
|
||||
/*NTC Handle*/ //使能Charger前先检测NTC温度,异常就不开充电。(CHIP_STA4 & 0x80):PG
|
||||
if( NTC_Pro_Flag ) //NTC保护,不充电。
|
||||
{
|
||||
CHG_CTL &= ~0x01; //Disable Charger.
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if( IRQ_FLAG9 & 0x10 ) //Charg complete interrupt
|
||||
{
|
||||
|
||||
#if ADC_ENABLE
|
||||
|
||||
if( Vbat_Adc < BAT_RECHARG )
|
||||
{
|
||||
IRQ_FLAG9 = 0x10;
|
||||
}
|
||||
else
|
||||
{
|
||||
CHG_CTL &= ~0x01; //Disable Charger
|
||||
}
|
||||
|
||||
Charger_Done = 1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
CHG_CTL |= 0x11; //Enable Charger And Charger Timeout
|
||||
#if BAT_VALUE
|
||||
|
||||
if( bat_level > ( C_bat_level_protect + 1 ) )
|
||||
{
|
||||
F_batlevel_protect = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Charger_Done = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
161
UsrSrc/discharge/discharge_module.c
Normal file
161
UsrSrc/discharge/discharge_module.c
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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
|
||||
\******************************************************************************/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* 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;
|
||||
}
|
||||
|
||||
#if BAT_VALUE
|
||||
|
||||
if( F_batlevel_protect )
|
||||
{
|
||||
BST_EN = 0;
|
||||
|
||||
gBoost_Prepared_Flag = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*输出短路保护 (使用中断标志位,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;
|
||||
|
||||
IRQ_FLAG0 = 0x01;
|
||||
|
||||
BST_EN = 1; //250ms定时开一次Boost
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NTC_ENABLE
|
||||
/*NTC Handle*/ //使能Boost前先检测NTC温度,异常就不开放电。
|
||||
if( NTC_Pro_Flag ) //NTC保护,不放电。
|
||||
{
|
||||
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_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
|
||||
|
||||
|
163
UsrSrc/gpio_comm/gpio_comm.c
Normal file
163
UsrSrc/gpio_comm/gpio_comm.c
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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"
|
||||
|
||||
bit Pattern_TX_Start = 0;
|
||||
|
||||
#if VOX_TX_PATTERN
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
uint8_t Gpio_TX_Steps = GPIO_TX_STEPS_START;
|
||||
|
||||
uint16_t Pattern_TX_Data = 0; //需要通过VOX发送的数据:高8位:盒子电量;低8位版本号
|
||||
|
||||
bit g_Key_Type = 0;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Gpio_Comm(uint8_t Data,bit Key_Type)
|
||||
*
|
||||
* Description : gpio TX Communicate 1ms调用周期
|
||||
|
||||
* Arguments : uint8_t data
|
||||
|
||||
* Returns : None
|
||||
|
||||
* Notes : None
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void Gpio_Comm(void)
|
||||
{
|
||||
static uint8_t Bit_Cnt;
|
||||
static uint8_t Pin_Status;
|
||||
static uint8_t Gpio_TX_Comm_Cnt;
|
||||
//static uint8_t Gpio_TX_Steps;
|
||||
|
||||
/*起始帧:55ms低电平 + 20ms高电平 + 20ms低电平。*/
|
||||
if( Pattern_TX_Start )
|
||||
{
|
||||
Gpio_TX_Comm_Cnt++;
|
||||
|
||||
if( Gpio_TX_Steps == GPIO_TX_STEPS_START )
|
||||
{
|
||||
if( Gpio_TX_Comm_Cnt <= START_LOW_55MS_TIM )
|
||||
{
|
||||
Vout_Ctrl_OFF(OFF);
|
||||
}
|
||||
else
|
||||
if( Gpio_TX_Comm_Cnt <= ( START_LOW_55MS_TIM + START_HIGH_20MS_TIM ) )
|
||||
{
|
||||
Vout_Ctrl_ON(ON);
|
||||
}
|
||||
else
|
||||
if( Gpio_TX_Comm_Cnt < ( START_LOW_55MS_TIM + START_HIGH_20MS_TIM + START_LOW_20MS_TIM ) )
|
||||
{
|
||||
Vout_Ctrl_OFF(OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gpio_TX_Steps = GPIO_TX_STEPS_BIT_SYC;
|
||||
|
||||
if( g_Key_Type )
|
||||
{
|
||||
Bit_Cnt = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*data帧:5个bit,前三个bit*/
|
||||
if( Gpio_TX_Steps == GPIO_TX_STEPS_BIT_SYC )
|
||||
{
|
||||
Bit_Cnt--;
|
||||
if(Bit_Cnt > 7)
|
||||
{
|
||||
Bit_Cnt = 8;
|
||||
Gpio_TX_Steps = GPIO_TX_STEPS_STOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
Gpio_TX_Steps = GPIO_TX_STEPS_DATA;
|
||||
}
|
||||
|
||||
Pin_Status = ( Pattern_TX_Data>>Bit_Cnt ) & 0x01;
|
||||
|
||||
Gpio_TX_Comm_Cnt = 0;
|
||||
}
|
||||
|
||||
if( Gpio_TX_Steps == GPIO_TX_STEPS_DATA ) //data帧
|
||||
{
|
||||
if( Gpio_TX_Comm_Cnt < START_LOW_20MS_TIM )
|
||||
{
|
||||
if( Pin_Status ) //bit high
|
||||
{
|
||||
Vout_Ctrl_ON(ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vout_Ctrl_OFF(OFF);
|
||||
}
|
||||
}
|
||||
else //bit low
|
||||
{
|
||||
Gpio_TX_Steps = GPIO_TX_STEPS_BIT_SYC;
|
||||
}
|
||||
}
|
||||
else
|
||||
if( Gpio_TX_Steps == GPIO_TX_STEPS_STOP ) //stop帧
|
||||
{
|
||||
if( Gpio_TX_Comm_Cnt < START_HIGH_20MS_TIM )
|
||||
{
|
||||
Vout_Ctrl_ON(ON);
|
||||
}
|
||||
else
|
||||
if( Gpio_TX_Comm_Cnt < ( START_HIGH_20MS_TIM + START_LOW_20MS_TIM ) )
|
||||
{
|
||||
Vout_Ctrl_OFF(OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vout_Ctrl_ON(ON);
|
||||
|
||||
Gpio_TX_Comm_Cnt = 0;
|
||||
|
||||
Pattern_TX_Start = 0;
|
||||
|
||||
g_Key_Type = 0;
|
||||
|
||||
Gpio_TX_Steps = GPIO_TX_STEPS_START;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
98
UsrSrc/hall/hall.c
Normal file
98
UsrSrc/hall/hall.c
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 "userapp.h"
|
||||
#include "sleep.h"
|
||||
|
||||
#ifdef HALL_ENABLE
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
uint8_t Hall_Sta_bk = 0xff;
|
||||
|
||||
CoverStatus_E CoverStatus;
|
||||
|
||||
bit CoverEvent_Flg = 0; //Hall开关触发事件标志位
|
||||
bit CoverEvent_Flg_led = 0;
|
||||
|
||||
/******************************************************************************\
|
||||
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;
|
||||
|
||||
#if LED_DISPLAY
|
||||
LED_On_Flag = 1;
|
||||
#endif
|
||||
Hall_Sta_bk = Hall_Sta;
|
||||
|
||||
// Enter_Sleep_Cnt_Restart_Flag = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
198
UsrSrc/key/key.c
Normal file
198
UsrSrc/key/key.c
Normal file
@ -0,0 +1,198 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 "userapp.h"
|
||||
#include "vox_module.h"
|
||||
#include "gpio_comm.h"
|
||||
#include "hall.h"
|
||||
|
||||
bit Key_Press_irq = 0;
|
||||
|
||||
bit Key_Press_short_irq = 0;
|
||||
|
||||
bit Key_Press_ll_irq_led = 0;
|
||||
|
||||
#ifdef KEY_ENABLE
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
#define KEY_PRESS_CNT0 5 //按键长按500ms显示长按灯效
|
||||
|
||||
#define KEY_PRESS_CNT1 15
|
||||
|
||||
#define KEY_PRESS_CNT 30 //按键按下计数3s
|
||||
|
||||
#define Vox_TX_Key_Pattern_Tim 3
|
||||
|
||||
#define Vox_TX_Pattern_Tim 24
|
||||
|
||||
#define Vox_TX_Interval 5 //Vox定时发送指令时间间隔
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
//bit Key_Press_Flag = 0;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Key_Handler(void)
|
||||
*
|
||||
* Description : Key Handler --- 主循环中调用,调用周期5ms。其中长按(按键时间大于2s)需要判断抬键动作才触发。
|
||||
CoverStatus --- 充电仓盖子状态。(本函数提供对应Key事件标志位,后续应用待定)
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void Key_Handler(void)
|
||||
{
|
||||
static uint8_t Key_Press_Debounce;
|
||||
|
||||
static uint8_t Msg_TX_Debounce;
|
||||
|
||||
static bit Key_Press_ll_irq;
|
||||
|
||||
static bit nKey_Press_Flag;
|
||||
|
||||
static bit nKey_Press_Flag1;
|
||||
|
||||
static bit Key_Press_Flag;
|
||||
|
||||
//static bit Key_Lift_Flag;
|
||||
|
||||
if( !(CHIP_STA0 & 0x02) ) //CHIP_STA0 的bit1为Key的状态值:0:按下;
|
||||
{
|
||||
Key_Press_Debounce++;
|
||||
if( Key_Press_Debounce >= KEY_PRESS_CNT ) //长按3s,VOX掉电
|
||||
{
|
||||
if( !nKey_Press_Flag )
|
||||
{
|
||||
nKey_Press_Flag = 1;
|
||||
|
||||
Key_Press_ll_irq = 1;
|
||||
|
||||
if( Earphone_Num_2Inbox )
|
||||
{
|
||||
Key_Press_ll_irq_led = 1;
|
||||
#if LED_DISPLAY
|
||||
LED_On_Flag = 1;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if( Key_Press_Debounce >= KEY_PRESS_CNT1 ) //长按1.5s,先升压,到3s后如果有双耳机充电,则显示灯效和发码。
|
||||
{
|
||||
if( !nKey_Press_Flag1 )
|
||||
{
|
||||
Wkup_Earphone_Flag = 1;
|
||||
|
||||
Key_Press_short_irq = 1;
|
||||
|
||||
nKey_Press_Flag1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
Key_Press_Flag = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Key_Press_Flag )
|
||||
{
|
||||
Key_Press_Flag = 0;
|
||||
|
||||
nKey_Press_Flag = 0;
|
||||
|
||||
//Key_Lift_Flag = 1;
|
||||
|
||||
nKey_Press_Flag1 = 0;
|
||||
|
||||
Key_Press_short_irq = 0;
|
||||
|
||||
if( (Key_Press_Debounce < KEY_PRESS_CNT0) ) //松开按键,按下时间小于500ms,则识别为短按,显示电量
|
||||
{
|
||||
Key_Press_irq = 1; //短按,显示电量
|
||||
#if LED_DISPLAY
|
||||
LED_On_Flag = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Key_Press_Debounce = 0;
|
||||
}
|
||||
|
||||
/*按键3s后,发清除配对码吗,每隔400ms发5次,发完后蓝灯亮4下。*/
|
||||
if( Key_Press_ll_irq )
|
||||
{
|
||||
if( Msg_TX_Debounce <= Vox_TX_Pattern_Tim )
|
||||
{
|
||||
if( (Msg_TX_Debounce % Vox_TX_Interval == 0) )
|
||||
{
|
||||
if( Earphone_Num_2Inbox ) //按键发码需双耳机在盒才发。
|
||||
{
|
||||
|
||||
//if( (CHIP_STA1 & 0xAC) == 0xA0 )
|
||||
{
|
||||
#if VOX_TX_PATTERN
|
||||
|
||||
Pattern_TX_Start = 1;
|
||||
|
||||
Pattern_TX_Data = 0x05;
|
||||
|
||||
g_Key_Type = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Msg_TX_Debounce++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Key_Press_ll_irq = 0;
|
||||
|
||||
Msg_TX_Debounce = 1;
|
||||
|
||||
if( CoverStatus == OPEN )
|
||||
{
|
||||
Vout_Ctrl_OFF(ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
157
UsrSrc/led/led.c
Normal file
157
UsrSrc/led/led.c
Normal file
@ -0,0 +1,157 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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"
|
||||
|
||||
#if LED_DISPLAY
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
#if 0
|
||||
/*
|
||||
* 函数名称 : LED_On
|
||||
* 功能描述 : 点亮LED
|
||||
* 参 数 : LED的ID
|
||||
* 返回值 : NONE
|
||||
*/
|
||||
/******************************************************************************/
|
||||
static void LED_On(uint8_t LedId)
|
||||
/******************************************************************************/
|
||||
{
|
||||
switch(LedId)
|
||||
{
|
||||
case LED_R:
|
||||
LEDR_ON();
|
||||
break;
|
||||
|
||||
case LED_B:
|
||||
LEDB_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_B:
|
||||
LEDB_OFF();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#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)
|
||||
/******************************************************************************/
|
||||
{
|
||||
if ( BL_LED.Breathing_Light_On )
|
||||
{
|
||||
if( BL_LED.BL_Timer <= BL_LED.BL_Flash_Duty )
|
||||
{
|
||||
LEDB_ON();
|
||||
}
|
||||
else
|
||||
{
|
||||
LEDB_OFF();
|
||||
}
|
||||
|
||||
if( BL_LED.BL_Timer >= BL_DUTY_MAX )
|
||||
{
|
||||
BL_LED.BL_Timer = 0;
|
||||
|
||||
if(BL_LED.Flash_Duty_Declining)
|
||||
{
|
||||
BL_LED.BL_Flash_Duty -= BL_STEP;
|
||||
}
|
||||
else
|
||||
if(BL_LED.Flash_Duty_Rising)
|
||||
{
|
||||
BL_LED.BL_Flash_Duty += BL_STEP;
|
||||
}
|
||||
}
|
||||
|
||||
if( BL_DUTY_MAX <= BL_LED.BL_Flash_Duty )
|
||||
{
|
||||
BL_LED.Flash_Duty_Declining = 1;
|
||||
|
||||
BL_LED.Flash_Duty_Rising = 0;
|
||||
}
|
||||
else
|
||||
if( BL_LED.BL_Flash_Duty <= 1 )
|
||||
{
|
||||
BL_LED.Flash_Duty_Rising = 1;
|
||||
|
||||
BL_LED.Flash_Duty_Declining = 0;
|
||||
}
|
||||
}
|
||||
|
||||
BL_LED.BL_Timer += LED_PLUS_TIME;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
64
UsrSrc/main.c
Normal file
64
UsrSrc/main.c
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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"
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
void main(void)
|
||||
{
|
||||
System_Init(); //ϵͳ³õʼ»¯
|
||||
|
||||
#ifdef _DEBUG_MAIN
|
||||
|
||||
printf("System Init.\r\n");
|
||||
|
||||
#endif
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
#if WTG_ENABLE
|
||||
WDT = 1;
|
||||
SWDT = 1;
|
||||
#endif
|
||||
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_STA0 & 0x01 ) || ( 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
|
||||
|
240
UsrSrc/system/system.c
Normal file
240
UsrSrc/system/system.c
Normal file
@ -0,0 +1,240 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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"
|
||||
#include "gpio_comm.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; //硬件trim需求。Disable Hall,Enable Key,
|
||||
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 = 0x40; //SCON: MODE 1, 8-bit UART, REN disable
|
||||
|
||||
TI0 = 1;
|
||||
RI0 = 1;
|
||||
ES0 = 1; //Enable UART0 IRQ
|
||||
|
||||
#endif
|
||||
|
||||
#if LED_DISPLAY
|
||||
|
||||
P01 = 1;
|
||||
|
||||
|
||||
SFRADDR = P0_OE; //Set P03、P04 LED1-LED2,P01 As TX
|
||||
SFRDATA |= 0x1A;
|
||||
|
||||
|
||||
LED_On_Flag = 1;
|
||||
|
||||
#endif
|
||||
|
||||
#if VOX_ENABLE
|
||||
|
||||
VOX_CTL0 = 0xC3; //VOX 负载接入、存在识别功能使能,负载自动识别。打开Vox vds钳压环使能(主要用于VOX 5V输出)。
|
||||
|
||||
SFRADDR = VOX_CON0; //设置VOX输出200mA,负载识别电流4.5uA。
|
||||
SFRDATA = (VOX_IOUT_200MA << 3) | VOX_ADT_Cur_4_5UA;
|
||||
|
||||
SFRADDR = VOX_CON2; //设置VOX轻重载转换滤波时间。bit3:2 VOX轻载转重载滤波时间;bit1:0 VOX重载转轻载滤波时间
|
||||
SFRDATA |= (VOX_LIGHT_TO_HAVEY_128 << 2) | VOX_HAVEY_TO_LIGHT_8;
|
||||
|
||||
#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
|
||||
|
||||
#ifdef 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
|
||||
|
||||
#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
|
||||
|
||||
#ifdef HALL_ENABLE
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef NTC_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;
|
||||
|
||||
/* 开外部中断使能 */
|
||||
EX0 = 1;
|
||||
EX2 = 1;
|
||||
|
||||
EAL = 1; //开总中断。
|
||||
|
||||
#if CHARGER_ENABLE
|
||||
|
||||
#ifdef SY8836 //合封OVP芯片SY8836
|
||||
|
||||
SFRADDR = PMU_CTL7; //合封芯片关闭VBUS OV检测使能
|
||||
SFRDATA &= ~0x20;
|
||||
|
||||
SFRADDR = REG_CHG0;
|
||||
SFRDATA |= 0x04; //合封关VDPM环
|
||||
|
||||
#endif
|
||||
|
||||
/*如下参数按需更改。*/
|
||||
REG_CHG1 = CHG_CURRENT_250MA; //设置充电电流 250mA
|
||||
|
||||
#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
|
||||
|
||||
Enter_Sleep_Cnt_Restart_Flag = 1;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
158
UsrSrc/timer/sys_tim.c
Normal file
158
UsrSrc/timer/sys_tim.c
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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_250ms = 0;
|
||||
uint8_t cnt_sys_tim_100ms = 0;
|
||||
uint8_t cnt_sys_tim_1s = 0;
|
||||
|
||||
//uint8_t cnt_sys_tim_10ms = 0;
|
||||
bit F_sys_tim_1ms = 0;
|
||||
|
||||
bit F_sys_tim_100ms = 0;
|
||||
bit F_sys_tim_1s = 0;
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Delay10ms(void) //@11.0592MHz
|
||||
*
|
||||
* Description : 10msÈí¶¨Ê±º¯Êý
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#if 0
|
||||
void Delay10ms(void) //@11.0592MHz
|
||||
{
|
||||
unsigned char i, j;
|
||||
|
||||
i = 108;
|
||||
j = 145;
|
||||
do
|
||||
{
|
||||
while (--j);
|
||||
} while (--i);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This function handles sys_tim Handler.
|
||||
* @param None
|
||||
* @retval None
|
||||
* 1ms
|
||||
*/
|
||||
void tim0_Interrupt(void) interrupt Interrupt_Vector_TF0 //interrupt address is 0x000B
|
||||
{
|
||||
//1ms
|
||||
TH0 += C_TIM0_Reload >> 8;
|
||||
TL0 += C_TIM0_Reload & 0xFF;
|
||||
|
||||
//---------------10ms----------------------------------------
|
||||
// cnt_sys_tim_10ms++;
|
||||
// if(cnt_sys_tim_10ms >= 5)
|
||||
{
|
||||
// cnt_sys_tim_10ms = 0;
|
||||
F_sys_tim_1ms = 1;
|
||||
}
|
||||
|
||||
//---------------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;
|
||||
|
||||
//-----------------250ms-------------------------
|
||||
cnt_sys_tim_1s++;
|
||||
if(cnt_sys_tim_1s >= 4)
|
||||
{
|
||||
cnt_sys_tim_1s = 0;
|
||||
F_sys_tim_1s = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if VOX_TX_PATTERN
|
||||
|
||||
// Gpio_Comm();
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef 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;
|
||||
|
||||
#if LED_DISPLAY
|
||||
|
||||
#ifdef BREATHING_LIGHT
|
||||
|
||||
LED_Breathing_Light();
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
150
UsrSrc/uart/uart.c
Normal file
150
UsrSrc/uart/uart.c
Normal file
@ -0,0 +1,150 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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;
|
||||
|
||||
#ifdef VOX_RX
|
||||
idata uint8_t RX0_Buffer[COM0_Data_Lenth] = 0; //接收缓冲
|
||||
bit Uart0_RX_Finish_Flag = 0;
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG_ALL
|
||||
|
||||
void Uart0SendData(uint8_t Txdata)
|
||||
{
|
||||
while(busy0);
|
||||
ACC = Txdata;
|
||||
if (P) //根据P来设置校验位
|
||||
{
|
||||
#if (PARITYBIT == ODD_PARITY)
|
||||
TB80 = 0; //设置校验位为0
|
||||
#elif (PARITYBIT == EVEN_PARITY)
|
||||
TB80 = 1; //设置校验位为1
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (PARITYBIT == ODD_PARITY)
|
||||
TB80 = 1; //设置校验位为1
|
||||
#elif (PARITYBIT == EVEN_PARITY)
|
||||
TB80 = 0; //设置校验位为0
|
||||
#endif
|
||||
}
|
||||
busy0 = 1;
|
||||
S0BUF = ACC;
|
||||
}
|
||||
|
||||
|
||||
char putchar(char c)
|
||||
{
|
||||
#if 0
|
||||
while(!TI0);
|
||||
TI0 = 0;
|
||||
return (S0BUF = c);
|
||||
#else
|
||||
Uart0SendData(c);
|
||||
return(c);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* 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( Length-- )
|
||||
{
|
||||
while(busy0);
|
||||
ACC = *TransBuf++;
|
||||
busy0 = 1;
|
||||
S0BUF = ACC;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
|
||||
#define Vox_Comm_Data_Len 5
|
||||
#define Vox_R_W_FLAG 4
|
||||
|
||||
/*uart0中断处理函数*/
|
||||
void uart0_Interrupt(void) interrupt Interrupt_Vector_RI_TI
|
||||
{
|
||||
// uint16_t CrcCheckSum = 0;
|
||||
|
||||
/*处理UART0发送中断*/
|
||||
if(TI0)
|
||||
{
|
||||
TI0 = 0;
|
||||
busy0 = 0;
|
||||
}
|
||||
|
||||
/*处理UART0接收中断,透传开关功能协议监听。*/
|
||||
if(RI0)
|
||||
{
|
||||
RI0 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
462
UsrSrc/userapp/userapp.c
Normal file
462
UsrSrc/userapp/userapp.c
Normal file
@ -0,0 +1,462 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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"
|
||||
#include "gpio_comm.h"
|
||||
|
||||
/******************************************************************************\
|
||||
Macro definitions
|
||||
\******************************************************************************/
|
||||
#define LED_ON_CNT 30 //LED显示2s后熄灭
|
||||
|
||||
#define LED_ON_KEY_CNT 38
|
||||
#define LED_ON_LOW_CNT 32
|
||||
|
||||
#define LED_OFF_CNT 5
|
||||
|
||||
#define LED_KEY_BLINK_CNT 5
|
||||
#define LED_BLINK_CNT 5
|
||||
|
||||
#define LED_PRO_TIM 40
|
||||
#define LED_PRO_CNT 2
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
bit LED_On_Flag = 0;
|
||||
|
||||
bit Wkup_Earphone_Flag = 0;
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
|
||||
|
||||
#ifdef LED_DISPLAY
|
||||
/*****************************************************************************
|
||||
* Function : void LED_Disp_Off(void)
|
||||
* Description : NONE
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : None
|
||||
* Note : None
|
||||
*****************************************************************************/
|
||||
|
||||
void LED_Disp_Off(void)
|
||||
{
|
||||
|
||||
#ifdef BREATHING_LIGHT
|
||||
BL_LED.Breathing_Light_On = 0;
|
||||
#endif
|
||||
|
||||
LEDR_OFF();
|
||||
|
||||
LEDB_OFF();
|
||||
|
||||
#if SLEEP_ENABLE
|
||||
|
||||
Enter_Sleep_Cnt_Restart_Flag = 1;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
/*****************************************************************************
|
||||
* Function : void LED_Display_App(void)
|
||||
* Description : 100ms调用周期
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : None
|
||||
* Note : None
|
||||
*****************************************************************************/
|
||||
|
||||
void LED_Display_App(void)
|
||||
{
|
||||
static uint8_t LED_On_Timer; //led亮时间计时
|
||||
|
||||
static bit LED_On_Flag1;
|
||||
|
||||
static bit LED_On_Chg_Flag;
|
||||
|
||||
static bit LED_On_ChgDone_Flag;
|
||||
|
||||
static uint8_t LED_On_Cnt;
|
||||
|
||||
/*NTC保护,4灯一直快闪(2Hz)*/
|
||||
if( NTC_Pro_Flag || Vox_Output_Short_Flag )
|
||||
{
|
||||
if( !LED_On_Flag1 )
|
||||
{
|
||||
LED_On_Flag1 = 1;
|
||||
|
||||
LED_Disp_Off();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( LED_On_Timer <= LED_PRO_TIM )
|
||||
{
|
||||
LED_On_Timer++;
|
||||
|
||||
if( (LED_On_Timer % LED_PRO_CNT == 0) )
|
||||
{
|
||||
LEDR_TOG();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LEDR_OFF();
|
||||
}
|
||||
}
|
||||
|
||||
#if SLEEP_ENABLE
|
||||
|
||||
Enter_Sleep_Cnt_Restart_Flag = 1;
|
||||
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/* 保护消失后,需要开启5V升压一段时间。 */
|
||||
if( LED_On_Flag1 )
|
||||
{
|
||||
LED_On_Flag1 = 0;
|
||||
|
||||
LED_Disp_Off();
|
||||
|
||||
LED_On_Chg_Flag = 0;
|
||||
|
||||
LED_On_ChgDone_Flag = 0;
|
||||
|
||||
LED_On_Flag = 1;
|
||||
|
||||
Wkup_Earphone_Flag = 1;
|
||||
}
|
||||
|
||||
if ( CHIP_STA4 & 0x80 ) //充电中
|
||||
{
|
||||
if ( Charger_Done ) // 充电完成,LED2常亮
|
||||
{
|
||||
if( !LED_On_ChgDone_Flag )
|
||||
{
|
||||
LED_On_ChgDone_Flag = 1;
|
||||
|
||||
LED_Disp_Off();
|
||||
}
|
||||
|
||||
LEDB_ON();
|
||||
}
|
||||
else //充电中,LED1呼吸
|
||||
{
|
||||
if( !LED_On_Chg_Flag )
|
||||
{
|
||||
LED_On_Chg_Flag = 1;
|
||||
|
||||
LED_On_ChgDone_Flag = 0;
|
||||
|
||||
LED_Disp_Off();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BREATHING_LIGHT
|
||||
BL_LED.Breathing_Light_On = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Key_Press_irq = 0;
|
||||
|
||||
Key_Press_ll_irq_led = 0;
|
||||
|
||||
CoverEvent_Flg_led = 0;
|
||||
|
||||
LED_On_Flag = 0;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if( LED_On_Chg_Flag )
|
||||
{
|
||||
LED_On_Chg_Flag = 0;
|
||||
|
||||
LED_On_ChgDone_Flag = 0;
|
||||
|
||||
LED_On_Flag = 1;
|
||||
|
||||
Wkup_Earphone_Flag = 1;
|
||||
|
||||
}
|
||||
|
||||
if( LED_On_Flag )
|
||||
{
|
||||
LED_On_Timer = 0;
|
||||
|
||||
LED_On_Flag = 0;
|
||||
|
||||
LED_Disp_Off();
|
||||
}
|
||||
|
||||
if( F_batlevel_protect )
|
||||
{
|
||||
Key_Press_irq = 0;
|
||||
|
||||
Key_Press_ll_irq_led = 0;
|
||||
|
||||
CoverEvent_Flg_led = 0;
|
||||
|
||||
Earphone_Chg_Flag = 0;
|
||||
|
||||
LED_On_Flag = 1; //清LED显示
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if( (Earphone_Chg_Flag || Key_Press_irq || Key_Press_ll_irq_led || CoverEvent_Flg_led) ) //耳机出入盒、按键触发,显示灯效
|
||||
{
|
||||
if( Key_Press_ll_irq_led )
|
||||
{
|
||||
LED_On_Cnt = LED_ON_KEY_CNT + LED_OFF_CNT;
|
||||
}
|
||||
else
|
||||
{
|
||||
LED_On_Cnt = LED_ON_CNT + LED_OFF_CNT;
|
||||
}
|
||||
|
||||
if( LED_On_Timer < LED_OFF_CNT )
|
||||
{
|
||||
LED_On_Timer++;
|
||||
}
|
||||
else
|
||||
if( LED_On_Timer < LED_On_Cnt )
|
||||
{
|
||||
LED_On_Timer++;
|
||||
|
||||
if( Key_Press_ll_irq_led )
|
||||
{
|
||||
if( (LED_On_Timer % LED_KEY_BLINK_CNT == 0) )
|
||||
{
|
||||
LEDB_TOG();
|
||||
}
|
||||
}
|
||||
else
|
||||
if( F_batlevel_low )
|
||||
{
|
||||
if( (LED_On_Timer % LED_BLINK_CNT == 0) )
|
||||
{
|
||||
LEDR_TOG();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LEDB_ON();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Key_Press_irq = 0;
|
||||
|
||||
Key_Press_ll_irq_led = 0;
|
||||
|
||||
CoverEvent_Flg_led = 0;
|
||||
|
||||
Earphone_Chg_Flag = 0;
|
||||
|
||||
LED_On_Flag = 1; //清LED显示
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Function : UserAPP
|
||||
* Description : 5ms调用周期
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : None
|
||||
* Note : None
|
||||
*****************************************************************************/
|
||||
void UserAPP(void)
|
||||
{
|
||||
|
||||
/*LED灯显功能驱动函数*/
|
||||
if(F_sys_tim_1ms)
|
||||
{
|
||||
F_sys_tim_1ms = 0;
|
||||
|
||||
#if VOX_TX_PATTERN
|
||||
Gpio_Comm();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if(F_sys_tim_100ms)
|
||||
{
|
||||
F_sys_tim_100ms = 0;
|
||||
|
||||
#ifdef HALL_ENABLE
|
||||
Hall_Handler(); //开关盖检测
|
||||
#endif
|
||||
|
||||
#if DISCHARGE_ENABLE
|
||||
DisCharge_Handler(); //放电boost功能
|
||||
#endif
|
||||
|
||||
#if CHARGER_ENABLE
|
||||
Charger_Handler(); //充电功能
|
||||
#endif
|
||||
|
||||
#ifdef KEY_ENABLE
|
||||
Key_Handler(); //按键检测
|
||||
#endif
|
||||
|
||||
#if ADC_ENABLE
|
||||
|
||||
Vbat_Adc = Vbat_Value(); //获取Bat电压
|
||||
|
||||
#ifdef NTC_ENABLE
|
||||
|
||||
NTC_Pro_Flag = PMU_NTC_Control();
|
||||
#endif
|
||||
|
||||
Vref_Adc = ADC_Chn_Data(ADC_VREF); //获取参考电压
|
||||
|
||||
#endif
|
||||
|
||||
#if VOX_ENABLE
|
||||
Vox_Det_Machine(); //开关盖盒子功能逻辑。
|
||||
#endif
|
||||
|
||||
#if BAT_VALUE
|
||||
check_bat_level(); //电量计
|
||||
#endif
|
||||
|
||||
#if LED_DISPLAY
|
||||
LED_Display_App(); //4颗LED灯显示UI
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if( F_sys_tim_1s )
|
||||
{
|
||||
F_sys_tim_1s = 0;
|
||||
|
||||
#if SLEEP_ENABLE
|
||||
|
||||
/*1、唤醒后倒数Ns后进入Sleep Mode。
|
||||
2、有VIN存在、Boost放电、有中断触发的情况下,系不会进入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;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG_MAIN
|
||||
printf("sleep decnt:%d,STA0:0x%x,STA1:0x%x,STA2:0x%x,STA4:0x%x\r\n", (uint16_t)Decnt_SleepDelay,(uint16_t)CHIP_STA0,(uint16_t)CHIP_STA1,(uint16_t)CHIP_STA2,(uint16_t)CHIP_STA4);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
if( Check_Require_Sleep() )
|
||||
{
|
||||
/* Boost UVLO保护,需要关闭ADT唤醒,否则会出现进不了休眠的问题。 */
|
||||
if( CHIP_STA0 & 0x80 )
|
||||
{
|
||||
/* Enter Sleep */
|
||||
SFRADDR = WKUP_EN3; //vox loadon wake up enable
|
||||
SFRDATA &= ~0x3C;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Enter Sleep */
|
||||
SFRADDR = WKUP_EN3; //vox loadon wake up enable
|
||||
SFRDATA |= 0x3C;
|
||||
}
|
||||
|
||||
/* InSleep Handler */ //Disable All IRQ
|
||||
#ifdef TIMER1_ENABLE
|
||||
ET1 = 0; //timer1 IRQ Disable
|
||||
#endif
|
||||
|
||||
#if UART0_ENABLE
|
||||
ES0 = 0; //UART0 IRQ Disable
|
||||
#endif
|
||||
|
||||
EX2 = 0;
|
||||
ET0 = 0; //timer0 IRQ Disable
|
||||
|
||||
VOX_CTL0 &= ~0x30; //VOX 5v Off
|
||||
|
||||
#if DISCHARGE_ENABLE
|
||||
BST_EN = 0; //Boost Disable
|
||||
#endif
|
||||
SFRADDR = ADC_CTL0;
|
||||
SFRDATA &= ~0x80; //ADC Disable.
|
||||
|
||||
SFRADDR = PMU_CTL0; //芯片硬件需求,固定
|
||||
SFRDATA &= ~0x30;
|
||||
|
||||
PCON |= 0x02; //Enter StandbyMode, Only int0 or int1 can wake up system
|
||||
|
||||
SFRADDR = PMU_CTL0; //芯片硬件需求,固定
|
||||
SFRDATA |= 0x30;
|
||||
|
||||
/* OutSleep Handler */ //Enable IRQ
|
||||
#if UART0_ENABLE
|
||||
ES0 = 1; //UART0 IRQ
|
||||
#endif
|
||||
|
||||
EX2 = 1;
|
||||
ET0 = 1; //timer0 IRQ
|
||||
#ifdef TIMER1_ENABLE
|
||||
ET1 = 1; //timer1 IRQ
|
||||
#endif
|
||||
|
||||
Decnt_SleepDelay = ENTER_STANDBYMODE_CNT;
|
||||
}
|
||||
else
|
||||
{
|
||||
Decnt_SleepDelay = ENTER_STANDBYMODE_CNT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
600
UsrSrc/vox/vox_module.c
Normal file
600
UsrSrc/vox/vox_module.c
Normal file
@ -0,0 +1,600 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 "userapp.h"
|
||||
#include "charger_module.h"
|
||||
#include "gpio_comm.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 2
|
||||
#define VOX_VOUT_0V_DEBOUNCE 2
|
||||
|
||||
#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_IOFF_HOLD_CNT 50
|
||||
|
||||
#define VOX_FOLLOW_CHG_CNT 10
|
||||
|
||||
#define VOX_CLOSE_HOLD_CNT 10 //关盖发码前保持时间
|
||||
|
||||
/******************************************************************************\
|
||||
Variables definitions
|
||||
\******************************************************************************/
|
||||
|
||||
bit Vox_Output_Short_Flag = 0;
|
||||
bit Earphone_Num_2Inbox = 0; //双耳机在盒标志位
|
||||
|
||||
#if VOX_FOLLOW_CHG
|
||||
|
||||
bit Vor_In_Box_Flag = 0;
|
||||
bit Vol_In_Box_Flag = 0;
|
||||
|
||||
bit Boost_VoxVout_Follow_Flag = 0;
|
||||
int8 Boost_Vout_Value = 0;
|
||||
bit Boost_Up_Flag = 0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define KEY_TWS_PAIR_TIMER 2
|
||||
#define KEY_TWS_PAIR_CNT 6
|
||||
|
||||
#define KEY_TWS_PAIR_CLEAR_CNT 30
|
||||
|
||||
/******************************************************************************\
|
||||
Functions definitions
|
||||
\******************************************************************************/
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Vout_Ctrl_OFF(uint8_t Type)
|
||||
*
|
||||
* Description : Vout Mos Control OFF
|
||||
|
||||
* Arguments : uint8_t Type:ON:TX Output High;OFF:TX Output Low.
|
||||
|
||||
* Returns :
|
||||
|
||||
* Notes :
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void Vout_Ctrl_OFF(uint8_t Type)
|
||||
{
|
||||
BST_EN = 0;
|
||||
|
||||
COM_TX = Type;
|
||||
|
||||
SFRADDR = P0_OE;
|
||||
SFRDATA &= 0xFB; //P02为Floating,P01为输出
|
||||
SFRDATA |= 0x02;
|
||||
|
||||
if( Type == ON )
|
||||
{
|
||||
VOX_CTL0 &= ~0x30; //VOX 5v Off, Enable VOX ADT
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Vout_Ctrl_ON(void)
|
||||
*
|
||||
* Description : Vout Mos Control ON
|
||||
|
||||
* Arguments :
|
||||
|
||||
* Returns :
|
||||
|
||||
* Notes :
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void Vout_Ctrl_ON(uint8_t Type)
|
||||
{
|
||||
SFRADDR = P0_OE;
|
||||
SFRDATA |= 0x04; //设置P02为输出,P01为Floating
|
||||
SFRDATA &= 0xFD;
|
||||
|
||||
COM_CTRL = 0;
|
||||
|
||||
BST_EN = 1;
|
||||
|
||||
if( Type == ON )
|
||||
{
|
||||
VOX_CTL0 |= 0x30; //VOX Enable 5V
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* void Vox_Det_Machine(void)
|
||||
*
|
||||
* Description : Vox Detect:耳机识别。 (100ms调用周期)
|
||||
*
|
||||
* Arguments : NONE
|
||||
|
||||
* Returns : NONE
|
||||
|
||||
* Notes : NONE
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
void Vox_Det_Machine(void)
|
||||
{
|
||||
static bit Get_CHIP_STA1_Flag1;
|
||||
|
||||
static bit Cover_Close_Flag;
|
||||
|
||||
static bit Cover_Open_Flag;
|
||||
|
||||
static bit TX_Cmd_Flag;
|
||||
|
||||
static bit Cover_Open_5V_Flag;
|
||||
|
||||
static bit Cover_Close_Flag0;
|
||||
|
||||
static bit Cover_Close_Flag1;
|
||||
|
||||
static bit Bat_Low_Pro_Flag;
|
||||
|
||||
static bit Vox_Chg_Full_Flag;
|
||||
|
||||
static uint8_t CHIP_STA1_BK;
|
||||
|
||||
static bit Follow_Chg_Start_Flag;
|
||||
|
||||
static uint8_t Vox_Vol_Hold_Timer;
|
||||
|
||||
static uint8_t Vox_TX_Timer;
|
||||
|
||||
static uint8_t Vox_TX_Timer1;
|
||||
|
||||
static uint8_t Vox_Output_Debounce;
|
||||
|
||||
/*Vox 过流保护,两只耳机都每隔200ms打嗝一次*/
|
||||
if( IRQ_FLAG0 & 0x0C )
|
||||
{
|
||||
IRQ_FLAG0 = 0x0C;
|
||||
|
||||
VOX_CTL0 &= ~0x30; //VOX Disable 5V And Disable VOX ADT
|
||||
|
||||
VOX_CTL0 |= 0x30; //VOX Enable 5V
|
||||
|
||||
Vox_Output_Short_Flag = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Vox_Output_Short_Flag = 0;
|
||||
|
||||
if( gBoost_Prepared_Flag )
|
||||
{
|
||||
if( CoverEvent_Flg ) //Hall事件触发。
|
||||
{
|
||||
if( !BST_EN )
|
||||
{
|
||||
Vout_Ctrl_ON(OFF);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOX_CTL0 |= 0x30; //VOX Enable 5V
|
||||
|
||||
Vox_Output_Debounce = 0;
|
||||
|
||||
Vox_Vol_Hold_Timer = 0; //关盖清0,开盖使用
|
||||
|
||||
Vox_TX_Timer = 0;
|
||||
|
||||
Vox_TX_Timer1 = 0;
|
||||
|
||||
Get_CHIP_STA1_Flag1 = 0;
|
||||
|
||||
Earphone_Num_2Inbox = 0;
|
||||
|
||||
if( CoverStatus == CLOSE ) //1、关盖关闭COM_CTRL;显示灯效。(无需查询Loadon、IOFF状态,无论耳机是否在仓,Vox 5V输出。)
|
||||
{
|
||||
Earphone_Chg_Flag = 0; //关盖取消耳机入盒灯效,显示关盖灯效。
|
||||
|
||||
Cover_Close_Flag = 1;
|
||||
|
||||
Cover_Close_Flag0 = 1;
|
||||
|
||||
Cover_Close_Flag1 = 1;
|
||||
|
||||
Vox_Vout_Enable = ON;
|
||||
|
||||
Cover_Open_Flag = 0;
|
||||
|
||||
Follow_Chg_Start_Flag = 0;
|
||||
|
||||
Vox_Chg_Full_Flag = 0;
|
||||
|
||||
#if VOX_FOLLOW_CHG
|
||||
Boost_VoxVout_Follow_Flag = 0;
|
||||
#endif
|
||||
}
|
||||
else //2、开盖处理:5v 500ms 转0V 500ms,后转ADT模式。
|
||||
{
|
||||
Cover_Close_Flag = 0;
|
||||
|
||||
Cover_Open_Flag = 1;
|
||||
|
||||
Cover_Open_5V_Flag = 0;
|
||||
}
|
||||
|
||||
CoverEvent_Flg = 0;
|
||||
}
|
||||
|
||||
/* 发送开盖指令*/
|
||||
if( Cover_Open_Flag ) /*开盖后,5V持续500ms后0V持续500ms,Vox转入adt模式,等待耳机出入盒,并显示相应的灯效。*/
|
||||
{
|
||||
if( Vox_Vol_Hold_Timer < VOX_VOUT_5V_DEBOUNCE ) //开关盖后5V 200ms,用于唤醒耳机。
|
||||
{
|
||||
Vox_Vol_Hold_Timer++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( Vox_TX_Timer < VOX_VOUT_0V_DEBOUNCE ) //转0V 200ms
|
||||
{
|
||||
Vout_Ctrl_OFF(OFF);
|
||||
|
||||
Vox_TX_Timer++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*按键1.5s、拔充电后Vox升压一段时间,用于唤醒耳机。*/
|
||||
if( Wkup_Earphone_Flag )
|
||||
{
|
||||
if( !BST_EN )
|
||||
{
|
||||
Vout_Ctrl_ON(OFF);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Get_CHIP_STA1_Flag1 = 0;
|
||||
|
||||
Vox_TX_Timer1 = 0;
|
||||
|
||||
VOX_CTL0 |= 0x30; //VOX Enable 5V
|
||||
|
||||
Wkup_Earphone_Flag = 0;
|
||||
}
|
||||
|
||||
if( !Get_CHIP_STA1_Flag1 )
|
||||
{
|
||||
if( Vox_Output_Debounce <= Vox_TX_Pattern_Tim )
|
||||
{
|
||||
if( (Vox_Output_Debounce % Vox_TX_Interval == 0) )
|
||||
{
|
||||
if( (CHIP_STA1 & 0xA0) == 0xA0 )
|
||||
{
|
||||
#if VOX_TX_PATTERN
|
||||
Pattern_TX_Start = 1;
|
||||
|
||||
g_Key_Type = 0;
|
||||
|
||||
Pattern_TX_Data = bat_level_pdata | 0xC4;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Vox_Output_Debounce++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if( Vox_TX_Timer1 < VOX_ADT_HOLD_CNT ) //关盖后5V持续300ms。
|
||||
{
|
||||
Vox_TX_Timer1++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Vox_Output_Debounce = 0;
|
||||
|
||||
Get_CHIP_STA1_Flag1 = 1;
|
||||
|
||||
Vout_Ctrl_OFF(ON);
|
||||
|
||||
TX_Cmd_Flag = 1;
|
||||
|
||||
Vox_Vout_Enable = OFF;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( TX_Cmd_Flag )
|
||||
{
|
||||
TX_Cmd_Flag = 0;
|
||||
|
||||
Vox_TX_Timer1 = 0;
|
||||
|
||||
if( (CHIP_STA1 & 0xAC) == 0xA0 )
|
||||
{
|
||||
Earphone_Num_2Inbox = 1; //2只耳机在盒,按键3s才能发码。
|
||||
}
|
||||
else
|
||||
{
|
||||
Earphone_Num_2Inbox = 0;
|
||||
}
|
||||
|
||||
CHIP_STA1_BK = CHIP_STA1 & 0xA0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*耳机出入盒判断*/
|
||||
if( CHIP_STA1_BK != (CHIP_STA1 & 0xA0) ) //查询耳机loadon状态,loadon状态改变,则说明有耳机出入盒。
|
||||
{
|
||||
if(CHIP_STA1 & 0xA0)
|
||||
{
|
||||
Earphone_Chg_Flag = 1;
|
||||
#ifdef LED_DISPLAY
|
||||
LED_On_Flag = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
CHIP_STA1_BK = CHIP_STA1 & 0xA0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( Cover_Close_Flag )
|
||||
{
|
||||
/*按键1.5s、拔充电后Vox升压一段时间,用于唤醒耳机。*/
|
||||
if( Wkup_Earphone_Flag )
|
||||
{
|
||||
if( !BST_EN )
|
||||
{
|
||||
Vout_Ctrl_ON(OFF);
|
||||
|
||||
Cover_Close_Flag0 = 0;
|
||||
|
||||
Get_CHIP_STA1_Flag1 = 0;
|
||||
|
||||
Vox_TX_Timer = 0;
|
||||
|
||||
Vox_Vol_Hold_Timer = 0;
|
||||
|
||||
Vox_Chg_Full_Flag = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOX_CTL0 |= 0x30; //VOX Enable 5V
|
||||
|
||||
Wkup_Earphone_Flag = 0;
|
||||
}
|
||||
|
||||
if( Vox_TX_Timer < VOX_CLOSE_HOLD_CNT ) //关盖后5V持续3s。
|
||||
{
|
||||
Vox_TX_Timer++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*关盖后,Vox转入ADT模式,判断有几只耳机在盒。*/
|
||||
if( !Cover_Close_Flag0 )
|
||||
{
|
||||
Vout_Ctrl_OFF(ON); //Vox转入ADT模式。
|
||||
|
||||
Cover_Close_Flag0 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !Get_CHIP_STA1_Flag1 )
|
||||
{
|
||||
if( (CHIP_STA1 & 0xAC) == 0xA0 )
|
||||
{
|
||||
Earphone_Num_2Inbox = 1; //2只耳机在盒,按键3s才能发码。
|
||||
}
|
||||
else
|
||||
{
|
||||
Earphone_Num_2Inbox = 0;
|
||||
}
|
||||
|
||||
Get_CHIP_STA1_Flag1 = 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( !Cover_Close_Flag1 )
|
||||
{
|
||||
|
||||
if( !BST_EN )
|
||||
{
|
||||
Vout_Ctrl_ON(OFF);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOX_CTL0 |= 0x30; //VOX Enable 5V
|
||||
|
||||
Cover_Close_Flag1 = 1;
|
||||
}
|
||||
|
||||
|
||||
#if VOX_FOLLOW_CHG
|
||||
if( !Follow_Chg_Start_Flag )
|
||||
{
|
||||
/*跟随充逻辑*/
|
||||
if( !Boost_VoxVout_Follow_Flag )
|
||||
{
|
||||
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
|
||||
|
||||
Boost_VoxVout_Follow_Flag = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Vox_Vol_Hold_Timer < VOX_FOLLOW_CHG_CNT ) //等耳机抽电。
|
||||
{
|
||||
Vox_Vol_Hold_Timer++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Vox_Vol_Hold_Timer = 0;
|
||||
|
||||
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;
|
||||
|
||||
Follow_Chg_Start_Flag = 1;
|
||||
|
||||
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 = OTP_KEY;
|
||||
SFRDATA = 0x69;
|
||||
|
||||
SFRADDR = BST_CTL0; //Boost 输出
|
||||
SFRDATA &= ~0x03;
|
||||
SFRDATA |= Boost_Vout_Value;
|
||||
|
||||
SFRADDR = OTP_KEY;
|
||||
SFRDATA = 0x01;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if( !Vox_Chg_Full_Flag )
|
||||
{
|
||||
if( ( (CHIP_STA1 & 0xAC) == 0xAC ) ) //耳机充满或盒子低电,则关闭Vout输出通路,关闭Boost。
|
||||
{
|
||||
if( Vox_Vol_Hold_Timer < VOX_VOUT_5V_LEAST_CNT ) //重载转轻载延时5s后关闭Boost输出。
|
||||
{
|
||||
Vox_Vol_Hold_Timer++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Vox_Chg_Full_Flag = 1;
|
||||
|
||||
Vox_Vout_Enable = OFF;
|
||||
|
||||
Vout_Ctrl_OFF(ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bat_Low_Pro_Flag = 0;
|
||||
}
|
||||
#if 1
|
||||
else
|
||||
{
|
||||
if( !Bat_Low_Pro_Flag )
|
||||
{
|
||||
Bat_Low_Pro_Flag = 1;
|
||||
|
||||
Vox_Vout_Enable = OFF;
|
||||
|
||||
Vout_Ctrl_OFF(ON);
|
||||
|
||||
CHIP_STA1_BK = CHIP_STA1 & 0xA0;
|
||||
|
||||
Wkup_Earphone_Flag = 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*耳机出入盒判断*/
|
||||
if( CHIP_STA1_BK != (CHIP_STA1 & 0xA0) ) //查询耳机loadon状态,loadon状态改变,则说明有耳机出入盒。
|
||||
{
|
||||
if(CHIP_STA1 & 0xA0)
|
||||
{
|
||||
Earphone_Chg_Flag = 1;
|
||||
#ifdef LED_DISPLAY
|
||||
LED_On_Flag = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
CHIP_STA1_BK = CHIP_STA1 & 0xA0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#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