1、首次提交,已经正常点亮
This commit is contained in:
commit
aebbd7deb4
|
|
@ -0,0 +1,85 @@
|
|||
# A .gitignore for Keil projects.
|
||||
# Taken mostly from http://www.keil.com/support/man/docs/uv4/uv4_b_filetypes.htm
|
||||
|
||||
# User-specific uVision files
|
||||
*.opt
|
||||
*.uvopt
|
||||
*.uvoptx
|
||||
*.uvgui
|
||||
*.uvgui.*
|
||||
*.uvguix.*
|
||||
|
||||
# Listing files
|
||||
#*.cod
|
||||
#*.map
|
||||
#*.m51
|
||||
#*.m66
|
||||
*._ip
|
||||
*.i
|
||||
*.lst
|
||||
*/Listings/*.txt
|
||||
|
||||
# define exception below if needed
|
||||
*.scr
|
||||
|
||||
# Object and HEX files
|
||||
*.axf
|
||||
*.b[0-3][0-9]
|
||||
*.hex
|
||||
*.d
|
||||
*.crf
|
||||
*.elf
|
||||
*.hex
|
||||
*.h86
|
||||
*.obj
|
||||
*.o
|
||||
*.sbr
|
||||
*.htm
|
||||
|
||||
# Build files
|
||||
# define exception below if needed
|
||||
*.bat
|
||||
*._ia
|
||||
*.__i
|
||||
*._ii
|
||||
|
||||
# Generated output files
|
||||
/Listings/*
|
||||
/Objects/*
|
||||
|
||||
# Debugger files
|
||||
# define exception below if needed
|
||||
*.ini
|
||||
|
||||
# Other files
|
||||
*.build_log.htm
|
||||
*.cdb
|
||||
*.dep
|
||||
*.ic
|
||||
*.lin
|
||||
*.lnp
|
||||
*.orc
|
||||
# define exception below if needed
|
||||
*.pack
|
||||
# define exception below if needed
|
||||
*.pdsc
|
||||
*.plg
|
||||
# define exception below if needed
|
||||
*.sct
|
||||
*.sfd
|
||||
*.sfr
|
||||
|
||||
# Miscellaneous
|
||||
*.tra
|
||||
*.fed
|
||||
*.l1p
|
||||
*.l2p
|
||||
*.iex
|
||||
|
||||
|
||||
/si/
|
||||
!*.bin
|
||||
!*.map
|
||||
|
||||
# To explicitly override the above, define any exceptions here; e.g.:
|
||||
# !my_customized_scatter_file.sct
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,57 @@
|
|||
; generated by Component: ARM Compiler 5.06 update 6 (build 750) Tool: ArmCC [4d3637]
|
||||
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave --gnu -o.\objects\board.o --asm_dir=.\Listings\ --list_dir=.\Listings\ --depend=.\objects\board.d --cpu=Cortex-M0 --apcs=interwork --diag_suppress=9931 -I..\..\src -I..\..\src\board -I..\..\src\common -I..\..\src\sdk\include -I..\..\src\sdk\include\M0 -I..\..\src\app -I"..\..\src\app\Honor 90Pro" -I..\..\src\aod\aod -I..\..\src\aod\aod_draw_mode -I..\..\src\aod\draw_mode -I.\RTE\_WL668T -IC:\Keil_v5\ARM\PACK\ARM\CMSIS\5.5.1\CMSIS\Core\Include -IC:\Keil_v5\ARM\PACK\ARM\CMSIS\5.5.1\Device\ARM\ARMCM0\Include -D__MICROLIB -D__UVISION_VERSION=528 -D_RTE_ -DARMCM0 --omf_browse=.\objects\board.crf ..\..\src\board\board.c]
|
||||
THUMB
|
||||
|
||||
AREA ||i.board_Init||, CODE, READONLY, ALIGN=2
|
||||
|
||||
board_Init PROC
|
||||
;;;20 */
|
||||
;;;21 void board_Init(void)
|
||||
000000 b510 PUSH {r4,lr}
|
||||
;;;22 {
|
||||
;;;23 /* system init ,配置MCU时钟 */
|
||||
;;;24 hal_system_init(HAL_SYSCLK_80M);
|
||||
000002 4804 LDR r0,|L1.20|
|
||||
000004 f7fffffe BL hal_system_init
|
||||
;;;25
|
||||
;;;26 /* 使用SWD口作为Debug Log输出,可配置成Uart方式 */
|
||||
;;;27 tau_log_init(115200, LOG_PORT_UART0);
|
||||
000008 20e1 MOVS r0,#0xe1
|
||||
00000a 2100 MOVS r1,#0
|
||||
00000c 0240 LSLS r0,r0,#9
|
||||
00000e f7fffffe BL tau_log_init
|
||||
;;;28
|
||||
;;;29 /* systick init,根据需要配置 */
|
||||
;;;30 //hal_system_enable_systick(1);
|
||||
;;;31 }
|
||||
000012 bd10 POP {r4,pc}
|
||||
ENDP
|
||||
|
||||
|L1.20|
|
||||
DCD 0x04c4b400
|
||||
|
||||
;*** Start embedded assembler ***
|
||||
|
||||
#line 1 "..\\..\\src\\board\\board.c"
|
||||
AREA ||.rev16_text||, CODE
|
||||
THUMB
|
||||
EXPORT |__asm___7_board_c_bcd01269____REV16|
|
||||
#line 467 "C:\\Keil_v5\\ARM\\PACK\\ARM\\CMSIS\\5.5.1\\CMSIS\\Core\\Include\\cmsis_armcc.h"
|
||||
|__asm___7_board_c_bcd01269____REV16| PROC
|
||||
#line 468
|
||||
|
||||
rev16 r0, r0
|
||||
bx lr
|
||||
ENDP
|
||||
AREA ||.revsh_text||, CODE
|
||||
THUMB
|
||||
EXPORT |__asm___7_board_c_bcd01269____REVSH|
|
||||
#line 482
|
||||
|__asm___7_board_c_bcd01269____REVSH| PROC
|
||||
#line 483
|
||||
|
||||
revsh r0, r0
|
||||
bx lr
|
||||
ENDP
|
||||
|
||||
;*** End embedded assembler ***
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,89 @@
|
|||
; generated by Component: ARM Compiler 5.06 update 6 (build 750) Tool: ArmCC [4d3637]
|
||||
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave --gnu -o.\objects\main.o --asm_dir=.\Listings\ --list_dir=.\Listings\ --depend=.\objects\main.d --cpu=Cortex-M0 --apcs=interwork --diag_suppress=9931 -I..\..\src -I..\..\src\board -I..\..\src\common -I..\..\src\sdk\include -I..\..\src\sdk\include\M0 -I..\..\src\app -I"..\..\src\app\Honor 90Pro" -I..\..\src\aod\aod -I..\..\src\aod\aod_draw_mode -I..\..\src\aod\draw_mode -I.\RTE\_WL668T -IC:\Keil_v5\ARM\PACK\ARM\CMSIS\5.5.1\CMSIS\Core\Include -IC:\Keil_v5\ARM\PACK\ARM\CMSIS\5.5.1\Device\ARM\ARMCM0\Include -D__MICROLIB -D__UVISION_VERSION=528 -D_RTE_ -DARMCM0 --omf_browse=.\objects\main.crf ..\..\src\app\main.c]
|
||||
THUMB
|
||||
|
||||
AREA ||i.main||, CODE, READONLY, ALIGN=2
|
||||
|
||||
main PROC
|
||||
;;;8
|
||||
;;;9 int main()
|
||||
000000 f7fffffe BL board_Init
|
||||
;;;10 {
|
||||
;;;11 board_Init();
|
||||
;;;12
|
||||
;;;13 while (1)
|
||||
;;;14 {
|
||||
;;;15 #if _MODULE_DEMO_ENABLE
|
||||
;;;16 module_demo_main();
|
||||
;;;17 #endif
|
||||
;;;18
|
||||
;;;19 #if _DEMO_S8_EN
|
||||
;;;20 s8_demo();
|
||||
;;;21 #endif
|
||||
;;;22
|
||||
;;;23 #if _DEMO_S8P_EN
|
||||
;;;24 s8p_demo();
|
||||
;;;25 #endif
|
||||
;;;26
|
||||
;;;27 #if _DEMO_S9_EN
|
||||
;;;28 s9_demo();
|
||||
;;;29 #endif
|
||||
;;;30
|
||||
;;;31 #if _DEMO_HONOR_90Pro_EN
|
||||
;;;32 Note11Pro_demo();
|
||||
000004 f7fffffe BL Note11Pro_demo
|
||||
;;;33 #endif
|
||||
;;;34 TAU_LOGD("668 Demo\n");
|
||||
000008 2322 MOVS r3,#0x22
|
||||
00000a a203 ADR r2,|L1.24|
|
||||
00000c a104 ADR r1,|L1.32|
|
||||
00000e 2000 MOVS r0,#0
|
||||
000010 f7fffffe BL tau_log_printf
|
||||
|L1.20|
|
||||
;;;35 while (1);
|
||||
000014 e7fe B |L1.20|
|
||||
;;;36 }
|
||||
;;;37 }
|
||||
ENDP
|
||||
|
||||
000016 0000 DCW 0x0000
|
||||
|L1.24|
|
||||
000018 7461755f DCB "tau_log",0
|
||||
00001c 6c6f6700
|
||||
|L1.32|
|
||||
000020 5b25735d DCB "[%s] (%04d) 668 Demo\n",0
|
||||
000024 20282530
|
||||
000028 34642920
|
||||
00002c 36363820
|
||||
000030 44656d6f
|
||||
000034 0a00
|
||||
000036 00 DCB 0
|
||||
000037 00 DCB 0
|
||||
|
||||
;*** Start embedded assembler ***
|
||||
|
||||
#line 1 "..\\..\\src\\app\\main.c"
|
||||
AREA ||.rev16_text||, CODE
|
||||
THUMB
|
||||
EXPORT |__asm___6_main_c_main____REV16|
|
||||
#line 467 "C:\\Keil_v5\\ARM\\PACK\\ARM\\CMSIS\\5.5.1\\CMSIS\\Core\\Include\\cmsis_armcc.h"
|
||||
|__asm___6_main_c_main____REV16| PROC
|
||||
#line 468
|
||||
|
||||
rev16 r0, r0
|
||||
bx lr
|
||||
ENDP
|
||||
AREA ||.revsh_text||, CODE
|
||||
THUMB
|
||||
EXPORT |__asm___6_main_c_main____REVSH|
|
||||
#line 482
|
||||
|__asm___6_main_c_main____REVSH| PROC
|
||||
#line 483
|
||||
|
||||
revsh r0, r0
|
||||
bx lr
|
||||
ENDP
|
||||
|
||||
;*** End embedded assembler ***
|
||||
|
||||
__ARM_use_no_argv EQU 0
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
/*
|
||||
* Auto generated Run-Time-Environment Configuration File
|
||||
* *** Do not modify ! ***
|
||||
*
|
||||
* Project: 'WL668T'
|
||||
* Target: 'WL668'
|
||||
*/
|
||||
|
||||
#ifndef RTE_COMPONENTS_H
|
||||
#define RTE_COMPONENTS_H
|
||||
|
||||
|
||||
/*
|
||||
* Define the Device Header File:
|
||||
*/
|
||||
#define CMSIS_device_header "ARMCM0.h"
|
||||
|
||||
|
||||
|
||||
#endif /* RTE_COMPONENTS_H */
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
/*
|
||||
* Auto generated Run-Time-Environment Configuration File
|
||||
* *** Do not modify ! ***
|
||||
*
|
||||
* Project: 'WL668T'
|
||||
* Target: 'WL668T'
|
||||
*/
|
||||
|
||||
#ifndef RTE_COMPONENTS_H
|
||||
#define RTE_COMPONENTS_H
|
||||
|
||||
|
||||
/*
|
||||
* Define the Device Header File:
|
||||
*/
|
||||
#define CMSIS_device_header "ARMCM0.h"
|
||||
|
||||
|
||||
|
||||
#endif /* RTE_COMPONENTS_H */
|
||||
|
|
@ -0,0 +1,461 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>WL668T</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pArmCC>5060750::V5.06 update 6 (build 750)::ARMCC</pArmCC>
|
||||
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>ARMCM0</Device>
|
||||
<Vendor>ARM</Vendor>
|
||||
<PackID>ARM.CMSIS.5.5.1</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000,0x00020000) IROM(0x00000000,0x00040000) CPUTYPE("Cortex-M0") CLOCK(12000000) ESEL ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000)</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:ARMCM0$Device\ARM\ARMCM0\Include\ARMCM0.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></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\Objects\</OutputDirectory>
|
||||
<OutputName>WL668T_Honor90Pro_20240424</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\Listings\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>1</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>fromelf --bin -o .\Objects\@L.bin .\Objects\@L.axf</UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments> </SimDllArguments>
|
||||
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM0</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments> </TargetDllArguments>
|
||||
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM0</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>1</AdsALst>
|
||||
<AdsACrf>1</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>1</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>1</AdsLsun>
|
||||
<AdsLven>1</AdsLven>
|
||||
<AdsLsxf>1</AdsLsxf>
|
||||
<RvctClst>1</RvctClst>
|
||||
<GenPPlst>1</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M0"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>16</StupSel>
|
||||
<useUlib>1</useUlib>
|
||||
<EndSel>1</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>4</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>0</Ir1Chk>
|
||||
<Ir2Chk>1</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>1</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x20000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x40000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x2000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x10000</StartAddress>
|
||||
<Size>0x10000</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x70000</StartAddress>
|
||||
<Size>0x8000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>3</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>2</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>1</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>1</v6Lang>
|
||||
<v6LangP>1</v6LangP>
|
||||
<vShortEn>1</vShortEn>
|
||||
<vShortWch>1</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\src;..\..\src\board;..\..\src\common;..\..\src\sdk\include;..\..\src\sdk\include\M0;..\..\src\app;..\..\src\app\Honor 90Pro;..\..\src\aod\aod;..\..\src\aod\aod_draw_mode;..\..\src\aod\draw_mode</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x00000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile></ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc></Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>app</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\src\app\main.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>Honor90Pro_demo.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\src\app\Honor 90Pro\Honor90Pro_demo.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>driver</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>CVWL668T.lib</FileName>
|
||||
<FileType>4</FileType>
|
||||
<FilePath>..\..\src\sdk\CVWL668T\lib\CVWL668T.lib</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>board</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>board.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\src\board\board.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>startup</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>startup_ARMCM0.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>..\..\src\board\startup\startup_ARMCM0.s</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components>
|
||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.2.0" condition="ARMv6_7_8-M Device">
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.5.1"/>
|
||||
<targetInfos>
|
||||
<targetInfo name="WL668T"/>
|
||||
</targetInfos>
|
||||
</component>
|
||||
</components>
|
||||
<files>
|
||||
<file attr="config" category="sourceAsm" condition="ARMCC" name="Device\ARM\ARMCM0\Source\ARM\startup_ARMCM0.s" version="1.0.0">
|
||||
<instance index="0" removed="1">RTE\Device\ARMCM0\startup_ARMCM0.s</instance>
|
||||
<component Cclass="Device" Cgroup="Startup" Cvendor="ARM" Cversion="1.1.0" condition="ARMCM0 CMSIS"/>
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.5.1"/>
|
||||
<targetInfos/>
|
||||
</file>
|
||||
<file attr="config" category="sourceC" name="Device\ARM\ARMCM0\Source\system_ARMCM0.c" version="1.0.0">
|
||||
<instance index="0" removed="1">RTE\Device\ARMCM0\system_ARMCM0.c</instance>
|
||||
<component Cclass="Device" Cgroup="Startup" Cvendor="ARM" Cversion="1.1.0" condition="ARMCM0 CMSIS"/>
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.5.1"/>
|
||||
<targetInfos/>
|
||||
</file>
|
||||
</files>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
1. 此目录下所有project文件仅为链接文件(使用宏定义和库文件区分)
|
||||
|
||||
2. 强烈建议将不使用的芯片型号文件夹删除,仅保留使用的芯片型号文件夹,以免串烧导致芯片烧坏
|
||||
|
||||
3. 如若更换芯片,仅需将提供的原工程下特定型号文件夹拷贝到模板工程,删除原芯片project下原型号文件夹,重新编译即可
|
||||
如原来使用668芯片,后面更换为668T芯片,仅需把客户工程project下668文件夹删除,重新从提供的源工程下的668T文件夹拷贝到客户工程project下,打开重新编译即可
|
||||
|
||||
注:SDK每次更新会在demo.c中增加代码或注释,请自行阅读。
|
||||
|
||||
|
||||
第三代产品包括:WL668,668T,468
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2019-2022, TAU Systems (R),All Rights Reserved.
|
||||
*
|
||||
* File: Mi12Lite.h
|
||||
* Description XiaoMi 12 Lite file
|
||||
* Version V0.1
|
||||
* Date 2023-06-25
|
||||
* Author Jaya
|
||||
*******************************************************************************/
|
||||
#ifndef __MI12_S20P_H__
|
||||
#define __MI12_S20P_H__
|
||||
|
||||
void s20p_demo(void);
|
||||
|
||||
#endif /* __MI12_LITE_DEMO_H__ */
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "test_cfg_global.h"
|
||||
#include "tau_log.h"
|
||||
#include "hal_system.h"
|
||||
#include "board.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
board_Init();
|
||||
|
||||
while (1)
|
||||
{
|
||||
#if _MODULE_DEMO_ENABLE
|
||||
module_demo_main();
|
||||
#endif
|
||||
|
||||
#if _DEMO_S8_EN
|
||||
s8_demo();
|
||||
#endif
|
||||
|
||||
#if _DEMO_S8P_EN
|
||||
s8p_demo();
|
||||
#endif
|
||||
|
||||
#if _DEMO_S9_EN
|
||||
s9_demo();
|
||||
#endif
|
||||
|
||||
#if _DEMO_HONOR_90Pro_EN
|
||||
Note11Pro_demo();
|
||||
#endif
|
||||
TAU_LOGD("668 Demo\n");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
module_demo:存放hal层给客户的demo code,每个客户都需要release
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_crc.c
|
||||
* Description: crc demo源文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: zzf
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "demo_hal_crc.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "crc-log"
|
||||
|
||||
/* CRC计算方式,0-CPU方式; 1-DMA方式 */
|
||||
#define CRC_DMA_CAL_EN (1)
|
||||
|
||||
/* for max total of test elements */
|
||||
#define CRC_ELEMENT_MAX_TATOL (32u)
|
||||
/* for crc initial POL regs value */
|
||||
#define CRC_32_POL_VALUE0 (0x04C11DB7u)
|
||||
#define CRC_16_POL_VALUE0 (0x8005u)
|
||||
/* for crc calculate in crc software calculate */
|
||||
#define CRC_SEED_VALUE_0 (0u)
|
||||
#define CRC_SEED_VALUE_F (0xFFFFu)
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global function and Global variable declarations
|
||||
*******************************************************************************/
|
||||
#if CRC_DMA_CAL_EN
|
||||
/* all the one element value crc calculate for software crc */
|
||||
static uint32_t sg_crc32_arry[CRC_ELEMENT_MAX_TATOL] =
|
||||
{
|
||||
0x00000000, 0xFFFFFFFF, 0xAAAAAAAA, 0xEEEEEEEE, 0x55555555, 0x66666666, 0x11111111, 0x77777777,
|
||||
0x12345678, 0x456789AB, 0x89ABCDEF, 0x3456789A, 0x6789ABCD, 0x9ABCDEF0, 0xBCDEF012, 0xFEDCAB98,
|
||||
0x5a5aa5a5, 0x37377373, 0x98988989, 0x76767676, 0x41233214, 0x67433467, 0x91DF91DF, 0x76347634,
|
||||
0x46378912, 0x57351059, 0xABFC9483, 0x837204AF, 0x41057DBA, 0x893CD024, 0x56378105, 0xFA34610B,
|
||||
};
|
||||
#else
|
||||
/* all the one element value crc calculate for software crc */
|
||||
static uint16_t sg_crc16_element_arry[CRC_ELEMENT_MAX_TATOL] =
|
||||
{
|
||||
0x0000, 0xFFFF, 0xAAAA, 0x2222, 0x3333, 0xDDDD, 0x9999, 0x8888,
|
||||
0x1234, 0x5678, 0x9ABC, 0x2345, 0x4567, 0xABCD, 0xCDEF, 0x789A,
|
||||
0x5a5a, 0x2323, 0x6868, 0x5aa5, 0x7887, 0x8558, 0x6336, 0xAFAF,
|
||||
0x3194, 0x7853, 0x7733, 0x76DE, 0x89CA, 0x7401, 0x7392, 0xD2A8,
|
||||
};
|
||||
#endif
|
||||
/*******************************************************************************
|
||||
* 4.Global function prototypes
|
||||
*******************************************************************************/
|
||||
#if CRC_DMA_CAL_EN
|
||||
/**
|
||||
* @brief DMA计算CRC值回调函数
|
||||
* @param calculate_result: CRC计算结果
|
||||
* @retval None
|
||||
*/
|
||||
void demo_crc_dma_callback(uint32_t calculate_result)
|
||||
{
|
||||
TAU_LOGD("dma demo[0x%x]\n", calculate_result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DMA计算CRC值
|
||||
* @param None
|
||||
* @retval true or false
|
||||
*/
|
||||
bool demo_crc_array_dma_cal(void)
|
||||
{
|
||||
crc_ctrl_handle_t crc_cfg_para =
|
||||
{
|
||||
CRC_32_POL_VALUE0,
|
||||
CRC_SEED_VALUE_0,
|
||||
CRC_32_BIT_PROTOCOL,
|
||||
CRC_FXOR_ENABLE,
|
||||
CRC_REV_ONLY_BITS_TRANSPOSE,
|
||||
CRC_REV_ONLY_BITS_TRANSPOSE
|
||||
};
|
||||
|
||||
hal_crc_dma_init(&crc_cfg_para, demo_crc_dma_callback, sg_crc32_arry, CRC_ELEMENT_MAX_TATOL);
|
||||
|
||||
hal_crc_dma_start();
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* @brief CPU阻塞式计算CRC值
|
||||
* @param None
|
||||
* @retval true or false
|
||||
*/
|
||||
bool demo_crc_array_cal(void)
|
||||
{
|
||||
crc_ctrl_handle_t crc_cfg_para =
|
||||
{
|
||||
CRC_16_POL_VALUE0,
|
||||
CRC_SEED_VALUE_F,
|
||||
CRC_16_BIT_PROTOCOL,
|
||||
CRC_FXOR_ENABLE,
|
||||
CRC_REV_BOTH_TRANSPOSE,
|
||||
CRC_REV_BOTH_TRANSPOSE
|
||||
};
|
||||
|
||||
hal_crc_init(&crc_cfg_para);
|
||||
uint32_t output_crc = hal_crc_cal(sg_crc16_element_arry, CRC_ELEMENT_MAX_TATOL);
|
||||
TAU_LOGD("cpu demo[0x%x]\n", output_crc);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief demo测试接口函数
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void demo_hal_crc_case(void)
|
||||
{
|
||||
TAU_LOGD("HAL CRC DEMO.\n");
|
||||
|
||||
#if CRC_DMA_CAL_EN
|
||||
demo_crc_array_dma_cal(); // DMA方式计算
|
||||
#else
|
||||
demo_crc_array_cal(); // CPU方式计算
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_crc.h
|
||||
* Description: crc demo头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: zzf
|
||||
*******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "hal_crc.h"
|
||||
#include "tau_delay.h"
|
||||
#include "tau_log.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifndef _DEMO_HAL_CRC_H_
|
||||
#define _DEMO_HAL_CRC_H_
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief demo测试接口函数
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void demo_hal_crc_case(void);
|
||||
|
||||
#endif //_DEMO_HAL_CRC_H_
|
||||
|
|
@ -0,0 +1,212 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_dsi_rx.c
|
||||
* Description: dsi rx 测试文件
|
||||
* Version: V0.1
|
||||
* Date: 2020-06-12
|
||||
* Author: lzy
|
||||
*******************************************************************************/
|
||||
|
||||
#include "tau_device_datatype.h"
|
||||
#include "tau_log.h"
|
||||
#include "tau_operations.h"
|
||||
#include "tau_common.h"
|
||||
#include "hal_dsi_rx_ctrl.h"
|
||||
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "demo_hal_dsi_rx"
|
||||
|
||||
//客户可配参数
|
||||
//输入配置
|
||||
#define INPUT_WIDTH 720
|
||||
#define INPUT_HEIGHT 1280
|
||||
//输入 MIPI lane rate,video mode 下需要计算delay, command mode可以不设置或者随便设置
|
||||
#define INPUT_MIPI_LANE_RATE 481000000
|
||||
//输入图像格式
|
||||
#define INPUT_COLOR_MODE DSI_RGB888
|
||||
//输出数据格式(DSI_DATA_CMD_MODE , DSI_DATA_VIDEO_MODE)
|
||||
#define INPUT_DATA_MODE DSI_DATA_VIDEO_MODE
|
||||
//输入mipi lane数量(DSI_RX_LANE_x x为1-4)
|
||||
#define INPUT_MIPI_LANE_NUM DSI_LANE_4
|
||||
//输入为video mode 时数据格式
|
||||
#define INPUT_VIDEO_MODEL DSI_NONBURST_EVENT
|
||||
//输入虚拟通道(0-3)
|
||||
#define INPUT_VC DSI_VC_0
|
||||
//输入的帧率(60/90/120/144Hz)
|
||||
#define INPUT_FRAME_RATE DSI_FRAME_RATE_60HZ
|
||||
//输入数据是否DSC压缩
|
||||
#define INPUT_COMPRESS false
|
||||
|
||||
//输出配置
|
||||
#define OUTPUT_WIDTH 720
|
||||
#define OUTPUT_HEIGHT 1280
|
||||
|
||||
static hal_dsi_rx_ctrl_handle_t *g_rx_ctrl_handle = NULL;
|
||||
|
||||
//客制化DCS处理函数
|
||||
static bool cus_dsc_execute(hal_dsi_rx_ctrl_handle_t *handler, hal_dcs_packet_t *dcs_packet)
|
||||
{
|
||||
TAU_LOGD("cus_dsc_execute DCS[0x%x]\n", dcs_packet->dcs_command);
|
||||
for (int i = 0; i < dcs_packet->param_length; i ++)
|
||||
{
|
||||
TAU_LOGD("cus_dsc_execute param[%d]:0x%x\n", i, dcs_packet->packet_param[i]);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* ack long cmd */
|
||||
hal_dsi_rx_ctrl_send_ack_cmd(g_rx_ctrl_handle,
|
||||
DSI_ACK_DT_GEN_LONG_RESPONSE,
|
||||
DSI_VC_0,
|
||||
5,
|
||||
0x1,
|
||||
0x2,
|
||||
0x3,
|
||||
0x4,
|
||||
0x5);
|
||||
#else
|
||||
/* ack short cmd */
|
||||
hal_dsi_rx_ctrl_send_ack_cmd(g_rx_ctrl_handle,
|
||||
DSI_ACK_DT_DCS_SHORT_RESPONSE_1B,
|
||||
DSI_VC_0,
|
||||
1,
|
||||
0xC1);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ap_dcs_read(uint8_t data_type, uint8_t dcs_cmd, uint8_t param)
|
||||
{
|
||||
if (dcs_cmd == 0xaa)
|
||||
{
|
||||
uint8_t cmd[] = {DSI_ACK_DT_DCS_LONG_RESPONSE,
|
||||
212, 0, 1,
|
||||
0x21, 0x07, 0x2C, 0x27, 0x2B, 0x7A, 0x78, 0x7A,
|
||||
0x7D, 0x7D, 0x7E, 0x7F, 0x7E, 0x7E, 0x7F, 0x7F,
|
||||
0x71, 0xE8, 0x36, 0x2A, 0x2E, 0x07, 0x89, 0x17,
|
||||
0x8B, 0x84, 0x28, 0x26, 0x6D, 0xEB, 0x12, 0x34,
|
||||
0x79, 0x78, 0x79, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C,
|
||||
0x7D, 0x7D, 0x7E, 0x7F, 0x7E, 0x7E, 0x7F, 0x7F,
|
||||
0x7C, 0x67, 0x6E, 0x6c, 0x8A, 0x5B, 0x71, 0x00,
|
||||
0x7D, 0x7D, 0x7E, 0x7F, 0x7E, 0x7E, 0x7F, 0x7F,
|
||||
0x7d, 0x68, 0x61, 0xd9, 0x1A, 0x5B, 0xa7, 0x00,
|
||||
0x7D, 0x7D, 0x7E, 0x7F, 0x7E, 0x7E, 0x7F, 0x7F,
|
||||
0x7e, 0x69, 0x63, 0xe9, 0x3c, 0x5B, 0xfE, 0x00,
|
||||
0x7D, 0x7D, 0x7E, 0x7F, 0x7E, 0x7E, 0x7F, 0x7F,
|
||||
0x7f, 0x60, 0x3E, 0x6f, 0x9b, 0x5B, 0x45, 0x00,
|
||||
0x7D, 0x7D, 0x7E, 0x7F, 0x7E, 0x7E, 0x7F, 0x7F,
|
||||
0x70, 0x61, 0x4E, 0xc9, 0xdA, 0x5B, 0x69, 0x00,
|
||||
0x7D, 0x7D, 0x7E, 0x7F, 0x7E, 0x7E, 0x7F, 0x7F,
|
||||
0x71, 0x63, 0xaE, 0x88, 0x0A, 0x5B, 0x30, 0x00,
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xab, 0xcd, 0xef,
|
||||
0x11, 0x22, 0x33, 0x44, 0x0A, 0x5B, 0x30, 0x00,
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xab, 0xcd, 0xef,
|
||||
0x7f, 0x60, 0x3E, 0x6f, 0x9b, 0x5B, 0x45, 0x00,
|
||||
0x7D, 0x7D, 0x7E, 0x7F, 0x7E, 0x7E, 0x7F, 0x7F,
|
||||
0x7f, 0x60, 0x3E, 0x6f, 0x9b, 0x5B, 0x45, 0x00,
|
||||
0x7D, 0x7D, 0x7E, 0x7F, 0x7E, 0x7E, 0x7F, 0x7F,
|
||||
0x71, 0xE8, 0x36, 0x2A, 0x2E, 0x07, 0x89, 0x17,
|
||||
0x8B, 0x84, 0x28, 0x26, 0x6D, 0xEB, 0x12, 0x34,
|
||||
0x11, 0x22, 0x33, 0x44
|
||||
};
|
||||
/*长包超128字节发送*/
|
||||
hal_dsi_rx_ctrl_ack_long_cmd(g_rx_ctrl_handle, sizeof(cmd) / sizeof(uint8_t), cmd);
|
||||
}
|
||||
else if (dcs_cmd == 0xFE)
|
||||
{
|
||||
uint16_t return_size;
|
||||
return_size = hal_dsi_rx_ctrl_get_max_ret_size(g_rx_ctrl_handle);
|
||||
if (return_size == 3)
|
||||
{
|
||||
uint8_t cmd[] = {DSI_ACK_DT_DCS_LONG_RESPONSE, 3, 0, 1, 0x40, 0x00, 0x03};
|
||||
|
||||
hal_dsi_rx_ctrl_ack_long_cmd(g_rx_ctrl_handle, sizeof(cmd) / sizeof(uint8_t), cmd);
|
||||
}
|
||||
else if (return_size == 32)
|
||||
{
|
||||
|
||||
uint8_t cmd[] = {DSI_ACK_DT_DCS_LONG_RESPONSE,
|
||||
32, 0, 1, 0x01, 0xc4, 0x01, 0xcd, 0x01, 0xfb, 0x55, 0x55,
|
||||
0x55, 0x4e, 0x4c, 0x4e, 0x2e, 0x2d, 0x31, 0x30,
|
||||
0x30, 0x38, 0x49, 0x42, 0x49, 0x3c, 0x39, 0x47,
|
||||
0x01, 0x07, 0x2b, 0xfa, 0x22, 0x19, 0x32, 0x02
|
||||
};
|
||||
|
||||
hal_dsi_rx_ctrl_ack_long_cmd(g_rx_ctrl_handle, sizeof(cmd) / sizeof(uint8_t), cmd);
|
||||
}
|
||||
}
|
||||
|
||||
TAU_LOGD("r %x\n", dcs_cmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static const hal_dcs_execute_entry_t g_cus_rx_dcs_execute_table[] =
|
||||
{
|
||||
{0x83, cus_dsc_execute, false}, //cus dcs 0x83, 处理函数为cus_dsc_execute,不需要立即运行,在while里异步即可
|
||||
{0, NULL, false} //{0,NULL,false} 数组最后一个固定成员,作为table结尾的判断标准
|
||||
};
|
||||
|
||||
static void open_mipi_rx()
|
||||
{
|
||||
if (g_rx_ctrl_handle == NULL)
|
||||
{
|
||||
g_rx_ctrl_handle = hal_dsi_rx_ctrl_create_handle();
|
||||
}
|
||||
|
||||
g_rx_ctrl_handle->base_info.src_w = INPUT_WIDTH;
|
||||
g_rx_ctrl_handle->base_info.src_h = INPUT_HEIGHT;
|
||||
g_rx_ctrl_handle->base_info.dst_w = OUTPUT_WIDTH;
|
||||
g_rx_ctrl_handle->base_info.dst_h = OUTPUT_HEIGHT;
|
||||
g_rx_ctrl_handle->base_info.src_frate = INPUT_FRAME_RATE;
|
||||
g_rx_ctrl_handle->base_info.src_mode = INPUT_DATA_MODE;
|
||||
g_rx_ctrl_handle->rx_color_mode = INPUT_COLOR_MODE;
|
||||
g_rx_ctrl_handle->rx_lanes = INPUT_MIPI_LANE_NUM;
|
||||
g_rx_ctrl_handle->rx_nonburst_models = INPUT_VIDEO_MODEL;
|
||||
g_rx_ctrl_handle->compress_en = INPUT_COMPRESS;
|
||||
g_rx_ctrl_handle->rx_hsclk_rate = INPUT_MIPI_LANE_RATE;
|
||||
g_rx_ctrl_handle->extra_info.flow_control_mode = FC_AUTO_MODE;
|
||||
g_rx_ctrl_handle->cus_dcs_entry_table = g_cus_rx_dcs_execute_table;
|
||||
g_rx_ctrl_handle->rx_dcs_read_entry = ap_dcs_read;
|
||||
|
||||
/*PIN28~PIN19依次为21c03*/
|
||||
g_rx_ctrl_handle->rx_lane_swap = RX_LANE_SWAP_2103;
|
||||
|
||||
/* 对 lane0~lane3 以及clk lane 进行PN交换*/
|
||||
g_rx_ctrl_handle->base_info.pn_swap = RX_LANE_0_PN_SWAP | RX_LANE_1_PN_SWAP | RX_LANE_2_PN_SWAP | RX_LANE_3_PN_SWAP | RX_LANE_CLK_PN_SWAP;
|
||||
|
||||
if (g_rx_ctrl_handle->compress_en == true)
|
||||
{
|
||||
//hal_dsi_rx_ctrl_pre_init_pps(g_rx_ctrl_handle, pps, 128);
|
||||
}
|
||||
hal_dsi_rx_ctrl_init(g_rx_ctrl_handle);
|
||||
#if 0
|
||||
//使用盒子发送读命令 0xA,0xB,0xC,0xD,0xE,0xF,0x1E,0x1D
|
||||
hal_dsi_rx_ctrl_set_auto_ack(g_rx_ctrl_handle, HAL_RX_QRESP_CODE0, DSI_ACK_DT_DCS_SHORT_RESPONSE_1B, 0x0F, 1, 0xab);
|
||||
hal_dsi_rx_ctrl_set_auto_ack(g_rx_ctrl_handle, HAL_RX_QRESP_CODE1, DSI_ACK_DT_DCS_SHORT_RESPONSE_2B, 0x0e, 2, 0xef, 0xcd);
|
||||
hal_dsi_rx_ctrl_set_auto_ack(g_rx_ctrl_handle, HAL_RX_QRESP_CODE2, DSI_ACK_DT_GEN_SHORT_RESPONSE_1B, 0x0a, 1, 0x12);
|
||||
hal_dsi_rx_ctrl_set_auto_ack(g_rx_ctrl_handle, HAL_RX_QRESP_CODE3, DSI_ACK_DT_GEN_SHORT_RESPONSE_2B, 0x0b, 2, 0x34, 0x56);
|
||||
hal_dsi_rx_ctrl_set_auto_ack(g_rx_ctrl_handle, HAL_RX_QRESP_CODE4, DSI_ACK_DT_DCS_LONG_RESPONSE, 0x0c, 4, 0x12, 0x34, 0x56, 0x78);
|
||||
hal_dsi_rx_ctrl_set_auto_ack(g_rx_ctrl_handle, HAL_RX_QRESP_CODE5, DSI_ACK_DT_GEN_LONG_RESPONSE, 0x0d, 4, 0xab, 0xcd, 0xef, 0x9a);
|
||||
hal_dsi_rx_ctrl_set_auto_ack(g_rx_ctrl_handle, HAL_RX_QRESP_CODE6, DSI_ACK_DT_GEN_LONG_RESPONSE, 0x1e, 8, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8);
|
||||
hal_dsi_rx_ctrl_set_auto_ack(g_rx_ctrl_handle, HAL_RX_QRESP_CODE7, DSI_ACK_DT_DCS_LONG_RESPONSE, 0x1d, 8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10);
|
||||
#endif
|
||||
hal_dsi_rx_ctrl_start(g_rx_ctrl_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief test system 主函数
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void demo_hal_dsi_rx_case()
|
||||
{
|
||||
open_mipi_rx();
|
||||
TAU_LOGD("open_mipi_rx done !\n");
|
||||
while (1)
|
||||
{
|
||||
hal_dsi_rx_ctrl_dcs_async_handler(g_rx_ctrl_handle);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_dsi_rx.h
|
||||
* Description: dsi rx 测试头文件
|
||||
* Version: V0.1
|
||||
* Date: 2020-06-12
|
||||
* Author: lzy
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __DEMO_HAL_DSI_RX_H__
|
||||
#define __DEMO_HAL_DSI_RX_H__
|
||||
|
||||
/**
|
||||
* @brief test system 主函数
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void demo_hal_dsi_rx_case(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,389 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_dsi_tx.c
|
||||
* Description: dsi_tx demo源文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: zzf
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "demo_hal_dsi_tx.h"
|
||||
#if AMOLED_NT37280
|
||||
#include "hal_swire.h"
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "tx-log"
|
||||
|
||||
#define DEMO_TX_VPG_EN (0) // 只适用于video模式输入video模式输出
|
||||
#define DEMO_RX_GEN_PATTERN (0) // TX VPG和RX pattern不建议同时打开
|
||||
#define DEMO_CCM_EN (0) // 基于RX pattern数据通路进行CCM调整
|
||||
#define DEMO_ENDIAN_EN (0) // RGB大小端配置
|
||||
#define DEMO_OVERWRITE_EN (0) // Overwrite功能配置
|
||||
#define DEMO_EDGE_DECT_EN (0) // 边缘检测功能配置
|
||||
#define DEMO_EDGE_ENHANCE_EN (0) // 边缘增强功能配置
|
||||
#define DEMO_FC_EN (0) // false color功能配置
|
||||
#define DEMO_BCS_EN (0) // BCS调整功能配置
|
||||
#define DEMO_BTA_LP_EN (0) // LP模式下BTA使用
|
||||
#define DEMO_BTA_HS_EN (0) // HS传输过程中BTA使用
|
||||
|
||||
|
||||
/* base_info输入端信息 */
|
||||
#define INPUT_WIDTH (1440)
|
||||
#define INPUT_HEIGHT (2960)
|
||||
#define INPUT_SRC_FRATE DSI_FRAME_RATE_60HZ
|
||||
/* 输出数据格式(DSI_DATA_CMD_MODE , DSI_DATA_VIDEO_MODE) */
|
||||
#define DSI_INPUT_DATA_MODE DSI_DATA_VIDEO_MODE
|
||||
#define DSI_OUTPUT_DATA_MODE DSI_DATA_VIDEO_MODE
|
||||
/* vid模式选择 */
|
||||
#define OUTPUT_VID_SEL_MODE DSI_BURST_MODE
|
||||
/* 虚拟通道(0-3) */
|
||||
#define VIRTUAL_CHANNEL DSI_VC_0
|
||||
/* TD_RSTN pin脚使用定义宏 */
|
||||
#define PIN_TD_RSTN IO_PAD_TD_RSTN
|
||||
|
||||
#if DEMO_RX_GEN_PATTERN
|
||||
/*输入mipi lane数量(DSI_RX_LANE_x x为1-4)*/
|
||||
#define INPUT_MIPI_LANE_NUM DSI_LANE_4
|
||||
/*输入图像格式*/
|
||||
#define INPUT_COLOR_MODE DSI_RGB888
|
||||
/*video mode输入时数据格式*/
|
||||
#define INPUT_VIDEO_MODEL DSI_NONBURST_EVENT
|
||||
/*输入MIPI lane rate,video mode下需要计算delay,command mode可以不设置或者随便设置*/
|
||||
#define INPUT_MIPI_LANE_RATE (1200000000)
|
||||
/*IPI pattern fps*/
|
||||
#define PATTERN_FPS (60)
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global function and Global variable declarations
|
||||
*******************************************************************************/
|
||||
static hal_dsi_tx_ctrl_handle_t *g_tx_ctrl_handle = NULL;
|
||||
#if DEMO_RX_GEN_PATTERN
|
||||
static hal_dsi_rx_ctrl_handle_t *g_rx_ctrl_handle = NULL;
|
||||
static uint8_t g_rx_pattern_sel = 0; // 0:Vertical mode ; 1:Horizontal mode
|
||||
#endif
|
||||
static bool panel_init = false;
|
||||
|
||||
#if DEMO_BTA_LP_EN
|
||||
static uint8_t bta_ack_data = 0;
|
||||
#endif
|
||||
|
||||
#if DEMO_BTA_HS_EN
|
||||
static bool sg_bta_need_flag = true;
|
||||
#endif
|
||||
/*******************************************************************************
|
||||
* 4.Global function prototypes
|
||||
*******************************************************************************/
|
||||
#if AMOLED_NT37280
|
||||
/**
|
||||
* @brief timer回调函数用于swire输出
|
||||
* @param data: 回调参数
|
||||
* @retval 无
|
||||
*/
|
||||
static void demo_tx_timer_callback(void *data)
|
||||
{
|
||||
hal_swire_set_waveform(12, 12, 12, 12);
|
||||
hal_swire_set_pulse(32);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 打开屏背光
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void demo_tx_panel_backlight_on(void)
|
||||
{
|
||||
hal_gpio_init_output(IO_PAD_AP_PWMEN, IO_LVL_HIGH);
|
||||
hal_swire_init();
|
||||
hal_swire_enable(true);
|
||||
|
||||
hal_swire_set_waveform(12, 12, 12, 12);
|
||||
hal_swire_set_pulse(36);
|
||||
|
||||
hal_timer_init(TIMER_NUM1);
|
||||
hal_timer_start(TIMER_NUM1, 16, demo_tx_timer_callback, NULL);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief PANEL初始化
|
||||
* @param None
|
||||
* @retval None
|
||||
**/
|
||||
void demo_panel_init(void)
|
||||
{
|
||||
#if AMOLED_NT37280
|
||||
demo_tx_panel_backlight_on();
|
||||
#endif
|
||||
|
||||
/*初始化TD_RSTN并产生屏端复位信号*/
|
||||
hal_gpio_init_output(PIN_TD_RSTN, IO_LVL_HIGH);
|
||||
hal_gpio_set_output_data(PIN_TD_RSTN, IO_LVL_HIGH);
|
||||
delayMs(10);
|
||||
hal_gpio_set_output_data(PIN_TD_RSTN, IO_LVL_LOW);
|
||||
delayMs(10);
|
||||
hal_gpio_set_output_data(PIN_TD_RSTN, IO_LVL_HIGH);
|
||||
delayMs(10);
|
||||
|
||||
/*bta read register*/
|
||||
#if DEMO_BTA_LP_EN
|
||||
hal_dsi_tx_ctrl_read_cmd(0x06, 0, 0xDA, 1, &bta_ack_data);
|
||||
TAU_LOGD("DA[0x%x]\n", bta_ack_data);
|
||||
#endif
|
||||
|
||||
/*initial code*/
|
||||
#if LCD_PT628_CSOT
|
||||
TAU_LOGD("LCD_PT628_CSOT pannel init\n");
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xBF, 0x00);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xC0, 0x00);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x00, 0x00);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x39, 0, 4, 0xFF, 0x87, 0x56, 0x01);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x00, 0x80);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x39, 0, 3, 0xFF, 0x87, 0x56);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x00, 0xE8);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xC0, 0x20);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x00, 0x00);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x39, 0, 4, 0xFF, 0x87, 0x56, 0x01);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x00, 0x80);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x39, 0, 3, 0xFF, 0x87, 0x56);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x05, 0, 1, 0x11);
|
||||
delayMs(120);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x35, 0x00);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x39, 0, 3, 0x51, 0x0F, 0xFF);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x05, 0, 1, 0x29);
|
||||
|
||||
#elif AMOLED_NT37280
|
||||
TAU_LOGD("AMOLED_NT37280 pannel init\n");
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xFF, 0xE0);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xFB, 0x01);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x18, 0x80);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x1A, 0x15);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x73, 0x01);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x89, 0x7F);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x0D, 0x9B);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x46, 0x17);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xFF, 0xF0);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xFB, 0x01);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x54, 0x03);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x9C, 0x00);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xFF, 0x20);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xFB, 0x01);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x34, 0x00);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x35, 0x66);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x36, 0x66);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xFF, 0x10);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xFB, 0x01);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x88, 0x07);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x39, 0, 5, 0x2A, 0x00, 0x00, 0x04, 0x37);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x39, 0, 5, 0x2B, 0x00, 0x00, 0x08, 0xE7);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x7F, 0x07);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xE9, 0x00);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xBF, 0x00);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0xC0, 0x00);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x15, 0, 2, 0x35, 0x00); //TE 35=00是标准60Hz; 35=01是有很多小信号
|
||||
hal_dsi_tx_ctrl_write_cmd(0x29, 0, 3, 0x51, 0x0F, 0xFF); //CABC
|
||||
hal_dsi_tx_ctrl_write_cmd(0x05, 0, 1, 0x11);
|
||||
delayMs(120);
|
||||
hal_dsi_tx_ctrl_write_cmd(0x05, 0, 1, 0x29);
|
||||
delayMs(10);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief RX初始化和开启
|
||||
* @param None
|
||||
* @retval None
|
||||
**/
|
||||
static void demo_open_mipi_rx(void)
|
||||
{
|
||||
/*RX demo详细请参考demo_hal_dsi_rx*/
|
||||
#if DEMO_RX_GEN_PATTERN
|
||||
/* 创建rx ctrl handle */
|
||||
if (g_rx_ctrl_handle == NULL)
|
||||
{
|
||||
g_rx_ctrl_handle = hal_dsi_rx_ctrl_create_handle();
|
||||
}
|
||||
g_rx_ctrl_handle->base_info.src_w = INPUT_WIDTH;
|
||||
g_rx_ctrl_handle->base_info.src_h = INPUT_HEIGHT;
|
||||
g_rx_ctrl_handle->base_info.dst_w = __DPI_HACT;
|
||||
g_rx_ctrl_handle->base_info.dst_h = __DPI_VACT;
|
||||
g_rx_ctrl_handle->rx_hsclk_rate = INPUT_MIPI_LANE_RATE;
|
||||
g_rx_ctrl_handle->base_info.src_frate = INPUT_SRC_FRATE;
|
||||
g_rx_ctrl_handle->base_info.src_mode = DSI_INPUT_DATA_MODE;
|
||||
g_rx_ctrl_handle->rx_color_mode = INPUT_COLOR_MODE;
|
||||
g_rx_ctrl_handle->rx_lanes = INPUT_MIPI_LANE_NUM;
|
||||
g_rx_ctrl_handle->rx_nonburst_models = INPUT_VIDEO_MODEL;
|
||||
|
||||
/* 初始化rx ctrl */
|
||||
hal_dsi_rx_ctrl_init(g_rx_ctrl_handle);
|
||||
|
||||
/* 配置RX video pattern */
|
||||
hal_dsi_rx_ctrl_enable_test_pattern(g_rx_ctrl_handle, g_rx_pattern_sel, true, PATTERN_FPS);
|
||||
|
||||
/* 启动rx ctrl */
|
||||
hal_dsi_rx_ctrl_start(g_rx_ctrl_handle);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TX初始化和开启
|
||||
* @param None
|
||||
* @retval None
|
||||
**/
|
||||
static void demo_open_mipi_tx(void)
|
||||
{
|
||||
/*创建TX实例*/
|
||||
if (g_tx_ctrl_handle == NULL)
|
||||
{
|
||||
g_tx_ctrl_handle = hal_dsi_tx_ctrl_create_handle();
|
||||
}
|
||||
g_tx_ctrl_handle->lane_num = _LANE_NUMBER;
|
||||
g_tx_ctrl_handle->channel_id = VIRTUAL_CHANNEL;
|
||||
g_tx_ctrl_handle->vid_mode = OUTPUT_VID_SEL_MODE;
|
||||
g_tx_ctrl_handle->cmd_tx_type = _CMD_TYPE;
|
||||
g_tx_ctrl_handle->dpi_vsa = __DPI_VSA;
|
||||
g_tx_ctrl_handle->dpi_vbp = __DPI_VBP;
|
||||
g_tx_ctrl_handle->dpi_vfp = __DPI_VFP;
|
||||
g_tx_ctrl_handle->dpi_hsa = __DPI_HSA;
|
||||
g_tx_ctrl_handle->dpi_hbp = __DPI_HBP;
|
||||
g_tx_ctrl_handle->dpi_hfp = __DPI_HFP;
|
||||
g_tx_ctrl_handle->base_info.src_w = INPUT_WIDTH;
|
||||
g_tx_ctrl_handle->base_info.src_h = INPUT_HEIGHT;
|
||||
g_tx_ctrl_handle->base_info.dst_w = __DPI_HACT;
|
||||
g_tx_ctrl_handle->base_info.dst_h = __DPI_VACT;
|
||||
g_tx_ctrl_handle->base_info.src_frate = INPUT_SRC_FRATE;
|
||||
g_tx_ctrl_handle->base_info.src_mode = DSI_INPUT_DATA_MODE;
|
||||
g_tx_ctrl_handle->base_info.dst_mode = DSI_OUTPUT_DATA_MODE;
|
||||
|
||||
#if LCD_PT628_CSOT //RGBG玻璃匹配RGB Driver IC
|
||||
//remap规则参数, 此款玻璃remapl_rule/remapr_rule使用同一规则; 如果玻璃存在两个规则需要支持,请定义两个数组分别配置remapl_rule/remapr_rule
|
||||
remap_rule_t remap_rule =
|
||||
{
|
||||
9, 11, 12, 8, 7, 10, 4, 5, 6, 2, 1, 3,
|
||||
20, 19, 22, 21, 23, 24, 14, 13, 15, 16, 17, 18
|
||||
};
|
||||
g_tx_ctrl_handle->pentile_info.pentile_24b = true; // 是否RGB驱动IC搭配RGBG玻璃使用
|
||||
g_tx_ctrl_handle->pentile_info.pentile_reverse_en = true; // 是否需要使用芯片本身行反转功能
|
||||
g_tx_ctrl_handle->pentile_info.pentile_enable = true; // 是否RGBG格式的数据传输
|
||||
g_tx_ctrl_handle->pentile_info.remapl_rule = &remap_rule; // reamp规则1
|
||||
g_tx_ctrl_handle->pentile_info.remapr_rule = &remap_rule; // reamp规则2
|
||||
g_tx_ctrl_handle->pentile_info.rgb_hact = 900; // 如果是RGB驱动IC搭配RGBG玻璃使用,此处配置RGB驱动IC的分辨率;dst_w按玻璃分辨率进行配置
|
||||
/* RGBG 屏幕补黑配置,此款玻璃两块补黑区域均参与子像素重排*/
|
||||
g_tx_ctrl_handle->pentile_info.blank_info0.blank_en = 1; // 是否使用补黑区域0
|
||||
g_tx_ctrl_handle->pentile_info.blank_info0.remap_en = 1; // 补黑区域0是否参与remap重排
|
||||
g_tx_ctrl_handle->pentile_info.blank_info0.st_col = 0; // 补黑区域0起始位置,按有效子像素序号进行计算
|
||||
g_tx_ctrl_handle->pentile_info.blank_info0.width = 12; // 补黑区域0补黑宽度,按子像素级计算
|
||||
g_tx_ctrl_handle->pentile_info.blank_info1.blank_en = 1; // 是否使用补黑区域1
|
||||
g_tx_ctrl_handle->pentile_info.blank_info1.remap_en = 1; // 补黑区域1是否参与remap重排
|
||||
g_tx_ctrl_handle->pentile_info.blank_info1.st_col = 1248; // 补黑区域1起始位置,按有效子像素序号进行计算,必须大于补黑区域0的起始位置
|
||||
g_tx_ctrl_handle->pentile_info.blank_info1.width = 216; // 补黑区域1补黑宽度,按子像素级计算
|
||||
#endif
|
||||
|
||||
#if DEMO_ENDIAN_EN
|
||||
hal_dsi_tx_ctrl_set_endianness(DPI_ENDIAN_BGR);// 默认RGB输出,可以更改为BGR 需要在初始化之前调用
|
||||
#endif
|
||||
|
||||
/*调用初始化接口进行TX初始化*/
|
||||
hal_dsi_tx_ctrl_init(g_tx_ctrl_handle);
|
||||
|
||||
/*屏幕初始化,复位时序和发送initial code*/
|
||||
if (!panel_init)
|
||||
{
|
||||
demo_panel_init();
|
||||
panel_init = true;
|
||||
}
|
||||
|
||||
#if DEMO_TX_VPG_EN /*使用TX VPG测试TX是否正常工作*/
|
||||
hal_dsi_tx_ctrl_set_vpg(true, TX_VPG_V_COLOR, false);
|
||||
#endif
|
||||
|
||||
/*tx start开始传输高速数据*/
|
||||
hal_dsi_tx_ctrl_start(g_tx_ctrl_handle);
|
||||
|
||||
/*可选功能配置,在任意时刻均可调用 start*/
|
||||
#if DEMO_CCM_EN
|
||||
ccm_coef_t coef;
|
||||
coef.coef_c00 = 0x1f3;
|
||||
coef.coef_c01 = 0xf3a;
|
||||
coef.coef_c02 = 0xfd3;
|
||||
coef.coef_c10 = 0xf9c;
|
||||
coef.coef_c11 = 0x19c;
|
||||
coef.coef_c12 = 0xfca;
|
||||
coef.coef_c20 = 0x27;
|
||||
coef.coef_c21 = 0xf46;
|
||||
coef.coef_c22 = 0x193;
|
||||
hal_dsi_tx_ctrl_set_ccm(&coef);
|
||||
#endif
|
||||
|
||||
#if DEMO_OVERWRITE_EN
|
||||
hal_dsi_tx_ctrl_set_overwrite_rgb(0x00, 0x00, 0xFF); //蓝色图形数据输出 参数为R/G/B灰度值
|
||||
hal_dsi_tx_ctrl_overwrite_enable(true); //开启overwrite功能
|
||||
/*........*/
|
||||
//hal_dsi_tx_ctrl_overwrite_enable(false); //需要关闭overwrite功能时调用
|
||||
#endif
|
||||
|
||||
#if DEMO_EDGE_DECT_EN
|
||||
dsi_tx_edge_dect_t edge_dect_para = {0x10, true};
|
||||
hal_dsi_tx_ctrl_set_edge_dect(&edge_dect_para);
|
||||
#endif
|
||||
|
||||
#if DEMO_EDGE_ENHANCE_EN
|
||||
dsi_tx_edge_enh_t edge_enh_para = {true, 64, 4, 64, 0};
|
||||
hal_dsi_tx_ctrl_set_edge_enhance(&edge_enh_para);
|
||||
#endif
|
||||
|
||||
#if DEMO_FC_EN
|
||||
dsi_tx_fc_t fc_para = {64, 64};
|
||||
hal_dsi_tx_ctrl_set_fc(&fc_para);
|
||||
#endif
|
||||
|
||||
#if DEMO_BCS_EN
|
||||
dsi_tx_bcs_t bcs_cfg = {0x00, 0x10, 0x10}; // 参数含义:{明亮度,对比度,饱和度}
|
||||
hal_dsi_tx_ctrl_set_bcs(&bcs_cfg);
|
||||
#endif
|
||||
/*可选功能配置,在任意时刻均可调用 end*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief demo测试接口函数
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void demo_dsi_tx_case(void)
|
||||
{
|
||||
TAU_LOGD("DSI TX DEMO.\n");
|
||||
demo_open_mipi_rx();
|
||||
demo_open_mipi_tx();
|
||||
|
||||
while (1)
|
||||
{
|
||||
#if DEMO_BTA_HS_EN
|
||||
if (sg_bta_need_flag) //当需要进行BTA回读的时候置标志位,等待Vporch阶段进行BTA回读获取有效数据
|
||||
{
|
||||
uint8_t bta_data = 0;
|
||||
if (hal_dsi_tx_ctrl_vporch_bta_opera(0x06, 0xDA, 1, &bta_data))
|
||||
{
|
||||
//Vporch阶段进行BTA回读获取到有效数据,关闭本次回读流程
|
||||
sg_bta_need_flag = false;
|
||||
TAU_LOGD("hs bta[0x%x]\n", bta_data);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_dsi_tx.h
|
||||
* Description: dsi-tx demo头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: zzf
|
||||
*******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "hal_dsi_tx_ctrl.h"
|
||||
#include "hal_dsi_rx_ctrl.h"
|
||||
#include "tau_delay.h"
|
||||
#include "tau_log.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifndef _DEMO_HAL_DSI_TX_H_
|
||||
#define _DEMO_HAL_DSI_TX_H_
|
||||
|
||||
#define LCD_PT628_CSOT (1) //4lane RGBG-1242x2699 RGB-900X2688
|
||||
#define AMOLED_NT37280 (0) //4lane 1080X2280
|
||||
|
||||
#if LCD_PT628_CSOT
|
||||
|
||||
#define _LANE_NUMBER (4) //数据lane的个数
|
||||
#define _CMD_TYPE (DSI_CMD_TX_LP) //0-HS,1-LP;
|
||||
|
||||
#define __DPI_VSA (16) //VSYNC宽度
|
||||
#define __DPI_VBP (16) //VSYNC后的无效像素
|
||||
#define __DPI_VACT (2688) //玻璃V分辨率定义
|
||||
#define __DPI_VFP (123 ) //VSYNC前的无效像素
|
||||
|
||||
#define __DPI_HSA (6) //HSYNC宽度
|
||||
#define __DPI_HBP (18) //HSYNC后的无效像素
|
||||
#define __DPI_HACT (1242) //玻璃H分辨率定义
|
||||
#define __DPI_HFP (32) //HSYNC前的无效像素
|
||||
|
||||
#elif AMOLED_NT37280
|
||||
|
||||
#define _LANE_NUMBER (4) //数据lane的个数
|
||||
#define _CMD_TYPE (DSI_CMD_TX_LP) //0-HS,1-LP;
|
||||
|
||||
#define __DPI_VSA (4) //VSYNC宽度
|
||||
#define __DPI_VBP (28) //VSYNC后的无效像素
|
||||
#define __DPI_VACT (2280) //V分辨率定义
|
||||
#define __DPI_VFP (10) //VSYNC前的无效像素
|
||||
|
||||
#define __DPI_HSA (8) //HSYNC宽度
|
||||
#define __DPI_HBP (16) //HSYNC后的无效像素
|
||||
#define __DPI_HACT (1080) //H分辨率定义
|
||||
#define __DPI_HFP (36) //HSYNC前的无效像素
|
||||
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief demo测试接口函数
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void demo_dsi_tx_case(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,218 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2021-2022, All Rights Reserved.
|
||||
*
|
||||
* File: test_hal_flash.c
|
||||
* Description: hal_flash 测试用例源文件
|
||||
* Version: V0.1
|
||||
* Date: 2022-04-21
|
||||
* Author: RANDY
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "demo_hal_flash.h"
|
||||
#include "hal_flash.h"
|
||||
#include "tau_delay.h"
|
||||
#include "tau_log.h"
|
||||
#include "tau_common.h"
|
||||
#include "test_cfg_global.h"
|
||||
|
||||
#if _MODULE_DEMO_FLASH_EN
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "demo_flash"
|
||||
|
||||
#define TEST_DATA_SIZE 32
|
||||
|
||||
#define DATA_BLOCK_SIZE (64*1024)
|
||||
#define DATA_PAGE_SIZE 1024
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
static fls_ops_cfg_t *fls_ops_cfg;
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
* @name :
|
||||
* @brief
|
||||
* @param
|
||||
* @retval
|
||||
**************************************************************************/
|
||||
|
||||
void test_hal_flash_get_public_region_test(void)
|
||||
{
|
||||
uint8_t test_data[TEST_DATA_SIZE] = 0;
|
||||
TAU_LOGD("test get data public\n");
|
||||
|
||||
fls_ops_cfg->flash_block = 7;//固定值
|
||||
fls_ops_cfg->flash_page = 0;//0-32
|
||||
fls_ops_cfg->page_offset_addr = 0;
|
||||
fls_ops_cfg->data_size = TEST_DATA_SIZE;
|
||||
fls_ops_cfg->user_data = test_data;
|
||||
|
||||
hal_flash_init();
|
||||
|
||||
//1 读数据
|
||||
hal_flash_public_region_ops(FLASH_PUBLIC_READ, fls_ops_cfg);
|
||||
|
||||
for (uint8_t i = 0; i < TEST_DATA_SIZE; i++)
|
||||
{
|
||||
TAU_LOGD("read data[%d]=0x%x ", i, test_data[i]);
|
||||
}
|
||||
|
||||
//2 写数据
|
||||
for (uint32_t i = 0; i < TEST_DATA_SIZE; i++)
|
||||
{
|
||||
test_data[i] = i;
|
||||
}
|
||||
|
||||
hal_flash_public_region_ops(FLASH_PUBLIC_WRITE, fls_ops_cfg);
|
||||
|
||||
//3 回读
|
||||
for (uint32_t i = 0; i < TEST_DATA_SIZE; i++)
|
||||
{
|
||||
test_data[i] = 0;
|
||||
}
|
||||
|
||||
hal_flash_public_region_ops(FLASH_PUBLIC_READ, fls_ops_cfg);
|
||||
|
||||
//4 对比
|
||||
for (uint8_t i = 0; i < TEST_DATA_SIZE; i++)
|
||||
{
|
||||
TAU_LOGD("read data[%d]=0x%x ", i, test_data[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 验证flash UID的读取,16byte的UID
|
||||
void test_flash_uid_read(void)
|
||||
{
|
||||
uint8_t get_id[16] = {0};
|
||||
|
||||
TAU_LOGD("test_flash_uid_read begin \n");
|
||||
|
||||
hal_flash_init();
|
||||
|
||||
hal_flash_read_uid(get_id, 16);
|
||||
//不同的IC,ID不一样,存在0x00或者0xFF的情况
|
||||
for (uint8_t i = 0; i < 16; i++)
|
||||
{
|
||||
TAU_LOGD("read ID [%d]=0x%X \n", i, get_id[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 获取user_data的数据个数
|
||||
* @param 无
|
||||
* @retval bool 无
|
||||
*/
|
||||
void get_user_data_size(void)
|
||||
{
|
||||
uint32_t user_data_size = 0;
|
||||
|
||||
TAU_LOGD("test get data addr\n");
|
||||
|
||||
user_data_size = hal_flash_get_user_data_size();
|
||||
|
||||
TAU_LOGD("user_data size 0x%x \n", user_data_size);
|
||||
}
|
||||
|
||||
|
||||
void test_hal_flash_get_user_region_test(void)
|
||||
{
|
||||
uint8_t user_data[32];
|
||||
uint32_t user_address = 0; //需要读取数据的位置
|
||||
uint32_t user_data_size = 0;
|
||||
|
||||
TAU_LOGD("test get data addr\n");
|
||||
//读取user data 0地址
|
||||
user_address = 0;
|
||||
|
||||
fls_ops_cfg->flash_block = user_address / DATA_BLOCK_SIZE;
|
||||
fls_ops_cfg->flash_page = (user_address % DATA_BLOCK_SIZE) / DATA_PAGE_SIZE;
|
||||
fls_ops_cfg->page_offset_addr = user_address % DATA_PAGE_SIZE;
|
||||
fls_ops_cfg->data_size = 16;
|
||||
fls_ops_cfg->user_data = user_data;
|
||||
hal_flash_user_region_ops(FLASH_USERDATA_READ, fls_ops_cfg);
|
||||
for (uint8_t i = 0; i < 2; i++)
|
||||
{
|
||||
TAU_LOGD("user_data[%d]=0x%x ", i, user_data[i]);
|
||||
}
|
||||
|
||||
//读取user data 0x6000地址
|
||||
user_address = 0x6000;
|
||||
|
||||
fls_ops_cfg->flash_block = user_address / DATA_BLOCK_SIZE;
|
||||
fls_ops_cfg->flash_page = (user_address % DATA_BLOCK_SIZE) / DATA_PAGE_SIZE;
|
||||
fls_ops_cfg->page_offset_addr = user_address % DATA_PAGE_SIZE;
|
||||
fls_ops_cfg->data_size = 16;
|
||||
fls_ops_cfg->user_data = user_data;
|
||||
hal_flash_user_region_ops(FLASH_USERDATA_READ, fls_ops_cfg);
|
||||
for (uint8_t i = 0; i < 2; i++)
|
||||
{
|
||||
TAU_LOGD("user_data[%d]=0x%x ", i, user_data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 获取user_data的绝对起始地址 的接口测试
|
||||
* @param 无
|
||||
* @retval bool 无
|
||||
*/
|
||||
|
||||
void demo_hal_flash(void)
|
||||
{
|
||||
uint8_t case_sel = 2;
|
||||
|
||||
switch (case_sel)
|
||||
{
|
||||
case 1:
|
||||
test_hal_flash_get_public_region_test();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
test_hal_flash_get_user_region_test();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
test_flash_uid_read();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
get_user_data_size();
|
||||
break;
|
||||
|
||||
case 5:
|
||||
//测试共享flash接口,需要外接SPI主机测试
|
||||
TAU_LOGI("test TMON \n");
|
||||
hal_flash_share_mode(true);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2021-2022, All Rights Reserved.
|
||||
*
|
||||
* File: test_hal_flash.h
|
||||
* Description: hal_flash测试用例头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-17
|
||||
* Author: Kevin
|
||||
*******************************************************************************/
|
||||
#ifndef __DEMO_HAL_FLASH_H__
|
||||
#define __DEMO_HAL_FLASH_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
void demo_hal_flash(void);
|
||||
|
||||
#endif /* __TEST_HAL_FLASH_H__ */
|
||||
|
||||
|
|
@ -0,0 +1,268 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_gpio.c
|
||||
* Description: GPIO测试用例源文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: kevin
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "hal_gpio.h"
|
||||
#include "tau_delay.h"
|
||||
#include "tau_log.h"
|
||||
#include "test_cfg_global.h"
|
||||
|
||||
#if _DEMO_GPIO_EN
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "gpio-log"
|
||||
|
||||
//output
|
||||
#define GPIO_OUT_TEST 1
|
||||
#define GPIO_OUT_IN_CONNECT 0
|
||||
|
||||
//input
|
||||
#define GPIO_IN_INT_SINGLE 0
|
||||
//IO mode init
|
||||
#define GPIO_MODE_INIT 0
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
static bool s_gpio_callback_flag = false;
|
||||
static sys_cfg_trigger_e s_gpio_trig = DETECT_HIGH_LVL;
|
||||
static io_pad_e s_gpio_demo_pad1 = IO_PAD_AP_TPRSTN;
|
||||
static io_pad_e s_gpio_demo_pad2 = IO_PAD_AP_PWMEN;
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
* @name : demo_gpio_callback
|
||||
* @brief : 测试回调函数
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void demo_gpio_callback(void *data)
|
||||
{
|
||||
gpio_int_e type = *(gpio_int_e *)data;
|
||||
gpio_int_e int_type = hal_gpio_get_int_type(s_gpio_demo_pad1);
|
||||
|
||||
TAU_LOGI("demo_gpio_callback type:%d, int_type:%d, s_gpio_trig:%d\r\n", type, int_type, s_gpio_trig);
|
||||
|
||||
hal_gpio_ctrl_eint(s_gpio_demo_pad1, DISABLE);
|
||||
|
||||
if (DETECT_HIGH_LVL == s_gpio_trig)
|
||||
{
|
||||
hal_gpio_set_output_data(s_gpio_demo_pad2, IO_LVL_LOW);
|
||||
}
|
||||
else if (DETECT_LOW_LVL == s_gpio_trig)
|
||||
{
|
||||
hal_gpio_set_output_data(s_gpio_demo_pad2, IO_LVL_HIGH);
|
||||
}
|
||||
|
||||
switch (s_gpio_trig)
|
||||
{
|
||||
case DETECT_HIGH_LVL:
|
||||
s_gpio_trig = DETECT_LOW_LVL;
|
||||
break;
|
||||
|
||||
case DETECT_LOW_LVL:
|
||||
s_gpio_trig = DETECT_RISING_EDGE;
|
||||
break;
|
||||
|
||||
case DETECT_RISING_EDGE:
|
||||
s_gpio_trig = DETECT_FALLING_EDGE;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
s_gpio_callback_flag = true;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* @name : demo_gpio_int
|
||||
* @brief : gpio测试中断通用配置
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void demo_gpio_int(io_pad_e pad, sys_cfg_trigger_e trig)
|
||||
{
|
||||
/*1.关闭中断*/
|
||||
hal_gpio_ctrl_eint(pad, DISABLE);
|
||||
|
||||
/*2.中断初始化*/
|
||||
hal_gpio_init_eint(pad, trig);
|
||||
|
||||
/*3.注册回调*/
|
||||
hal_gpio_reg_eint_cb(pad, demo_gpio_callback);
|
||||
|
||||
/*4.使能中断*/
|
||||
hal_gpio_ctrl_eint(pad, ENABLE);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* @name : demo_gpio_out_case
|
||||
* @brief : gpio output功能测试
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void demo_gpio_out_case(void)
|
||||
{
|
||||
gpio_level_e flag = IO_LVL_LOW;
|
||||
|
||||
TAU_LOGI("demo_gpio_out_case\r\n");
|
||||
|
||||
hal_gpio_init_output(s_gpio_demo_pad1, flag);
|
||||
while (1)
|
||||
{
|
||||
delayMs(10);
|
||||
flag = (flag == IO_LVL_LOW) ? IO_LVL_HIGH : IO_LVL_LOW;
|
||||
hal_gpio_set_output_data(s_gpio_demo_pad1, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* @name : demo_gpio_in_case
|
||||
* @brief : gpio input功能测试
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void demo_gpio_in_case(void)
|
||||
{
|
||||
gpio_level_e flag = IO_LVL_LOW;
|
||||
|
||||
TAU_LOGI("demo_gpio_in_case\r\n");
|
||||
|
||||
hal_gpio_init_input(s_gpio_demo_pad1);
|
||||
hal_gpio_init_output(s_gpio_demo_pad2, flag);
|
||||
while (1)
|
||||
{
|
||||
delayMs(10);
|
||||
flag = (flag == IO_LVL_LOW) ? IO_LVL_HIGH : IO_LVL_LOW;
|
||||
hal_gpio_set_output_data(s_gpio_demo_pad2, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* @name : demo_gpio_int_single
|
||||
* @brief : gpio input配置单个中断
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void demo_gpio_int_single(void)
|
||||
{
|
||||
sys_cfg_trigger_e trig = s_gpio_trig;
|
||||
|
||||
TAU_LOGI("demo_gpio_int_single trig:%d\r\n", trig);
|
||||
|
||||
if (DETECT_HIGH_LVL == s_gpio_trig || DETECT_RISING_EDGE == s_gpio_trig)
|
||||
{
|
||||
hal_gpio_init_output(s_gpio_demo_pad2, IO_LVL_LOW);
|
||||
}
|
||||
else if (DETECT_LOW_LVL == s_gpio_trig || DETECT_FALLING_EDGE == s_gpio_trig)
|
||||
{
|
||||
hal_gpio_init_output(s_gpio_demo_pad2, IO_LVL_HIGH);
|
||||
}
|
||||
|
||||
demo_gpio_int(s_gpio_demo_pad1, trig);
|
||||
|
||||
if (DETECT_HIGH_LVL == s_gpio_trig || DETECT_RISING_EDGE == s_gpio_trig)
|
||||
{
|
||||
delayMs(100);
|
||||
hal_gpio_set_output_data(s_gpio_demo_pad2, IO_LVL_HIGH);
|
||||
}
|
||||
else if (DETECT_LOW_LVL == s_gpio_trig || DETECT_FALLING_EDGE == s_gpio_trig)
|
||||
{
|
||||
delayMs(100);
|
||||
hal_gpio_set_output_data(s_gpio_demo_pad2, IO_LVL_LOW);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GPIO初始化配置,根据实际原理图提前配置IO功能以及状态,默认功能可不配置
|
||||
* TP相关I2C/SPI 在tp_transfer.c
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
static void demo_gpio_init(void)
|
||||
{
|
||||
io_pad_attr_t attrs[] =
|
||||
{
|
||||
//1.配置成GPIO 输出
|
||||
{IO_PIN_8, PIN8_MODE_GPIO7, IO_IOE_OUTPUT, IO_LVL_LOW}, /* PIN_8(TD_RSTN), GPIO,输出,低电平 */
|
||||
{IO_PIN_17, PIN17_MODE_GPIO8, IO_IOE_OUTPUT, IO_LVL_LOW}, /* PIN_17(PWMEN), GPIO,输出,低电平 */
|
||||
{IO_PIN_16, PIN16_MODE_GPIO2, IO_IOE_OUTPUT, IO_LVL_LOW}, /* PIN_16(AP_INT),GPIO,输出,低电平 */
|
||||
|
||||
//2.配置成GPIO 输入
|
||||
{IO_PIN_29, PIN29_MODE_GPIO3, IO_IOE_INPUT, IO_LVL_NONE}, /* PIN_29(AP_TE), GPIO,输入 */
|
||||
|
||||
//3.配置UART TX
|
||||
{IO_PIN_2, PIN2_MODE_UART0_TX, IO_IOE_NONE, IO_LVL_NONE}, /* PIN_2(UART0_TX), UART,TX */
|
||||
|
||||
//4.配置I2C
|
||||
{IO_PIN_5, PIN5_MODE_I2C1_SCL, IO_IOE_NONE, IO_LVL_NONE}, /* PIN_5(TD_SPIM_CLK), I2C,SCL */
|
||||
{IO_PIN_6, PIN6_MODE_I2C1_SDA, IO_IOE_NONE, IO_LVL_NONE}, /* PIN_6(TD_SPIM_CSN), I2C,SDA */
|
||||
|
||||
//5.配置SPIS
|
||||
{IO_PIN_30, PIN30_MODE_SPIS_MISO, IO_IOE_NONE, IO_LVL_NONE}, /* PIN_30(AP_SPIS_MISO), SPIS,MISO */
|
||||
{IO_PIN_31, PIN31_MODE_SPIS_CSN, IO_IOE_NONE, IO_LVL_NONE}, /* PIN_31(AP_SPIS_CSN), SPIS,CSN */
|
||||
{IO_PIN_32, PIN32_MODE_SPIS_SCLK, IO_IOE_NONE, IO_LVL_NONE}, /* PIN_32(AP_SPIS_CLK), SPIS,CLK */
|
||||
{IO_PIN_33, PIN33_MODE_SPIS_MOSI, IO_IOE_NONE, IO_LVL_NONE} /* PIN_33(AP_SPIS_MOSI), SPIS,MOSI */
|
||||
};
|
||||
uint8_t size = sizeof(attrs) / sizeof(io_pad_attr_t);
|
||||
hal_gpio_config_pad(attrs, size);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* @name : demo_gpio_case
|
||||
* @brief : 测试用例
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
void demo_gpio_case(void)
|
||||
{
|
||||
s_gpio_callback_flag = true;
|
||||
|
||||
#if GPIO_IN_INT_SINGLE
|
||||
while (1)
|
||||
{
|
||||
if (s_gpio_callback_flag)
|
||||
{
|
||||
s_gpio_callback_flag = false;
|
||||
demo_gpio_int_single();
|
||||
}
|
||||
}
|
||||
#elif GPIO_OUT_TEST
|
||||
demo_gpio_out_case();
|
||||
#elif GPIO_OUT_IN_CONNECT
|
||||
demo_gpio_in_case();
|
||||
#elif GPIO_MODE_INIT
|
||||
demo_gpio_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_gpio.h
|
||||
* Description: GPIO测试用例头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: kevin
|
||||
*******************************************************************************/
|
||||
#ifndef __DEMO_GPIO_H__
|
||||
#define __DEMO_GPIO_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
void demo_gpio_case(void);
|
||||
|
||||
#endif /* __DEMO_GPIO_H__ */
|
||||
|
||||
|
|
@ -0,0 +1,412 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2020-2023, tau Systems (R),All Rights Reserved.
|
||||
*
|
||||
* File: demo_hal_i2ci.c
|
||||
* Description: i2c demo code
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: swx
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "hal_i2c_master.h"
|
||||
#include "hal_i2c_slave.h"
|
||||
#include "demo_hal_i2c.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "tau_log.h"
|
||||
#include "tau_delay.h"
|
||||
|
||||
#if _MODULE_DEMO_I2C_EN
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "demo_hal_i2c"
|
||||
#define BUFFER_SIZE 10 // 以10个数据为例
|
||||
|
||||
#define CHECK_TRANS_RESULT(src, dst, size) \
|
||||
for(uint32_t check_num = 0; check_num < size; check_num ++) \
|
||||
{\
|
||||
if(src[check_num] != dst[check_num])\
|
||||
{\
|
||||
TAU_LOGD("src[%d] = %x, dst[%d] = %x , error!!\n",check_num,src[check_num],check_num,dst[check_num]);\
|
||||
return false;\
|
||||
}\
|
||||
}\
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global function and Global variable declarations
|
||||
*******************************************************************************/
|
||||
static uint8_t i2cm_read_buffer[BUFFER_SIZE];
|
||||
static uint8_t i2cs_read_buffer[BUFFER_SIZE];
|
||||
static uint8_t i2cs_write_buffer[BUFFER_SIZE];
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief i2c master的IO初始化
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
static void i2cm_io_init(void)
|
||||
{
|
||||
io_pad_attr_t attrs[] =
|
||||
{
|
||||
{IO_PAD_TD_SPIM_CLK, PIN5_MODE_I2C1_SCL, IO_IOE_NONE, IO_LVL_HIGH},
|
||||
{IO_PAD_TD_SPIM_CSN, PIN6_MODE_I2C1_SDA, IO_IOE_NONE, IO_LVL_HIGH}
|
||||
};
|
||||
uint8_t size = sizeof(attrs) / sizeof(io_pad_attr_t);
|
||||
hal_gpio_config_pad(attrs, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief i2c slave的IO初始化
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
static void i2cs_io_init(void)
|
||||
{
|
||||
io_pad_attr_t attrs[] =
|
||||
{
|
||||
{IO_PAD_AP_SPIS_CLK, PIN32_MODE_I2C02_SCL, IO_IOE_NONE, IO_LVL_HIGH},
|
||||
{IO_PAD_AP_SPIS_CSN, PIN31_MODE_I2C02_SDA, IO_IOE_NONE, IO_LVL_HIGH}
|
||||
};
|
||||
uint8_t size = sizeof(attrs) / sizeof(io_pad_attr_t);
|
||||
hal_gpio_config_pad(attrs, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief i2c slave的中断回调服务函数
|
||||
* @param index: I2Cx index
|
||||
* @param int_status: 中断事件
|
||||
* @param recieve_num: 接收到的packet数
|
||||
* @retval none
|
||||
*/
|
||||
static void i2cs_callback(i2c_index_e index, hal_i2cs_event_e int_status, size_t recieve_num)
|
||||
{
|
||||
/* 收到READ_REQ中断 */
|
||||
if (int_status == I2CS_EVENT_READ)
|
||||
{
|
||||
/* 更新I2CS的txbuffer,将i2cs_write_buffer的数据发送给主机 */
|
||||
hal_i2cs_update_tx_buffer(index, i2cs_write_buffer, BUFFER_SIZE, false);
|
||||
}
|
||||
/* 收到stop中断 */
|
||||
else if (int_status == I2CS_EVENT_STOP)
|
||||
{
|
||||
if (recieve_num > 0)
|
||||
{
|
||||
/* 将读到的值写到i2cs_write_buffer中 */
|
||||
for (int i = 0; i < recieve_num; i++)
|
||||
i2cs_write_buffer[i] = i2cs_read_buffer[i];
|
||||
}
|
||||
/* 更新I2CS的rxbuffer */
|
||||
hal_i2cs_update_rx_buffer(index, i2cs_read_buffer, BUFFER_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief i2c master初始化
|
||||
* @param index: I2Cx index
|
||||
* @param addr: 从机地址
|
||||
* @param addr_bits: 从机地址位数
|
||||
* @param speed: 主机速率设置
|
||||
* @retval none
|
||||
*/
|
||||
void i2cm_init(i2c_index_e index, uint16_t addr, uint8_t addr_bits, uint32_t speed)
|
||||
{
|
||||
/* I2CS的IO初始化 */
|
||||
i2cm_io_init();
|
||||
|
||||
/* I2CM初始化 */
|
||||
hal_i2cm_init(index, addr, addr_bits, speed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief i2c slave初始化
|
||||
* @param index: I2Cx index
|
||||
* @param addr: 从机自身地址
|
||||
* @param addr_bits: 从机地址位数
|
||||
* @retval none
|
||||
*/
|
||||
void i2cs_init(i2c_index_e index, uint16_t addr, uint8_t addr_bits)
|
||||
{
|
||||
/* I2CS的IO初始化 */
|
||||
i2cs_io_init();
|
||||
|
||||
/* I2CS的初始化 */
|
||||
hal_i2cs_init(index, addr, addr_bits);
|
||||
|
||||
/* I2CS注册回调函函数 */
|
||||
hal_i2cs_register_callback(index, i2cs_callback);
|
||||
|
||||
/* I2CS设置初始读写buffer */
|
||||
hal_i2cs_update_rx_buffer(index, i2cs_read_buffer, BUFFER_SIZE);
|
||||
hal_i2cs_update_tx_buffer(index, i2cs_write_buffer, BUFFER_SIZE, false);
|
||||
|
||||
/* I2CS启动 */
|
||||
hal_i2cs_start(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief i2c master去初始化
|
||||
* @param index: I2Cx index
|
||||
* @retval none
|
||||
*/
|
||||
void i2cm_deinit(i2c_index_e index)
|
||||
{
|
||||
hal_i2cm_deinit(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief i2c slave去初始化
|
||||
* @param index: I2Cx index
|
||||
* @retval none
|
||||
*/
|
||||
void i2cs_deinit(i2c_index_e index)
|
||||
{
|
||||
hal_i2cs_stop(index);
|
||||
hal_i2cs_deinit(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief i2c case buffer初始化
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
static void i2c_case_buffer_init(void)
|
||||
{
|
||||
TAU_LOGD("i2c_case_buffer_init\n");
|
||||
/* init buffer */
|
||||
uint8_t i = 0 ;
|
||||
for (i = 0; i < BUFFER_SIZE; i ++)
|
||||
{
|
||||
i2cm_read_buffer[i] = 0;
|
||||
i2cs_read_buffer[i] = 0;
|
||||
i2cs_write_buffer[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 芯片I2CM与I2CS对接,验证I2CM用CPU方式传输数据的正确性
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
static bool hal_i2c_cpu_transfer_case(void)
|
||||
{
|
||||
uint8_t write_buffer[10] = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19};
|
||||
uint8_t addr_bit = 7;
|
||||
uint32_t speed = 400000;
|
||||
uint16_t addr = 0x50;
|
||||
|
||||
/* I2CM初始化,I2C1+目标地址0x50+7位地址+400k传输速率 */
|
||||
i2cm_init(I2C_INDEX_1, addr, addr_bit, speed);
|
||||
|
||||
/* I2CS初始化,I2C0+本机地址0x50+7位地址 */
|
||||
i2cs_init(I2C_INDEX_0, addr, addr_bit);
|
||||
|
||||
/* buffer初始化 */
|
||||
i2c_case_buffer_init();
|
||||
|
||||
/* I2CM写write_buffer数据到0x50地址的从机 */
|
||||
if (hal_i2cm_write(I2C_INDEX_1, write_buffer, BUFFER_SIZE) != true)
|
||||
{
|
||||
TAU_LOGD("I2CM CPU write data fail!\n");
|
||||
return false;
|
||||
}
|
||||
TAU_LOGD("tx: %x %x %x %x %x %x %x %x %x %x\n", write_buffer[0], write_buffer[1], write_buffer[2], \
|
||||
write_buffer[3], write_buffer[4], write_buffer[5], write_buffer[6], write_buffer[7], write_buffer[8], \
|
||||
write_buffer[9]);
|
||||
|
||||
/* I2CM向地址为0x50的从机读取BUFFER_SIZE个数据,此case中,寄存器addr和size为0,可自行添加 */
|
||||
if (hal_i2cm_read(I2C_INDEX_1, 0, 0, i2cm_read_buffer, BUFFER_SIZE) != true)
|
||||
{
|
||||
TAU_LOGD("I2CM CPU read data fail!\n");
|
||||
return false;
|
||||
}
|
||||
TAU_LOGD("rx: %x %x %x %x %x %x %x %x %x %x\n", i2cm_read_buffer[0], i2cm_read_buffer[1], \
|
||||
i2cm_read_buffer[2], i2cm_read_buffer[3], i2cm_read_buffer[4], i2cm_read_buffer[5], \
|
||||
i2cm_read_buffer[6], i2cm_read_buffer[7], i2cm_read_buffer[8], i2cm_read_buffer[9]);
|
||||
|
||||
/* 检查传输结果,I2CM发出去的数据是否与接收到的数据一致 */
|
||||
CHECK_TRANS_RESULT(write_buffer, i2cm_read_buffer, BUFFER_SIZE);
|
||||
|
||||
/* I2CM && I2CS去初始化 */
|
||||
i2cs_deinit(I2C_INDEX_0);
|
||||
i2cm_deinit(I2C_INDEX_1);
|
||||
TAU_LOGD("hal_i2c_cpu_transfer_case done!\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 芯片I2CM与I2CS对接,验证I2CM用DMA方式传输数据的正确性
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
static bool hal_i2c_dma_transfer_case(void)
|
||||
{
|
||||
uint8_t write_buffer[10] = {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29};
|
||||
uint8_t addr_bit = 7;
|
||||
uint32_t speed = 400000;
|
||||
uint16_t addr = 0x50;
|
||||
|
||||
/* I2CM初始化,I2C1+目标地址0x50+7位地址+400k传输速率 */
|
||||
i2cm_init(I2C_INDEX_1, addr, addr_bit, speed);
|
||||
|
||||
/* I2CS初始化,I2C0+本机地址0x50+7位地址 */
|
||||
i2cs_init(I2C_INDEX_0, addr, addr_bit);
|
||||
|
||||
/* buffer初始化 */
|
||||
i2c_case_buffer_init();
|
||||
|
||||
/* I2CM写write_buffer数据到0x50地址的从机 */
|
||||
hal_i2cm_dma_write(I2C_INDEX_1, write_buffer, BUFFER_SIZE);
|
||||
|
||||
/* 等待I2CM传输完成 */
|
||||
while (!hal_i2cm_get_transfer_complete(I2C_INDEX_1));
|
||||
TAU_LOGD("tx: %x %x %x %x %x %x %x %x %x %x\n", write_buffer[0], write_buffer[1], write_buffer[2], \
|
||||
write_buffer[3], write_buffer[4], write_buffer[5], write_buffer[6], write_buffer[7], write_buffer[8], \
|
||||
write_buffer[9]);
|
||||
|
||||
/* I2CM向地址为0x50的从机读取BUFFER_SIZE个数据,此case中,寄存器addr和size为0,可自行添加 */
|
||||
hal_i2cm_dma_read(I2C_INDEX_1, 0, 0, i2cm_read_buffer, BUFFER_SIZE);
|
||||
|
||||
/* 等待I2CM传输完成 */
|
||||
while (!hal_i2cm_get_transfer_complete(I2C_INDEX_1));
|
||||
TAU_LOGD("rx: %x %x %x %x %x %x %x %x %x %x\n", i2cm_read_buffer[0], i2cm_read_buffer[1], \
|
||||
i2cm_read_buffer[2], i2cm_read_buffer[3], i2cm_read_buffer[4], i2cm_read_buffer[5], \
|
||||
i2cm_read_buffer[6], i2cm_read_buffer[7], i2cm_read_buffer[8], i2cm_read_buffer[9]);
|
||||
|
||||
/* 检查传输结果,I2CM发出去的数据是否与接收到的数据一致 */
|
||||
CHECK_TRANS_RESULT(write_buffer, i2cm_read_buffer, BUFFER_SIZE);
|
||||
|
||||
/* I2CM && I2CS去初始化 */
|
||||
i2cs_deinit(I2C_INDEX_0);
|
||||
i2cm_deinit(I2C_INDEX_1);
|
||||
TAU_LOGD("hal_i2c_dma_transfer_case done!\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 芯片I2CM与I2CS对接,验证双slave通信的正确性
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
static bool hal_i2c_double_slave_case(void)
|
||||
{
|
||||
uint16_t i2cs1_addr = 0x50;
|
||||
uint8_t i2cs1_addrbit = 7;
|
||||
uint16_t i2cs2_addr = 0x120;
|
||||
uint8_t i2cs2_addrbit = 10;
|
||||
uint32_t speed = 400000;
|
||||
uint8_t write_buffer1[10] = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19};
|
||||
uint8_t write_buffer2[10] = {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29};
|
||||
|
||||
/* I2CM初始化,I2C1+目标地址0x50+7位地址+400k传输速率 */
|
||||
i2cm_init(I2C_INDEX_1, i2cs1_addr, i2cs1_addrbit, speed);
|
||||
|
||||
/* I2CS初始化,I2C0+本机地址0x50+7位地址 */
|
||||
i2cs_init(I2C_INDEX_0, i2cs1_addr, i2cs1_addrbit);
|
||||
|
||||
/* I2CS初始化,I2C2+本机地址0x120+10位地址 */
|
||||
i2cs_init(I2C_INDEX_2, i2cs2_addr, i2cs2_addrbit);
|
||||
|
||||
/* I2CM写write_buffer1数据到0x50地址的从机 */
|
||||
hal_i2cm_dma_write(I2C_INDEX_1, write_buffer1, BUFFER_SIZE);
|
||||
|
||||
/* 等待I2CM传输完成 */
|
||||
while (!hal_i2cm_get_transfer_complete(I2C_INDEX_1));
|
||||
TAU_LOGD("tx: %x %x %x %x %x %x %x %x %x %x\n", write_buffer1[0], write_buffer1[1], write_buffer1[2], \
|
||||
write_buffer1[3], write_buffer1[4], write_buffer1[5], write_buffer1[6], write_buffer1[7], write_buffer1[8], \
|
||||
write_buffer1[9]);
|
||||
|
||||
/* I2CM向地址为0x50的从机读取BUFFER_SIZE个数据,此case中,寄存器addr和size为0,可自行添加 */
|
||||
hal_i2cm_dma_read(I2C_INDEX_1, 0, 0, i2cm_read_buffer, BUFFER_SIZE);
|
||||
|
||||
/* 等待I2CM传输完成 */
|
||||
while (!hal_i2cm_get_transfer_complete(I2C_INDEX_1));
|
||||
TAU_LOGD("rx: %x %x %x %x %x %x %x %x %x %x\n", i2cm_read_buffer[0], i2cm_read_buffer[1], \
|
||||
i2cm_read_buffer[2], i2cm_read_buffer[3], i2cm_read_buffer[4], i2cm_read_buffer[5], \
|
||||
i2cm_read_buffer[6], i2cm_read_buffer[7], i2cm_read_buffer[8], i2cm_read_buffer[9]);
|
||||
|
||||
/* 检查传输结果,I2CM发出去的数据是否与接收到的数据一致 */
|
||||
CHECK_TRANS_RESULT(write_buffer1, i2cm_read_buffer, BUFFER_SIZE);
|
||||
|
||||
/* 修改I2CM的目标从机地址为10位地址的0x120 */
|
||||
hal_i2cm_set_slave_addr(I2C_INDEX_1, i2cs2_addr, i2cs2_addrbit);
|
||||
|
||||
/* I2CM写write_buffer2数据到0x120地址的从机 */
|
||||
hal_i2cm_dma_write(I2C_INDEX_1, write_buffer2, BUFFER_SIZE);
|
||||
|
||||
/* 等待I2CM传输完成 */
|
||||
while (!hal_i2cm_get_transfer_complete(I2C_INDEX_1));
|
||||
TAU_LOGD("tx: %x %x %x %x %x %x %x %x %x %x\n", write_buffer2[0], write_buffer2[1], write_buffer2[2], \
|
||||
write_buffer2[3], write_buffer2[4], write_buffer2[5], write_buffer2[6], write_buffer2[7], write_buffer2[8], \
|
||||
write_buffer2[9]);
|
||||
|
||||
/* I2CM向地址为0x120的从机读取BUFFER_SIZE个数据,此case中,寄存器addr和size为0,可自行添加 */
|
||||
hal_i2cm_dma_read(I2C_INDEX_1, 0, 0, i2cm_read_buffer, BUFFER_SIZE);
|
||||
|
||||
/* 等待I2CM传输完成 */
|
||||
while (!hal_i2cm_get_transfer_complete(I2C_INDEX_1));
|
||||
TAU_LOGD("rx: %x %x %x %x %x %x %x %x %x %x\n", i2cm_read_buffer[0], i2cm_read_buffer[1], \
|
||||
i2cm_read_buffer[2], i2cm_read_buffer[3], i2cm_read_buffer[4], i2cm_read_buffer[5], \
|
||||
i2cm_read_buffer[6], i2cm_read_buffer[7], i2cm_read_buffer[8], i2cm_read_buffer[9]);
|
||||
|
||||
/* 检查传输结果,I2CM发出去的数据是否与接收到的数据一致 */
|
||||
CHECK_TRANS_RESULT(write_buffer2, i2cm_read_buffer, BUFFER_SIZE);
|
||||
|
||||
/* I2CM && I2CS去初始化 */
|
||||
i2cm_deinit(I2C_INDEX_1);
|
||||
i2cs_deinit(I2C_INDEX_0);
|
||||
i2cs_deinit(I2C_INDEX_2);
|
||||
TAU_LOGD("hal_i2c_double_slave_case done!\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief i2c demo case
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void demo_hal_i2c(void)
|
||||
{
|
||||
/* I2C DMA传输case */
|
||||
if (!hal_i2c_dma_transfer_case())
|
||||
{
|
||||
i2cs_deinit(I2C_INDEX_0);
|
||||
i2cm_deinit(I2C_INDEX_1);
|
||||
TAU_LOGD("hal_i2c_dma_transfer_case fail!\n");
|
||||
}
|
||||
|
||||
/* 双slave传输case */
|
||||
if (!hal_i2c_double_slave_case())
|
||||
{
|
||||
i2cm_deinit(I2C_INDEX_1);
|
||||
i2cs_deinit(I2C_INDEX_0);
|
||||
i2cs_deinit(I2C_INDEX_2);
|
||||
TAU_LOGD("hal_i2c_double_slave_case fail!\n");
|
||||
}
|
||||
|
||||
/* I2C CPU传输case */
|
||||
if (!hal_i2c_cpu_transfer_case())
|
||||
{
|
||||
i2cs_deinit(I2C_INDEX_0);
|
||||
i2cm_deinit(I2C_INDEX_1);
|
||||
TAU_LOGD("hal_i2c_cpu_transfer_case fail!\n");
|
||||
}
|
||||
|
||||
TAU_LOGD("i2c case done\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2020-2023, tau Systems (R),All Rights Reserved.
|
||||
*
|
||||
* File: demo_hal_i2c.h
|
||||
* Description: demo i2c 头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: swx
|
||||
*******************************************************************************/
|
||||
#ifndef __DEMO_HAL_I2C_H__
|
||||
#define __DEMO_HAL_I2C_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "test_cfg_global.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
void demo_hal_i2c(void);
|
||||
|
||||
#endif /* __DEMO_HAL_I2C_H__ */
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_pwm.c
|
||||
* Description: pwm demo code
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: jaya
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "stdarg.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
#include "test_cfg_global.h"
|
||||
#include "hal_pwm.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "tau_log.h"
|
||||
#include "tau_delay.h"
|
||||
#include "demo_hal_pwm.h"
|
||||
|
||||
#if _MODULE_DEMO_PWM_EN
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "demo_hal_pwm"
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global function and Global variable declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief 数字PWM输出demo
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
bool demo_digital_pwm_output(void)
|
||||
{
|
||||
/* GPIO 初始化,配置PIN15输出PWM, PWM可配置从PIN2/PIN13/PIN15/PIN17/PIN36输出 */
|
||||
hal_gpio_set_mode(IO_PIN_15, PIN15_MODE_PWMO);
|
||||
//hal_gpio_set_mode(IO_PIN_17, PIN17_MODE_PWMO);
|
||||
|
||||
/* PWM 初始化 ,配置为30K 255阶 */
|
||||
if (hal_pwm_init(30000, 255))
|
||||
{
|
||||
/* PWM enable */
|
||||
hal_pwm_enable(true);
|
||||
uint8_t i = 0;
|
||||
while (i != 255)
|
||||
{
|
||||
/* PWM 配置占空比, 从1/255开始到100%*/
|
||||
hal_pwm_set_duty(i);
|
||||
delayMs(20);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/* PWM disable */
|
||||
hal_pwm_enable(false);
|
||||
/* PWM deinit */
|
||||
hal_pwm_deinit();
|
||||
TAU_LOGD("demo_digital_pwm_output done\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 模拟PWM输出demo
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
bool demo_analog_pwm_output_with_vcc(void)
|
||||
{
|
||||
/* 模拟PWM,可选择不从数字IO输出PWM,也可以选择从数字IO输出 */
|
||||
hal_gpio_set_mode(IO_PIN_15, PIN15_MODE_PWMO);
|
||||
//hal_gpio_set_mode(IO_PIN_17, PIN17_MODE_PWMO);
|
||||
|
||||
/* PWM 初始化 ,配置为30K 255阶 */
|
||||
if (hal_pwm_init(30000, 255))
|
||||
{
|
||||
/* PWM enable */
|
||||
hal_pwm_enable(true);
|
||||
/* ELVCC 接入3-6V的电源,PWM 配置从ELVCC调试后的电源 */
|
||||
hal_pwm_set_elvcc_output(true);
|
||||
|
||||
uint8_t i = 0;
|
||||
while (i != 255)
|
||||
{
|
||||
hal_pwm_set_duty(i);
|
||||
delayMs(20);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/* PWM disable */
|
||||
hal_pwm_enable(false);
|
||||
/* PWM deinit */
|
||||
hal_pwm_deinit();
|
||||
TAU_LOGD("demo_digital_pwm_output done\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief pwm demo case
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void demo_hal_pwm(void)
|
||||
{
|
||||
TAU_LOGD("pwm dmeo \n");
|
||||
//demo_digital_pwm_output();
|
||||
demo_analog_pwm_output_with_vcc();
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2020-2023, tau Systems (R),All Rights Reserved.
|
||||
*
|
||||
* File: demo_hal_pwm.h
|
||||
* Description: demo pwm 头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: jaya
|
||||
*******************************************************************************/
|
||||
#ifndef __DEMO_HAL_PWM_H__
|
||||
#define __DEMO_HAL_PWM_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "test_cfg_global.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
void demo_hal_pwm(void);
|
||||
|
||||
#endif /* __DEMO_HAL_PWM_H__ */
|
||||
|
||||
|
|
@ -0,0 +1,218 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_pwr.c
|
||||
* Description: pwr demo code
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: jaya
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "stdarg.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
#include "test_cfg_global.h"
|
||||
#include "hal_pwr.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "tau_log.h"
|
||||
#include "tau_delay.h"
|
||||
#include "demo_hal_pwr.h"
|
||||
|
||||
#if _MODULE_DEMO_PWR_EN
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "demo_hal_pwr"
|
||||
|
||||
#define MAIN_POWER_SELECT PWR_SEL_VCC /* 主供电电源选择 */
|
||||
#define SLEEP_MODE_POWER PWR_SLEEP_IN_TP18 /* 息屏电源选择 */
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global function and Global variable declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
static bool sg_system_resume = false;
|
||||
|
||||
static void ap_rstn_pull_high_cb(void *data)
|
||||
{
|
||||
TAU_LOGD("AP RSTN !\n");
|
||||
/* system resume begin */
|
||||
sg_system_resume = true;
|
||||
/* 关闭AP reset检查 */
|
||||
hal_gpio_set_ap_reset_int(DISABLE, NULL, DETECT_HIGH_LVL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief normal sleep mode demo
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
static bool demo_normal_sleep_mode()
|
||||
{
|
||||
/* 主电源供电选择 */
|
||||
hal_pwr_set_main_power(MAIN_POWER_SELECT);
|
||||
|
||||
if (MAIN_POWER_SELECT == PWR_SEL_VCC)
|
||||
{
|
||||
while (hal_pwr_get_vcc_power_ready() == false);
|
||||
}
|
||||
|
||||
/* system 正常启动 */
|
||||
|
||||
/* sustem suspend */
|
||||
/* 关闭外设/图像通路 */
|
||||
|
||||
/* 息屏电源供电选择 */
|
||||
hal_pwr_set_sleep_mode_power(SLEEP_MODE_POWER);
|
||||
|
||||
/* enter deep sleep mode */
|
||||
TAU_LOGD("enter stop mode now\n");
|
||||
|
||||
/* normal sleep mode, MCU可以正常工作 */
|
||||
hal_gpio_set_ap_reset_int(ENABLE, ap_rstn_pull_high_cb, DETECT_RISING_EDGE);
|
||||
|
||||
hal_pwr_enter_normal_sleep_mode();
|
||||
while (1)
|
||||
{
|
||||
/* normal sleep mode 下外设模块正常,打印正常,SWD通讯正常 */
|
||||
TAU_LOGD("wait ap rstn\n");
|
||||
if (sg_system_resume)
|
||||
{
|
||||
break;
|
||||
}
|
||||
delayMs(1000);
|
||||
}
|
||||
|
||||
/* 退出sleep mode */
|
||||
hal_pwr_exit_sleep_mode();
|
||||
/* system resume */
|
||||
TAU_LOGD("system resum\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief stop sleep mode demo
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
static bool demo_stop_sleep_mode()
|
||||
{
|
||||
/* 主电源供电选择 */
|
||||
hal_pwr_set_main_power(MAIN_POWER_SELECT);
|
||||
|
||||
if (MAIN_POWER_SELECT == PWR_SEL_VCC)
|
||||
{
|
||||
while (hal_pwr_get_vcc_power_ready() == false);
|
||||
}
|
||||
|
||||
/* system 正常启动 */
|
||||
|
||||
/* sustem suspend */
|
||||
/* 关闭外设/图像通路 */
|
||||
|
||||
/* 息屏电源供电选择 */
|
||||
hal_pwr_set_sleep_mode_power(SLEEP_MODE_POWER);
|
||||
|
||||
/* enter deep sleep mode */
|
||||
while (1)
|
||||
{
|
||||
|
||||
TAU_LOGD("enter stop mode now\n");
|
||||
|
||||
/* 等待打印完成 */
|
||||
delayMs(200); /* 实际使用不需要延时 */
|
||||
|
||||
/* 配置唤醒AP RSTN 、SPIS CS、TD INT 唤醒*/
|
||||
hal_pwr_set_stop_sleep_wakeup_pin(IO_PAD_AP_RSTN, WUP_RISING_EDGE);
|
||||
hal_pwr_set_stop_sleep_wakeup_pin(IO_PAD_AP_SPIS_CSN, WUP_FALLING_EDGE);
|
||||
hal_pwr_set_stop_sleep_wakeup_pin(IO_PAD_TD_INT, WUP_FALLING_EDGE);
|
||||
delayMs(1000); /* 实际使用不需要延时 */
|
||||
/* 进入stop sleep mode, MCU停止运行,SWD无法通讯 */
|
||||
io_pad_e wakeup_io = hal_pwr_enter_stop_sleep_mode();
|
||||
|
||||
TAU_LOGD("stop sleep mode wake up by io %d\n", wakeup_io);
|
||||
|
||||
if (wakeup_io == IO_PAD_AP_RSTN)
|
||||
{
|
||||
TAU_LOGD("AP RSTN reset, system resume\n");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
TAU_LOGD("Touch process\n");
|
||||
/* 处理touchu 事件 处理完成后继续进入sleep mode*/
|
||||
}
|
||||
}
|
||||
|
||||
/* 退出sleep mode */
|
||||
hal_pwr_exit_sleep_mode();
|
||||
/* system resume */
|
||||
TAU_LOGD("system resum\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief deep sleep mode demo
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
static bool demo_deep_sleep_mode()
|
||||
{
|
||||
pwr_reset_flag_e reset_flag = hal_pwr_get_reset_flag();
|
||||
TAU_LOGD("wakeup flag %d\n", reset_flag);
|
||||
if (reset_flag == RF_TDINT_WAKEUP)
|
||||
{
|
||||
/* TD_INT reset, 处理触摸事件, 唤醒AP 等待AP RSTN*/
|
||||
TAU_LOGD("TD_INT reset\n");
|
||||
}
|
||||
/* 主电源供电选择 */
|
||||
hal_pwr_set_main_power(MAIN_POWER_SELECT);
|
||||
|
||||
if (MAIN_POWER_SELECT == PWR_SEL_VCC)
|
||||
{
|
||||
while (hal_pwr_get_vcc_power_ready() == false);
|
||||
}
|
||||
|
||||
/* system 正常启动 */
|
||||
|
||||
/* enter deep sleep mode */
|
||||
TAU_LOGD("enter deep mode now\n");
|
||||
|
||||
/* 息屏电源供电选择 */
|
||||
hal_pwr_set_sleep_mode_power(SLEEP_MODE_POWER);
|
||||
|
||||
/* deep sleep mode,配置AP RSTN 上升沿,TD INT 下降沿唤醒 */
|
||||
hal_pwr_enter_deep_sleep_mode(WUP_RISING_EDGE, WUP_FALLING_EDGE);
|
||||
/* 数字完全掉电,SWD无法通讯,唤醒后芯片重启 */
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief pwr demo case
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void demo_hal_pwr(void)
|
||||
{
|
||||
TAU_LOGD("pwr dmeo \n");
|
||||
/* normal sleep mode demo */
|
||||
demo_normal_sleep_mode();
|
||||
/* stop sleep mode demo */
|
||||
demo_stop_sleep_mode();
|
||||
/* deep sleep mode demo */
|
||||
demo_deep_sleep_mode();
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2020-2023, tau Systems (R),All Rights Reserved.
|
||||
*
|
||||
* File: demo_hal_pwr.h
|
||||
* Description: demo pwr 头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: jaya
|
||||
*******************************************************************************/
|
||||
#ifndef __DEMO_HAL_PWR_H__
|
||||
#define __DEMO_HAL_PWR_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "test_cfg_global.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
void demo_hal_pwr(void);
|
||||
|
||||
#endif /* __DEMO_HAL_PWR_H__ */
|
||||
|
||||
|
|
@ -0,0 +1,485 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2020-2023, tau Systems (R),All Rights Reserved.
|
||||
*
|
||||
* File: demo_hal_spi.c
|
||||
* Description: spi demo code
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: swx
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "hal_spi_master.h"
|
||||
#include "hal_spi_slave.h"
|
||||
#include "demo_hal_spi.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "tau_log.h"
|
||||
#include "tau_delay.h"
|
||||
|
||||
#if _MODULE_DEMO_SPI_EN
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "demo_hal_spi"
|
||||
|
||||
#define BUFFER_SIZE 255
|
||||
|
||||
#define CHECK_TRANS_RESULT(src, dst, size) \
|
||||
for(uint32_t check_num = 0; check_num < size; check_num ++) \
|
||||
{\
|
||||
if(src[check_num] != dst[check_num])\
|
||||
{\
|
||||
TAU_LOGD("src[%d] = %x, dst[%d] = %x , error!!\n",check_num,src[check_num],check_num,dst[check_num]);\
|
||||
return false;\
|
||||
}\
|
||||
}\
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global function and Global variable declarations
|
||||
*******************************************************************************/
|
||||
bool spis_hw_miss_flag = false;
|
||||
|
||||
/*SPIS硬件回复功能32组回复数据*/
|
||||
uint8_t spis_hw_header_data0[] = {0xf0, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d};
|
||||
uint8_t spis_hw_header_data1[] = {0xf1, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19};
|
||||
uint8_t spis_hw_header_data2[] = {0xf2, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29};
|
||||
uint8_t spis_hw_header_data3[] = {0xf3, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39};
|
||||
uint8_t spis_hw_header_data4[] = {0xf4, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49};
|
||||
uint8_t spis_hw_header_data5[] = {0xf5, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59};
|
||||
uint8_t spis_hw_header_data6[] = {0xf6, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69};
|
||||
uint8_t spis_hw_header_data7[] = {0xf7, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79};
|
||||
uint8_t spis_hw_header_data8[] = {0xf8, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89};
|
||||
uint8_t spis_hw_header_data9[] = {0xf9, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99};
|
||||
uint8_t spis_hw_header_data10[] = {0xfa, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9};
|
||||
uint8_t spis_hw_header_data11[] = {0xfb, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9};
|
||||
uint8_t spis_hw_header_data12[] = {0xfc, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9};
|
||||
uint8_t spis_hw_header_data13[] = {0xfd, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9};
|
||||
uint8_t spis_hw_header_data14[] = {0xfe, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9};
|
||||
uint8_t spis_hw_header_data15[] = {0xff, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9};
|
||||
uint8_t spis_hw_header_data16[] = {0xf0, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, 0x81, 0x91};
|
||||
uint8_t spis_hw_header_data17[] = {0xf1, 0x22, 0x31, 0x42, 0x52, 0x62, 0x72, 0x82, 0x92};
|
||||
uint8_t spis_hw_header_data18[] = {0xf2, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, 0x83, 0x93};
|
||||
uint8_t spis_hw_header_data19[] = {0xf3, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, 0x84, 0x94};
|
||||
uint8_t spis_hw_header_data20[] = {0xf4, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
|
||||
uint8_t spis_hw_header_data21[] = {0xf5, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19};
|
||||
uint8_t spis_hw_header_data22[] = {0xf6, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29};
|
||||
uint8_t spis_hw_header_data23[] = {0xf7, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39};
|
||||
uint8_t spis_hw_header_data24[] = {0xf8, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49};
|
||||
uint8_t spis_hw_header_data25[] = {0xf9, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59};
|
||||
uint8_t spis_hw_header_data26[] = {0xfa, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69};
|
||||
uint8_t spis_hw_header_data27[] = {0xfb, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79};
|
||||
uint8_t spis_hw_header_data28[] = {0xfc, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89};
|
||||
uint8_t spis_hw_header_data29[] = {0xfd, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99};
|
||||
uint8_t spis_hw_header_data30[] = {0xfe, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89};
|
||||
uint8_t spis_hw_header_data31[] = {0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xf0, 0x13, 0xff};
|
||||
|
||||
static hal_spis_hw_ack_info_t spis_hw_test_header[32] =
|
||||
{
|
||||
/*序号_匹配值_匹配长度_使能_回复延时_回复数据的地址_回复数据长度 */
|
||||
{0, {0x01, 0x02, 0x03, 0x04}, 0, 1, 0, spis_hw_header_data0, sizeof(spis_hw_header_data0) / sizeof(uint8_t) - 1},
|
||||
{1, {0x05, 0x06, 0x07, 0x08}, 1, 1, 1, spis_hw_header_data1, sizeof(spis_hw_header_data1) / sizeof(uint8_t) - 1},
|
||||
{2, {0x09, 0x0a, 0x0b, 0x0c}, 2, 1, 2, spis_hw_header_data2, sizeof(spis_hw_header_data2) / sizeof(uint8_t) - 1},
|
||||
{3, {0x0d, 0x0e, 0x0f, 0x10}, 3, 1, 3, spis_hw_header_data3, sizeof(spis_hw_header_data3) / sizeof(uint8_t) - 1},
|
||||
{4, {0x11, 0x12, 0x13, 0x14}, 0, 1, 4, spis_hw_header_data4, sizeof(spis_hw_header_data4) / sizeof(uint8_t) - 1},
|
||||
{5, {0x15, 0x16, 0x17, 0x18}, 1, 1, 5, spis_hw_header_data5, sizeof(spis_hw_header_data5) / sizeof(uint8_t) - 1},
|
||||
{6, {0x19, 0x1a, 0x1b, 0x1c}, 2, 1, 6, spis_hw_header_data6, sizeof(spis_hw_header_data6) / sizeof(uint8_t) - 1},
|
||||
{7, {0x1d, 0x1e, 0x1f, 0x20}, 3, 1, 7, spis_hw_header_data7, sizeof(spis_hw_header_data7) / sizeof(uint8_t) - 1},
|
||||
{8, {0x21, 0x22, 0x23, 0x24}, 0, 1, 8, spis_hw_header_data8, sizeof(spis_hw_header_data8) / sizeof(uint8_t) - 1},
|
||||
{9, {0x25, 0x26, 0x27, 0x28}, 1, 1, 9, spis_hw_header_data9, sizeof(spis_hw_header_data9) / sizeof(uint8_t) - 1},
|
||||
{10, {0x29, 0x2a, 0x2b, 0x2c}, 2, 1, 10, spis_hw_header_data10, sizeof(spis_hw_header_data10) / sizeof(uint8_t) - 1},
|
||||
{11, {0x2d, 0x2e, 0x2f, 0x30}, 3, 1, 0, spis_hw_header_data11, sizeof(spis_hw_header_data11) / sizeof(uint8_t) - 1},
|
||||
{12, {0x31, 0x32, 0x33, 0x34}, 0, 1, 1, spis_hw_header_data12, sizeof(spis_hw_header_data12) / sizeof(uint8_t) - 1},
|
||||
{13, {0x35, 0x36, 0x37, 0x38}, 1, 1, 2, spis_hw_header_data13, sizeof(spis_hw_header_data13) / sizeof(uint8_t) - 1},
|
||||
{14, {0x39, 0x3a, 0x3b, 0x3c}, 2, 1, 3, spis_hw_header_data14, sizeof(spis_hw_header_data14) / sizeof(uint8_t) - 1},
|
||||
{15, {0x3d, 0x3e, 0x3f, 0x40}, 3, 1, 4, spis_hw_header_data15, sizeof(spis_hw_header_data15) / sizeof(uint8_t) - 1},
|
||||
{16, {0x41, 0x42, 0x43, 0x44}, 0, 1, 5, spis_hw_header_data16, sizeof(spis_hw_header_data16) / sizeof(uint8_t) - 1},
|
||||
{17, {0x45, 0x46, 0x47, 0x48}, 1, 1, 6, spis_hw_header_data17, sizeof(spis_hw_header_data17) / sizeof(uint8_t) - 1},
|
||||
{18, {0x49, 0x4a, 0x4b, 0x4c}, 2, 1, 7, spis_hw_header_data18, sizeof(spis_hw_header_data18) / sizeof(uint8_t) - 1},
|
||||
{19, {0x4d, 0x4e, 0x4f, 0x50}, 3, 1, 8, spis_hw_header_data19, sizeof(spis_hw_header_data19) / sizeof(uint8_t) - 1},
|
||||
{20, {0x51, 0x52, 0x53, 0x54}, 0, 1, 9, spis_hw_header_data20, sizeof(spis_hw_header_data20) / sizeof(uint8_t) - 1},
|
||||
{21, {0x55, 0x56, 0x57, 0x58}, 1, 1, 10, spis_hw_header_data21, sizeof(spis_hw_header_data21) / sizeof(uint8_t) - 1},
|
||||
{22, {0x59, 0x5a, 0x5b, 0x5c}, 2, 1, 11, spis_hw_header_data22, sizeof(spis_hw_header_data22) / sizeof(uint8_t) - 1},
|
||||
{23, {0x5d, 0x5e, 0x5f, 0x60}, 3, 1, 12, spis_hw_header_data23, sizeof(spis_hw_header_data23) / sizeof(uint8_t) - 1},
|
||||
{24, {0x61, 0x62, 0x63, 0x64}, 0, 1, 13, spis_hw_header_data24, sizeof(spis_hw_header_data24) / sizeof(uint8_t) - 1},
|
||||
{25, {0x65, 0x66, 0x67, 0x68}, 1, 1, 14, spis_hw_header_data25, sizeof(spis_hw_header_data25) / sizeof(uint8_t) - 1},
|
||||
{26, {0x69, 0x6a, 0x6b, 0x6c}, 2, 1, 15, spis_hw_header_data26, sizeof(spis_hw_header_data26) / sizeof(uint8_t) - 1},
|
||||
{27, {0x6d, 0x6e, 0x6f, 0x70}, 3, 1, 11, spis_hw_header_data27, sizeof(spis_hw_header_data27) / sizeof(uint8_t) - 1},
|
||||
{28, {0x71, 0x72, 0x73, 0x74}, 0, 1, 12, spis_hw_header_data28, sizeof(spis_hw_header_data28) / sizeof(uint8_t) - 1},
|
||||
{29, {0x75, 0x76, 0x77, 0x78}, 1, 1, 13, spis_hw_header_data29, sizeof(spis_hw_header_data29) / sizeof(uint8_t) - 1},
|
||||
{30, {0x79, 0x7a, 0x7b, 0x7c}, 2, 1, 12, spis_hw_header_data30, sizeof(spis_hw_header_data30) / sizeof(uint8_t) - 1},
|
||||
{31, {0x7d, 0x7e, 0x7f, 0x80}, 3, 1, 14, spis_hw_header_data31, sizeof(spis_hw_header_data31) / sizeof(uint8_t) - 1},
|
||||
};
|
||||
|
||||
static uint8_t spim_write_buffer[BUFFER_SIZE] = {0};
|
||||
static uint8_t spim_read_buffer[BUFFER_SIZE] = {0};
|
||||
static uint8_t spis_read_buffer[BUFFER_SIZE] = {0};
|
||||
static uint8_t spis_write_buffer[BUFFER_SIZE] = {0};
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief spi master IO初始化
|
||||
* @param none
|
||||
* @retval
|
||||
*/
|
||||
static void spim_io_init(void)
|
||||
{
|
||||
io_pad_attr_t attrs[] =
|
||||
{
|
||||
{IO_PAD_TD_SPIM_CLK, PIN5_MODE_SPIM_SCLK, IO_IOE_NONE, IO_LVL_HIGH},
|
||||
{IO_PAD_TD_SPIM_CSN, PIN6_MODE_SPIM_CSN, IO_IOE_NONE, IO_LVL_HIGH},
|
||||
{IO_PAD_TD_SPIM_MISO, PIN7_MODE_SPIM_MISO, IO_IOE_NONE, IO_LVL_HIGH},
|
||||
{IO_PAD_TD_SPIM_MOSI, PIN4_MODE_SPIM_MOSI, IO_IOE_NONE, IO_LVL_HIGH}
|
||||
};
|
||||
uint8_t size = sizeof(attrs) / sizeof(io_pad_attr_t);
|
||||
hal_gpio_config_pad(attrs, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief spi slave IO初始化
|
||||
* @param none
|
||||
* @retval
|
||||
*/
|
||||
static void spis_io_init(void)
|
||||
{
|
||||
io_pad_attr_t attrs[] =
|
||||
{
|
||||
{IO_PAD_AP_SPIS_CLK, PIN32_MODE_SPIS_SCLK, IO_IOE_NONE, IO_LVL_HIGH},
|
||||
{IO_PAD_AP_SPIS_CSN, PIN31_MODE_SPIS_CSN, IO_IOE_NONE, IO_LVL_HIGH},
|
||||
{IO_PAD_AP_SPIS_MISO, PIN30_MODE_SPIS_MISO, IO_IOE_NONE, IO_LVL_HIGH},
|
||||
{IO_PAD_AP_SPIS_MOSI, PIN33_MODE_SPIS_MOSI, IO_IOE_NONE, IO_LVL_HIGH}
|
||||
};
|
||||
uint8_t size = sizeof(attrs) / sizeof(io_pad_attr_t);
|
||||
hal_gpio_config_pad(attrs, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief spi slave中断回调函数
|
||||
* @param event:SPIS收到的中断事件
|
||||
* @param packet_info: SPIS收到的数据packet
|
||||
* @retval
|
||||
*/
|
||||
void spis_callback(hal_spis_event_e event, hal_spis_packet_info_t *packet_info)
|
||||
{
|
||||
/* 收到CS_RISE中断 */
|
||||
if (event == SPIS_EVENT_RCV_CS_RISE)
|
||||
{
|
||||
/* 更新SPIS的txbuffer和rxbuffer */
|
||||
hal_spis_update_rx_buffer(spis_read_buffer, BUFFER_SIZE);
|
||||
hal_spis_update_tx_buffer(spis_write_buffer, BUFFER_SIZE, true);
|
||||
}
|
||||
/* 收到CS_FALL中断 */
|
||||
else if (event == SPIS_EVENT_RCV_CS_FALL)
|
||||
{
|
||||
//TAU_LOGD("spis_test SPIS_EVENT_RCV_CS_FALL\n");
|
||||
}
|
||||
/* 收到数据接收指定阈值中断 */
|
||||
else if (event == SPIS_EVENT_RCV_CNT)
|
||||
{
|
||||
//TAU_LOGD("spis_test SPIS_EVENT_RCV_CNT\n");
|
||||
}
|
||||
/* 收到数据接收完全中断 */
|
||||
else if (event == SPIS_EVENT_RCV_FULL)
|
||||
{
|
||||
//TAU_LOGD("spis_test SPIS_EVENT_RCV_CNT\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief spi slave硬件快速回复功能中断回调函数
|
||||
* @param event:SPIS收到的中断事件
|
||||
* @param packet_info: SPIS收到的数据packet
|
||||
* @retval
|
||||
*/
|
||||
void spis_hw_callback(hal_spis_event_e event, hal_spis_packet_info_t *packet_info)
|
||||
{
|
||||
/* 收到CS_RISE中断 */
|
||||
if (event == SPIS_EVENT_RCV_CS_RISE)
|
||||
{
|
||||
/* 产生了ALL_MISS中断的标记 */
|
||||
if (spis_hw_miss_flag)
|
||||
{
|
||||
/* 使能SPIS硬件快速回复功能,默认回复值为0xE0 */
|
||||
hal_spis_set_hw_ack_enable(ENABLE, 0xE0);
|
||||
spis_hw_miss_flag = false;
|
||||
}
|
||||
/* SPIS更新读写buffer */
|
||||
hal_spis_update_tx_buffer(spis_hw_header_data31, sizeof(spis_hw_header_data31) / sizeof(uint8_t), true);
|
||||
hal_spis_update_rx_buffer(spis_read_buffer, BUFFER_SIZE);
|
||||
}
|
||||
|
||||
/* 收到ALL_MISS中断 */
|
||||
if (event == SPIS_EVENT_ALL_MISS)
|
||||
{
|
||||
/* 关闭SPIS硬件快速回复功能,默认回复值为0xF0 */
|
||||
hal_spis_set_hw_ack_enable(DISABLE, 0xf0);
|
||||
spis_hw_miss_flag = true;
|
||||
TAU_LOGE("All miss intr test\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取随机值函数
|
||||
* @param range_begin: 随机值范围起始
|
||||
* @param renge_end: 随机值范围结束
|
||||
* @retval uint32_t : 范围内随机值
|
||||
*/
|
||||
uint32_t unit_case_get_rand(uint32_t range_begin, uint32_t renge_end)
|
||||
{
|
||||
uint32_t range = 1;
|
||||
if (renge_end > range_begin)
|
||||
{
|
||||
range = renge_end - range_begin + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
TAU_LOGE("rand range[%d ~ %d] error! default set to 1\n");
|
||||
}
|
||||
return (uint32_t)((rand() % range) + range_begin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief spi master和slave的发送/接收buffer初始化
|
||||
* @param none
|
||||
* @retval
|
||||
*/
|
||||
static bool spi_case_rand_buffer(bool spim_en, bool spis_en)
|
||||
{
|
||||
TAU_LOGD("spi_case_rand_buffer\n");
|
||||
/* read buffer默认初始化为0, tx buffer 初始为随机数 */
|
||||
uint8_t i = 0 ;
|
||||
uint32_t count = BUFFER_SIZE;
|
||||
for (i = 0; i < count; i ++)
|
||||
{
|
||||
spis_read_buffer[i] = 0;
|
||||
spim_read_buffer[i] = 0;
|
||||
if (spim_en)
|
||||
{
|
||||
spim_write_buffer[i] = unit_case_get_rand(0, 255);
|
||||
}
|
||||
if (spis_en)
|
||||
{
|
||||
spis_write_buffer[i] = unit_case_get_rand(0, 255);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 芯片SPIM与SPIS对接,验证基础传输数据的正确性
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
static bool hal_spi_base_case(void)
|
||||
{
|
||||
uint32_t speed = 400000;
|
||||
uint8_t cpha = 0;
|
||||
uint8_t cpol = 0;
|
||||
|
||||
/* 随机buffer值 */
|
||||
spi_case_rand_buffer(true, true);
|
||||
|
||||
/* SPIS IO初始化 */
|
||||
spis_io_init();
|
||||
/* SPIS初始化,相位0+极性0 */
|
||||
hal_spis_init(cpha, cpol);
|
||||
/* SPIS设置初始读写buffer */
|
||||
hal_spis_update_rx_buffer(spis_read_buffer, BUFFER_SIZE);
|
||||
hal_spis_update_tx_buffer(spis_write_buffer, BUFFER_SIZE, true);
|
||||
/* SPIS注册回调函函数,这里开启了CS_RISE、CS_FALL、RX_CNT、RX_FULL中断,RX_CNT阈值设置为100 */
|
||||
hal_spis_register_callback(spis_callback, SPIS_EVENT_RCV_CS_RISE | SPIS_EVENT_RCV_CS_FALL | SPIS_EVENT_RCV_CNT | SPIS_EVENT_RCV_FULL, 100);
|
||||
/* SPIS启动 */
|
||||
hal_spis_start();
|
||||
|
||||
/* SPIM IOc初始化 */
|
||||
spim_io_init();
|
||||
/* SPIM初始化,400k传输速率+相位0+极性0 */
|
||||
hal_spim_init(speed, cpha, cpol);
|
||||
|
||||
TAU_LOGD("base trans para cpha[%d] cpol[%d] speed[%d] \n", cpha, cpol, speed);
|
||||
|
||||
/* 测试 SPIM CPU读写 */
|
||||
hal_spim_read(spim_write_buffer, BUFFER_SIZE, spim_read_buffer, BUFFER_SIZE);
|
||||
/* SPIM 写完,检查 SPIS RX buffer 是否等于 SPIM TX buffer*/
|
||||
CHECK_TRANS_RESULT(spim_write_buffer, spis_read_buffer, BUFFER_SIZE);
|
||||
/* SPIM 读完,检查 SPIS TX buffer 是否等于 SPIM RX buffer*/
|
||||
CHECK_TRANS_RESULT(spis_write_buffer, spim_read_buffer, BUFFER_SIZE);
|
||||
|
||||
/* 随机buffer值 */
|
||||
spi_case_rand_buffer(true, false);
|
||||
|
||||
/* 测试 SPIM CPU写 */
|
||||
hal_spim_write(spim_write_buffer, BUFFER_SIZE);
|
||||
/* SPIM 写完,检查 SPIS RX buffer 是否等于 SPIM TX buffer*/
|
||||
CHECK_TRANS_RESULT(spim_write_buffer, spis_read_buffer, BUFFER_SIZE);
|
||||
|
||||
/* 传输完成,关闭SPI */
|
||||
hal_spis_stop();
|
||||
hal_spis_deinit();
|
||||
hal_spim_deinit();
|
||||
|
||||
TAU_LOGD("hal_spi_base_case done!\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 芯片SPIM与SPIS对接, 验证SPIS 硬件快速回复传输功能
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
static bool hal_spis_hw_case(void)
|
||||
{
|
||||
uint32_t speed = 400000;
|
||||
uint8_t cpha = 0;
|
||||
uint8_t cpol = 0;
|
||||
uint8_t write_buffer[30] = {0x9e, 0xa0, 0x00, 0x01, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||
0x8a, 0x1b, 0x1c, 0x5d, 0x7e, 0x4f, 0x20, 0x21, 0x22, 0x23,
|
||||
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31, 0x32, 0x33
|
||||
};
|
||||
/* SPIS IO初始化 */
|
||||
spis_io_init();
|
||||
/* SPIS初始化,相位0+极性0 */
|
||||
hal_spis_init(cpha, cpol);
|
||||
|
||||
/* SPIS设置初始读buffer */
|
||||
hal_spis_update_rx_buffer(spis_read_buffer, BUFFER_SIZE);
|
||||
/* SPIS设置初始写buffer */
|
||||
hal_spis_update_tx_buffer(spis_hw_header_data31, sizeof(spis_hw_header_data31) / sizeof(uint8_t), true);
|
||||
/* SPIS注册回调函函数,这里开启了CS_RISE和ALL_MISS中断 */
|
||||
hal_spis_register_callback(spis_hw_callback, SPIS_EVENT_RCV_CS_RISE | SPIS_EVENT_ALL_MISS, 0);
|
||||
|
||||
/* 设置SPIS硬件快速回复参数 */
|
||||
hal_spis_set_hw_ack_info(spis_hw_test_header, (sizeof(spis_hw_test_header) / sizeof(hal_spis_hw_ack_info_t)));
|
||||
/* 使能SPIS硬件快速回复功能,默认回复值为0xE0 */
|
||||
hal_spis_set_hw_ack_enable(ENABLE, 0xE0);
|
||||
/* SPIS启动 */
|
||||
hal_spis_start();
|
||||
|
||||
/* SPIM IO初始化 */
|
||||
spim_io_init();
|
||||
/* SPIM初始化,400k传输速率+相位0+极性0 */
|
||||
hal_spim_init(speed, cpha, cpol);
|
||||
|
||||
/* 32组硬件快速回复功能参数demo */
|
||||
for (int k = 0; k < 32; k++)
|
||||
{
|
||||
/* write_buffer前4个字节设置为每组参数的匹配值 */
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
write_buffer[j] = spis_hw_test_header[k].cmp_data[j];
|
||||
}
|
||||
|
||||
/* 将第11组和第14组的write_buffer[0]自加,这样匹配不到后就会产生ALL_MISS中断 */
|
||||
if ((k == 10) || (k == 13))
|
||||
{
|
||||
write_buffer[0]++;
|
||||
}
|
||||
|
||||
/* FLUSH SPIM FIFO */
|
||||
hal_spim_flush();
|
||||
/* SPIM发送30个write_buffer数据给SPIS,并读取SPIS的30个数据到spim_read_buffer */
|
||||
hal_spim_read(write_buffer, 30, spim_read_buffer, 30);
|
||||
|
||||
/* 等待SPIM传输完成 */
|
||||
while (!hal_spim_get_transfer_complete());
|
||||
|
||||
printf("SPIM_TX:");
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
printf("%02x ", spis_read_buffer[i]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("SPIM_RX:");
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
printf("%02x ", spim_read_buffer[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
/* 以下是校验SPIS的硬件快速回复数据是否正确 */
|
||||
int index = spis_hw_test_header[k].delay_clk + 1 + spis_hw_test_header[k].cmp_len + 1;
|
||||
printf("CMP_LEN:%d, DELAY_CLK:%d\n", spis_hw_test_header[k].cmp_len, spis_hw_test_header[k].delay_clk);
|
||||
bool flag = true;
|
||||
for (int i = 0; i < spis_hw_test_header[k].ack_length; i++)
|
||||
{
|
||||
if (spis_hw_test_header[k].ack_address[i] == spim_read_buffer[index + i])
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
printf("Group[%d] OK\n", k);
|
||||
flag = false;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((k == 10) || (k == 13))
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
printf("Group[%d] All_miss init test\n", k);
|
||||
flag = false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Header_addr[%d]:%02x Header_addr[%d]:%02x ", i, spis_hw_test_header[k].ack_address[i], index + i, spim_read_buffer[index + i]);
|
||||
printf("Group[%d] error\n", k);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/* 传输完成,关闭SPI */
|
||||
hal_spis_stop();
|
||||
hal_spis_deinit();
|
||||
hal_spim_deinit();
|
||||
TAU_LOGD("hal_spis_hw_case done!\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief spi demo case
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void demo_hal_spi(void)
|
||||
{
|
||||
/* 基础传输case */
|
||||
if (!hal_spi_base_case())
|
||||
{
|
||||
hal_spis_stop();
|
||||
hal_spis_deinit();
|
||||
hal_spim_deinit();
|
||||
TAU_LOGD("hal_spi_base_case fail!\n");
|
||||
}
|
||||
|
||||
/* SPIS硬件快速回复功能case */
|
||||
if (!hal_spis_hw_case())
|
||||
{
|
||||
hal_spis_stop();
|
||||
hal_spis_deinit();
|
||||
hal_spim_deinit();
|
||||
TAU_LOGD("hal_spis_hw_case fail!\n");
|
||||
}
|
||||
|
||||
TAU_LOGD("spi case done\n");
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2020-2023, tau Systems (R),All Rights Reserved.
|
||||
*
|
||||
* File: demo_hal_spi.h
|
||||
* Description: demo spi 头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: swx
|
||||
*******************************************************************************/
|
||||
#ifndef __DEMO_HAL_SPI_H__
|
||||
#define __DEMO_HAL_SPI_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "test_cfg_global.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
void demo_hal_spi(void);
|
||||
|
||||
#endif /* __DEMO_HAL_SPI_H__ */
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_swire.c
|
||||
* Description: swire demo code
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: jaya
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "stdarg.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
#include "test_cfg_global.h"
|
||||
#include "hal_swire.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "tau_log.h"
|
||||
#include "tau_delay.h"
|
||||
#include "demo_hal_swire.h"
|
||||
|
||||
#if _MODULE_DEMO_SWIRE_EN
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "demo_hal_swire"
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global function and Global variable declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief swire 手动产生波形 demo
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
static bool demo_hal_swire_gen_swire_manual(void)
|
||||
{
|
||||
/* 配置PIN15为SWIRE 输出*/
|
||||
hal_gpio_set_mode(IO_PAD_AP_SWIRE, PIN15_MODE_SWIRE);
|
||||
/* swire 初始化 */
|
||||
hal_swire_init();
|
||||
/* 启动swire, Swire引脚信号拉高 */
|
||||
hal_swire_enable(true);
|
||||
delayMs(100);
|
||||
/* 配置pulse 为36,产生36个脉冲波形后保持拉高 */
|
||||
hal_swire_set_pulse(36);
|
||||
delayMs(100);
|
||||
/* 配置pulse 为25,产生25个脉冲波形后保持拉高 */
|
||||
hal_swire_set_pulse(25);
|
||||
delayMs(100);
|
||||
/* 关闭swire, Swire引脚信号拉低 */
|
||||
hal_swire_enable(false);
|
||||
/* swire去初始化 */
|
||||
hal_swire_deinit();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief swire 自动产生波形 demo
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
static bool demo_hal_swire_gen_swire_auto(void)
|
||||
{
|
||||
/* 配置PIN15为SWIRE 输出*/
|
||||
hal_gpio_set_mode(IO_PAD_AP_SWIRE, PIN15_MODE_SWIRE);
|
||||
/* swire 初始化 */
|
||||
hal_swire_init();
|
||||
hal_swire_set_timer(TIMER_NUM0, 16, true);
|
||||
|
||||
/* 启动swire, Swire引脚信号拉高,每个16ms发送一次swire信号 */
|
||||
hal_swire_enable(true);
|
||||
|
||||
/*保持每16ms输出36个脉冲,持续100ms*/
|
||||
hal_swire_set_pulse(36); /* 使用timer情况下pulse配置为0时实际输出255个脉冲, 可以在enable之前或者enable前后配置发送正确波形,消除255脉冲问题 */
|
||||
delayMs(100);
|
||||
|
||||
/* 配置pulse 为25,保持每16ms输出36个脉冲,持续100ms */
|
||||
hal_swire_set_pulse(25);
|
||||
|
||||
/* 关闭swire, Swire引脚信号拉低 */
|
||||
hal_swire_enable(false);
|
||||
/* swire去初始化 */
|
||||
hal_swire_deinit();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief swire 配置波形形状demo
|
||||
* @param
|
||||
* @retval bool true/false
|
||||
*/
|
||||
static bool demo_hal_swire_set_swire_waveform(void)
|
||||
{
|
||||
/* 配置PIN15为SWIRE 输出*/
|
||||
hal_gpio_set_mode(IO_PAD_AP_SWIRE, PIN15_MODE_SWIRE);
|
||||
/* swire 初始化 */
|
||||
hal_swire_init();
|
||||
/* 配置波形,持续时间50us */
|
||||
hal_swire_set_waveform(50, 50, 50, 50);
|
||||
/* 启动swire, Swire引脚信号拉高 */
|
||||
hal_swire_enable(true);
|
||||
delayMs(100);
|
||||
/* 配置pulse 为36,产生36个脉冲波形后保持拉高 */
|
||||
hal_swire_set_pulse(36);
|
||||
delayMs(100);
|
||||
/* 关闭swire, Swire引脚信号拉低 */
|
||||
hal_swire_enable(false);
|
||||
/* swire去初始化 */
|
||||
hal_swire_deinit();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief swire demo case
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void demo_hal_swire(void)
|
||||
{
|
||||
TAU_LOGD("swire dmeo \n");
|
||||
demo_hal_swire_gen_swire_manual();
|
||||
//demo_hal_swire_gen_swire_auto();
|
||||
//demo_hal_swire_set_swire_waveform();
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2020-2023, tau Systems (R),All Rights Reserved.
|
||||
*
|
||||
* File: demo_hal_swire.h
|
||||
* Description: demo swire 头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: jaya
|
||||
*******************************************************************************/
|
||||
#ifndef __DEMO_HAL_SWIRE_H__
|
||||
#define __DEMO_HAL_SWIRE_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "test_cfg_global.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
void demo_hal_swire(void);
|
||||
|
||||
#endif /* __DEMO_HAL_SWIRE_H__ */
|
||||
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_timer.c
|
||||
* Description: timer demo源文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: zzf
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "hal_timer.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "tau_log.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "timer-log"
|
||||
|
||||
#define TIMER_DEMO_NORMAL 0 //定时器常规使用,循环超时
|
||||
#define TIMER_DEMO_RESTART 1 //中断重启定时器
|
||||
|
||||
#define TIMER_SEL TIMER_NUM0 //timer0-3 都ok
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
static io_pad_e sg_timer_io_pad = IO_PAD_GPIO1;
|
||||
static gpio_level_e sg_timer_io_lvl = IO_LVL_LOW;
|
||||
#if TIMER_DEMO_RESTART
|
||||
static uint16_t sg_timer_count = 1;
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
#if TIMER_DEMO_RESTART
|
||||
/**
|
||||
* @brief 重新循环中断回调函数
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void demo_timer_restart_callback(void *data)
|
||||
{
|
||||
/* 翻转GPIO */
|
||||
sg_timer_io_lvl = (sg_timer_io_lvl ? IO_LVL_LOW : IO_LVL_HIGH);
|
||||
hal_gpio_set_output_data(sg_timer_io_pad, sg_timer_io_lvl);
|
||||
|
||||
/* 重新启动定时器 */
|
||||
sg_timer_count = sg_timer_count * 10;
|
||||
if (sg_timer_count > 100)
|
||||
{
|
||||
sg_timer_count = 1;
|
||||
}
|
||||
hal_timer_start(TIMER_SEL, sg_timer_count * 10, demo_timer_restart_callback, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 重新中断例程初始化
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void demo_timer_case_restart(void)
|
||||
{
|
||||
/*重新初始化定时器*/
|
||||
hal_timer_init(TIMER_SEL);
|
||||
hal_timer_set_repeat(TIMER_SEL, false);
|
||||
|
||||
/*初始化GPIO低电平*/
|
||||
hal_gpio_init_output(sg_timer_io_pad, sg_timer_io_lvl);
|
||||
|
||||
/*更新当前timer测试参数*/
|
||||
hal_timer_start(TIMER_SEL, sg_timer_count * 10, demo_timer_restart_callback, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TIMER_DEMO_NORMAL
|
||||
/**
|
||||
* @brief 多次循环中断回调函数
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void demo_timer_normal_callback(void *data)
|
||||
{
|
||||
/* 翻转GPIO */
|
||||
sg_timer_io_lvl = (sg_timer_io_lvl ? IO_LVL_LOW : IO_LVL_HIGH);
|
||||
hal_gpio_set_output_data(sg_timer_io_pad, sg_timer_io_lvl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 重新中断例程初始化
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void demo_timer_case_normal(void)
|
||||
{
|
||||
/*重新初始化定时器*/
|
||||
hal_timer_init(TIMER_SEL);
|
||||
hal_timer_set_repeat(TIMER_SEL, true);
|
||||
|
||||
/*初始化GPIO低电平*/
|
||||
hal_gpio_init_output(sg_timer_io_pad, sg_timer_io_lvl);
|
||||
|
||||
/*更新当前timer测试参数*/
|
||||
hal_timer_start(TIMER_SEL, 10, demo_timer_normal_callback, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief demo测试接口函数
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void demo_timer_case(void)
|
||||
{
|
||||
TAU_LOGI("start test\r\n");
|
||||
|
||||
#if TIMER_DEMO_NORMAL
|
||||
demo_timer_case_normal(); // 10ms定时进行IO电平翻转
|
||||
#elif TIMER_DEMO_RESTART
|
||||
demo_timer_case_restart();
|
||||
#endif
|
||||
|
||||
TAU_LOGI("end test\r\n");
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_timer.h
|
||||
* Description: timer demo头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: zzf
|
||||
*******************************************************************************/
|
||||
#ifndef __DEMO_TIMER_H__
|
||||
#define __DEMO_TIMER_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief demo测试接口函数
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void demo_timer_case(void);
|
||||
|
||||
#endif /* __DEMO_TIMER_H__ */
|
||||
|
|
@ -0,0 +1,648 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_uart.c
|
||||
* Description: 测试说明:将电脑端USB转串口分别连接UART0,1测试
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-09
|
||||
* Author: kc
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "stdarg.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
#include "test_cfg_global.h"
|
||||
#include "hal_uart.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "tau_log.h"
|
||||
#include "tau_delay.h"
|
||||
#include "demo_hal_uart.h"
|
||||
|
||||
#if _MODULE_DEMO_UART_EN
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "uart-log"
|
||||
|
||||
#define UART_TEST_AUTO 1
|
||||
|
||||
#define TEST_UART_BAUDRATE 115200
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global function and Global variable declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief 测试case
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
UART_CASE_BLOCKING = 0,
|
||||
UART_CASE_NONE_BLOCKING,
|
||||
UART_CASE_DMA,
|
||||
UART_CASE_MAX,
|
||||
UART_CASE_LOOP_BACK,
|
||||
UART_CASE_DEINIT,
|
||||
} uart_case_e;
|
||||
|
||||
typedef void (*unit_test_func)();
|
||||
typedef struct unit_test_entry_t
|
||||
{
|
||||
char case_name[128]; /* Case名称 */
|
||||
unit_test_func case_func; /* Case处理函数 */
|
||||
} unit_test_entry_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
static char sg_uart_log[256] = {0};
|
||||
static char sg_uart_send_buff[1024] = {0};
|
||||
static char sg_uart_recv_buff[1024] = {0};
|
||||
static uart_case_e sg_uart_case = UART_CASE_BLOCKING;
|
||||
static hal_uart_num_e sg_uart_cur_num = HAL_UART_0;
|
||||
volatile static bool sg_uart_case_done = true;
|
||||
static hal_uart_config_t s_huart;
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
void STRFMT(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;//初始化指向可变参数列表的指针
|
||||
//将第一个可变参数的地址付给ap,即ap指向可变参数列表的开始
|
||||
va_start(ap, fmt);
|
||||
//将参数fmt、ap指向的可变参数一起转换成格式化字符串,放string数组中,其作用同sprintf(),只是参数类型不同
|
||||
vsprintf(sg_uart_log, fmt, ap);
|
||||
va_end(ap); //ap付值为0,没什么实际用处,主要是为程序健壮性
|
||||
}
|
||||
|
||||
#define TEST_LOG(num,format,...) \
|
||||
do { \
|
||||
STRFMT(format, ##__VA_ARGS__); \
|
||||
hal_uart_send_blocking(num, (uint8_t *)sg_uart_log, strlen(sg_uart_log)); \
|
||||
} while (0)
|
||||
/**************************************************************************
|
||||
* @name : TEST_UART_PinMux_Init
|
||||
* @brief : UART 脚位功能初始化
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void test_uart_mode_init(void)
|
||||
{
|
||||
//UART 0
|
||||
hal_gpio_set_mode(IO_PAD_UART0_TX, PIN2_MODE_UART0_TX);
|
||||
hal_gpio_set_mode(IO_PAD_UART0_RX, PIN36_MODE_UART0_RX);
|
||||
//UART 1 只有唯一一组
|
||||
//hal_gpio_set_mode(IO_PAD_UART1_TX, PIN14_MODE_UART1_TX);
|
||||
//hal_gpio_set_mode(IO_PAD_TD_TP_RESX, PIN13_MODE_UART1_RX);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* @name : test_uart_deinit
|
||||
* @brief : uart注销
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void test_uart_common_deinit(hal_uart_num_e num)
|
||||
{
|
||||
delayMs(500);
|
||||
hal_uart_deinit(num);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* @name : test_uart_normal_init
|
||||
* @brief : uart 普通模式初始化
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void test_uart_common_init(hal_uart_num_e num)
|
||||
{
|
||||
hal_uart_config_t huart = {0};
|
||||
huart.baudrate = TEST_UART_BAUDRATE;
|
||||
huart.data_width = HAL_UART_DATAWIDTH_8;
|
||||
huart.parity = HAL_UART_PARITY_NO;
|
||||
huart.stopbits = HAL_UART_STOPBIT_1;
|
||||
hal_uart_init(num, &huart);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取端口号
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static char test_uart_get_input_str(hal_uart_num_e num)
|
||||
{
|
||||
char str = 0;
|
||||
hal_uart_recv_blocking(num, (uint8_t *)&str, 1);
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取输入字符串个数
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static uint32_t test_uart_get_input_num(hal_uart_num_e num)
|
||||
{
|
||||
uint32_t recv = 0;
|
||||
char str[10] = {0};
|
||||
uint8_t i = 0;
|
||||
|
||||
TEST_LOG(num, "input recv num and space to exit:");
|
||||
|
||||
while (1)
|
||||
{
|
||||
hal_uart_recv_blocking(num, (uint8_t *)&str[i], 1);
|
||||
if (str[i] >= '0' && str[i] <= '9')
|
||||
{
|
||||
TEST_LOG(num, "%c", (char)str[i]);
|
||||
i++;
|
||||
}
|
||||
else if (str[i] == 32)
|
||||
{
|
||||
str[i] = 0;
|
||||
TEST_LOG(num, "\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
recv = atol(str);
|
||||
return recv;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 复位uart所在PAD为GPIO mode
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void test_uart_reset_uart_mode(void)
|
||||
{
|
||||
hal_gpio_init_input(IO_PAD_AP_SPIS_MOSI);
|
||||
hal_gpio_init_input(IO_PAD_UART0_TX);
|
||||
hal_gpio_init_input(IO_PAD_AP_SPIS_MISO);
|
||||
hal_gpio_init_input(IO_PAD_UART0_RX);
|
||||
hal_gpio_init_input(IO_PAD_AP_TPRSTN);
|
||||
hal_gpio_init_input(IO_PAD_AP_PWMEN);
|
||||
hal_gpio_init_input(IO_PAD_TD_SPIM_MOSI);
|
||||
hal_gpio_init_input(IO_PAD_UART1_TX);
|
||||
hal_gpio_init_input(IO_PAD_TD_TP_RESX);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 在UART2上设置UART1的TX和RX PAD
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void test_uart_set_uart_mode(void)
|
||||
{
|
||||
char str = 0;
|
||||
hal_uart_num_e uart_org_num = sg_uart_cur_num;
|
||||
|
||||
TEST_LOG(uart_org_num, "select UART(0/1):\n");
|
||||
TEST_LOG(uart_org_num, "Enter:");
|
||||
str = test_uart_get_input_str(uart_org_num);
|
||||
TEST_LOG(uart_org_num, "%c\n\n", str);
|
||||
sg_uart_cur_num = (hal_uart_num_e)(str - '0');
|
||||
|
||||
if (HAL_UART_1 == sg_uart_cur_num) /* 测试UART1 */
|
||||
{
|
||||
//sel tx
|
||||
TEST_LOG(uart_org_num, "select UART1 TX:\n");
|
||||
TEST_LOG(uart_org_num, "0:IO_PAD_UART1_TX->PIN14_MODE_UART1_TX\n");
|
||||
//sel rx
|
||||
TEST_LOG(uart_org_num, "select UART1 RX:\n");
|
||||
TEST_LOG(uart_org_num, "0:IO_PAD_TD_TP_RESX->PIN13_MODE_UART1_RX\n");
|
||||
TEST_LOG(uart_org_num, "change the connect pin and press space to continue \n");
|
||||
delayMs(200);
|
||||
|
||||
test_uart_reset_uart_mode();
|
||||
hal_gpio_set_mode(IO_PAD_UART1_TX, PIN14_MODE_UART1_TX);
|
||||
hal_gpio_set_mode(IO_PAD_TD_TP_RESX, PIN13_MODE_UART1_RX);
|
||||
hal_uart_deinit(HAL_UART_0);
|
||||
test_uart_common_init(HAL_UART_1);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t sel_tx, sel_rx;
|
||||
//sel tx
|
||||
TEST_LOG(uart_org_num, "select UART0 TX:\n");
|
||||
TEST_LOG(uart_org_num, "0:IO_PAD_UART0_TX->PIN2_MODE_UART0_TX\n");
|
||||
TEST_LOG(uart_org_num, "1:IO_PAD_AP_SPIS_MOSI->PIN33_MODE_UART0_TX \n");
|
||||
TEST_LOG(uart_org_num, "2:IO_PAD_TD_SPIM_MOSI->PIN4_MODE_UART0_TX\n");
|
||||
TEST_LOG(uart_org_num, "Enter:");
|
||||
str = test_uart_get_input_str(uart_org_num);
|
||||
TEST_LOG(uart_org_num, "%c\n\n", str);
|
||||
sel_tx = str - '0';
|
||||
|
||||
//sel rx
|
||||
TEST_LOG(uart_org_num, "select UART0 RX:\n");
|
||||
TEST_LOG(uart_org_num, "0:IO_PAD_UART0_RX->PIN36_MODE_UART0_RX\n");
|
||||
TEST_LOG(uart_org_num, "1:IO_PAD_AP_SPIS_MISO->PIN30_MODE_UART0_RX\n");
|
||||
TEST_LOG(uart_org_num, "2:IO_PAD_AP_TPRSTN->PIN18_MODE_UART0_RX\n");
|
||||
TEST_LOG(uart_org_num, "3:IO_PAD_AP_PWMEN->PIN17_MODE_UART0_RX\n");
|
||||
TEST_LOG(uart_org_num, "4:IO_PAD_UART1_TX->PIN14_MODE_UART0_RX\n");
|
||||
TEST_LOG(uart_org_num, "Enter:");
|
||||
str = test_uart_get_input_str(uart_org_num);
|
||||
TEST_LOG(uart_org_num, "%c\n\n", str);
|
||||
sel_rx = str - '0';
|
||||
|
||||
TEST_LOG(uart_org_num, "change the connect pin and press space to continue \n");
|
||||
delayMs(500);
|
||||
test_uart_reset_uart_mode();
|
||||
|
||||
switch (sel_tx)
|
||||
{
|
||||
case 0:
|
||||
hal_gpio_set_mode(IO_PAD_UART0_TX, PIN2_MODE_UART0_TX);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
hal_gpio_set_mode(IO_PAD_AP_SPIS_MOSI, PIN33_MODE_UART0_TX);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
hal_gpio_set_mode(IO_PAD_TD_SPIM_MOSI, PIN4_MODE_UART0_TX);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (sel_rx)
|
||||
{
|
||||
case 0:
|
||||
hal_gpio_set_mode(IO_PAD_UART0_RX, PIN36_MODE_UART0_RX);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
hal_gpio_set_mode(IO_PAD_AP_SPIS_MISO, PIN30_MODE_UART0_RX);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
hal_gpio_set_mode(IO_PAD_AP_TPRSTN, PIN18_MODE_UART0_RX);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
hal_gpio_set_mode(IO_PAD_AP_PWMEN, PIN17_MODE_UART0_RX);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
hal_gpio_set_mode(IO_PAD_UART1_TX, PIN14_MODE_UART0_RX);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
hal_uart_deinit(HAL_UART_1);
|
||||
test_uart_common_init(HAL_UART_0);
|
||||
}
|
||||
while (1)
|
||||
{
|
||||
str = test_uart_get_input_str(sg_uart_cur_num);
|
||||
if (str == 32)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 是否重复
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static bool test_uart_sel_continue()
|
||||
{
|
||||
uint8_t str = 0;
|
||||
delayMs(500);
|
||||
test_uart_common_deinit(sg_uart_cur_num);
|
||||
test_uart_common_init(sg_uart_cur_num);
|
||||
TEST_LOG(sg_uart_cur_num, " y repeat \n");
|
||||
TEST_LOG(sg_uart_cur_num, " n exit \n");
|
||||
while (1)
|
||||
{
|
||||
str = test_uart_get_input_str(sg_uart_cur_num);
|
||||
switch (str)
|
||||
{
|
||||
case 'y':
|
||||
TEST_LOG(sg_uart_cur_num, "y\n");
|
||||
return true;
|
||||
|
||||
case 'n':
|
||||
TEST_LOG(sg_uart_cur_num, "n\n");
|
||||
return false;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* @name : test_uart_blocking
|
||||
* @brief : UART TX,RX阻塞读写。
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void test_uart_blocking(void)
|
||||
{
|
||||
uint32_t recv = 0;
|
||||
delayMs(500);
|
||||
test_uart_common_deinit(sg_uart_cur_num);
|
||||
test_uart_common_init(sg_uart_cur_num);
|
||||
delayMs(500);
|
||||
TEST_LOG(sg_uart_cur_num, "test uart%d start.\n", sg_uart_cur_num);
|
||||
|
||||
//test recv
|
||||
recv = test_uart_get_input_num(sg_uart_cur_num);
|
||||
TEST_LOG(sg_uart_cur_num, "input %d char one time:\n", recv);
|
||||
memset(sg_uart_recv_buff, 0, recv + 1);
|
||||
if (!hal_uart_recv_blocking(sg_uart_cur_num, (uint8_t *)sg_uart_recv_buff, recv))
|
||||
{
|
||||
TEST_LOG(sg_uart_cur_num, "an error has occurred!\n");
|
||||
}
|
||||
TEST_LOG(sg_uart_cur_num, "%s\n", sg_uart_recv_buff);
|
||||
|
||||
//test send
|
||||
TEST_LOG(sg_uart_cur_num, "send:\n");
|
||||
strcpy(sg_uart_send_buff, sg_uart_recv_buff);
|
||||
if (!hal_uart_send_blocking(sg_uart_cur_num, (uint8_t *)sg_uart_send_buff, strlen(sg_uart_send_buff)))
|
||||
{
|
||||
TEST_LOG(sg_uart_cur_num, "an error has occurred!\n");
|
||||
}
|
||||
|
||||
TEST_LOG(sg_uart_cur_num, "\n");
|
||||
|
||||
sg_uart_case_done = true;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* @name : test_uart_trans_cb
|
||||
* @brief : 用户回调函数
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void test_uart_trans_cb(status_t status, void *user_data)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case STATUS_UART_RX_IDLE:
|
||||
case STATUS_UART_TX_IDLE:
|
||||
*(bool *)user_data = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* @name : test_uart_none_blocking
|
||||
* @brief : UART TX,RX非阻塞读写。
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void test_uart_none_blocking(void)
|
||||
{
|
||||
uint32_t recv = 0;
|
||||
volatile bool int_done = false;
|
||||
delayMs(500);
|
||||
test_uart_common_deinit(sg_uart_cur_num);
|
||||
s_huart.baudrate = TEST_UART_BAUDRATE;
|
||||
s_huart.data_width = HAL_UART_DATAWIDTH_8;
|
||||
s_huart.parity = HAL_UART_PARITY_NO;
|
||||
s_huart.stopbits = HAL_UART_STOPBIT_1;
|
||||
s_huart.callback = test_uart_trans_cb;
|
||||
s_huart.user_data = &int_done;
|
||||
hal_uart_init(sg_uart_cur_num, &s_huart);
|
||||
delayMs(500);
|
||||
TEST_LOG(sg_uart_cur_num, "test uart%d start...\n", sg_uart_cur_num);
|
||||
TEST_LOG(sg_uart_cur_num, "input and output 10 char:\n");
|
||||
int_done = false;
|
||||
memset(sg_uart_recv_buff, 0, recv + 1);
|
||||
while (!hal_uart_recv_none_blocking(sg_uart_cur_num, (uint8_t *)sg_uart_recv_buff, 10))
|
||||
{
|
||||
//TEST_LOG(sg_uart_cur_num, "device busy!\n");
|
||||
}
|
||||
while (!int_done);
|
||||
|
||||
//test send
|
||||
int_done = false;
|
||||
strcpy(sg_uart_send_buff, sg_uart_recv_buff);
|
||||
while (!hal_uart_send_none_blocking(sg_uart_cur_num, (uint8_t *)sg_uart_send_buff, strlen(sg_uart_send_buff)))
|
||||
{
|
||||
//TEST_LOG(sg_uart_cur_num, "device busy!\n");
|
||||
}
|
||||
while (!int_done);
|
||||
|
||||
TEST_LOG(sg_uart_cur_num, "\n");
|
||||
|
||||
sg_uart_case_done = true;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* @name : test_uart_dma_transmit
|
||||
* @brief : UART DMA读写测试
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
static void test_uart_dma_transmit(void)
|
||||
{
|
||||
uint32_t recv = 0;
|
||||
char str = 0;
|
||||
bool int_done = false;
|
||||
|
||||
while (1)
|
||||
{
|
||||
TEST_LOG(sg_uart_cur_num, "test uart%d start...\n", sg_uart_cur_num);
|
||||
recv = test_uart_get_input_num(sg_uart_cur_num);
|
||||
TEST_LOG(sg_uart_cur_num, "please input %d char once:\n", recv);
|
||||
|
||||
test_uart_common_deinit(sg_uart_cur_num);
|
||||
s_huart.baudrate = TEST_UART_BAUDRATE;
|
||||
s_huart.data_width = HAL_UART_DATAWIDTH_8;
|
||||
s_huart.parity = HAL_UART_PARITY_NO;
|
||||
s_huart.stopbits = HAL_UART_STOPBIT_1;
|
||||
s_huart.callback = test_uart_trans_cb;
|
||||
s_huart.user_data = &int_done;
|
||||
hal_uart_init(sg_uart_cur_num, &s_huart);
|
||||
|
||||
int_done = false;
|
||||
memset(sg_uart_recv_buff, 0, recv + 1);
|
||||
while (!hal_uart_dma_recv(sg_uart_cur_num, (uint8_t *)sg_uart_recv_buff, recv))
|
||||
{
|
||||
//TEST_LOG(sg_uart_cur_num, "device busy!\n");
|
||||
}
|
||||
while (!int_done)
|
||||
{
|
||||
delayMs(500);
|
||||
};
|
||||
|
||||
TEST_LOG(sg_uart_cur_num, "%s\n", sg_uart_recv_buff);
|
||||
TEST_LOG(sg_uart_cur_num, "please input %d char twice:\n", recv);
|
||||
|
||||
int_done = false;
|
||||
memset(sg_uart_recv_buff, 0, recv + 1);
|
||||
while (!hal_uart_dma_recv(sg_uart_cur_num, (uint8_t *)sg_uart_recv_buff, recv))
|
||||
{
|
||||
//TEST_LOG(sg_uart_cur_num, "device busy!\n");
|
||||
}
|
||||
while (!int_done)
|
||||
{
|
||||
delayMs(100);
|
||||
//TEST_LOG("recv dma not done!!!\n");
|
||||
};
|
||||
TEST_LOG(sg_uart_cur_num, "%s\n", sg_uart_recv_buff);
|
||||
|
||||
int_done = false;
|
||||
strcpy(sg_uart_send_buff, "uart dma tx test comp once!\n");
|
||||
while (!hal_uart_dma_send(sg_uart_cur_num, (uint8_t *)sg_uart_send_buff, strlen(sg_uart_send_buff)))
|
||||
{
|
||||
//TEST_LOG(sg_uart_cur_num, "device busy!\n");
|
||||
}
|
||||
while (!int_done);
|
||||
|
||||
int_done = false;
|
||||
strcpy(sg_uart_send_buff, "uart dma tx test comp twice!\n");
|
||||
while (!hal_uart_dma_send(sg_uart_cur_num, (uint8_t *)sg_uart_send_buff, strlen(sg_uart_send_buff)))
|
||||
{
|
||||
//TEST_LOG(sg_uart_cur_num, "device busy!\n");
|
||||
}
|
||||
while (!int_done);
|
||||
|
||||
if (sg_uart_cur_num == HAL_UART_0)
|
||||
{
|
||||
hal_uart_dma_path_close(HAL_UART0_DMA_PATH_TX);
|
||||
hal_uart_dma_path_close(HAL_UART0_DMA_PATH_RX);
|
||||
//TEST_LOG(sg_uart_cur_num, "close uart0 dma channel\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
hal_uart_dma_path_close(HAL_UART1_DMA_PATH_TX);
|
||||
hal_uart_dma_path_close(HAL_UART1_DMA_PATH_RX);
|
||||
//TEST_LOG(sg_uart_cur_num, "close uart1 dma channel\n");
|
||||
}
|
||||
delayMs(500);
|
||||
/* 用普通方式初始化uart */
|
||||
test_uart_common_deinit(sg_uart_cur_num);
|
||||
test_uart_common_init(sg_uart_cur_num);
|
||||
|
||||
TEST_LOG(sg_uart_cur_num, "0:continue\n");
|
||||
TEST_LOG(sg_uart_cur_num, "1:exit\n");
|
||||
TEST_LOG(sg_uart_cur_num, "Enter:");
|
||||
while (1)
|
||||
{
|
||||
str = test_uart_get_input_str(sg_uart_cur_num);
|
||||
if ('0' == str)
|
||||
{
|
||||
TEST_LOG(sg_uart_cur_num, "%c\n", str);
|
||||
break;
|
||||
}
|
||||
else if ('1' == str)
|
||||
{
|
||||
TEST_LOG(sg_uart_cur_num, "%c\n", str);
|
||||
sg_uart_case_done = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const unit_test_entry_t sg_uart_unit_test_table[] =
|
||||
{
|
||||
{"blocking case ...", test_uart_blocking},
|
||||
{"none blocking case ...", test_uart_none_blocking},
|
||||
{"dma trans case ...", test_uart_dma_transmit},
|
||||
{"end", NULL},
|
||||
};
|
||||
|
||||
#if UART_TEST_AUTO
|
||||
/**
|
||||
* @brief uart测试用例切换
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void test_uart_auto_case(void)
|
||||
{
|
||||
for (sg_uart_case = UART_CASE_BLOCKING; sg_uart_case < UART_CASE_MAX; sg_uart_case++)
|
||||
{
|
||||
TEST_LOG(sg_uart_cur_num, "%s\n", sg_uart_unit_test_table[sg_uart_case].case_name);
|
||||
|
||||
sg_uart_case_done = false;
|
||||
|
||||
/*配置并启动定时器*/
|
||||
sg_uart_unit_test_table[sg_uart_case].case_func();
|
||||
|
||||
/*等待超时中断*/
|
||||
while (!sg_uart_case_done);
|
||||
|
||||
TEST_LOG(sg_uart_cur_num, "test case pass \n");
|
||||
TEST_LOG(sg_uart_cur_num, "\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* @brief uart测试用例切换
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void test_uart_unit_case(uint8_t case_num)
|
||||
{
|
||||
TEST_LOG(sg_uart_cur_num, "%s\n", sg_uart_unit_test_table[case_num].case_name);
|
||||
|
||||
sg_uart_case_done = false;
|
||||
|
||||
/*配置并启动定时器*/
|
||||
sg_uart_unit_test_table[case_num].case_func();
|
||||
|
||||
/*等待超时中断*/
|
||||
while (!sg_uart_case_done);
|
||||
|
||||
TEST_LOG(sg_uart_cur_num, "test case pass!!\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/**************************************************************************
|
||||
* @name : demo_hal_uart_case
|
||||
* @brief :
|
||||
* @param[in] :
|
||||
* @return :
|
||||
* @retval :
|
||||
**************************************************************************/
|
||||
void demo_hal_uart_case(void)
|
||||
{
|
||||
test_uart_common_init(sg_uart_cur_num);
|
||||
test_uart_mode_init();
|
||||
while (1)
|
||||
{
|
||||
test_uart_set_uart_mode();
|
||||
|
||||
#if UART_TEST_AUTO
|
||||
test_uart_auto_case();
|
||||
#else
|
||||
test_uart_unit_case(sg_uart_case);
|
||||
#endif
|
||||
|
||||
if (!test_uart_sel_continue())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
TEST_LOG(sg_uart_cur_num, "uart test done!\n");
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2020-2023, tau Systems (R),All Rights Reserved.
|
||||
*
|
||||
* File: demo_hal_uart.h
|
||||
* Description: hal uart测试用例头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-09
|
||||
* Author: kc
|
||||
*******************************************************************************/
|
||||
#ifndef __DEMO_HAL_UART_H__
|
||||
#define __DEMO_HAL_UART_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "test_cfg_global.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
void demo_hal_uart_case(void);
|
||||
|
||||
#endif /* __DEMO_HAL_UART_H__ */
|
||||
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_wdg.c
|
||||
* Description: watch dog demo源文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: zzf
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "hal_wdg.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "tau_delay.h"
|
||||
#include "tau_log.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "wdg-log"
|
||||
|
||||
#define WDG_CASE_RST 0 //复位模式
|
||||
#define WDG_CASE_INTR 1 //中断模式
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
#if WDG_CASE_INTR
|
||||
static io_pad_e sg_wdg_io_pad = IO_PAD_GPIO1;
|
||||
static gpio_level_e sg_wdg_io_lvl = IO_LVL_LOW;
|
||||
/* 循环喂狗 */
|
||||
static uint8_t sg_feed_cnt = 0;
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
#if WDG_CASE_RST
|
||||
/**
|
||||
* @brief 复位模式测试
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void demo_wdg_case_rst_mode(void)
|
||||
{
|
||||
TAU_LOGI("reset start...\n");
|
||||
|
||||
/* WDG初始化复位模式 */
|
||||
hal_wdg_init();
|
||||
|
||||
/* 启动 */
|
||||
hal_wdg_start(WDG_MODE_RESET, 5000);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WDG_CASE_INTR
|
||||
/**
|
||||
* @brief 测试回调函数
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void demo_wdg_callback(void *data)
|
||||
{
|
||||
/* 翻转GPIO */
|
||||
sg_wdg_io_lvl = (sg_wdg_io_lvl ? IO_LVL_LOW : IO_LVL_HIGH);
|
||||
hal_gpio_set_output_data(sg_wdg_io_pad, sg_wdg_io_lvl);
|
||||
sg_feed_cnt++;
|
||||
|
||||
if (sg_feed_cnt > 10)
|
||||
{
|
||||
hal_wdg_stop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 中断模式测试
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void demo_wdg_case_int_mode(void)
|
||||
{
|
||||
TAU_LOGI("int start...\n");
|
||||
|
||||
/* WDG初始化 */
|
||||
hal_wdg_init();
|
||||
|
||||
/* 设置循环超时 */
|
||||
hal_wdg_set_repeat(true);
|
||||
|
||||
/* 设置回调函数 */
|
||||
hal_wdg_register_callback(demo_wdg_callback, NULL);
|
||||
|
||||
/*初始化GPIO低状态*/
|
||||
hal_gpio_init_output(sg_wdg_io_pad, sg_wdg_io_lvl);
|
||||
|
||||
/* 设置中断模式 */
|
||||
hal_wdg_start(WDG_MODE_INTERRUPT, 200);
|
||||
|
||||
|
||||
while (sg_feed_cnt < 6)
|
||||
{
|
||||
sg_feed_cnt++;
|
||||
hal_wdg_kick_dog();
|
||||
delayMs(150);
|
||||
TAU_LOGI("feed [%d]th done\n", sg_feed_cnt);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief demo测试接口函数
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void demo_wdg_case(void)
|
||||
{
|
||||
TAU_LOGI("demo_wdg_case\r\n");
|
||||
|
||||
#if WDG_CASE_RST
|
||||
demo_wdg_case_rst_mode();
|
||||
#elif WDG_CASE_INTR
|
||||
demo_wdg_case_int_mode();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: demo_hal_wdg.h
|
||||
* Description: watch dog demo头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: zzf
|
||||
*******************************************************************************/
|
||||
#ifndef __DEMO_WDG_H__
|
||||
#define __DEMO_WDG_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief demo测试接口函数
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void demo_wdg_case(void);
|
||||
|
||||
#endif /* __DEMO_WDG_H__ */
|
||||
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
* File: ap_demo_main.c
|
||||
* Description: ap demo main file
|
||||
* Version: V0.1
|
||||
* Date: 2022-04-15
|
||||
* Author: Jaya
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "module_demo_main.h"
|
||||
|
||||
void module_demo_main()
|
||||
{
|
||||
#if _MODULE_DEMO_DSI_TX_EN
|
||||
demo_dsi_tx_case();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_DSI_RX_EN
|
||||
demo_hal_dsi_rx_case();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_TIMER_EN
|
||||
demo_timer_case();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_WDG_EN
|
||||
demo_wdg_case();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_GPIO_EN
|
||||
demo_gpio_case();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_SWIRE_EN
|
||||
demo_hal_swire();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_SPI_EN
|
||||
demo_hal_spi();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_I2C_EN
|
||||
demo_hal_i2c();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_FLASH_EN
|
||||
demo_hal_flash();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_PWM_EN
|
||||
demo_hal_pwm();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_PWR_EN
|
||||
demo_hal_pwr();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_UART_EN
|
||||
demo_hal_uart_case();
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_CRC_EN
|
||||
demo_hal_crc_case();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
* File: module_demo_main.h
|
||||
* Description: module demo main file
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: Jaya
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __MODULE_DEMO_MAIN_H__
|
||||
#define __MODULE_DEMO_MAIN_H__
|
||||
#include "test_cfg_global.h"
|
||||
|
||||
#if _MODULE_DEMO_DSI_TX_EN
|
||||
#include "demo_hal_dsi_tx.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_DSI_RX_EN
|
||||
#include "demo_hal_dsi_rx.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_TIMER_EN
|
||||
#include "demo_hal_timer.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_WDG_EN
|
||||
#include "demo_hal_wdg.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_GPIO_EN
|
||||
#include "demo_hal_gpio.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_SWIRE_EN
|
||||
#include "demo_hal_swire.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_SPI_EN
|
||||
#include "demo_hal_spi.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_I2C_EN
|
||||
#include "demo_hal_i2c.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_FLASH_EN
|
||||
#include "demo_hal_flash.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_PWM_EN
|
||||
#include "demo_hal_pwm.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_PWR_EN
|
||||
#include "demo_hal_pwr.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_UART_EN
|
||||
#include "demo_hal_uart.h"
|
||||
#endif
|
||||
|
||||
#if _MODULE_DEMO_CRC_EN
|
||||
#include "demo_hal_crc.h"
|
||||
#endif
|
||||
|
||||
void module_demo_main(void);
|
||||
|
||||
#endif /* __MODULE_DEMO_MAIN_H__ */
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
* File: test_cfg_global.h
|
||||
* Description: 测试用例全局配置头文件
|
||||
* Version: V0.1
|
||||
* Date: 2021-05-01
|
||||
* Author: kevin
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __TEST_GLOBAL_CONFIG_H__
|
||||
#define __TEST_GLOBAL_CONFIG_H__
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
/* 模块demo 宏定义 */
|
||||
#define _MODULE_DEMO_ENABLE 0
|
||||
#define _MODULE_DEMO_TIMER_EN 0
|
||||
#define _MODULE_DEMO_DSI_TX_EN 0
|
||||
#define _MODULE_DEMO_DSI_RX_EN 0
|
||||
#define _MODULE_DEMO_PWM_EN 0
|
||||
#define _MODULE_DEMO_SWIRE_EN 0
|
||||
#define _MODULE_DEMO_WDG_EN 0
|
||||
#define _MODULE_DEMO_GPIO_EN 0
|
||||
#define _MODULE_DEMO_I2C_EN 0
|
||||
#define _MODULE_DEMO_SPI_EN 0
|
||||
#define _MODULE_DEMO_PWR_EN 0
|
||||
/* ap demo 宏定义 */
|
||||
|
||||
#define _DEMO_HONOR_90Pro_EN 1
|
||||
|
||||
|
||||
#if _DEMO_HONOR_90Pro_EN
|
||||
#include "Honor90Pro_demo.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: board.c
|
||||
* Description 板级文件
|
||||
* Version V0.1
|
||||
* Date 2023-07-23
|
||||
* Author lzy
|
||||
*******************************************************************************/
|
||||
#include "board.h"
|
||||
#include "hal_system.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "ArmCM0.h"
|
||||
#include "tau_log.h"
|
||||
|
||||
/**
|
||||
* @brief 系统板级初始化,配置系统时钟,调试log输出
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void board_Init(void)
|
||||
{
|
||||
/* system init ,配置MCU时钟 */
|
||||
hal_system_init(HAL_SYSCLK_80M);
|
||||
|
||||
/* 使用SWD口作为Debug Log输出,可配置成Uart方式 */
|
||||
tau_log_init(115200, LOG_PORT_UART0);
|
||||
|
||||
/* systick init,根据需要配置 */
|
||||
//hal_system_enable_systick(1);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: board.h
|
||||
* Description: baord 初始化头文件
|
||||
* Version: V0.1
|
||||
* Date: 2020-01-08
|
||||
* Author: lzy
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __BOARD_H__
|
||||
#define __BOARD_H__
|
||||
|
||||
/**
|
||||
* @brief 系统板级初始化,配置系统时钟,调试log输出
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void board_Init(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
;/**************************************************************************//**
|
||||
; * @file startup_ARMCM0.s
|
||||
; * @brief CMSIS Core Device Startup File for
|
||||
; * ARMCM0 Device
|
||||
; * @version V5.4.0
|
||||
; * @date 12. December 2018
|
||||
; ******************************************************************************/
|
||||
;/*
|
||||
; * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
|
||||
; *
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
; * not use this file except in compliance with the License.
|
||||
; * You may obtain a copy of the License at
|
||||
; *
|
||||
; * www.apache.org/licenses/LICENSE-2.0
|
||||
; *
|
||||
; * Unless required by applicable law or agreed to in writing, software
|
||||
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
; * See the License for the specific language governing permissions and
|
||||
; * limitations under the License.
|
||||
; */
|
||||
|
||||
;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
|
||||
|
||||
|
||||
;<h> Stack Configuration
|
||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
;</h>
|
||||
|
||||
Stack_Size EQU 0x00001000
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
__stack_limit
|
||||
Stack_Mem SPACE Stack_Size
|
||||
__initial_sp
|
||||
|
||||
|
||||
;<h> Heap Configuration
|
||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
;</h>
|
||||
|
||||
Heap_Size EQU 0x00000C00
|
||||
|
||||
IF Heap_Size != 0 ; Heap is provided
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
Heap_Mem SPACE Heap_Size
|
||||
__heap_limit
|
||||
ENDIF
|
||||
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; -14 NMI Handler
|
||||
DCD HardFault_Handler ; -13 Hard Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; -5 SVCall Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; -2 PendSV Handler
|
||||
DCD SysTick_Handler ; -1 SysTick Handler
|
||||
|
||||
|
||||
; Interrupts
|
||||
DCD VIDC_IRQn_Handler ; 0 Interrupt 0
|
||||
DCD LCDC_IRQn_Handler ; 1 Interrupt 1
|
||||
DCD MIPI_RX_IRQn_Handler ; 2 Interrupt 2
|
||||
DCD MIPI_TX_IRQn_Handler ; 3 Interrupt 3
|
||||
DCD MEMC_IRQn_Handler ; 4 Interrupt 4
|
||||
DCD VPRE_IRQn_Handler ; 5 Interrupt 5
|
||||
DCD FLSCTRL_IRQn_Handler ; 6 Interrupt 6
|
||||
DCD DMA_IRQn_Handler ; 7 Interrupt 7
|
||||
DCD TIMER0_IRQn_Handler ; 8 Interrupt 8
|
||||
DCD TIMER1_IRQn_Handler ; 9 Interrupt 9
|
||||
DCD TIMER2_IRQn_Handler ; 10 Interrupt 10
|
||||
DCD TIMER3_IRQn_Handler ; 11 Interrupt 11
|
||||
DCD WDG_IRQn_Handler ; 12 Interrupt 12
|
||||
DCD UART_IRQn_Handler ; 13 Interrupt 13
|
||||
DCD I2C0_IRQn_Handler ; 14 Interrupt 14
|
||||
DCD I2C1_IRQn_Handler ; 15 Interrupt 15
|
||||
DCD SPIS_IRQn_Handler ; 16 Interrupt 16
|
||||
DCD SPIM_IRQn_Handler ; 17 Interrupt 17
|
||||
DCD VPRE1_IRQn_Handler ; 18 Interrupt 18
|
||||
DCD I2C2_IRQn_Handler ; 19 Interrupt 19
|
||||
DCD OTP_IRQn_Handler ; 20 Interrupt 20
|
||||
DCD SWIRE_IRQn_Handler ; 21 Interrupt 21
|
||||
DCD PVD_IRQn_Handler ; 22 Interrupt 22
|
||||
DCD AP_NRESET_IRQn_Handler ; 23 Interrupt 23
|
||||
DCD EXTI_INT0_IRQn_Handler ; 24 Interrupt 24
|
||||
DCD EXTI_INT1_IRQn_Handler ; 25 Interrupt 25
|
||||
DCD EXTI_INT2_IRQn_Handler ; 26 Interrupt 26
|
||||
DCD EXTI_INT3_IRQn_Handler ; 27 Interrupt 27
|
||||
DCD EXTI_INT4_IRQn_Handler ; 28 Interrupt 28
|
||||
DCD EXTI_INT5_IRQn_Handler ; 29 Interrupt 29
|
||||
DCD EXTI_INT6_IRQn_Handler ; 30 Interrupt 30
|
||||
DCD EXTI_INT7_IRQn_Handler ; 31 Interrupt 31
|
||||
|
||||
SPACE ( 0 * 4) ; Interrupts 10 .. 31 are left out
|
||||
|
||||
__Vectors_End
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
_NVIC_ICER0 EQU 0xE000E180 ;清中断使能寄存器地址
|
||||
_NVIC_ICPR0 EQU 0xE000E280 ;清中断pending寄存器地址
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset Handler
|
||||
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT __main
|
||||
|
||||
;清中断使能和pending ——开始——
|
||||
CPSID I ; 屏蔽中断
|
||||
LDR R0, =_NVIC_ICER0
|
||||
LDR R1, =_NVIC_ICPR0
|
||||
LDR R2, =0xFFFFFFFF
|
||||
MOVS R3, #1 ; 设置循环次数 M0只有1组(32个)中断,故只需要循环1次
|
||||
_irq_clear
|
||||
;CBZ R3, _irq_clear_end
|
||||
CMP R3,#0 ; 循环次数等于0,跳转到_irq_clear_end
|
||||
BNE _irq_clear_end
|
||||
STR R2, [R0] ;,#4 ; NVIC_ICER0 - 清 enable IRQ 寄存器
|
||||
STR R2, [R1] ;,#4 ; NVIC_ICPR0 - 清 pending IRQ 寄存器
|
||||
SUBS R3, #1 ; 循环数自减1
|
||||
B _irq_clear
|
||||
_irq_clear_end
|
||||
;清中断使能和pending ——结束——
|
||||
CPSIE I ; 开启中断
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
|
||||
; Macro to define default exception/interrupt handlers.
|
||||
; Default handler are weak symbols with an endless loop.
|
||||
; They can be overwritten by real handlers.
|
||||
MACRO
|
||||
Set_Default_Handler $Handler_Name
|
||||
$Handler_Name PROC
|
||||
EXPORT $Handler_Name [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MEND
|
||||
|
||||
|
||||
; Default exception/interrupt handler
|
||||
|
||||
Set_Default_Handler NMI_Handler
|
||||
Set_Default_Handler HardFault_Handler
|
||||
Set_Default_Handler SVC_Handler
|
||||
Set_Default_Handler PendSV_Handler
|
||||
Set_Default_Handler SysTick_Handler
|
||||
|
||||
Set_Default_Handler VIDC_IRQn_Handler
|
||||
Set_Default_Handler LCDC_IRQn_Handler
|
||||
Set_Default_Handler MIPI_RX_IRQn_Handler
|
||||
Set_Default_Handler MIPI_TX_IRQn_Handler
|
||||
Set_Default_Handler MEMC_IRQn_Handler
|
||||
Set_Default_Handler VPRE_IRQn_Handler
|
||||
Set_Default_Handler FLSCTRL_IRQn_Handler
|
||||
Set_Default_Handler DMA_IRQn_Handler
|
||||
Set_Default_Handler TIMER0_IRQn_Handler
|
||||
Set_Default_Handler TIMER1_IRQn_Handler
|
||||
|
||||
Set_Default_Handler TIMER2_IRQn_Handler
|
||||
Set_Default_Handler TIMER3_IRQn_Handler
|
||||
Set_Default_Handler WDG_IRQn_Handler
|
||||
Set_Default_Handler UART_IRQn_Handler
|
||||
Set_Default_Handler I2C0_IRQn_Handler
|
||||
Set_Default_Handler I2C1_IRQn_Handler
|
||||
Set_Default_Handler SPIS_IRQn_Handler
|
||||
Set_Default_Handler SPIM_IRQn_Handler
|
||||
Set_Default_Handler VPRE1_IRQn_Handler
|
||||
Set_Default_Handler I2C2_IRQn_Handler
|
||||
|
||||
Set_Default_Handler OTP_IRQn_Handler
|
||||
Set_Default_Handler SWIRE_IRQn_Handler
|
||||
Set_Default_Handler PVD_IRQn_Handler
|
||||
Set_Default_Handler AP_NRESET_IRQn_Handler
|
||||
Set_Default_Handler EXTI_INT0_IRQn_Handler
|
||||
Set_Default_Handler EXTI_INT1_IRQn_Handler
|
||||
Set_Default_Handler EXTI_INT2_IRQn_Handler
|
||||
Set_Default_Handler EXTI_INT3_IRQn_Handler
|
||||
Set_Default_Handler EXTI_INT4_IRQn_Handler
|
||||
Set_Default_Handler EXTI_INT5_IRQn_Handler
|
||||
|
||||
Set_Default_Handler EXTI_INT6_IRQn_Handler
|
||||
Set_Default_Handler EXTI_INT7_IRQn_Handler
|
||||
ALIGN
|
||||
|
||||
|
||||
; User setup Stack & Heap
|
||||
|
||||
IF :LNOT::DEF:__MICROLIB
|
||||
IMPORT __use_two_region_memory
|
||||
ENDIF
|
||||
|
||||
EXPORT __stack_limit
|
||||
EXPORT __initial_sp
|
||||
IF Heap_Size != 0 ; Heap is provided
|
||||
EXPORT __heap_base
|
||||
EXPORT __heap_limit
|
||||
ENDIF
|
||||
|
||||
END
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: tau_common.h
|
||||
* Description 通用数据类型相关定义头文件
|
||||
* Version V0.1
|
||||
* Date 2020-09-07
|
||||
* Author lzy
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __TAU_COMMON_H
|
||||
#define __TAU_COMMON_H
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "stdint.h"
|
||||
#include "math.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* \name 通用常量定义
|
||||
* @{
|
||||
*/
|
||||
//#define ENABLE 1
|
||||
//#define DISABLE 0
|
||||
|
||||
#define ON 1
|
||||
#define OFF 0
|
||||
|
||||
#define NONE 0
|
||||
#define EOS '\0'
|
||||
|
||||
/*
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define bool _Bool
|
||||
#endif /* ifndef __cplusplus */
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#define TAU_LITTLE_ENDIAN 1234 /**< \brief 小端模式 */
|
||||
#define TAU_BIG_ENDIAN 3412 /**< \brief 大端模式 */
|
||||
|
||||
/** @} */
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* \name 常用宏定义
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define __I volatile /*!< Defines 'read only' permissions */
|
||||
#else
|
||||
#define __I volatile const /*!< Defines 'read only' permissions */
|
||||
#endif
|
||||
#define __O volatile /*!< Defines 'write only' permissions */
|
||||
#define __IO volatile /*!< Defines 'read / write' permissions */
|
||||
|
||||
#define TAU_INLINE inline
|
||||
#define TAU_STATIC_INLINE static inline
|
||||
#define TAU_STATIC static
|
||||
#define TAU_CONST const
|
||||
#define TAU_EXTERN extern
|
||||
|
||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
/**
|
||||
* \brief 求结构体成员的偏移
|
||||
* \attention 不同平台上,由于成员大小和内存对齐等原因,
|
||||
* 同一结构体成员的偏移可能是不一样的
|
||||
*
|
||||
* \par 示例
|
||||
* \code
|
||||
* struct my_struct {
|
||||
* int m1;
|
||||
* char m2;
|
||||
* };
|
||||
* int offset_m2;
|
||||
*
|
||||
* offset_m2 = TAU_OFFSET(struct my_struct, m2);
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_OFFSET(structure, member) ((uint32_t)(&(((structure *)0)->member)))
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \brief 通过结构体成员指针获取包含该结构体成员的结构体
|
||||
*
|
||||
* \param ptr 指向结构体成员的指针
|
||||
* \param type 结构体类型
|
||||
* \param member 结构体中该成员的名称
|
||||
*
|
||||
* \par 示例
|
||||
* \code
|
||||
* struct my_struct = {
|
||||
* int m1;
|
||||
* char m2;
|
||||
* };
|
||||
* struct my_struct my_st;
|
||||
* char *p_m2 = &my_st.m2;
|
||||
* struct my_struct *p_st = TAU_CONTAINER_OF(p_m2, struct my_struct, m2);
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_CONTAINER_OF(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-TAU_OFFSET(type, member)))
|
||||
|
||||
/**
|
||||
* \brief 计算结构体成员的大小
|
||||
*
|
||||
* \code
|
||||
* struct a = {
|
||||
* uint32_t m1;
|
||||
* uint32_t m2;
|
||||
* };
|
||||
* int size_m2;
|
||||
*
|
||||
* size_m2 = TAU_MEMBER_SIZE(a, m2); //size_m2 = 4
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_MEMBER_SIZE(structure, member) (sizeof(((structure *)0)->member))
|
||||
|
||||
/**
|
||||
* \brief 计算数组元素个数
|
||||
*
|
||||
* \code
|
||||
* int a[] = {0, 1, 2, 3};
|
||||
* int element_a = TAU_NELEMENTS(a); // element_a = 4
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_NELEMENTS(array) (sizeof(array) / sizeof((array)[0]))
|
||||
|
||||
/**
|
||||
* \brief 向上舍入
|
||||
*
|
||||
* \param x 被运算的数
|
||||
* \param align 对齐因素
|
||||
*
|
||||
* \code
|
||||
* int size = TAU_ROUND_UP(15, 4); // size = 16
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_ROUND_UP(x, align) (((int)(x)/(align))*(align) + (((int)(x)%(align)) ? (align) : 0))
|
||||
|
||||
/**
|
||||
* \brief 向下舍入
|
||||
*
|
||||
* \param x 被运算的数
|
||||
* \param align 对齐因素
|
||||
*
|
||||
* \code
|
||||
* int size = TAU_ROUND_DOWN(15, 4); // size = 12
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_ROUND_DOWN(x, align) (((int)(x)/(align))*(align))
|
||||
|
||||
/** \brief 倍数向上舍入 */
|
||||
#define TAU_DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d))
|
||||
|
||||
/**
|
||||
* \brief 测试是否对齐
|
||||
*
|
||||
* \param x 被运算的数
|
||||
* \param align 对齐因素,必须为2的乘方
|
||||
*
|
||||
* \code
|
||||
* if (TAU_ALIGNED(x, 4) {
|
||||
* ; // x对齐
|
||||
* } else {
|
||||
* ; // x不对齐
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_ALIGNED(x, align) (((int)(x) & (align - 1)) == 0)
|
||||
|
||||
/** \brief 将1字节BCD数据转换为16进制数据 */
|
||||
#define TAU_BCD_TO_HEX(val) (((val)&0x0f) + ((val) >> 4) * 10)
|
||||
|
||||
/** \brief 将1字节16进制数据转换为BCD数据 */
|
||||
#define TAU_HEX_TO_BCD(val) ((((val) / 10) << 4) + (val) % 10)
|
||||
|
||||
/**
|
||||
* \brief 向上取整
|
||||
*/
|
||||
#define TAU_CEIL(val) ceil(val)
|
||||
|
||||
|
||||
/*! @brief Construct the version number for drivers. */
|
||||
#define MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/*!< @brief 用于返回状态和错误 */
|
||||
typedef uint32_t status_t;
|
||||
|
||||
/* \brief 通用回调函数指针定义 */
|
||||
typedef void (*fcb_type)(void *data);
|
||||
|
||||
typedef void (*uart_trans_cb)(status_t status, void *user_data);
|
||||
|
||||
typedef void (*flash_trans_cb)(status_t status, void *user_data);
|
||||
#endif /* __TAU_COMMON_H */
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* File Name: tau_delay.h
|
||||
*
|
||||
*
|
||||
*
|
||||
* Author: Fortsense 3D Firmware Team
|
||||
*
|
||||
* Date: 2020/12/04
|
||||
*
|
||||
* Project: Taurus
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* HISTORY:
|
||||
**/
|
||||
#ifndef _DELAY_H_
|
||||
#define _DELAY_H_
|
||||
#include "stdint.h"
|
||||
|
||||
/**
|
||||
* @brief delay ms 函数,误差2%以内
|
||||
* @param ms:delay时长
|
||||
* @retval none
|
||||
*/
|
||||
void delayMs(uint32_t ms);
|
||||
|
||||
/**
|
||||
* @brief delay us 函数,误差2%以内
|
||||
* @param us:delay时长
|
||||
* @retval none
|
||||
*/
|
||||
void delayUs(uint32_t us);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,229 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: tau_device_datatype.h
|
||||
* Description device datatype
|
||||
* Version V0.1
|
||||
* Date 2020-12-04
|
||||
* Author kevin
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _TAU_DEVICE_DATATYPE_H_
|
||||
#define _TAU_DEVICE_DATATYPE_H_
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
|
||||
#include "stdint.h"
|
||||
#include "tau_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/*! @brief 计算组状态码 */
|
||||
#define MAKE_STATUS(group, code) ((((group)*100) + (code)))
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/*! @brief 分组状态值 */
|
||||
enum _status_groups
|
||||
{
|
||||
STATUS_GROUP_GENERIC = 0,
|
||||
STATUS_GROUP_I2C = 1,
|
||||
STATUS_GROUP_UART = 2,
|
||||
STATUS_GROUP_SPI = 3,
|
||||
STATUS_GROUP_TIMER = 4,
|
||||
};
|
||||
|
||||
/*! @brief 常用状态码 */
|
||||
enum _generic_status
|
||||
{
|
||||
STATUS_SUCCESS = MAKE_STATUS(STATUS_GROUP_GENERIC, 0),
|
||||
STATUS_FAIL = MAKE_STATUS(STATUS_GROUP_GENERIC, 1),
|
||||
STATUS_READ_ONLY = MAKE_STATUS(STATUS_GROUP_GENERIC, 2),
|
||||
STATUS_OUT_OF_RANGE = MAKE_STATUS(STATUS_GROUP_GENERIC, 3),
|
||||
STATUS_INVALID_ARGUMENT = MAKE_STATUS(STATUS_GROUP_GENERIC, 4),
|
||||
STATUS_TIME_OUT = MAKE_STATUS(STATUS_GROUP_GENERIC, 5),
|
||||
STATUS_NO_TRANSFER_IN_PROGRESS = MAKE_STATUS(STATUS_GROUP_GENERIC, 6),
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief UART状态枚举定义
|
||||
*
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
STATUS_UART_TX_BUSY = MAKE_STATUS(STATUS_GROUP_UART, 0), /*!< Transmitter is busy. */
|
||||
STATUS_UART_RX_BUSY = MAKE_STATUS(STATUS_GROUP_UART, 1), /*!< Receiver is busy. */
|
||||
STATUS_UART_TX_IDLE = MAKE_STATUS(STATUS_GROUP_UART, 2), /*!< USART transmitter is idle. */
|
||||
STATUS_UART_RX_IDLE = MAKE_STATUS(STATUS_GROUP_UART, 3), /*!< USART receiver is idle. */
|
||||
STATUS_UART_TX_ERR = MAKE_STATUS(STATUS_GROUP_UART, 7), /*!< Error happens on txFIFO. */
|
||||
STATUS_UART_RX_ERR = MAKE_STATUS(STATUS_GROUP_UART, 9), /*!< Error happens on rxFIFO. */
|
||||
STATUS_UART_RX_RING_BUFF_OVERRUN = MAKE_STATUS(STATUS_GROUP_UART, 8), /*!< Error happens on rx ring buffer */
|
||||
STATUS_UART_NOISE_ERR = MAKE_STATUS(STATUS_GROUP_UART, 10), /*!< USART noise error. */
|
||||
STATUS_UART_FRAMING_ERR = MAKE_STATUS(STATUS_GROUP_UART, 11), /*!< USART framing error. */
|
||||
STATUS_UART_PARITY_ERR = MAKE_STATUS(STATUS_GROUP_UART, 12), /*!< USART parity error. */
|
||||
STATUS_UART_BAUDRATE_NOT_SPT = MAKE_STATUS(STATUS_GROUP_UART, 13), /*!< Baudrate is not support in current clock source */
|
||||
} uart_status_e;
|
||||
|
||||
/*!
|
||||
* @brief timer状态
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
STATUS_TIMER_IDLE = MAKE_STATUS(STATUS_GROUP_TIMER, 0), /*!< 空闲 */
|
||||
STATUS_TIMER_RUNNING = MAKE_STATUS(STATUS_GROUP_TIMER, 1), /*!< 运行中 */
|
||||
STATUS_TIMER_TIMEOUT = MAKE_STATUS(STATUS_GROUP_TIMER, 2), /*!< 超时 */
|
||||
} timer_status_e;
|
||||
|
||||
/*!
|
||||
* @brief system触发事件(中断/复位)模式
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DETECT_HIGH_LVL = 0,
|
||||
DETECT_LOW_LVL,
|
||||
DETECT_RISING_EDGE,
|
||||
DETECT_FALLING_EDGE,
|
||||
DETECT_DOUBLE_EDGE
|
||||
} sys_cfg_trigger_e;
|
||||
|
||||
/**
|
||||
* @brief GPIO interrupt type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TIMER_NUM0 = 0,
|
||||
TIMER_NUM1,
|
||||
TIMER_NUM2,
|
||||
TIMER_NUM3,
|
||||
TIMER_NUM_MAX
|
||||
} timer_num_e;
|
||||
|
||||
/**
|
||||
* @brief GPIO interrupt type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GPIO_INT_EXTI_INT0 = 0,
|
||||
GPIO_INT_EXTI_INT1,
|
||||
GPIO_INT_EXTI_INT2,
|
||||
GPIO_INT_EXTI_INT3,
|
||||
GPIO_INT_EXTI_INT4,
|
||||
GPIO_INT_EXTI_INT5,
|
||||
GPIO_INT_EXTI_INT6,
|
||||
GPIO_INT_EXTI_INT7,
|
||||
GPIO_INT_MAX
|
||||
} gpio_int_e;
|
||||
|
||||
/*! @brief PWMI中断类型 */
|
||||
typedef enum _pwm_int_type
|
||||
{
|
||||
PWM_INT_HIGH_OVERFLOW = 0,
|
||||
PWM_INT_LOW_OVERFLOW,
|
||||
PWM_INT_TOTAL_OVERFLOW,
|
||||
PWM_INT_HIGH_DONE,
|
||||
PWM_INT_LOW_DONE,
|
||||
PWM_INT_TOTAL_DONE,
|
||||
PWM_INT_MAX
|
||||
} pwm_int_type_e;
|
||||
|
||||
/**
|
||||
* @brief I2C chose
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
I2C_SELECT_0 = 0, //常用slave
|
||||
I2C_SELECT_1, //常用master
|
||||
} i2c_select_e;
|
||||
|
||||
/*!
|
||||
* @brief 传输速度
|
||||
* @note
|
||||
*/
|
||||
typedef enum _i2c_rate
|
||||
{
|
||||
I2C_RATE_STANDARD = 1, //100kHz
|
||||
I2C_RATE_FAST, //400kHz
|
||||
I2C_RATE_HIGH, //1MHz
|
||||
} i2c_rate_e;
|
||||
|
||||
/*!
|
||||
* @brief I2C Index
|
||||
* @note
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
I2C_INDEX_0,
|
||||
I2C_INDEX_1,
|
||||
I2C_INDEX_2,
|
||||
I2C_INDEX_MAX
|
||||
} i2c_index_e;
|
||||
|
||||
/*!
|
||||
* @brief DMA channel type
|
||||
* @note
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AHB_DMA_CH0,
|
||||
AHB_DMA_CH1,
|
||||
AHB_DMA_CH2,
|
||||
AHB_DMA_CH3,
|
||||
AHB_DMA_CH4,
|
||||
AHB_DMA_CH5,
|
||||
AHB_DMA_CH6,
|
||||
AHB_DMA_CH7,
|
||||
AHB_DMA_CH_NUM
|
||||
} dma_channel_type_e;
|
||||
|
||||
/*! @brief Type used for all status and error return values. */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DISABLE = 0,
|
||||
ENABLE = !DISABLE
|
||||
} function_state_e;
|
||||
|
||||
/**
|
||||
* @brief The reversal types of the bit order of the input/output data
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CRC_REV_NO_TRANSPOSE = 0, /*!< No transposition */
|
||||
CRC_REV_ONLY_BITS_TRANSPOSE, /*!< Bits in bytes are transposed; bytes are not transposed */
|
||||
CRC_REV_BOTH_TRANSPOSE, /*!< Both bits in bytes and bytes are transposed */
|
||||
CRC_REV_ONLY_BYTES_TRANSPOSE, /*!< Only bytes are transposed; no bits in a byte are transposed */
|
||||
} crc_reversal_type_e;
|
||||
|
||||
/**
|
||||
* @brief Complement Read Of CRC Data Register
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CRC_FXOR_DISABLE = 0, /*!< No XOR on reading */
|
||||
CRC_FXOR_ENABLE, /*!< Invert or complement the read value of the CRC Data register */
|
||||
} crc_fxor_function_e;
|
||||
|
||||
/**
|
||||
* @brief width of CRC protocol (polynomial)
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CRC_16_BIT_PROTOCOL = 0, /*!< 0: 16-bit CRC protocol */
|
||||
CRC_32_BIT_PROTOCOL, /*!< 1: 32-bit CRC protocol */
|
||||
} crc_protocol_type_e;
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,405 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: tau_dsi_datatype.h
|
||||
* Description: mipi dsi 通用头文件
|
||||
* Version: V0.1
|
||||
* Date: 2021-01-13
|
||||
* Author: lzy
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __MIPI_DSI_COMMON_H__
|
||||
#define __MIPI_DSI_COMMON_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#define DSC_PPS_SIZE 128
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief Data Types for Peripheral-sourced Packets,From Mipi DSI Spec
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DSI_ACK_DT_ERROR = 0x02,
|
||||
DSI_ACK_DT_EOTP = 0x08,
|
||||
DSI_ACK_DT_GEN_SHORT_RESPONSE_1B = 0x11,
|
||||
DSI_ACK_DT_GEN_SHORT_RESPONSE_2B = 0x12,
|
||||
DSI_ACK_DT_GEN_LONG_RESPONSE = 0x1A,
|
||||
DSI_ACK_DT_DCS_LONG_RESPONSE = 0x1C,
|
||||
DSI_ACK_DT_DCS_SHORT_RESPONSE_1B = 0x21,
|
||||
DSI_ACK_DT_DCS_SHORT_RESPONSE_2B = 0x22,
|
||||
DSI_ACK_DT_MAX
|
||||
} dsi_ack_data_type_e;
|
||||
|
||||
/**
|
||||
* @brief Software handle data types
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DSI_RECV_DT_PPS = 0x0A, //Picture Parameter Set
|
||||
DSI_RECV_DT_GEN_WRITE_1B = 0x13, //Generic Short WRITE, 1 parameter
|
||||
DSI_RECV_DT_GEN_WRITE_2B = 0x23, //Generic Short WRITE, 2 parameters
|
||||
DSI_RECV_DT_GEN_READ_0B = 0x04, //Generic READ, no parameters
|
||||
DSI_RECV_DT_GEN_READ_1B = 0x14, //Generic READ, 1 parameter
|
||||
DSI_RECV_DT_GEN_READ_2B = 0x24, //Generic READ, 2 parameters
|
||||
DSI_RECV_DT_DCS_WRITE_0B = 0x05, //DCS Short WRITE, no parameters
|
||||
DSI_RECV_DT_DCS_WRITE_1B = 0x15, //DCS Short WRITE, 1 parameter
|
||||
DSI_RECV_DT_DCS_READ_0B = 0x06, //DCS READ, no parameters
|
||||
DSI_RECV_DT_GEN_WRITE_LONG = 0x29, //Generic Long Write
|
||||
DSI_RECV_DT_DCS_WRITE_LONG = 0x39, //DCS Long Write/write_LUT Command Packet
|
||||
DSI_RECV_DT_MAX
|
||||
} dsi_data_type_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DCS_ENTER_IDLE_MODE = 0x39,
|
||||
DCS_ENTER_INVERT_MODE = 0x21,
|
||||
DCS_ENTER_NORMAL_MODE = 0x13,
|
||||
DCS_ENTER_PARTIAL_MODE = 0x12,
|
||||
DCS_ENTER_SLEEP_MODE = 0x10,
|
||||
DCS_EXIT_IDLE_MODE = 0x38,
|
||||
DCS_EXIT_INVERT_MODE = 0x20,
|
||||
DCS_EXIT_SLEEP_MODE = 0x11,
|
||||
DCS_GET_3D_CONTROL = 0x3F,
|
||||
DCS_GET_ADDRESS_MODE = 0x0B,
|
||||
DCS_GET_BLUE_CHANNEL = 0x08,
|
||||
DCS_GET_COMPRESSION_MODE = 0x03,
|
||||
DCS_GET_DIAGNOSTIC_RESULT = 0x0F,
|
||||
DCS_GET_DISPLAY_MODE = 0x0D,
|
||||
DCS_GET_GREEN_CHANNEL = 0x07,
|
||||
DCS_GET_PIXEL_FORMAT = 0x0C,
|
||||
DCS_GET_POWER_MODE = 0x0A,
|
||||
DCS_GET_RED_CHANNEL = 0x06,
|
||||
DCS_GET_SCANLINE = 0x45,
|
||||
DCS_GET_SIGNAL_MODE = 0x0E,
|
||||
DCS_NOP = 0x00,
|
||||
DCS_READ_DDB_CONTINUE = 0xA8,
|
||||
DCS_READ_DDB_START = 0xA1,
|
||||
DCS_READ_MEMORY_CONTINUE = 0x3E,
|
||||
DCS_READ_MEMORY_START = 0x2E,
|
||||
DCS_SET_3D_CONTROL = 0x3D,
|
||||
DCS_SET_ADDRESS_MODE = 0x36,
|
||||
DCS_SET_COLUMN_ADDRESS = 0x2A,
|
||||
DCS_SET_DISPLAY_OFF = 0x28,
|
||||
DCS_SET_DISPLAY_ON = 0x29,
|
||||
DCS_SET_GAMMA_CURVE = 0x26,
|
||||
DCS_SET_PAGE_ADDRESS = 0x2B,
|
||||
DCS_SET_PARTIAL_COLUMNS = 0x31,
|
||||
DCS_SET_PARTIAL_ROWS = 0x30,
|
||||
DCS_SET_PIXEL_FORMAT = 0x3A,
|
||||
DCS_SET_SCROLL_AREA = 0x33,
|
||||
DCS_SET_SCROLL_START = 0x37,
|
||||
DCS_SET_TEAR_OFF = 0x34,
|
||||
DCS_SET_TEAR_ON = 0x35,
|
||||
DCS_SET_TEAR_SCANLINE = 0x44,
|
||||
DCS_SET_VSYNC_TIMING = 0x40,
|
||||
DCS_SOFT_RESET = 0x01,
|
||||
DCS_WRITE_LUT = 0x2D,
|
||||
DCS_WRITE_MEMORY_CONTINUE = 0x3C,
|
||||
DCS_WRITE_MEMORY_START = 0x2C
|
||||
} dsi_dcs_cmd_type_e;
|
||||
|
||||
/**
|
||||
* @brief video data transfer mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DSI_DATA_VIDEO_MODE = 0,
|
||||
DSI_DATA_CMD_MODE = 1,
|
||||
DSI_DATA_MODE_MAX
|
||||
} dsi_video_data_mode_e;
|
||||
|
||||
/**
|
||||
* @brief dsi virtual channel
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DSI_VC_0 = 0,
|
||||
DSI_VC_1 = 1,
|
||||
DSI_VC_2 = 2,
|
||||
DSI_VC_3 = 3,
|
||||
DSI_VC_MAX
|
||||
} dsi_virtual_channel_e;
|
||||
|
||||
/**
|
||||
* @brief video data mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DSI_FRAME_RATE_60HZ = 0,
|
||||
DSI_FRAME_RATE_90HZ = 1,
|
||||
DSI_FRAME_RATE_120HZ = 2,
|
||||
DSI_FRAME_RATE_144HZ = 3,
|
||||
DSI_FRAME_RATE_160HZ = 4,
|
||||
DSI_FRAME_RATE_MAX
|
||||
} dsi_video_frame_rate_e;
|
||||
|
||||
/**
|
||||
* @brief dsi rx color coding
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DSI_RGB565 = 1,
|
||||
DSI_RGB666 = 2, /*!< 18 bbp(18bits per pixel) */
|
||||
DSI_RGB666_LOOSELY = 3, /*!< 24 bbp(24bits per pixel) */
|
||||
DSI_RGB888 = 4, /*!< 24 bbp(24bits per pixel) */
|
||||
DSI_RGB10_10_10 = 5,
|
||||
DSI_RGB12_12_12 = 6,
|
||||
DSI_YCbCr422_16 = 7,
|
||||
DSI_PENTILE_16 = DSI_YCbCr422_16,
|
||||
DSI_YCbCr422_20_LOOSELY = 8,
|
||||
DSI_YCbCr422_24 = 9,
|
||||
DSI_YCbCr420_12 = 10,
|
||||
DSI_DSC_STREAM = 11,
|
||||
DSI_COLOR_CODE_MAX
|
||||
} dsi_color_code_e;
|
||||
|
||||
/**
|
||||
* @brief dsi endianness type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DPI_ENDIAN_RGB = 0,
|
||||
DPI_ENDIAN_BGR
|
||||
} dsi_endianness_e;
|
||||
|
||||
/**
|
||||
* @brief mipi lane number
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DSI_LANE_1 = 1,
|
||||
DSI_LANE_2 = 2,
|
||||
DSI_LANE_3 = 3,
|
||||
DSI_LANE_4 = 4,
|
||||
DSI_LANE_NUME_MAX
|
||||
} dsi_lane_nume_e;
|
||||
|
||||
/**
|
||||
* @brief video mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DSI_NONBURST_PULSE = 0,
|
||||
DSI_NONBURST_EVENT = 1,
|
||||
DSI_BURST_MODE = 2,
|
||||
DSI_VIDEO_MODE_MAX
|
||||
} dsi_video_mode_type_e;
|
||||
|
||||
/**
|
||||
* @brief panel init cmd transfer type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DSI_CMD_TX_HS = 0,
|
||||
DSI_CMD_TX_LP = 1
|
||||
} dsi_tx_cmd_tx_type_e;
|
||||
|
||||
/**
|
||||
* @brief angle of rotation
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
VIDOE_ROT_ANGLE_0 = 0, /* 不旋转 */
|
||||
VIDOE_ROT_ANGLE_90 = 1, /* 旋转90度 */
|
||||
VIDOE_ROT_ANGLE_180 = 2, /* 旋转180度 */
|
||||
VIDOE_ROT_ANGLE_270 = 3, /* 转转270度 */
|
||||
VIDOE_ROT_ANGLE_MAX
|
||||
} video_rotate_angle_e;
|
||||
|
||||
/**
|
||||
* @brief mipi rx lane swap
|
||||
软件配置 PIN28&PIN27 PIN26&PIN25 PIN24&PIN23 PIN22&PIN21 PIN20&PIN19
|
||||
RX_LANE_SWAP_0123 D0P&D0N D1P&D1N CLKP&CLKN D2P&D2N D3P&D3N
|
||||
RX_LANE_SWAP_3210 D3P&D3N D2P&D2N CLKP&CLKN D1P&D1N D0P&D0N
|
||||
RX_LANE_SWAP_2103(default) D2P&D2N D1P&D1N CLKP&CLKN D0P&D0N D3P&D3N
|
||||
RX_LANE_SWAP_3012 D3P&D3N D0P&D0N CLKP&CLKN D1P&D1N D2P&D2N
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RX_LANE_SWAP_0123 = 0x0,
|
||||
RX_LANE_SWAP_3210 = 0x1,
|
||||
RX_LANE_SWAP_2103 = 0x2,
|
||||
RX_LANE_SWAP_DEFAULT_ORDER = 0x2, /* 默认原理图为2103顺序 */
|
||||
RX_LANE_SWAP_3012 = 0x3,
|
||||
RX_LANE_SWAP_MAX
|
||||
} dsi_rx_lane_swap_e;
|
||||
|
||||
/**
|
||||
* @brief mipi P/N lane swap flag
|
||||
* eg: pn_swap = RX_LANE_0_PN_SWAP | RX_LANE_CLK_PN_SWAP;
|
||||
* 表示 lane0 与 CLK 的P跟N交换,其他lane不变。
|
||||
* 注意这里的lane表示的是进行完lane swap的lane,如lane swap配置RX_LANE_SWAP_3012,再配置RX_LANE_0_PN_SWAP则表示PIN26&PIN25进行PN交换,由D0P&D0N变成D0N&D0P
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RX_LANE_0_PN_SWAP = 0x1,
|
||||
RX_LANE_1_PN_SWAP = 0x2,
|
||||
RX_LANE_2_PN_SWAP = 0x4,
|
||||
RX_LANE_3_PN_SWAP = 0x8,
|
||||
RX_LANE_CLK_PN_SWAP = 0x10
|
||||
} dsi_rx_lane_pn_swap_e;
|
||||
|
||||
/**
|
||||
* @brief error processing level
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ERR_HANDLE_NONE = 0,
|
||||
ERR_HANDLE_L1 = 1,
|
||||
ERR_HANDLE_L2 = 2,
|
||||
ERR_HANDLE_L3 = 3,
|
||||
ERR_HANDLE_MAX
|
||||
} hal_err_handle_level_e;
|
||||
|
||||
/**
|
||||
* @brief flow control mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FC_AUTO_MODE = 0, /* 自动匹配模式,根据base info配置匹配1-4 */
|
||||
FC_V2V_NORMAL_MODE = 1, /* Video to Video 模式转换 */
|
||||
FC_V2C_NORMAL_MODE = 2, /* Video to Command 模式转换 */
|
||||
FC_C2V_NORMAL_MODE = 3, /* Command to Video 模式转换 */
|
||||
FC_C2C_NORMAL_MODE = 4, /* Command to Command 模式转换 */
|
||||
FC_PRO_MOTION_MODE = 6, /* 自适应帧率转换(LTPO模式) */
|
||||
FC_PRO_MOTION_MODE_2 = 5, /* 自适应帧率转换(LTPO模式) */
|
||||
FC_PRO_MOTION_WITH_PU_MODE = 7, /* 自适应帧率带PU */
|
||||
FC_V2V_AUTO_SYCN_MODE = 8, /* Video to Video 软件同步 */
|
||||
FC_V2V_DIRECT_MODE = 9, /* Video to Video 直通模式 */
|
||||
FC_MODE_MAX
|
||||
} flow_control_mode_e;
|
||||
|
||||
/**
|
||||
* @brief transform 基本信息
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t top;
|
||||
uint16_t bottom;
|
||||
uint16_t left;
|
||||
uint16_t right;
|
||||
bool enable;
|
||||
} pic_edge_info_t;
|
||||
|
||||
/**
|
||||
* @brief transform 基本信息
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t src_w; /* mipi rx 接收的 width */
|
||||
uint32_t src_h; /* mipi rx 接收的 height */
|
||||
uint32_t dst_w; /* mipi tx 发送的 width */
|
||||
uint32_t dst_h; /* mipi tx 发送的 height */
|
||||
dsi_video_frame_rate_e src_frate; /* mipi rx 接收的frame rate */
|
||||
dsi_video_data_mode_e src_mode; /* mipi rx 接收video 数据传输模式(video/cmd mode) */
|
||||
dsi_video_data_mode_e dst_mode; /* mipi tx 输出video 数据传输模式(video/cmd mode) */
|
||||
uint16_t pn_swap; /* mipi P/N swap标志位, rx可配置/tx暂不支持 */
|
||||
} dsi_base_trans_info_t;
|
||||
|
||||
/**
|
||||
* @brief transform 基本信息
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bool mirror_en; /* 对video 做水平镜像标志位 */
|
||||
bool pu_optimize; /* 用于优化PU显示效果,默认为false;true:优化PU显示显示效果,高功耗;false:普通PU模式,低功耗 */
|
||||
video_rotate_angle_e rot_angle; /* 对video 做旋转的角度 */
|
||||
flow_control_mode_e flow_control_mode; /* 图像数据流控制模式 */
|
||||
pic_edge_info_t crop_info; /* 图像边缘裁剪配置 not impletmented */
|
||||
pic_edge_info_t blank_info; /* 图像边缘补黑配置 not impletmented */
|
||||
bool bw_optimize; /* 带宽自动检查,默认打开 */
|
||||
uint8_t pq_type; /* picture quality,参数为 pq_type_e */
|
||||
} dsi_base_extra_info_t;
|
||||
|
||||
/**
|
||||
* @brief ccm系数
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t coef_c00;
|
||||
uint32_t coef_c01;
|
||||
uint32_t coef_c02;
|
||||
uint32_t coef_c10;
|
||||
uint32_t coef_c11;
|
||||
uint32_t coef_c12;
|
||||
uint32_t coef_c20;
|
||||
uint32_t coef_c21;
|
||||
uint32_t coef_c22;
|
||||
} ccm_coef_t;
|
||||
|
||||
/**
|
||||
* @brief hight performan mode level
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HIGHT_PERFORMAN_NONE = 0,
|
||||
HIGHT_PERFORMAN_L1 = 1,
|
||||
HIGHT_PERFORMAN_L2 = 2,
|
||||
HIGHT_PERFORMAN_MAX
|
||||
} hight_performan_mode_e;
|
||||
|
||||
/**
|
||||
* @brief TX False color去伪彩参数结构体
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t edgemedslope;
|
||||
uint16_t desatslope;
|
||||
} dsi_tx_fc_t;
|
||||
|
||||
/**
|
||||
* @brief TX 边缘增强参数结构体
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bool y_enh_method;
|
||||
uint8_t enhance_str;
|
||||
uint16_t enhance_slope;
|
||||
uint16_t boundscale_low;
|
||||
uint16_t boundscale_high;
|
||||
} dsi_tx_edge_enh_t;
|
||||
|
||||
/**
|
||||
* @brief TX 边缘检测参数结构体
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t edge_thr;
|
||||
bool use_large_kernel;
|
||||
} dsi_tx_edge_dect_t;
|
||||
|
||||
/**
|
||||
* @brief TX bcsa 参数结构体
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int8_t brightness; /* 亮度调整, 范围-127 - 127 */
|
||||
uint16_t contrast; /* 对比度调整,范围0 - 4095 */
|
||||
uint16_t saturation; /* 饱和度调整,范围0 - 4095 */
|
||||
} dsi_tx_bcs_t;
|
||||
|
||||
/**
|
||||
* @brief partial display 参数结构体
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t st_line; /*部分显示起始行位置*/
|
||||
uint32_t st_col; /*部分显示起始列位置*/
|
||||
uint32_t end_line; /*部分显示结束行位置*/
|
||||
uint32_t end_col; /*部分显示结束列位置*/
|
||||
uint8_t value_r; /*部分显示背景色R值*/
|
||||
uint8_t value_g; /*部分显示背景色G值*/
|
||||
uint8_t value_b; /*部分显示背景色B值*/
|
||||
} dsi_tx_par_dis_t;
|
||||
|
||||
#endif //__MIPI_DSI_COMMON_H__
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: tau_log.h
|
||||
* Description log file
|
||||
* Version V0.1
|
||||
* Date 2020-12-08
|
||||
* Author linyw
|
||||
*******************************************************************************/
|
||||
#ifndef _TAU_LOG_H_
|
||||
#define _TAU_LOG_H_
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "ArmCM0.h"
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "tau_log"
|
||||
#define LOG_CURREN_LEVEL kLOG_LEVEL_DBG /* 配置打印等级 TODO:每个模块可配置打印等级 */
|
||||
#define LOG_BUF_SIZE (256) /* 配置打印缓存的大小 */
|
||||
|
||||
/*
|
||||
* Using the following three macros for conveniently logging.
|
||||
*/
|
||||
#define TAU_LOGD(format,...) \
|
||||
do { \
|
||||
tau_log_printf(kLOG_LEVEL_DBG, "[%s] (%04d) " format, LOG_TAG, __LINE__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define TAU_LOGI(format,...) \
|
||||
do { \
|
||||
tau_log_printf(kLOG_LEVEL_INF, "[%s] (%04d) " format, LOG_TAG, __LINE__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define TAU_LOGE(format,...) \
|
||||
do { \
|
||||
tau_log_printf(kLOG_LEVEL_ERR, "[%s] (%04d) " format, LOG_TAG, __LINE__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief log打印等级枚举
|
||||
*
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
kLOG_LEVEL_DBG = 0,
|
||||
kLOG_LEVEL_INF,
|
||||
kLOG_LEVEL_ERR,
|
||||
kLOG_LEVEL_NONE /* 不打印任何参数 */
|
||||
} log_level_e;
|
||||
|
||||
/**
|
||||
* @brief log打印端口枚举
|
||||
*
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
LOG_PORT_UART0, /* 使用串口输出打印 */
|
||||
LOG_PORT_UART1, /* 使用串口输出打印 */
|
||||
LOG_PORT_SWD, /* 使用swd输出打印 */
|
||||
LOG_PORT_UNKNOWN
|
||||
} log_port_e;
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief 初始化log系统
|
||||
* @param baud_rate 波特率
|
||||
* @param log_port 打印端口选择
|
||||
* @retval none
|
||||
*/
|
||||
void tau_log_init(uint32_t baud_rate, log_port_e log_port);
|
||||
|
||||
/**
|
||||
* @brief 初始化log系统
|
||||
* @param baud_rate 波特率
|
||||
* @param log_port 打印端口选择
|
||||
* @retval none
|
||||
*/
|
||||
void tau_log_printf(log_level_e log_lv, const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,229 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: tau_operations.h
|
||||
* Description 位操作与字节操作相关定义头文件
|
||||
* Version V0.1
|
||||
* Date 2020-09-07
|
||||
* Author lzy
|
||||
*******************************************************************************/
|
||||
#ifndef __TAU_BYTEOPS_H
|
||||
#define __TAU_BYTEOPS_H
|
||||
|
||||
/**
|
||||
* \name 通用位常数定义
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \brief 长整数位数 */
|
||||
#ifndef TAU_BITS_PER_LONG
|
||||
#define TAU_BITS_PER_LONG 32
|
||||
#endif
|
||||
|
||||
/** \brief 字节位数 */
|
||||
#define TAU_BITS_PER_BYTE 8
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* \name 通用位操作
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \brief bit移位
|
||||
* TAU_BIT(2) is 0x4
|
||||
*/
|
||||
#define TAU_BIT(bit) (1u << (bit))
|
||||
|
||||
/** \brief 值移位
|
||||
* TAU_SBF(0xFF, 8) is 0xff00
|
||||
*/
|
||||
#define TAU_SBF(value, field) ((value) << (field))
|
||||
|
||||
/** \brief bit置位
|
||||
* TAU_BIT_SET(0, 8) is 0x100
|
||||
*/
|
||||
#define TAU_BIT_SET(data, bit) ((data) |= TAU_BIT(bit))
|
||||
|
||||
/** \brief bit清零
|
||||
* TAU_BIT_CLR(0xFF, 2) is 0xfb
|
||||
*/
|
||||
#define TAU_BIT_CLR(data, bit) ((data) &= ~TAU_BIT(bit))
|
||||
|
||||
/** \brief bit置位, 根据 mask 指定的位
|
||||
* TAU_BIT_SET_MASK(0xF0F0, 0xF00) is 0xfff0
|
||||
*/
|
||||
#define TAU_BIT_SET_MASK(data, mask) ((data) |= (mask))
|
||||
|
||||
/** \brief bit清零, 根据 mask 指定的位
|
||||
* TAU_BIT_CLR_MASK(0xFFFF, 0xFF00) is 0xff
|
||||
*/
|
||||
#define TAU_BIT_CLR_MASK(data, mask) ((data) &= ~(mask))
|
||||
|
||||
/** \brief bit翻转
|
||||
* TAU_BIT_TOGGLE(0xFFFF, 0) is 0xfffe
|
||||
* TAU_BIT_TOGGLE(0x0000, 1) is 0x2
|
||||
*/
|
||||
#define TAU_BIT_TOGGLE(data, bit) ((data) ^= TAU_BIT(bit))
|
||||
|
||||
/** \brief bit修改
|
||||
* TAU_BIT_MODIFY(0, 8, 1) is 0x100
|
||||
* TAU_BIT_MODIFY(0xFFFF, 1, 0) is 0xfffd
|
||||
*/
|
||||
#define TAU_BIT_MODIFY(data, bit, value) \
|
||||
((value) ? TAU_BIT_SET(data, bit) : TAU_BIT_CLR(data, bit))
|
||||
|
||||
/** \brief 测试bit是否置位
|
||||
* TAU_BIT_ISSET(0xF0F1, 1) is 0
|
||||
* TAU_BIT_ISSET(0xF0F2, 1) is 2
|
||||
*/
|
||||
#define TAU_BIT_ISSET(data, bit) ((data) & TAU_BIT(bit))
|
||||
|
||||
/** \brief 获取bit值
|
||||
* TAU_BIT_GET(0xF0F1, 1) is 0
|
||||
* TAU_BIT_GET(0xF0F2, 1) is 1
|
||||
*/
|
||||
#define TAU_BIT_GET(data, bit) (TAU_BIT_ISSET(data, bit) ? 1 : 0)
|
||||
|
||||
/** \brief 检测bit值
|
||||
* TAU_BIT_CHECK(0xF5FF, 4) is 1
|
||||
*/
|
||||
#define TAU_BIT_CHECK(data, bit) \
|
||||
(((data) & TAU_BIT(bit)) ? 1 : 0)
|
||||
|
||||
/** \brief 获取 n bits 掩码值
|
||||
* TAU_BITS_MASK(2) is 0x3
|
||||
*/
|
||||
#define TAU_BITS_MASK(n) (~((~0u) << (n)))
|
||||
|
||||
/** \brief 获取位段值
|
||||
* TAU_BITS_GET(0xF5FF, 0x0F00, 8) is 0x5
|
||||
*/
|
||||
#define TAU_BITS_GET(data, mask, pos) \
|
||||
(((data) & (mask)) >> (pos))
|
||||
|
||||
/** \brief 获取位段值
|
||||
* TAU_BITS_CHECK(0xF5FF, 0x0F00) is 1
|
||||
*/
|
||||
#define TAU_BITS_CHECK(data, mask) \
|
||||
(((data) & (mask)) ? 1 : 0)
|
||||
|
||||
/** \brief 修改位段值
|
||||
* TAU_BITS_MODIFY(0xF5FF, 0x0FF0, 0x8A0) is 0xF8AF
|
||||
*/
|
||||
#define TAU_BITS_MODIFY(data, clear_mask, set_mask) \
|
||||
(data) = (((data) & (~(clear_mask))) | (set_mask))
|
||||
|
||||
/** \brief 设置位段值
|
||||
* TAU_WRITE_REG32(0x05FF, 0xFFFA) is 0xFFFA
|
||||
*/
|
||||
#define TAU_WRITE_REG32(data, value) ((data) = (value))
|
||||
|
||||
/** \brief 设置位段值
|
||||
* TAU_RAED_REG32(0x05FF) is 0x05FF
|
||||
*/
|
||||
#define TAU_RAED_REG32(data) (data)
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* \brief 取2-byte整数的高位byte
|
||||
*
|
||||
* \par 示例
|
||||
* \code
|
||||
* uint16_t a = 0x1234;
|
||||
* uint16_t b;
|
||||
*
|
||||
* b = TAU_MSB(a); //b=0x12
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_MSB(x) (((x) >> 8) & 0xff)
|
||||
|
||||
/**
|
||||
* \brief 取2-byte整数的低位byte
|
||||
*
|
||||
* \par 示例
|
||||
* \code
|
||||
* uint16_t a = 0x1234;
|
||||
* uint16_t b;
|
||||
*
|
||||
* b = TAU_LSB(a); //b=0x34
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_LSB(x) ((x) & 0xff)
|
||||
|
||||
/**
|
||||
* \brief 取2-word整数的高位word
|
||||
*
|
||||
* \par 示例
|
||||
* \code
|
||||
* uint32_t a = 0x12345678;
|
||||
* uint32_t b;
|
||||
*
|
||||
* b = TAU_MSW(a); //b=0x1234
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_MSW(x) (((x) >> 16) & 0xffff)
|
||||
|
||||
/**
|
||||
* \brief 取2-word整数的低位word
|
||||
*
|
||||
* \par 示例
|
||||
* \code
|
||||
* uint32_t a = 0x12345678;
|
||||
* uint32_t b;
|
||||
*
|
||||
* b = TAU_LSW(a); //b=0x5678
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_LSW(x) ((x) & 0xffff)
|
||||
|
||||
/**
|
||||
* \brief 交换32-bit整数的高位word和低位word
|
||||
*
|
||||
* \par 示例
|
||||
* \code
|
||||
* uint32_t a = 0x12345678;
|
||||
* uint32_t b;
|
||||
*
|
||||
* b = TAU_WORDSWAP(a); //b=0x56781234
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_WORDSWAP(x) (TAU_MSW(x) | (TAU_LSW(x) << 16))
|
||||
|
||||
/**
|
||||
* \brief 交换32-bit整数的字节顺序
|
||||
*
|
||||
* \par 示例
|
||||
* \code
|
||||
* uint32_t a = 0x12345678;
|
||||
* uint32_t b;
|
||||
*
|
||||
* b = TAU_LONGSWAP(a); //b=0x78563412
|
||||
* \endcode
|
||||
*/
|
||||
#define TAU_LONGSWAP(x) ((TAU_LLSB(x) << 24) | \
|
||||
(TAU_LNLSB(x) << 16) | \
|
||||
(TAU_LNMSB(x) << 8) | \
|
||||
(TAU_LMSB(x)))
|
||||
|
||||
#define TAU_LLSB(x) ((x) & 0xff) /**< \brief 取32bit整数第1个字节 */
|
||||
#define TAU_LNLSB(x) (((x) >> 8) & 0xff) /**< \brief 取32bit整数第2个字节 */
|
||||
#define TAU_LNMSB(x) (((x) >> 16) & 0xff) /**< \brief 取32bit整数第3个字节 */
|
||||
#define TAU_LMSB(x) (((x) >> 24) & 0xff) /**< \brief 取32bit整数第4个字节 */
|
||||
#define TAU_LNSB(x,n) (((x) >> ((n) * 8) ) & 0xff) /**< \brief 取32bit整数第n个字节 ,参数 0 - 3*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __TAU_BYTEOPS_H */
|
||||
|
||||
/* end of file */
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,184 @@
|
|||
/**************************************************************************//**
|
||||
* @file ARMCM0.h
|
||||
* @brief CMSIS Core Peripheral Access Layer Header File for
|
||||
* ARMCM0 Device
|
||||
* @version V5.3.1
|
||||
* @date 09. July 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ARMCM0_H
|
||||
#define ARMCM0_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------- Interrupt Number Definition ------------------------ */
|
||||
|
||||
typedef enum IRQn
|
||||
{
|
||||
/* ------------------- Processor Exceptions Numbers ----------------------------- */
|
||||
NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */
|
||||
HardFault_IRQn = -13, /* 3 HardFault Interrupt */
|
||||
SVCall_IRQn = -5, /* 11 SV Call Interrupt */
|
||||
PendSV_IRQn = -2, /* 14 Pend SV Interrupt */
|
||||
SysTick_IRQn = -1, /* 15 System Tick Interrupt */
|
||||
|
||||
/* ------------------- Processor Interrupt Numbers ------------------------------ */
|
||||
VIDC_IRQn = 0,
|
||||
LCDC_IRQn = 1,
|
||||
MIPI_RX_IRQn = 2,
|
||||
MIPI_TX_IRQn = 3,
|
||||
MEMC_IRQn = 4,
|
||||
VPRE_IRQn = 5,
|
||||
FLSCTRL_IRQn = 6,
|
||||
DMA_IRQn = 7,
|
||||
TIMER0_IRQn = 8,
|
||||
TIMER1_IRQn = 9,
|
||||
TIMER2_IRQn = 10,
|
||||
TIMER3_IRQn = 11,
|
||||
WDG_IRQn = 12,
|
||||
UART_IRQn = 13,
|
||||
I2C0_IRQn = 14,
|
||||
I2C1_IRQn = 15,
|
||||
SPIS_IRQn = 16,
|
||||
SPIM_IRQn = 17,
|
||||
VPRE1_IRQn = 18,
|
||||
I2C2_IRQn = 19,
|
||||
OTP_IRQn = 20,
|
||||
SWIRE_IRQn = 21,
|
||||
PVD_IRQn = 22,
|
||||
AP_NRESET_IRQn = 23,
|
||||
EXTI_INT0_IRQn = 24,
|
||||
EXTI_INT1_IRQn = 25,
|
||||
EXTI_INT2_IRQn = 26,
|
||||
EXTI_INT3_IRQn = 27,
|
||||
EXTI_INT4_IRQn = 28,
|
||||
EXTI_INT5_IRQn = 29,
|
||||
EXTI_INT6_IRQn = 30,
|
||||
EXTI_INT7_IRQn = 31
|
||||
/* Interrupts 10 .. 31 are left out */
|
||||
} IRQn_Type;
|
||||
|
||||
|
||||
/* ================================================================================ */
|
||||
/* ================ Processor and Core Peripheral Section ================ */
|
||||
/* ================================================================================ */
|
||||
|
||||
/* ------- Start of section using anonymous unions and disabling warnings ------- */
|
||||
#if defined (__CC_ARM)
|
||||
#pragma push
|
||||
#pragma anon_unions
|
||||
#elif defined (__ICCARM__)
|
||||
#pragma language=extended
|
||||
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wc11-extensions"
|
||||
#pragma clang diagnostic ignored "-Wreserved-id-macro"
|
||||
#elif defined (__GNUC__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#elif defined (__TMS470__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#elif defined (__TASKING__)
|
||||
#pragma warning 586
|
||||
#elif defined (__CSMC__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#else
|
||||
#warning Not supported compiler type
|
||||
#endif
|
||||
|
||||
/* -------- Configuration of Core Peripherals ----------------------------------- */
|
||||
#define __CM0_REV 0x0000U /* Core revision r0p0 */
|
||||
#define __MPU_PRESENT 0U /* no MPU present */
|
||||
#define __VTOR_PRESENT 0U /* no VTOR present */
|
||||
#define __NVIC_PRIO_BITS 2U /* Number of Bits used for Priority Levels */ //20220228
|
||||
#define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */
|
||||
|
||||
#define __FPU_PRESENT 0U /* Set to 1 if FPU is present */
|
||||
#define __FPU_DP 0U /* single precision FPU */
|
||||
#define __ICACHE_PRESENT 0U /* Set to 1 if I-CACHE is present */
|
||||
#define __DCACHE_PRESENT 0U /* Set to 1 if D-CACHE is present */
|
||||
#define __DSP_PRESENT 0U /* no DSP extension present */
|
||||
|
||||
#include "core_cm0.h" /* Processor and core peripherals */
|
||||
#include "system_ARMCM0.h" /* System Header */
|
||||
|
||||
/* -------- End of section using anonymous unions and disabling warnings -------- */
|
||||
#if defined (__CC_ARM)
|
||||
#pragma pop
|
||||
#elif defined (__ICCARM__)
|
||||
/* leave anonymous unions enabled */
|
||||
#elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined (__GNUC__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#elif defined (__TMS470__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#elif defined (__TASKING__)
|
||||
#pragma warning restore
|
||||
#elif defined (__CSMC__)
|
||||
/* anonymous unions are enabled by default */
|
||||
#else
|
||||
#warning Not supported compiler type
|
||||
#endif
|
||||
|
||||
/* In HS mode and when the DMA is used, all variables and data structures dealing
|
||||
with the DMA during the transaction process should be 4-bytes aligned */
|
||||
#define DMA_WORD_ALIGN_EN
|
||||
#ifdef DMA_WORD_ALIGN_EN
|
||||
#if defined (__GNUC__) /* GNU Compiler */
|
||||
#define __ALIGN_END __attribute__ ((aligned (4)))
|
||||
#define __ALIGN_BEGIN
|
||||
#else
|
||||
#define __ALIGN_END
|
||||
#if defined (__CC_ARM) /* ARM Compiler */
|
||||
#define __ALIGN_BEGIN __align(4)
|
||||
#elif defined (__ICCARM__) /* IAR Compiler */
|
||||
#define __ALIGN_BEGIN
|
||||
#elif defined (__TASKING__) /* TASKING Compiler */
|
||||
#define __ALIGN_BEGIN __align(4)
|
||||
#endif /* __CC_ARM */
|
||||
#endif /* __GNUC__ */
|
||||
#else
|
||||
|
||||
#define __ALIGN_BEGIN
|
||||
#define __ALIGN_END
|
||||
|
||||
#define __ALIGN_END_1 __attribute__ ((aligned (1)))
|
||||
#endif /* DMA_WORD_ALIGN_EN */
|
||||
|
||||
/* __packed keyword used to decrease the data type alignment to 1-byte */
|
||||
#if defined (__CC_ARM) /* ARM Compiler */
|
||||
#define __packed __packed
|
||||
#elif defined (__ICCARM__) /* IAR Compiler */
|
||||
#define __packed __packed
|
||||
#elif defined ( __GNUC__ ) /* GNU Compiler */
|
||||
#define __packed __attribute__ ((__packed__))
|
||||
#define __weak __attribute__((weak))
|
||||
#elif defined (__TASKING__) /* TASKING Compiler */
|
||||
#define __packed __unaligned
|
||||
#endif /* __CC_ARM */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ARMCM0_H */
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_crc.h
|
||||
* Description: hal crc ͷ<EFBFBD>ļ<EFBFBD>
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: zzf
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_CRC_H
|
||||
#define __HAL_CRC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_device_datatype.h"
|
||||
#include "tau_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Exported constant and macro definitions
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Exported structures, unions and enumerations
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief crc calculation unit structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t polynomial_value;
|
||||
uint32_t initial_seed_value;
|
||||
crc_protocol_type_e crc_protocol;
|
||||
crc_fxor_function_e crc_foxr;
|
||||
crc_reversal_type_e crc_reversal_in;
|
||||
crc_reversal_type_e crc_reversal_out;
|
||||
} crc_ctrl_handle_t;
|
||||
|
||||
/**
|
||||
* @brief crc dma callback function define
|
||||
*/
|
||||
typedef void (*crc_dma_callback)(uint32_t crc_result);
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Exported variable declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Exported function declarations
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief The initialization for CRC calculation unit
|
||||
* @param crc_ctrl_handle: configuration parameters in initialization
|
||||
* @retval true or false
|
||||
**/
|
||||
bool hal_crc_init(const crc_ctrl_handle_t *crc_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief The initialization for CRC calculation unit
|
||||
* @param None
|
||||
* @retval true or false
|
||||
**/
|
||||
bool hal_crc_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Reset CRC calculation unit and DR to CRCR_INIT value
|
||||
* @param None
|
||||
* @retval true or false
|
||||
**/
|
||||
bool hal_crc_reset(void);
|
||||
|
||||
/**
|
||||
* @brief Get the result of CRC calculation uint
|
||||
* @param buffer_address: 16-bit or 32-bit crc calculate buffer address
|
||||
* @param buffer_length: the length of buffer
|
||||
* @retval 32-bit crc calculate result
|
||||
**/
|
||||
uint32_t hal_crc_cal(const void *buffer_address, uint32_t buffer_length);
|
||||
|
||||
/**
|
||||
* @brief initial DMA transfer
|
||||
* @param crc_ctrl_handle: configuration parameters in initialization
|
||||
* @param buffer_address: 16-bit or 32-bit crc calculate buffer address
|
||||
* @param buffer_length: the length of buffer(0~65535)
|
||||
* @param cb_func: dma interrupt callback function to get the result of crc calculation
|
||||
* @retval true or false
|
||||
**/
|
||||
bool hal_crc_dma_init(const crc_ctrl_handle_t *crc_ctrl_handle, crc_dma_callback cb_func, const void *buffer_address, uint16_t buffer_length);
|
||||
|
||||
/**
|
||||
* @brief deinitial DMA transfer
|
||||
* @param None
|
||||
* @retval true or false
|
||||
**/
|
||||
bool hal_crc_dma_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief start DMA transfer
|
||||
* @param None
|
||||
* @retval true or false
|
||||
**/
|
||||
bool hal_crc_dma_start(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __HAL_CRC_H */
|
||||
|
||||
/***************** (C) COPYRIGHT ISP Systems (R) END OF FILE ******************/
|
||||
|
|
@ -0,0 +1,523 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_dsi_rx_ctrl.h
|
||||
* Description: hal mipi dsi rx path control 头文件
|
||||
* Version: V0.1
|
||||
* Date: 2021-04-06
|
||||
* Author: lzy
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_DSI_RX_CTRL_H__
|
||||
#define __HAL_DSI_RX_CTRL_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_dsi_datatype.h"
|
||||
#include "tau_common.h"
|
||||
#include "tau_log.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
#define RX_DCS_QUEUE_MAX_SIZE 20 /* DCS存储队列长度 */
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
typedef struct hal_dcs_execute_entry_t hal_dcs_execute_entry_t;
|
||||
|
||||
typedef struct hal_dcs_packet_t hal_dcs_packet_t;
|
||||
|
||||
typedef struct hal_dsi_rx_ctrl_handle_t hal_dsi_rx_ctrl_handle_t;
|
||||
|
||||
/* DCS CMD 回调函数, 注册进cus_dcs_entry_table里, 匹配对应的DCS 后回调*/
|
||||
typedef bool (*hal_dsi_rx_ctrl_dcs_execute)(hal_dsi_rx_ctrl_handle_t *rx_handle, hal_dcs_packet_t *dcs_packet);
|
||||
|
||||
/* AP 读cmd 回调, 需要快速回CMD 时可注册, 为NULL 时DSC 读指令与写指令经过parse后由cus_dcs_entry_table回调 */
|
||||
typedef bool (*hal_dsi_rx_ctrl_read_entry)(uint8_t data_type, uint8_t dcs_cmd, uint8_t param);
|
||||
|
||||
/* AP PPS 更新回调,参数为PPS 以及从PPS 里解析出来的picture width/height, 用于分辨率切换, 不注册该接口时内部处理PPS */
|
||||
typedef bool (*hal_dsi_rx_ctrl_pps_entry)(uint8_t *pps, uint8_t size, uint32_t pic_width, uint32_t pic_height);
|
||||
|
||||
/**
|
||||
* @brief hal_rx_event_e select
|
||||
*/
|
||||
typedef enum hal_rx_event_e
|
||||
{
|
||||
HAL_RX_FS_EVENT = 0x1, /* Frame start event */
|
||||
HAL_RX_LINE_EVENT = 0x2, /* Frame receive line event */
|
||||
HAL_RX_END_EVENT = 0x4, /* Frame end event */
|
||||
} hal_rx_event_e;
|
||||
|
||||
/**
|
||||
* @brief rx pq filter index
|
||||
* 默认使用linear,特殊场景使用OPT filter
|
||||
* RX_FLT_OPT_0最模糊,边缘最平滑,index越大越清晰,边缘锯齿会加重
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RX_FLT_OPT_0 = 0,
|
||||
RX_FLT_OPT_1 = 1,
|
||||
RX_FLT_OPT_2 = 2,
|
||||
RX_FLT_OPT_3 = 3,
|
||||
RX_FLT_OPT_4 = 4,
|
||||
RX_FLT_OPT_5 = 5,
|
||||
RX_FLT_OPT_6 = 6,
|
||||
RX_FLT_OPT_7 = 7,
|
||||
RX_FLT_OPT_8 = 8,
|
||||
RX_FLT_OPT_9 = 9,
|
||||
RX_FLT_OPT_10 = 10,
|
||||
RX_FLT_LINEAR = 11,
|
||||
RX_FLT_MAX
|
||||
} hal_dsi_rx_pq_filter_e;
|
||||
|
||||
/* RX debug 回调函数,用于获取frame start 等功能debug */
|
||||
typedef void (*hal_dsi_rx_ctrl_event_entry)(hal_rx_event_e event, void *data);
|
||||
|
||||
/**
|
||||
* @brief dsi rx ctrl handle struct
|
||||
*/
|
||||
typedef struct hal_dsi_rx_ctrl_handle_t
|
||||
{
|
||||
dsi_base_trans_info_t base_info; /* mipi video 转换基本信息 */
|
||||
dsi_base_extra_info_t extra_info; /* 新增旋转、镜像配置 */
|
||||
dsi_color_code_e rx_color_mode; /* 输入color mode */
|
||||
dsi_lane_nume_e rx_lanes; /* mipi data lane */
|
||||
dsi_video_mode_type_e rx_nonburst_models; /* transmission packet sequences */
|
||||
bool compress_en; /* DSC 压缩标志 */
|
||||
uint32_t rx_hsclk_rate; /* mipi 高速信号lane rate */
|
||||
uint8_t rx_dsc_pps[DSC_PPS_SIZE]; /* DSC 压缩PPS参数 */
|
||||
const hal_dcs_execute_entry_t *cus_dcs_entry_table; /* DCS处理函数列表 */
|
||||
hal_dsi_rx_ctrl_read_entry rx_dcs_read_entry; /* Host读指令数据函数,为NULL时由rx_dcs_queue注册cmd处理 */
|
||||
hal_dsi_rx_ctrl_pps_entry pps_update_entry; /* PPS Update 时回调函数,用于分辨率切换更新PPS,为NULL时内部处理 */
|
||||
bool used; /* handle使用标志位 */
|
||||
hal_err_handle_level_e err_handler_level; /* RX接收错误的时候对模块做reset等级, 等级越高reset模块越多 */
|
||||
uint8_t rx_strength; /* 用于调节RX信号强度,仅适用于开启内阻校准模式,档位0~7,默认3 */
|
||||
hight_performan_mode_e hight_performan_mode; /* 高性能模式等级,参考hight_performan_mode_e */
|
||||
dsi_rx_lane_swap_e rx_lane_swap; /* lane swap default order is 2103*/
|
||||
hal_dsi_rx_pq_filter_e rx_pq_index; /* 画质调整滤波器,默认为linear最优效果,特殊场景使用OPT filter */
|
||||
} hal_dsi_rx_ctrl_handle_t;
|
||||
|
||||
/**
|
||||
* @brief DCS command execute entry
|
||||
*/
|
||||
typedef struct hal_dcs_execute_entry_t
|
||||
{
|
||||
uint32_t dcs_command; /* DCS command */
|
||||
hal_dsi_rx_ctrl_dcs_execute execute_func; /* command 对应处理函数 */
|
||||
bool immediately_func; /* 执行机制:true-在中断里立即执行,false-加入DCS队列异步执行 */
|
||||
} hal_dcs_execute_entry_t;
|
||||
|
||||
/**
|
||||
* @brief 存储 DCS packet 结构体
|
||||
*/
|
||||
typedef struct hal_dcs_packet_t
|
||||
{
|
||||
uint32_t data_type; /* data type */
|
||||
uint32_t dcs_command; /* dcs command */
|
||||
uint32_t param_length; /* dcs param length */
|
||||
uint8_t *packet_param; /* dcs param */
|
||||
uint16_t crc_data; /* dcs crc */
|
||||
const hal_dcs_execute_entry_t *dcs_execute_entry; /* dcs packet 处理函数入口*/
|
||||
} hal_dcs_packet_t;
|
||||
|
||||
/**
|
||||
* @brief video mode 下 RX pattern参数结构体
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ipi_pg_hsa;
|
||||
uint32_t ipi_pg_hbp;
|
||||
uint32_t ipi_pg_hfp;
|
||||
uint32_t ipi_pg_vsa;
|
||||
uint32_t ipi_pg_vbp;
|
||||
uint32_t ipi_pg_vfp;
|
||||
uint32_t frame_rate;
|
||||
} hal_dsi_rx_ipi_pg_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief dcs command filter select
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_RX_DCS_FILTER_0 = 0x0,
|
||||
HAL_RX_DCS_FILTER_1 = 0x1,
|
||||
HAL_RX_DCS_FILTER_2 = 0x2,
|
||||
HAL_RX_DCS_FILTER_3 = 0x3,
|
||||
HAL_RX_DCS_FILTER_4 = 0x4,
|
||||
HAL_RX_DCS_FILTER_5 = 0x5,
|
||||
HAL_RX_DCS_FILTER_6 = 0x6,
|
||||
HAL_RX_DCS_FILTER_7 = 0x7,
|
||||
HAL_RX_DCS_FILTER_8 = 0x8,
|
||||
HAL_RX_DCS_FILTER_9 = 0x9,
|
||||
HAL_RX_DCS_FILTER_A = 0xA,
|
||||
HAL_RX_DCS_FILTER_B = 0xB,
|
||||
HAL_RX_DCS_FILTER_MAX
|
||||
} hal_rx_dcs_filter_sel_e;
|
||||
|
||||
|
||||
/**
|
||||
* @brief dcs command filter select
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_RX_QRESP_CODE0 = 0,
|
||||
HAL_RX_QRESP_CODE1 = 1,
|
||||
HAL_RX_QRESP_CODE2 = 2,
|
||||
HAL_RX_QRESP_CODE3 = 3,
|
||||
HAL_RX_QRESP_CODE4 = 4,
|
||||
HAL_RX_QRESP_CODE5 = 5,
|
||||
HAL_RX_QRESP_CODE6 = 6,
|
||||
HAL_RX_QRESP_CODE7 = 7,
|
||||
HAL_RX_QRESP_MAX
|
||||
} hal_rx_dcs_qresp_e;
|
||||
|
||||
/**
|
||||
* @brief pentile source color format
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PENTILE_SRC_FORMAT_RGB = 0x0,
|
||||
PENTILE_SRC_FORMAT_BGR = 0x1,
|
||||
PENTILE_SRC_FORMAT_RGBG_BGRG = 0x8,
|
||||
PENTILE_SRC_FORMAT_GBGR_GRGB = 0x9,
|
||||
PENTILE_SRC_FORMAT_BGRG_RGBG = 0xA,
|
||||
PENTILE_SRC_FORMAT_GRGB_GBGR = 0xB,
|
||||
PENTILE_SRC_FORMAT_RGBG_RGBG = 0xC,
|
||||
PENTILE_SRC_FORMAT_GBGR_GBGR = 0xD,
|
||||
PENTILE_SRC_FORMAT_BGRG_BGRG = 0xE,
|
||||
PENTILE_SRC_FORMAT_GRGB_GRGB = 0xF,
|
||||
PENTILE_SRC_FORMAT_MAX
|
||||
} pentile_src_format_e;
|
||||
|
||||
/**
|
||||
* @brief 设置RX CLK
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RX_CLK_100M = 0,
|
||||
RX_CLK_150M = 1,
|
||||
RX_CLK_200M = 2,
|
||||
RX_CLK_300M = 3,
|
||||
RX_CLK_40M = 4,
|
||||
RX_CLK_80M = 5,
|
||||
RX_CLK_MAX
|
||||
} hal_rx_clk_e;
|
||||
|
||||
/**
|
||||
* @brief pq_type_e select
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PQ_TYPE_DEFAULT = 0x0,
|
||||
PQ_TYPE_LIMIT = 0x1,
|
||||
PQ_TYPE_MAX
|
||||
} pq_type_e;
|
||||
|
||||
/**
|
||||
* @brief 线的粗细
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
LINE_WEIGHT_FINE = 0,
|
||||
LINE_WEIGHT_MEDIUM = 1,
|
||||
LINE_WEIGHT_BOLD = 2,
|
||||
LINE_WEIGHT_MAX
|
||||
} line_weight_e;
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief 创建dsi rx ctrl handle (释放时需调用hal_dsi_rx_ctrl_release_handle)
|
||||
* @param none
|
||||
* @retval dsi rx handle
|
||||
*/
|
||||
hal_dsi_rx_ctrl_handle_t *hal_dsi_rx_ctrl_create_handle(void);
|
||||
|
||||
/**
|
||||
* @brief 释放dsi rx ctrl handle
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_release_handle(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief 设置rx ctrl handle 里的 PPS 参数
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param pps: pps 参数
|
||||
* @param pps_size: pps 参数长度
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_pre_init_pps(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint8_t pps[], uint32_t pps_size);
|
||||
|
||||
/**
|
||||
* @brief 初始化dsi rx 模块
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_init(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief dsi rx 模块去初始化
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_deinit(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief 启动dsi rx
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_start(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief 重新配置dsi rx参数并恢复状态 (debug使用, 重新配置rx_ctrl_handle参数后调用该接口重启)
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_restart(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief 停止dsi rx
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_stop(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief 手动设置RX clk,一般RX CLK 由底层自动计算,用于特殊video mode场景出现FIFO FULL情况调试使用
|
||||
* @param rxbr_clk: rx clk, 需要大于hs_lane_rate/8
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_set_rx_clk(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, hal_rx_clk_e rxbr_clk);
|
||||
|
||||
/**
|
||||
* @brief 发送 MIPI HOST的读响应 CMD
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param data_type: data type
|
||||
* @param vc: virtual channel
|
||||
* @param cmd_count: ack command 的长度
|
||||
* @param ... : 需要发送的command(数量与cmd_count 配置一致)
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_send_ack_cmd(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, dsi_ack_data_type_e data_type, dsi_virtual_channel_e vc, uint8_t cmd_count, ...);
|
||||
|
||||
/**
|
||||
* @brief 使用数组方式回复短包,与hal_dsi_rx_ctrl_send_ack_cmd功能一致
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param data_size: 数组长度,固定为4
|
||||
* @param data: 回复cmd数据,数据排列有严格规定:
|
||||
* data[0]:DI(data type)
|
||||
* data[1]:data 0
|
||||
* data[2]:data 1
|
||||
* data[3]:内部pkt type,短包固定为0
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_ack_short_cmd(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint8_t data_size, uint8_t data[]);
|
||||
|
||||
/**
|
||||
* @brief 使用数组方式回复长包,与hal_dsi_rx_ctrl_send_ack_cmd功能一致
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param data_size: 数组长度,为Word Count + header长度 (header固定为4)
|
||||
* @param data: 回复cmd数据,数据排列有严格规定:
|
||||
* data[0]:DI(data type)
|
||||
* data[1]:wc 0 (Word Count 低八位)
|
||||
* data[2]:wc 1 (Word Count 高八位)
|
||||
* data[3]:内部pkt type,长包固定为1
|
||||
* data[N]:长包数据
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_ack_long_cmd(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint32_t data_size, uint8_t data[]);
|
||||
|
||||
/**
|
||||
* @brief 异步处理DSC接口,执行cus_dcs_entry_table里对应DCS immediately_func为false的函数
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @retval true - 正常处理1个DSC , false - 无DSC 处理
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_dcs_async_handler(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief 使用硬件filter丢弃不需要处理的CMD,避免MCU资源被无效CMD占用
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param filter_number: filter 编号(0-7)
|
||||
* @param cmd_start: 需要丢弃command code起始位
|
||||
* @param cmd_end: 需要丢弃command code终止位
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_set_hw_cmd_filter(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle,
|
||||
hal_rx_dcs_filter_sel_e filter_number,
|
||||
uint32_t cmd_start, uint32_t cmd_end);
|
||||
|
||||
/**
|
||||
* @brief 使用内置pattern代替mipi输入(用于测试)
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param pg_orient: pattern 方向(0:Vertical mode ; 1:Horizontal mode)
|
||||
* @param enable: 开启/关闭pattern
|
||||
* @param frame_rate: pattern 帧率
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_enable_test_pattern(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint8_t pg_orient, bool enable, int frame_rate);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 获取AP 配置 BTA回复数据最大size
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @retval 返回数据大小
|
||||
*/
|
||||
uint32_t hal_dsi_rx_ctrl_get_max_ret_size(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief 获取AP Compression Mode Command配置,默认为0,谨慎使用
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @retval AP 配置compressen_en
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_get_compressen_en(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief 输入分辨率切换接口
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_toggle_resolution(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief 配置 RX escape clk
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param esc_clk: escape clk 单位Hz,10000000时回CMD为10Mhz
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_set_cus_esc_clk(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint32_t esc_clk);
|
||||
|
||||
/**
|
||||
* @brief 自动计算并配置硬件filter
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param enable: 启动/关闭 硬件filter
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_set_auto_hw_filter(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, bool enable);
|
||||
|
||||
/*
|
||||
* @brief 输入帧率修改(针对video mode)
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param frame_rate:frame rate
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_toggle_input_frame_rate(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, dsi_video_frame_rate_e frame_rate);
|
||||
|
||||
/*
|
||||
* @brief 注册写命令的回调函数,用于特殊命令序列时写命令的处理.
|
||||
可配合hal_dsi_rx_ctrl_set_auto_hw_filter关闭hw filter用于获取所有软件CMD
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param 写命令处理函数
|
||||
* @retval none
|
||||
*/
|
||||
void hal_dsi_rx_ctrl_register_write_cmd_entry(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, hal_dsi_rx_ctrl_dcs_execute execute_func);
|
||||
|
||||
/**
|
||||
* @brief 配置硬件自动回复命令
|
||||
* 最大回复长度64,AP需要配置set_max_return_size后并且对比一直才会自动回复,不需要软件再参与
|
||||
* 应用于所有回复固定数据的场景
|
||||
* @param RXBR: registers struct
|
||||
* @param qresp_number: qresp 编号(0-7)
|
||||
* @param data_type: 需要回复的读命令的datatype
|
||||
* @param cmd_code: 需要回复的读命令
|
||||
* @param cmd_count: 需要回复的命令的大小,长包最大size为64,与set_max_return_size一致才会回复
|
||||
* @param ...: 需要回复的参数
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_rx_ctrl_set_auto_ack(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, hal_rx_dcs_qresp_e qresp_number, dsi_ack_data_type_e data_type, uint32_t cmd_code, uint8_t cmd_count, ...);
|
||||
|
||||
/*
|
||||
* @brief 初始化画点模式
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param draw_en: 画点模式使能
|
||||
* @param pxl_init_en: 是否对全屏数据赋值,true:使用init_value赋值,false:使用上一帧数据作为初始值
|
||||
* @param color_mode: 画点模式数据源格式见dsi_color_code_e
|
||||
* @param init_value: 全屏初始化数据,bit[23:16]--R,bit[15:8]--G,bit[7:0]--B
|
||||
* @retval none
|
||||
*/
|
||||
void hal_dsi_rx_ctrl_draw_mode_init(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, bool draw_en, bool pxl_init_en, dsi_color_code_e color_mode, uint32_t init_value);
|
||||
|
||||
/*
|
||||
* @brief 配置像素颜色
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param x: 像素点的x 坐标
|
||||
* @param y: 像素点的y 坐标
|
||||
* @param red_data: 像素点R分量
|
||||
* @param green_data: 像素点G分量
|
||||
* @param blue_data: 像素点B分量
|
||||
* @retval none
|
||||
*/
|
||||
void hal_dsi_rx_ctrl_set_pixel_data(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, int x, int y, uint8_t red_data, uint8_t green_data, uint8_t blue_data);
|
||||
|
||||
|
||||
/**
|
||||
* @brief video mode下强制将数据设置为特定的color mode,具体type见dsi_color_code_e
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param enable: 使能强制数据模式
|
||||
* @param frc_vid_code: 强制的数据格式
|
||||
* @retval none
|
||||
*/
|
||||
void hal_dsi_rx_ctrl_force_video_crtl(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, bool enable, dsi_color_code_e frc_vid_code);
|
||||
|
||||
/**
|
||||
* @brief 注册RX 事件回调函数
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param event_cb: 回调函数
|
||||
* @param event_mask: 接收事件掩码,见hal_rx_event_e(eg:HAL_RX_FS_EVENT|HAL_RX_LINE_EVENT)
|
||||
* @param enable: 事件回调开关
|
||||
* @param user_data: 预留扩展参数,不同事件事件配置不同参数
|
||||
* @retval none
|
||||
*/
|
||||
void hal_dsi_rx_ctrl_register_callback(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, hal_dsi_rx_ctrl_event_entry event_cb, uint32_t event_mask, bool enable, void *user_data);
|
||||
|
||||
/**
|
||||
* @brief 配置是否打开长包CRC检查
|
||||
* @param rx_ctrl_handle: dsi rx handle
|
||||
* @param enable: 开启或者屏蔽CRC检测
|
||||
* @retval none
|
||||
*/
|
||||
void hal_dsi_rx_ctrl_set_check_crc(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, bool enable);
|
||||
|
||||
/**
|
||||
* @brief 配置rx log 等级
|
||||
* @param rx_drv_level: rx log等级见枚举log_level_e
|
||||
* @retval none
|
||||
*/
|
||||
void hal_dsi_rx_ctrl_set_log_level(log_level_e rx_drv_level);
|
||||
|
||||
/**
|
||||
* @brief 带颜色画线函数(直线、斜线)
|
||||
* @param x1,y1 起点坐标
|
||||
* @param x2,y2 终点坐标
|
||||
* @param red_data: 像素点R分量
|
||||
* @param green_data: 像素点G分量
|
||||
* @param blue_data: 像素点B分量
|
||||
* @param line_weight: 线粗
|
||||
* @return none
|
||||
*/
|
||||
void hal_dsi_rx_ctrl_draw_line(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t red_data, uint8_t green_data, uint8_t blue_data, line_weight_e line_weight);
|
||||
|
||||
/**
|
||||
* @brief 设置需要获取pixel的坐标
|
||||
* @param cap_x: 抓取pixel的x坐标
|
||||
* @param cap_y: 抓取pixel的y坐标
|
||||
* @return none
|
||||
*/
|
||||
void hal_dsi_rx_ctrl_set_cap_pixel_pos(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle, uint16_t x0, uint16_t y0);
|
||||
|
||||
/**
|
||||
* @brief 获取指定坐标颜色,必须先设置获取颜色的坐标
|
||||
* @return 返回指定坐标颜色
|
||||
*/
|
||||
uint32_t hal_dsi_rx_ctrl_get_cap_pixel_color(hal_dsi_rx_ctrl_handle_t *rx_ctrl_handle);
|
||||
|
||||
#endif //__HAL_DSI_RX_CTRL_H__
|
||||
|
|
@ -0,0 +1,349 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_dsi_tx_ctrl.h
|
||||
* Description: hal mipi dsi tx 头文件
|
||||
* Version: V0.1
|
||||
* Date: 2021-04-23
|
||||
* Author: jaya
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_DSI_TX_CTRL_H__
|
||||
#define __HAL_DSI_TX_CTRL_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_dsi_datatype.h"
|
||||
#include "tau_device_datatype.h"
|
||||
#include "hal_gpio.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief blank display configure type
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t st_col; /* 补黑区域起始坐标,RGBG格式以子像素计数*/
|
||||
uint16_t width; /* 补黑区域宽度,RGBG格式以子像素计数*/
|
||||
uint8_t remap_en; /* 补黑区域是否参与子像素重排*/
|
||||
uint8_t blank_en; /* 补黑区域开关*/
|
||||
} blank_disp_t;
|
||||
|
||||
/**
|
||||
* @brief pentile remap rule configuration type in rom code
|
||||
*/
|
||||
typedef uint8_t (remap_rule_t)[24];
|
||||
|
||||
/**
|
||||
* @brief 客制化MIPI TX参数结构体
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bool pentile_enable; /* 是否pentile输出*/
|
||||
bool pentile_reverse_en; /* 是否打开芯片本身行翻转功能*/
|
||||
bool pentile_24b; /* 是否以RGB IC搭配RGBG玻璃*/
|
||||
uint32_t rgb_hact; /* RGB IC搭配RGBG玻璃使用时IC水平方向分辨率*/
|
||||
remap_rule_t *remapl_rule; /* RGB IC搭配RGBG玻璃使用时remap规则1*/
|
||||
remap_rule_t *remapr_rule; /* RGB IC搭配RGBG玻璃使用时remap规则2*/
|
||||
blank_disp_t blank_info0; /* 补黑参数配置信息*/
|
||||
blank_disp_t blank_info1; /* 补黑参数配置信息*/
|
||||
} dsi_tx_pent_info_t;
|
||||
|
||||
/**
|
||||
* @brief MIPI TX clk/data lane是否自动进LP控制枚举类型
|
||||
* 不同driver IC spec不同,对Lane rate范围要求也不同
|
||||
* 无法点亮时可尝试替换不同的模式
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ALWAYS_HS = 0, // vid输出默认此模式,仅VSA自动进LP; cmd输出暂不支持此模式
|
||||
ONLY_DATA_LANE_AUTO_LP = 1, // cmd输出默认此模式,data lane行间自动进LP, clk保持HS
|
||||
CLK_DATA_LANE_AUTO_LP = 2, // data/clk lane行间自动进LP
|
||||
} dsi_tx_lane_lp_e;
|
||||
|
||||
/**
|
||||
* @brief tx pq filter index
|
||||
* 默认使用OPT
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TX_FLT_OPT = 0,
|
||||
TX_FLT_LINEAR = 1,
|
||||
TX_FLT_MAX
|
||||
} hal_dsi_tx_pq_filter_e;
|
||||
|
||||
/**
|
||||
* @brief 客制化MIPI TX参数结构体
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
dsi_base_trans_info_t base_info; /* mipi video 转换基本信息 */
|
||||
uint32_t dpi_vsa; /* DPI VSA*/
|
||||
uint32_t dpi_vbp; /* DPI VBP*/
|
||||
uint32_t dpi_vfp; /* DPI VFP*/
|
||||
uint32_t dpi_hsa; /* DPI HSA*/
|
||||
uint32_t dpi_hbp; /* DPI HBP*/
|
||||
uint32_t dpi_hfp; /* DPI HFP*/
|
||||
float tx_frame_rate; /* 默认60Hz输出,不建议配置为其他,仅作为debug使用 */
|
||||
uint8_t lane_num; /* TX 使用的 lane 数量*/
|
||||
bool used; /* handle使用标志位 内部自动更新状态,不需要操作*/
|
||||
bool lp_exit_lpdt; /* 每一条LP CMD都退出LPDT */
|
||||
dsi_tx_lane_lp_e tx_lane_lp; /* clk/data lane是否自动进LP模式配置 */
|
||||
dsi_virtual_channel_e channel_id; /* 虚拟通道ID,默认为0*/
|
||||
dsi_video_mode_type_e vid_mode; /* video输出时选择输出的vid模式种类 */
|
||||
dsi_tx_cmd_tx_type_e cmd_tx_type; /* 初始化模式传输命令方式,0:HS; 1:LP */
|
||||
dsi_tx_pent_info_t pentile_info; /* pentile屏基本信息 */
|
||||
hal_dsi_tx_pq_filter_e tx_pq_index; /* 画质调整滤波器,默认为OPT最优效果 */
|
||||
} hal_dsi_tx_ctrl_handle_t;
|
||||
|
||||
/**
|
||||
* @brief TE 信号产生模式
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TE_60HZ_MODE = 0,
|
||||
TE_USER_MODE = 1, /* 底层不产生TE, 由hal_dsi_tx_ctrl_gen_a_tear_signal 接口产生 */
|
||||
TE_STOP_MODE = 1,
|
||||
TE_90HZ_MODE = 2,
|
||||
TE_120HZ_MODE = 3,
|
||||
TE_144HZ_MODE = 4,
|
||||
TE_160HZ_MODE = 5,
|
||||
TE_MODE_MAX
|
||||
} te_mode_e;
|
||||
|
||||
/**
|
||||
* @brief dpi tx vpg style
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TX_VPG_V_COLOR = 0,
|
||||
TX_VPG_H_COLOR = 1,
|
||||
TX_VPG_V_BER = 2,
|
||||
TX_VPG_FLICKER = 3,
|
||||
TX_VPG_MAX
|
||||
} dsi_tx_vpg_style_e;
|
||||
|
||||
/**
|
||||
* @brief MIPI TX初始化
|
||||
* @param tx_ctrl_handle: MIPI TX实例
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_tx_ctrl_init(hal_dsi_tx_ctrl_handle_t *tx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief MIPI TX反初始化
|
||||
* @param tx_ctrl_handle: MIPI TX实例
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_tx_ctrl_deinit(hal_dsi_tx_ctrl_handle_t *tx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief MIPI TX创建实例
|
||||
* @param None
|
||||
* @retval tx_ctrl_handle: MIPI TX实例
|
||||
*/
|
||||
hal_dsi_tx_ctrl_handle_t *hal_dsi_tx_ctrl_create_handle(void);
|
||||
|
||||
/**
|
||||
* @brief MIPI TX释放实例
|
||||
* @param tx_ctrl_handle: MIPI TX实例
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_tx_ctrl_release_handle(hal_dsi_tx_ctrl_handle_t *tx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief MIPI TX开始运行
|
||||
* @param tx_ctrl_handle: MIPI TX实例
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_tx_ctrl_start(hal_dsi_tx_ctrl_handle_t *tx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief MIPI TX停止运行
|
||||
* @param tx_ctrl_handle: MIPI TX实例
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_tx_ctrl_stop(hal_dsi_tx_ctrl_handle_t *tx_ctrl_handle);
|
||||
|
||||
/**
|
||||
* @brief MIPI TX接收命令
|
||||
* @param data_type: 数据类型,参考枚举类型dsi_data_type_e
|
||||
* @param vc: 虚拟通道编号,参考枚举类型dsi_virtual_channel_e
|
||||
* @param cmd: DCS指令
|
||||
* @param size: 读取数据长度
|
||||
* @param data: 数据存放地址
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_read_cmd(uint8_t data_type, uint8_t vc, uint8_t cmd, uint8_t size, uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief video高速数据传输时V porch阶段进行bta回读接口
|
||||
* @param data_type: 数据类型,参考枚举类型dsi_data_type_e
|
||||
* @param cmd: DCS指令
|
||||
* @param size: 读取数据长度
|
||||
* @param data: 数据存放地址
|
||||
* @retval true-BTA回复获取有效,false-BTA回复未获得
|
||||
* @attention 需要考虑V porch时长是否足够size长度的寄存器回读,否则造成TX数据通路出错
|
||||
*/
|
||||
bool hal_dsi_tx_ctrl_vporch_bta_opera(uint8_t data_type, uint8_t cmd, uint8_t size, uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief MIPI TX发送命令
|
||||
* @param data_type: 数据类型,参考枚举类型dsi_data_type_e
|
||||
* @param vc: 虚拟通道编号,参考枚举类型dsi_virtual_channel_e
|
||||
* @param cmd_count: 可变参数个数
|
||||
* @param ...: 可变参数
|
||||
* @retval true-command发送正常;false-TX当前状态不能发送command
|
||||
*/
|
||||
bool hal_dsi_tx_ctrl_write_cmd(uint8_t data_type, uint8_t vc, uint8_t cmd_count, ...);
|
||||
|
||||
/**
|
||||
* @brief MIPI TX发送命令
|
||||
* @param data_type: 数据类型,参考枚举类型dsi_data_type_e
|
||||
* @param vc: 虚拟通道编号,参考枚举类型dsi_virtual_channel_e
|
||||
* @param size: data个数
|
||||
* @param data: data数组
|
||||
* @retval true-command发送正常;false-TX当前状态不能发送command
|
||||
*/
|
||||
bool hal_dsi_tx_ctrl_write_array_cmd(uint8_t data_type, uint8_t vc, uint8_t size, const uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief 切换至 LP cmd发送模式
|
||||
* @param enable: true-进行cmd发送;false-结束LP cmd发送
|
||||
* @retval None
|
||||
* @attention 应用场景:AP enter sleep后传输发送LP cmd
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_cmd_mode(bool enable);
|
||||
|
||||
/**
|
||||
* @brief 设置TX escape mode时钟
|
||||
* @param esc_clk: escape clk 单位Hz,10000000时CMD为10Mhz
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_set_escape_clock_div(uint32_t esc_clk);
|
||||
|
||||
/**
|
||||
* @brief 设置RGB或BGR
|
||||
* @param endianness: 选择RGB或BGR显示,参考dsi_endianness_e
|
||||
* @attention 接口需要在初始化接口hal_dsi_tx_ctrl_init调用前才能生效
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_set_endianness(dsi_endianness_e endianness);
|
||||
|
||||
/**
|
||||
* @brief 设置CCM参数
|
||||
* @param coef: 客制化参数,参考结构体ccm_coef_t
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_set_ccm(ccm_coef_t *ccm);
|
||||
|
||||
/**
|
||||
* @brief 设置边缘检测算法参数
|
||||
* @param edge_dect_para: 边缘检测算法参数,参考 dsi_tx_edge_dect_t;关闭模块时可以传参NULL
|
||||
* @param edge_dect_en: 是否开启边缘检测模块
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_set_edge_dect(dsi_tx_edge_dect_t *edge_dect_para, bool edge_dect_en);
|
||||
|
||||
/**
|
||||
* @brief 设置边缘增强效果算法参数
|
||||
* @param edge_enh_para: 边缘增强算法参数,参考 dsi_tx_edge_enh_t;关闭模块时可以传参NULL
|
||||
* @param edge_enh_en: 是否开启边缘增强模块
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_set_edge_enhance(dsi_tx_edge_enh_t *edge_enh_para, bool edge_enh_en);
|
||||
|
||||
/**
|
||||
* @brief 设置False Color remove算法参数
|
||||
* @param fc_para: false color参数,参考 dsi_tx_fc_t;关闭模块时可以传参NULL
|
||||
* @param fc_en: 是否开启false color配置模块
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_set_fc(dsi_tx_fc_t *fc_para, bool fc_en);
|
||||
|
||||
/**
|
||||
* @brief 设置bcs参数
|
||||
* @param bcs_para: 明亮度/对比度/饱和度,参考 dsi_tx_bcs_t;关闭模块时可以传参NULL
|
||||
* @param bcs_en: 是否开启bcs配置模块
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_set_bcs(dsi_tx_bcs_t *bcs_para, bool bcs_en);
|
||||
|
||||
/**
|
||||
* @brief 设置复写颜色
|
||||
* @param R: RGB的R分量
|
||||
* @param G: RGB的G分量
|
||||
* @param B: RGB的B分量
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_set_overwrite_rgb(uint8_t R, uint8_t G, uint8_t B);
|
||||
|
||||
/**
|
||||
* @brief 打开overwrite功能
|
||||
* @param enable: true-打开overwrite; false-关闭overwrite
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_overwrite_enable(bool enable);
|
||||
|
||||
/**
|
||||
* @brief 设置部分显示
|
||||
* @param enable: true-打开partial显示; false-关闭partial显示
|
||||
* @param par_disp_cfg display区域和背景色设置,参考 dsi_tx_par_dis_t; 关闭模块功能时可以传参NULL
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_partial_disp_enable(bool enable, dsi_tx_par_dis_t *par_disp_cfg);
|
||||
|
||||
/**
|
||||
* @brief 控制TX VPG的输出
|
||||
* @param vpg_en: 使能VPG
|
||||
* @param style: VPG的样式
|
||||
* @param vpg_hline_adj: false-正常情况使用,true-VPG显示滚动情况下使用
|
||||
* @attention vpg_hline_adj此参数只能解决带宽余量相差不大的情况,如果带宽需求超出过多,依然无法解决带宽不足引起的VPG显示滚动问题
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_set_vpg(bool vpg_en, dsi_tx_vpg_style_e style, bool vpg_hline_adj);
|
||||
|
||||
/**
|
||||
* @brief 配置TE模式
|
||||
* @param tx_ctrl_handle: dsi tx handle
|
||||
* @param te: te mode
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_set_tear_mode(hal_dsi_tx_ctrl_handle_t *tx_ctrl_handle, te_mode_e te);
|
||||
|
||||
/**
|
||||
* @brief 生成一个TE信号
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void hal_dsi_tx_ctrl_gen_a_tear_signal(void);
|
||||
|
||||
/**
|
||||
* @brief command mode输出模式下产生一帧数据
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
bool hal_dsi_tx_ctrl_gen_a_frame(void);
|
||||
|
||||
/**
|
||||
* @brief 配置输入输出同步行数,用于调整图像撕裂问题
|
||||
* @param tx_ctrl_handle: dsi tx handle
|
||||
* @param line_num: 同步行号,范围1 ~ output height
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_dsi_tx_ctrl_set_cus_sync_line(hal_dsi_tx_ctrl_handle_t *tx_ctrl_handle, uint32_t line_num);
|
||||
|
||||
/**
|
||||
* @brief 获取TX当前显示行号
|
||||
* @param tx_ctrl_handle: dsi tx handle
|
||||
* @retval 当前显示行号,包括vsa + vbp + vactive + vfp
|
||||
*/
|
||||
uint32_t hal_dsi_tx_ctrl_get_disp_line(hal_dsi_tx_ctrl_handle_t *tx_ctrl_handle);
|
||||
|
||||
#endif //__HAL_DSI_TX_CTRL_H__
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_system.h
|
||||
* Description hal 通用系统接口头文件
|
||||
* Version V0.1
|
||||
* Date 2023-03-03
|
||||
* Author kevin
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_FLASH_H__
|
||||
#define __HAL_FLASH_H__
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t flash_block;
|
||||
uint8_t flash_page;
|
||||
uint16_t data_size;
|
||||
uint16_t page_offset_addr;
|
||||
uint8_t *user_data;
|
||||
} fls_ops_cfg_t;
|
||||
|
||||
/**
|
||||
* @brief 用户空间的操作
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FLASH_USERDATA_READ,
|
||||
} fls_userdata_ops_e;
|
||||
|
||||
|
||||
/**
|
||||
* @brief 公共区域的操作
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FLASH_PUBLIC_READ,
|
||||
FLASH_PUBLIC_WRITE,
|
||||
FLASH_PUBLIC_ERASE_4K,
|
||||
FLASH_PUBLIC_ERASE_32K
|
||||
} fls_public_ops_e;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief 初始化flash 模块,使用完flash模块后需要deinit用于节省功耗
|
||||
* @param
|
||||
* @retval bool 无
|
||||
*/
|
||||
void hal_flash_init(void);
|
||||
|
||||
/**
|
||||
* @brief 关闭flash 模块
|
||||
* @param
|
||||
* @retval bool 无
|
||||
*/
|
||||
void hal_flash_deinit(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief flash ctl读取flash-uid操作
|
||||
* @param UID[16] 存放UID的数组,UID最大长度为16
|
||||
* @param UID 数组长度(最大16)
|
||||
* @retval
|
||||
*/
|
||||
void hal_flash_read_uid(uint8_t *UID, uint8_t size);
|
||||
|
||||
/**
|
||||
* @brief 发送0xAB指令控制flash退出deep sleep power mode
|
||||
* @param none
|
||||
* @retval null
|
||||
*/
|
||||
void hal_flash_release_power_down(void);
|
||||
|
||||
/**
|
||||
* @brief 发送0xB9指令控制flash进入deep sleep power mode
|
||||
* @param none
|
||||
* @retval null
|
||||
*/
|
||||
void hal_flash_power_down(void);
|
||||
|
||||
/**
|
||||
* @brief 配置共享flash开关(使用过后注意关闭,常开功耗会增加)
|
||||
* @param enable:true:可通过F_SPI访问内部flash , false:不可通过F_SPI访问内部flash
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_flash_share_mode(bool enable);
|
||||
|
||||
/**
|
||||
* @brief 获取user_data的个数
|
||||
* @param
|
||||
* @retval 数据个数
|
||||
*/
|
||||
uint32_t hal_flash_get_user_data_size(void);
|
||||
|
||||
/**
|
||||
* @brief Flash user data区域,该区域由烧录器烧录,软件只读,不可写。
|
||||
Size从hal_flash_get_user_data_size接口获取
|
||||
* @param ops:选择操作的方式:读
|
||||
cfg: flash_block: flash block = userdata偏移地址/64K
|
||||
flash_page: flash page = (userdata偏移地址%/64K)/1K
|
||||
page_offset_addr: userdata偏移地址%block(1K),flash page内偏移地址(0-1023)
|
||||
data_size: 读取数据的总长度 (0-1023)
|
||||
user_data: 读取的数据
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_flash_user_region_ops(fls_userdata_ops_e ops, fls_ops_cfg_t *cfg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Flash公共区域,可读写、擦除,大小32KB
|
||||
* @param ops:选择操作的方式:读/写/擦除
|
||||
cfg: flash_block:固定为0
|
||||
flash_page:0-31 (总共32KB)
|
||||
page_offset_addr: flash page内偏移地址(0-1023)
|
||||
data_size: 需要操作数据的总长度 (0-1023)
|
||||
user_data: 需要操作的数据
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_flash_public_region_ops(fls_public_ops_e ops, fls_ops_cfg_t *cfg);
|
||||
#endif //__HAL_FLASH_H__
|
||||
|
|
@ -0,0 +1,725 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_gpio.h
|
||||
* Description: gpio HAL层头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-27
|
||||
* Author: kevin
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_GPIO_H__
|
||||
#define __HAL_GPIO_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_device_datatype.h"
|
||||
#include "tau_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief GPIO pin
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/*以GPIO命名PIN*/
|
||||
IO_PAD_GPIO0 = 0,
|
||||
IO_PAD_GPIO1,
|
||||
IO_PAD_GPIO2,
|
||||
IO_PAD_GPIO3,
|
||||
IO_PAD_GPIO4,
|
||||
IO_PAD_GPIO5,
|
||||
IO_PAD_GPIO6,
|
||||
IO_PAD_GPIO7,
|
||||
IO_PAD_GPIO8,
|
||||
IO_PAD_GPIO9,
|
||||
IO_PAD_GPIO10,
|
||||
IO_PAD_GPIO11,
|
||||
IO_PAD_GPIO12,
|
||||
IO_PAD_GPIO13,
|
||||
IO_PAD_GPIO14,
|
||||
IO_PAD_GPIO15,
|
||||
IO_PAD_GPIO16,
|
||||
IO_PAD_GPIO17,
|
||||
IO_PAD_GPIO18,
|
||||
IO_PAD_GPIO19,
|
||||
IO_PAD_GPIO20,
|
||||
IO_PAD_GPIO21,
|
||||
IO_PAD_GPIO22,
|
||||
IO_PAD_GPIO23,
|
||||
IO_PAD_GPIO24,
|
||||
IO_PAD_GPIO25,
|
||||
|
||||
/*以实际PAD NAME命名PIN*/
|
||||
IO_PAD_AP_SPIS_MISO = IO_PAD_GPIO0,
|
||||
IO_PAD_AP_SPIS_MOSI = IO_PAD_GPIO1,
|
||||
IO_PAD_AP_INT = IO_PAD_GPIO2,
|
||||
IO_PAD_AP_TE = IO_PAD_GPIO3,
|
||||
IO_PAD_AP_SWIRE = IO_PAD_GPIO4,
|
||||
IO_PAD_TD_SPIM_MISO = IO_PAD_GPIO5,
|
||||
IO_PAD_TD_SPIM_MOSI = IO_PAD_GPIO6,
|
||||
IO_PAD_TD_RSTN = IO_PAD_GPIO7,
|
||||
IO_PAD_AP_PWMEN = IO_PAD_GPIO8,
|
||||
IO_PAD_AP_SPIS_CLK = IO_PAD_GPIO9,
|
||||
IO_PAD_AP_SPIS_CSN = IO_PAD_GPIO10,
|
||||
IO_PAD_TD_FC_CLK = IO_PAD_GPIO11,
|
||||
IO_PAD_TD_FC_CSN = IO_PAD_GPIO12,
|
||||
IO_PAD_TD_FC_IO0 = IO_PAD_GPIO13,
|
||||
IO_PAD_TD_FC_IO1 = IO_PAD_GPIO14,
|
||||
IO_PAD_SWD_CLK = IO_PAD_GPIO15,
|
||||
IO_PAD_SWD_DIO = IO_PAD_GPIO16,
|
||||
IO_PAD_AP_RSTN = IO_PAD_GPIO17,
|
||||
IO_PAD_UART0_TX = IO_PAD_GPIO18,
|
||||
IO_PAD_TD_SPIM_CLK = IO_PAD_GPIO19,
|
||||
IO_PAD_TD_SPIM_CSN = IO_PAD_GPIO20,
|
||||
IO_PAD_AP_TPRSTN = IO_PAD_GPIO21,
|
||||
IO_PAD_TD_INT = IO_PAD_GPIO22,
|
||||
IO_PAD_TD_TP_RESX = IO_PAD_GPIO23,
|
||||
IO_PAD_UART1_TX = IO_PAD_GPIO24,
|
||||
IO_PAD_UART0_RX = IO_PAD_GPIO25,
|
||||
|
||||
IO_PAD_MAX,
|
||||
|
||||
|
||||
/*以实际引脚序号命名PIN*/
|
||||
IO_PIN_1 = IO_PAD_SWD_CLK,
|
||||
IO_PIN_2 = IO_PAD_UART0_TX,
|
||||
IO_PIN_3 = IO_PAD_SWD_DIO,
|
||||
IO_PIN_4 = IO_PAD_TD_SPIM_MOSI,
|
||||
IO_PIN_5 = IO_PAD_TD_SPIM_CLK,
|
||||
IO_PIN_6 = IO_PAD_TD_SPIM_CSN,
|
||||
IO_PIN_7 = IO_PAD_TD_SPIM_MISO,
|
||||
IO_PIN_8 = IO_PAD_TD_RSTN,
|
||||
IO_PIN_9 = IO_PAD_TD_FC_CSN,
|
||||
IO_PIN_10 = IO_PAD_TD_FC_CLK,
|
||||
IO_PIN_11 = IO_PAD_TD_FC_IO0,
|
||||
IO_PIN_12 = IO_PAD_TD_FC_IO1,
|
||||
IO_PIN_13 = IO_PAD_TD_TP_RESX,
|
||||
IO_PIN_14 = IO_PAD_UART1_TX,
|
||||
IO_PIN_15 = IO_PAD_AP_SWIRE,
|
||||
IO_PIN_16 = IO_PAD_AP_INT,
|
||||
IO_PIN_17 = IO_PAD_AP_PWMEN,
|
||||
IO_PIN_18 = IO_PAD_AP_TPRSTN,
|
||||
|
||||
IO_PIN_29 = IO_PAD_AP_TE,
|
||||
IO_PIN_30 = IO_PAD_AP_SPIS_MISO,
|
||||
IO_PIN_31 = IO_PAD_AP_SPIS_CSN,
|
||||
IO_PIN_32 = IO_PAD_AP_SPIS_CLK,
|
||||
IO_PIN_33 = IO_PAD_AP_SPIS_MOSI,
|
||||
IO_PIN_34 = IO_PAD_AP_RSTN,
|
||||
IO_PIN_35 = IO_PAD_TD_INT,
|
||||
IO_PIN_36 = IO_PAD_UART0_RX,
|
||||
|
||||
} io_pad_e;
|
||||
|
||||
|
||||
/*
|
||||
芯片引脚 | 默认mode | 可选mode
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_1 | IO_PAD_SWCLK, | PIN1_MODE_SWDCLK
|
||||
| | PIN1_MODE_GPIO15
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_2 | IO_PAD_UART0_TX, | PIN2_MODE_UART0_TX
|
||||
| | PIN2_MODE_PWMO
|
||||
| | PIN2_MODE_GPIO18
|
||||
| | PIN2_MODE_PWMI
|
||||
| | PIN2_MODE_TEAR1
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_3 | IO_PAD_SWDIO, | PIN3_MODE_SWDIO
|
||||
| | PIN3_MODE_GPIO16
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_4 | IO_PAD_TD_SPIM_MOSI, | PIN4_MODE_SPIM_MOSI
|
||||
| | PIN4_MODE_I2C02_SDA
|
||||
| | PIN4_MODE_GPIO6
|
||||
| | PIN4_MODE_UART0_TX
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_5 | IO_PAD_TD_SPIM_CLK, | PIN5_MODE_SPIM_SCLK
|
||||
| | PIN5_MODE_I2C1_SCL
|
||||
| | PIN5_MODE_GPIO19
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_6 | IO_PAD_TD_SPIM_CSN, | PIN6_MODE_SPIM_CSN
|
||||
| | PIN6_MODE_I2C1_SDA
|
||||
| | PIN6_MODE_GPIO20
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_7 | IO_PAD_TD_SPIM_MISO, | PIN7_MODE_SPIM_MISO
|
||||
| | PIN7_MODE_I2C02_SCL
|
||||
| | PIN7_MODE_GPIO5
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_8 | IO_PAD_TD_RSTN, | PIN8_MODE_GPIO7
|
||||
| | PIN8_MODE_I2C02_SDA
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_9 | IO_PAD_TD_FC_CSN, | PIN9_MODE_TSPIS_CSN
|
||||
| | PIN9_MODE_GPIO12
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_10 | IO_PAD_TD_FC_CLK, | PIN10_MODE_TSPIS_CLK
|
||||
| | PIN10_MODE_GPIO11
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_11 | IO_PAD_TD_FC_IO0, | PIN11_MODE_TSPIS_IO0
|
||||
| | PIN11_MODE_GPIO13
|
||||
| | PIN11_MODE_I2C02_SDA
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_12 | IO_PAD_TD_FC_IO1, | PIN12_MODE_TSPIS_IO1
|
||||
| | PIN12_MODE_GPIO14
|
||||
| | PIN12_MODE_I2C02_SCL
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_13 | IO_PAD_TD_TP_RESX, | PIN13_MODE_GPIO23
|
||||
| | PIN13_MODE_PWMO
|
||||
| | PIN13_MODE_UART1_RX
|
||||
| | PIN13_MODE_UART1_RX
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_14 | IO_PAD_UART1_TX, | PIN14_MODE_GPIO24
|
||||
| | PIN14_MODE_UART0_RX
|
||||
| | PIN14_MODE_UART1_TX
|
||||
| |
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_15 | IO_PAD_AP_SWIRE, | PIN15_MODE_SWIRE
|
||||
| | PIN15_MODE_PWMO
|
||||
| | PIN15_MODE_GPIO4
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_16 | IO_PAD_AP_INT, | PIN16_MODE_GPIO2
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_17 | IO_PAD_AP_PWMEN, | PIN17_MODE_UART0_RX
|
||||
| | PIN17_MODE_GPIO8
|
||||
| | PIN17_MODE_PWMO
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_18 | IO_PAD_AP_TPRSTN, | PIN18_MODE_UART0_RX
|
||||
| | PIN18_MODE_GPIO21
|
||||
| | PIN18_MODE_I2C02_SCL
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_29 | IO_PAD_AP_TE, | PIN29_MODE_JTAG_TRSTN
|
||||
| | PIN29_MODE_TEAR
|
||||
| | PIN29_MODE_GPIO3
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_30 | IO_PAD_AP_SPIS_MISO, | PIN30_MODE_JTAG_TDO
|
||||
| | PIN30_MODE_SPIS_MISO
|
||||
| | PIN30_MODE_GPIO0
|
||||
| | PIN30_MODE_UART0_RX
|
||||
| | PIN30_MODE_I2C1_SCL
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_31 | IO_PAD_AP_SPIS_CSN, | PIN31_MODE_JTAG_TMS
|
||||
| | PIN31_MODE_SPIS_CSN
|
||||
| | PIN31_MODE_GPIO10
|
||||
| | PIN31_MODE_I2C02_SDA
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_32 | IO_PAD_AP_SPIS_CLK, | PIN32_MODE_JTAG_TCK
|
||||
| | PIN32_MODE_SPIS_SCLK
|
||||
| | PIN32_MODE_GPIO9
|
||||
| | PIN32_MODE_I2C02_SCL
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_33 | IO_PAD_AP_SPIS_MOSI, | PIN33_MODE_JTAG_TDI
|
||||
| | PIN33_MODE_SPIS_MOSI
|
||||
| | PIN33_MODE_GPIO1
|
||||
| | PIN33_MODE_UART0_TX
|
||||
| | PIN33_MODE_I2C1_SDA_0
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_34 | IO_PAD_AP_RSTN, | PIN34_MODE_GPIO17
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_35 | IO_PAD_TD_INT, | PIN35_MODE_GPIO22
|
||||
----------------------------------------------------------------
|
||||
IO_PIN_36 | IO_PAD_UART0_RX, | PIN36_MODE_UART0_RX
|
||||
| | PIN36_MODE_PWMO
|
||||
| | PIN36_MODE_GPIO25
|
||||
----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief PIN1 IO_PAD_SWD_CLK 可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN1_MODE_SWDCLK = 0,
|
||||
PIN1_MODE_GPIO15 = 2,
|
||||
} pin1_mode_e;
|
||||
|
||||
|
||||
/**
|
||||
* @brief PIN2 PAD_UART0_TX可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN2_MODE_UART0_TX = 0,
|
||||
PIN2_MODE_PWMO = 1,
|
||||
PIN2_MODE_GPIO18 = 2,
|
||||
PIN2_MODE_PWMI = 3,
|
||||
PIN2_MODE_TEAR1 = 4,
|
||||
} pin2_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN3 IO_PAD_SWD_DIO 可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN3_MODE_SWDIO = 0,
|
||||
PIN3_MODE_GPIO16 = 2,
|
||||
} pin3_mode_e;
|
||||
|
||||
|
||||
/**
|
||||
* @brief PIN4 PAD_TD_SPIM_MOSI可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN4_MODE_SPIM_MOSI = 0,
|
||||
PIN4_MODE_I2C02_SDA = 1,
|
||||
PIN4_MODE_GPIO6 = 2,
|
||||
PIN4_MODE_UART0_TX = 3,
|
||||
} pin4_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN5 PAD_TD_SPIM_CLK可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN5_MODE_SPIM_SCLK = 0,
|
||||
PIN5_MODE_I2C1_SCL = 1,
|
||||
PIN5_MODE_GPIO19 = 2,
|
||||
} pin5_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN6 PAD_TD_SPIM_CSN可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN6_MODE_SPIM_CSN = 0,
|
||||
PIN6_MODE_I2C1_SDA = 1,
|
||||
PIN6_MODE_GPIO20 = 2,
|
||||
} pin6_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN7 PAD_TD_SPIM_MISO可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN7_MODE_SPIM_MISO = 0,
|
||||
PIN7_MODE_I2C02_SCL = 1,
|
||||
PIN7_MODE_GPIO5 = 2,
|
||||
} pin7_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN8 PAD_TD_RSTN可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN8_MODE_GPIO7 = 2,
|
||||
PIN8_MODE_I2C02_SDA = 3,
|
||||
} pin8_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN9 PAD_TD_FC_CSN可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN9_MODE_TSPIS_CSN = 0,
|
||||
PIN9_MODE_GPIO12 = 2,
|
||||
} pin9_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN10 PAD_TD_FC_CLK可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN10_MODE_TSPIS_CLK = 0,
|
||||
PIN10_MODE_GPIO11 = 2,
|
||||
} pin10_mode_e;
|
||||
|
||||
|
||||
/**
|
||||
* @brief PIN11 PAD_TD_FC_IO0可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN11_MODE_TSPIS_IO0 = 0,
|
||||
PIN11_MODE_GPIO13 = 2,
|
||||
PIN11_MODE_I2C02_SDA = 3,
|
||||
} pin11_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN12 PAD_TD_FC_IO1可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN12_MODE_TSPIS_IO1 = 0,
|
||||
PIN12_MODE_GPIO14 = 2,
|
||||
PIN12_MODE_I2C02_SCL = 3,
|
||||
} pin12_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN13 PAD_TD_TP_RESX可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN13_MODE_GPIO23 = 2,
|
||||
PIN13_MODE_PWMO = 3,
|
||||
PIN13_MODE_UART1_RX = 4,
|
||||
} pin13_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN14 PAD_UART1_TX可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN14_MODE_GPIO24 = 2,
|
||||
PIN14_MODE_UART0_RX = 3,
|
||||
PIN14_MODE_UART1_TX = 4,
|
||||
} pin14_mode_e;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief PIN15 PAD_AP_SWIRE可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN15_MODE_SWIRE = 0,
|
||||
PIN15_MODE_PWMO = 1,
|
||||
PIN15_MODE_GPIO4 = 2,
|
||||
} pin15_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN16 IO_PAD_AP_INT 可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN16_MODE_GPIO2 = 2,
|
||||
} pin16_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN17 PAD_AP_PWMEN可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN17_MODE_UART0_RX = 1,
|
||||
PIN17_MODE_GPIO8 = 2,
|
||||
PIN17_MODE_PWMO = 3,
|
||||
} pin17_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN18 IO_PAD_AP_TPRSTN 可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN18_MODE_UART0_RX = 0,
|
||||
PIN18_MODE_GPIO21 = 2,
|
||||
PIN18_MODE_I2C02_SCL = 3,
|
||||
} pin18_mode_e;
|
||||
|
||||
|
||||
//----------
|
||||
|
||||
/**
|
||||
* @brief PIN29 IO_PAD_AP_TE 可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN29_MODE_JTAG_TRSTN = 0,
|
||||
PIN29_MODE_TEAR = 1,
|
||||
PIN29_MODE_GPIO3 = 2,
|
||||
} pin29_mode_e;
|
||||
|
||||
|
||||
/**
|
||||
* @brief PIN30 IO_PAD_AP_SPIS_MISO 可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN30_MODE_JTAG_TDO = 0,
|
||||
PIN30_MODE_SPIS_MISO = 1,
|
||||
PIN30_MODE_GPIO0 = 2,
|
||||
PIN30_MODE_UART0_RX = 3,
|
||||
PIN30_MODE_I2C1_SCL = 6,
|
||||
} pin30_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN31 IO_PAD_AP_SPIS_CSN 可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN31_MODE_JTAG_TMS = 0,
|
||||
PIN31_MODE_SPIS_CSN = 1,
|
||||
PIN31_MODE_GPIO10 = 2,
|
||||
PIN31_MODE_I2C02_SDA = 3,
|
||||
} pin31_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN32 IO_PAD_AP_SPIS_CLK 可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN32_MODE_JTAG_TCK = 0,
|
||||
PIN32_MODE_SPIS_SCLK = 1,
|
||||
PIN32_MODE_GPIO9 = 2,
|
||||
PIN32_MODE_I2C02_SCL = 3,
|
||||
} pin32_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN33 IO_PAD_AP_SPIS_MOSI 可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN33_MODE_JTAG_TDI = 0,
|
||||
PIN33_MODE_SPIS_MOSI = 1,
|
||||
PIN33_MODE_GPIO1 = 2,
|
||||
PIN33_MODE_UART0_TX = 3,
|
||||
PIN33_MODE_I2C1_SDA_0 = 6,
|
||||
} pin33_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PIN34 PAD_AP_RST可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN34_MODE_GPIO17 = 2,
|
||||
} pin34_mode_e;
|
||||
|
||||
|
||||
/**
|
||||
* @brief PIN35 PAD_TD_INT可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN35_MODE_GPIO22 = 2,
|
||||
} pin35_mode_e;
|
||||
|
||||
|
||||
/**
|
||||
* @brief PIN36 PAD_UART_RX可选的mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PIN36_MODE_UART0_RX = 0,
|
||||
PIN36_MODE_PWMO = 1,
|
||||
PIN36_MODE_GPIO25 = 2,
|
||||
} pin36_mode_e;
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief PAD_SFC_CLK可选的mode 内部PAD
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
IO_MODE_INTER_FC_CLK = 0,
|
||||
IO_MODE_TSPIS_CLK_EN = 2,
|
||||
} pad_sfc_clk_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PAD_SFC_CSN可选的mode 内部PAD
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
IO_MODE_INTER_FC_CSN = 0,
|
||||
IO_MODE_TSPIS_CSN_EN = 2,
|
||||
} pad_sfc_csn_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PAD_SFC_IO0可选的mode 内部PAD
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
IO_MODE_INTER_FC_IO0 = 0,
|
||||
IO_MODE_TSPIS_IO0_EN = 2,
|
||||
} pad_sfc_io0_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PAD_SFC_IO1可选的mode 内部PAD
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
IO_MODE_INTER_FC_IO1 = 0,
|
||||
IO_MODE_TSPIS_IO1_EN = 2,
|
||||
} pad_sfc_io1_mode_e;
|
||||
|
||||
/**
|
||||
* @brief PAD电压转换速率
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
IO_SLEW_RATE_SLOW = 0,
|
||||
IO_SLEW_RATE_FAST = 1,
|
||||
} pad_slew_rate_e;
|
||||
|
||||
/*******************************************************************************
|
||||
* IOE
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief GPIO io方向
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
IO_IOE_INPUT = 0,
|
||||
IO_IOE_OUTPUT,
|
||||
IO_IOE_NONE
|
||||
} gpio_ioe_e;
|
||||
|
||||
/**
|
||||
* @brief GPIO level
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
IO_LVL_LOW = 0,
|
||||
IO_LVL_HIGH,
|
||||
IO_LVL_NONE
|
||||
} gpio_level_e;
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief PAD与MODE的MAP结构体
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
io_pad_e pad;
|
||||
uint8_t mode;
|
||||
gpio_ioe_e ioe;
|
||||
gpio_level_e lvl;
|
||||
} io_pad_attr_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief 配置指定PAD为GPIO mode,方向为input,指定中断触发方式
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @param trig:4种中断触发方式,参考枚举类型sys_cfg_trigger_e
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_init_eint(io_pad_e pad, sys_cfg_trigger_e trig);
|
||||
|
||||
/**
|
||||
* @brief 注册GPIO中断回调函数
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @param cb_func:回调函数地址
|
||||
* @param data:回调函数参数地址
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_reg_eint_cb(io_pad_e pad, fcb_type cb_func);
|
||||
|
||||
/**
|
||||
* @brief 开关GPIO中断
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @param state:开关控制
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_ctrl_eint(io_pad_e pad, bool state);
|
||||
|
||||
/**
|
||||
* @brief 获取GPIO中断类型
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @retval 无
|
||||
*/
|
||||
gpio_int_e hal_gpio_get_int_type(io_pad_e pad);
|
||||
|
||||
/**
|
||||
* @brief 配置指定PAD为GPIO mode,方向为output,指定初始电平
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @param lvl:初始电平,参考枚举类型gpio_level_e
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_init_output(io_pad_e pad, gpio_level_e lvl);
|
||||
|
||||
/**
|
||||
* @brief 封装设置输出接口
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @param lvl:初始电平,参考枚举类型gpio_level_e
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_set_output_data(io_pad_e pad, gpio_level_e lvl);
|
||||
|
||||
/**
|
||||
* @brief 配置指定PAD为GPIO mode,方向为input
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_init_input(io_pad_e pad);
|
||||
|
||||
/**
|
||||
* @brief 读取输入电平
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @retval 无
|
||||
*/
|
||||
gpio_level_e hal_gpio_get_input_data(io_pad_e pad);
|
||||
|
||||
/**
|
||||
* @brief 设置io mode
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @param mode:工作模式,参考各PAD对应的mode枚举类型
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_set_mode(io_pad_e pad, uint8_t mode);
|
||||
|
||||
/**
|
||||
* @brief 设置io 为高阻态
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_set_high_impedance(io_pad_e pad);
|
||||
|
||||
/**
|
||||
* @brief 获取指定PAD的默认上拉、下拉状态
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @param up_enable:默认上拉状态
|
||||
* @param down_enable:默认下拉状态
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_get_pull_state(io_pad_e pad, bool *up_enable, bool *down_enable);
|
||||
|
||||
/**
|
||||
* @brief 配置指定PAD的默认上拉、下拉状态
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @param up_enable:默认上拉状态
|
||||
* @param down_enable:默认下拉状态
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_set_pull_state(io_pad_e pad, bool up_enable, bool down_enable);
|
||||
|
||||
/**
|
||||
* @brief 配置指定PAD是否为施密特触发
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @param st_enable:1为施密特触发,0为正常触发
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_set_schmitt_trigger(io_pad_e pad, bool st_enable);
|
||||
|
||||
/**
|
||||
* @brief 配置指定PAD的驱动能力
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @param strength:驱动强度,取值为0~3
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_set_driving_strength(io_pad_e pad, uint8_t strength);
|
||||
|
||||
/**
|
||||
* @brief 配置指定PAD的电压转换速率
|
||||
* @param pad:GPIO序号,参考枚举类型gpio_pad_e
|
||||
* @param rate:驱动强度,取值为0~3
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_set_slew_rate(io_pad_e pad, pad_slew_rate_e rate);
|
||||
|
||||
/**
|
||||
* @brief 配置AP_RSTN引脚中断
|
||||
* @param enable: 中断开关
|
||||
* @param cb_func:回调函数
|
||||
* @param trig:触发模式
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_set_ap_reset_int(bool enable, fcb_type cb_func, sys_cfg_trigger_e trig);
|
||||
|
||||
/**
|
||||
* @brief 批量设置IO参数
|
||||
* @param attrs: PAD属性
|
||||
* @param size: 数组成员个数
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_gpio_config_pad(io_pad_attr_t *attrs, uint8_t size);
|
||||
|
||||
#endif /* __HAL_GPIO_H__ */
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2021-2025, All Rights Reserved.
|
||||
*
|
||||
* File: hal_i2c_master.h
|
||||
* Description hal i2c master模块接口头文件
|
||||
* Version V0.1
|
||||
* Date 2023-07-27
|
||||
* Author swx
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_I2C_MASTER_H__
|
||||
#define __HAL_I2C_MASTER_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_device_datatype.h"
|
||||
#include "tau_common.h"
|
||||
#include "string.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief hal_i2cm_init
|
||||
* @param index: I2Cx index
|
||||
* @param slave_addr: 从机地址
|
||||
* @param addr_bits: 从机地址位数
|
||||
* @param i2c_m_speed_hz: 主机速率设置
|
||||
* @retval none
|
||||
*/
|
||||
void hal_i2cm_init(i2c_index_e index, uint16_t slave_addr, uint8_t addr_bits, uint32_t i2cm_speed_hz);
|
||||
|
||||
/**
|
||||
* @brief hal_i2cm_deinit
|
||||
* @param index: I2Cx index
|
||||
* @retval none
|
||||
*/
|
||||
void hal_i2cm_deinit(i2c_index_e index);
|
||||
|
||||
/**
|
||||
* @brief hal_i2cm_set_slave_addr
|
||||
* @param index: I2Cx index
|
||||
* @param slave_addr: 从机地址
|
||||
* @param addr_bits: 从机地址位数
|
||||
* @retval none
|
||||
*/
|
||||
void hal_i2cm_set_slave_addr(i2c_index_e index, uint16_t slave_addr, uint8_t addr_bits);
|
||||
|
||||
/**
|
||||
* @brief i2c master 发送数据
|
||||
* @param index: I2Cx index
|
||||
* @param tx_buffer: 发送数据buffer
|
||||
* @param tx_size: 发送数据个数
|
||||
* @retval true/false: 成功/失败
|
||||
*/
|
||||
bool hal_i2cm_write(i2c_index_e index, const uint8_t *tx_buffer, uint32_t tx_size);
|
||||
|
||||
/**
|
||||
* @brief i2c master 接收数据
|
||||
* @param index: I2Cx index
|
||||
* @param reg_address:寄存器地址
|
||||
* @param reg_size: 寄存器地址size
|
||||
* @param rx_buffer: 接收数据buffer
|
||||
* @param rx_size: 接收数据个数
|
||||
* @retval true/false: 成功/失败
|
||||
*/
|
||||
bool hal_i2cm_read(i2c_index_e index, uint32_t reg_address, size_t reg_size, uint8_t *rx_buffer, size_t rx_size);
|
||||
|
||||
/**
|
||||
* @brief i2c master 多地址参数接收数据
|
||||
* @param index: I2Cx index
|
||||
* @param reg_address:寄存器地址
|
||||
* @param reg_size: 寄存器地址size
|
||||
* @param rx_buffer: 接收数据buffer
|
||||
* @param rx_size: 接收数据个数
|
||||
* @retval true/false: 成功/失败
|
||||
*/
|
||||
bool hal_i2cm_multi_params_read(i2c_index_e index, uint8_t *reg_address, size_t reg_size, uint8_t *rx_buffer, size_t rx_size);
|
||||
|
||||
/**
|
||||
* @brief i2c master dma 发送数据
|
||||
* @param index: I2Cx index
|
||||
* @param tx_buffer: 发送数据buffer
|
||||
* @param tx_size: 发送数据个数
|
||||
* @retval true: 数据已排入 DMA 通道,但不一定全部发送
|
||||
* false:发送出错,需要重新调用函数发送
|
||||
*/
|
||||
bool hal_i2cm_dma_write(i2c_index_e index, const uint8_t *tx_buffer, uint32_t tx_size);
|
||||
|
||||
/**
|
||||
* @brief i2c master dma 接收数据
|
||||
* @param index: I2Cx index
|
||||
* @param reg_address:寄存器地址
|
||||
* @param reg_size: 寄存器地址size
|
||||
* @param rx_buffer: 接收数据buffer
|
||||
* @param rx_size: 接收数据个数
|
||||
* @retval true:寄存器地址发送成功,并已配置DMA接收通道,但不一定完成接收
|
||||
* false:接收出错,需要重新调用函数接收
|
||||
*/
|
||||
bool hal_i2cm_dma_read(i2c_index_e index, uint32_t reg_address, size_t reg_size, uint8_t *rx_buffer, size_t rx_size);
|
||||
|
||||
/**
|
||||
* @brief i2c master dma 多地址参数接收数据
|
||||
* @param index: I2Cx index
|
||||
* @param reg_address:寄存器地址
|
||||
* @param reg_size: 寄存器地址size
|
||||
* @param rx_buffer: 接收数据buffer
|
||||
* @param rx_size: 接收数据个数
|
||||
* @retval true:寄存器地址发送成功,并已配置DMA接收通道,但不一定完成接收
|
||||
* false:接收出错,需要重新调用函数接收
|
||||
*/
|
||||
bool hal_i2cm_multi_params_dma_read(i2c_index_e index, uint8_t *reg_address, size_t reg_size, uint8_t *rx_buffer, size_t rx_size);
|
||||
|
||||
/**
|
||||
* @brief 获取 i2c master 发送状态
|
||||
* @param index: I2Cx index
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_i2cm_get_transfer_complete(i2c_index_e index);
|
||||
|
||||
#endif /* __HAL_I2C_MASTER_H__*/
|
||||
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2021-2025, All Rights Reserved.
|
||||
*
|
||||
* File: hal_i2c_slave.h
|
||||
* Description hal i2c slave模块接口头文件
|
||||
* Version V0.1
|
||||
* Date 2023-07-27
|
||||
* Author swx
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_I2C_SLAVE_H__
|
||||
#define __HAL_I2C_SLAVE_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_device_datatype.h"
|
||||
#include "tau_common.h"
|
||||
#include "string.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief i2cs event packet info
|
||||
*/
|
||||
typedef struct hal_i2cs_packet_info_t
|
||||
{
|
||||
uint8_t *rx_buffer; /* 接收buffer */
|
||||
uint32_t rx_buffer_size; /* 接收buffer size */
|
||||
const uint8_t *tx_buffer; /* 发送buffer */
|
||||
uint32_t tx_buffer_size; /* 发送buffer size */
|
||||
bool tx_circle; /* 发送circle mode */
|
||||
uint32_t packet_size; /* packet size : READ、RST、STOP中断事件时整个传输过程中I2CM发送packet的总量 */
|
||||
} hal_i2cs_packet_info_t;
|
||||
|
||||
/**
|
||||
* @brief i2cs event
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
I2CS_EVENT_READ = 0, //发生 读请求 中断
|
||||
I2CS_EVENT_RST, //发生 restart 中断
|
||||
I2CS_EVENT_STOP //发生 stop 中断
|
||||
} hal_i2cs_event_e;
|
||||
|
||||
typedef void (*hal_i2cs_cb)(i2c_index_e index, hal_i2cs_event_e event, size_t receive_num);
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief hal_i2cs_init
|
||||
* @param index: I2Cx index
|
||||
* @param slave_addr: 从机地址
|
||||
* @param addr_bits: 从机地址位数
|
||||
* @retval none
|
||||
*/
|
||||
void hal_i2cs_init(i2c_index_e index, uint16_t slave_addr, uint8_t addr_bits);
|
||||
|
||||
/**
|
||||
* @brief hal_i2cs_deinit
|
||||
* @param index: I2Cx index
|
||||
* @retval none
|
||||
*/
|
||||
void hal_i2cs_deinit(i2c_index_e index);
|
||||
|
||||
/**
|
||||
* @brief hal_i2cs_set_continue_transfer
|
||||
* @param index: I2Cx index
|
||||
* @param status: true/false
|
||||
* @retval none
|
||||
*/
|
||||
void hal_i2cs_set_continue_transfer(i2c_index_e index, bool status);
|
||||
|
||||
/**
|
||||
* @brief 获取i2c slave发送成功字节数
|
||||
* 注意这是通信过程i2c slave发送的数据量,如果更新了i2c slave的tx_buffer,则清零
|
||||
* @param index: I2Cx index
|
||||
* @retval 发送总字节数
|
||||
*/
|
||||
uint32_t hal_i2cs_get_tx_cnt(i2c_index_e index);
|
||||
|
||||
/**
|
||||
* @brief 获取 i2c slave 接收数量
|
||||
* 注意这是通信过程i2c slave接收的数据量,如果更新了i2c slave的rx_buffer,则清零
|
||||
* @param index: I2Cx index
|
||||
* @retval 数据接收数量
|
||||
*/
|
||||
uint32_t hal_i2cs_get_rx_cnt(i2c_index_e index);
|
||||
|
||||
/**
|
||||
* @brief 清零 i2c slave 接收数量
|
||||
* @param index: I2Cx index
|
||||
* @retval none
|
||||
*/
|
||||
void hal_i2cs_rx_cnt_clear(i2c_index_e index);
|
||||
|
||||
/**
|
||||
* @brief 获取 i2c slave 发送状态
|
||||
* @param index: I2Cx index
|
||||
* @retval true:数据发送完成
|
||||
* false:数据还在发送
|
||||
*/
|
||||
bool hal_i2cs_get_write_complete(i2c_index_e index);
|
||||
|
||||
/**
|
||||
* @brief i2c slave 注册回调函数
|
||||
* @param index: I2Cx index
|
||||
* @param cb:call back
|
||||
* @retval
|
||||
*/
|
||||
void hal_i2cs_register_callback(i2c_index_e index, hal_i2cs_cb cb);
|
||||
|
||||
/**
|
||||
* @brief i2c slave 配置接收buffer, 底层自动接收数据后调用callback
|
||||
* @param index: I2Cx index
|
||||
* @param rx_buffer:自动模式数据接收buffer
|
||||
* @param rx_size: 自动模式数据接收buffer size
|
||||
* @retval none
|
||||
*/
|
||||
void hal_i2cs_update_rx_buffer(i2c_index_e index, uint8_t *rx_buffer, size_t rx_size);
|
||||
|
||||
/**
|
||||
* @brief i2c slave 配置自动发送buffer
|
||||
* @param index: I2Cx index
|
||||
* @param tx_buffer:自动模式数据发送buffer
|
||||
* @param tx_size: 自动模式数据发收buffer size
|
||||
* @param circle:circle mode,重复发送buffer的数据
|
||||
* @retval none
|
||||
*/
|
||||
void hal_i2cs_update_tx_buffer(i2c_index_e index, const uint8_t *tx_buffer, uint32_t tx_size, bool circle);
|
||||
|
||||
/**
|
||||
* @brief i2c slave 启动
|
||||
* @param index: I2Cx index
|
||||
* @retval none
|
||||
*/
|
||||
void hal_i2cs_start(i2c_index_e index);
|
||||
|
||||
/**
|
||||
* @brief i2c slave 停止
|
||||
* @param index: I2Cx index
|
||||
* @retval none
|
||||
*/
|
||||
void hal_i2cs_stop(i2c_index_e index);
|
||||
|
||||
#endif /* __HAL_I2C_SLAVE_H__*/
|
||||
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_pwm.h
|
||||
* Description: pwm HAL层头文件
|
||||
* Version: V0.1
|
||||
* Date: 2021-03-17
|
||||
* Author: jaya
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_PWM_H__
|
||||
#define __HAL_PWM_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_device_datatype.h"
|
||||
#include "tau_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief pwm 初始化
|
||||
* @param frequency: PWM 频率 < 30000 (30K)
|
||||
* @param duty_step: 占空比调试阶数,与硬件相关,不能超过硬件限制(建议配置255)
|
||||
最大阶数 = (1000000000/130)/frequency,常见如下
|
||||
frequency, max step(最大step可配置)
|
||||
{ 30000, 255 }
|
||||
{ 4000, 1923}
|
||||
{ 3000, 2564}
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_pwm_init(uint32_t frequency, uint32_t duty_step);
|
||||
|
||||
/**
|
||||
* @brief pwm 启动停止控制
|
||||
* @param enable: 启动/停止
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwm_enable(bool enable);
|
||||
|
||||
/**
|
||||
* @brief pwm 设置占空比
|
||||
* @param duty_ratio: 占空比,范围为0 - duty_step(hal_pwm_init配置的参数)
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwm_set_duty(uint32_t duty_ratio);
|
||||
|
||||
/**
|
||||
* @brief pwm 配置从elvcc直接输出背光电源
|
||||
* @param enable: ELVCC输出启停
|
||||
* @retval none
|
||||
*/
|
||||
bool hal_pwm_set_elvcc_output(bool enable);
|
||||
|
||||
/**
|
||||
* @brief 配置elvcc PWM 驱动背光能力,范围 0 - 15, capactiy为15时驱动能力最强,ELVCC输出电流最大
|
||||
* @param capacity: 0 - 15,hal_pwm_set_elvcc_output配置时会恢复默认值15
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwm_set_elvcc_capacity(uint8_t capacity);
|
||||
|
||||
/**
|
||||
* @brief pwm 去初始化
|
||||
* @param none
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_pwm_deinit(void);
|
||||
|
||||
#endif /* __HAL_PWM_H__ */
|
||||
|
|
@ -0,0 +1,325 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_pwr.h
|
||||
* Description: pwr hal层头文件
|
||||
* Version: V0.1
|
||||
* Date: 2023-07-21
|
||||
* Author: lyw
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_PWR_H__
|
||||
#define __HAL_PWR_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_device_datatype.h"
|
||||
#include "tau_common.h"
|
||||
#include "hal_gpio.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief IC主供电电源选择
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PWR_SEL_IOV18 = 0, /* IC选择IOV18主供电(默认值) */
|
||||
PWR_SEL_TP18 = 1, /* IC选择TP18主供电 */
|
||||
PWR_SEL_VCC = 2, /* IC选择VCC主供电 */
|
||||
PWR_SEL_VDD13CP = 3, /* IC选择VDD13CP外接电源主供电*/
|
||||
} pwr_main_power_sel_e;
|
||||
|
||||
/**
|
||||
* @brief Sleep mode 供电模式
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PWR_SLEEP_IN_NON = 0, /* Sleep Mode期间无外部供电(默认值) */
|
||||
PWR_SLEEP_IN_TP18 = 1, /* Sleep Mode期间TP18有电,其他电源掉电或不存在 */
|
||||
PWR_SLEEP_IN_VCC = 2, /* Sleep Mode期间VCC有电,其他电源掉电或不存在 */
|
||||
PWR_SLEEP_IN_VCC_TP18 = 3, /* Sleep Mode期间TP18与VCC有电,其他电源掉电或不存在 */
|
||||
PWR_SLEEP_IN_IOV18 = 4, /* Sleep Mode期间IOV18有电,其他电源掉电或不存在 */
|
||||
PWR_SLEEP_IN_IOV18_TP18 = 5, /* Sleep Mode期间IOV18与TP18有电,其他电源掉电或不存在 */
|
||||
PWR_SLEEP_IN_IOV18_VCC = 6, /* Sleep Mode期间IOV18与VCC有电,其他电源掉电或不存在 */
|
||||
PWR_SLEEP_IN_IOV18_VCC_TP18 = 7, /* Sleep Mode期间IOV18、TP18、VCC均有电,其他电源掉电或不存在 */
|
||||
} pwr_sleep_power_sel_e;
|
||||
|
||||
/**
|
||||
* @brief sleep mode 唤醒沿配置
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
WUP_RISING_EDGE = 2, /* 上升沿唤醒 */
|
||||
WUP_FALLING_EDGE = 3 /* 下降沿唤醒 */
|
||||
} pwr_wakeup_trigger_e;
|
||||
|
||||
/**
|
||||
* @brief 软件启动原因
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RF_POWER_ON = 0, /* Power On,正常上电 */
|
||||
RF_CORE_RST = 1, /* 软件reset, 调用NVIC_SystemReset产生reset */
|
||||
RF_WDT_RST = 2, /* WDT reset */
|
||||
RF_CHIP_RST = 3, /* Chip reset,调用hal_system_reset_chip产生的reset */
|
||||
RF_APRSTN_WAKEUP = 4, /* deep sleep mode 下AP_RSTN reset */
|
||||
RF_TDINT_WAKEUP = 5 /* deep sleep mode 下TD_INT reset */
|
||||
} pwr_reset_flag_e;
|
||||
|
||||
/**
|
||||
* @brief pwr sleep mode type
|
||||
* 不同sleep mode具体应用场景见《PWR说明文档》
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PWR_NORMAL_SLEEP_MODE = 0, /* 待机下需要处理外设(I2C)等事件使用,调用hal_pwr_enter_normal_sleep_mode 进入,hal_pwr_exit_sleep_mode退出 */
|
||||
PWR_STOP_SLEEP_MODE = 1, /* 待机下需要通过任意GPIO唤醒时使用此模式,进入之前关闭所有模块以及MCU,通过hal_pwr_set_stop_sleep_wakeup_pin 注册GPIO中唤醒源,调用hal_pwr_enter_stop_sleep_mode 进入,hal_pwr_exit_sleep_mode退出 */
|
||||
PWR_DEEP_SLEEP_MODE = 2 /* 待机下只需要通过AP RSTN跟TD INT引脚唤醒使用时使用此模式,调用hal_pwr_enter_deep_sleep_mode 唤醒后重启,通过hal_pwr_get_reset_flag确定唤醒源 */
|
||||
} pwr_sleep_mode_e;
|
||||
|
||||
/*! @brief HV LDO输出电压配置*/
|
||||
typedef enum _pwr_hv_ldo_e
|
||||
{
|
||||
HV_LDO_0 = 0, /*1.20V*/
|
||||
HV_LDO_1 = 1, /*1.26V*/
|
||||
HV_LDO_2 = 2, /*1.32V*/
|
||||
HV_LDO_3 = 3, /*1.38V*/
|
||||
HV_LDO_4 = 4, /*1.44V*/
|
||||
HV_LDO_5 = 5, /*1.50V*/
|
||||
HV_LDO_6 = 6, /*1.56V*/
|
||||
HV_LDO_7 = 7, /*1.62V*/
|
||||
HV_LDO_8 = 8, /*1.68V*/
|
||||
HV_LDO_9 = 9, /*1.74V*/
|
||||
HV_LDO_10 = 10, /*1.80V*/
|
||||
HV_LDO_11 = 11, /*1.86V*/
|
||||
HV_LDO_12 = 12, /*2.04V*/
|
||||
HV_LDO_13 = 13, /*2.46V*/
|
||||
HV_LDO_14 = 14, /*3.00V*/
|
||||
HV_LDO_15 = 15, /*3.30V*/
|
||||
} pwr_hv_ldo_e;
|
||||
|
||||
/*! @brief LDO 13S输出电压配置*/
|
||||
typedef enum _pwr_ldo_13s_e
|
||||
{
|
||||
LDO_13S_0 = 0, /*1.22V*/
|
||||
LDO_13S_1 = 1, /*1.25V*/
|
||||
LDO_13S_2 = 2, /*1.27V*/
|
||||
LDO_13S_3 = 3, /*1.30V*/
|
||||
LDO_13S_4 = 4, /*1.33V*/
|
||||
LDO_13S_5 = 5, /*1.37V*/
|
||||
LDO_13S_6 = 6, /*1.40V*/
|
||||
LDO_13S_7 = 7, /*1.43V*/
|
||||
} pwr_ldo_13s_e;
|
||||
|
||||
/*! @brief LDO 18S输出电压配置*/
|
||||
typedef enum _pwr_ldo_18s_e
|
||||
{
|
||||
LDO_18S_0 = 0, /*1.61V*/
|
||||
LDO_18S_1 = 1, /*1.64V*/
|
||||
LDO_18S_2 = 2, /*1.67V*/
|
||||
LDO_18S_3 = 3, /*1.70V*/
|
||||
LDO_18S_4 = 4, /*1.74V*/
|
||||
LDO_18S_5 = 5, /*1.77V*/
|
||||
LDO_18S_6 = 6, /*1.80V*/
|
||||
LDO_18S_7 = 7, /*1.83V*/
|
||||
} pwr_ldo_18s_e;
|
||||
|
||||
/*! @brief PWR PVD index */
|
||||
typedef enum
|
||||
{
|
||||
PVD_IOVCC = 3,
|
||||
PVD_VCI = 15,
|
||||
} pwr_pvd_index_e;
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief IC主供电选择,如果是配置vcc主供电,可通过hal_pwr_get_vcc_power_ready获取电源状态
|
||||
* 注:上电只能配置一次,不可随意切换
|
||||
* @param power_sel 主供电选择,见枚举描述
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwr_set_main_power(pwr_main_power_sel_e power_sel);
|
||||
|
||||
/**
|
||||
* @brief 获取VCC电源稳定状态,使用hal_pwr_set_main_power切换电源后,通过此接口获取电源稳定状态
|
||||
* eg: 使用hal_pwr_set_main_power切换至VCC主供电,在VCC电源接口上电之前,此接口返回值为false
|
||||
* @param None
|
||||
* @retval true-电源切换完成 false-电源未切换完成
|
||||
*/
|
||||
bool hal_pwr_get_vcc_power_ready(void);
|
||||
|
||||
/**
|
||||
* @brief 配置VCC开关,芯片启动默认打开VCC CP,不存在VCC的情况下可关闭
|
||||
* @param enable: true:打开CP, false:关闭CP
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwr_set_vcc_enable(bool enable);
|
||||
|
||||
/**
|
||||
* @brief sleep mode 期间电源情况配置
|
||||
* 调用sleep mode之前配置,根据配置情况在sleep mode自动切换电源
|
||||
* exit sleep mode后切换回hal_pwr_set_main_power的电源
|
||||
* @param powerin =000 息屏期间状态,IOV18掉电0,VCC掉电0,TP18也掉电0;
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwr_set_sleep_mode_power(pwr_sleep_power_sel_e power_sel);
|
||||
|
||||
/**
|
||||
* @brief 进入normal sleep mode 模式(详细使用方法见《PWR说明文档》)
|
||||
* 待机下需要处理外设(I2C)等事件使用,图像通路关闭,MCU&外设正常运行
|
||||
* 调用hal_pwr_exit_sleep_mode退出
|
||||
* @param none
|
||||
* @retval bool true/false
|
||||
*/
|
||||
bool hal_pwr_enter_normal_sleep_mode(void);
|
||||
|
||||
/**
|
||||
* @brief 进入stop sleep mode 模式(详细使用方法见《PWR说明文档》)
|
||||
* 待机下需要通过任意GPIO唤醒时使用此模式,进入之前关闭所有模块,通过hal_pwr_set_stop_sleep_wakeup_pin 注册GPIO中唤醒源。
|
||||
* 调用此接口后MCU会停止运行,等待中断唤醒后该函数才返回,调用hal_pwr_exit_sleep_mode真正退出stop sleep mode
|
||||
* @param none
|
||||
* @retval io_pad_e:唤醒接口
|
||||
*/
|
||||
io_pad_e hal_pwr_enter_stop_sleep_mode(void);
|
||||
|
||||
/**
|
||||
* @brief 注册 stop sleep mode 唤醒IO (详细使用方法见文档)
|
||||
* @param pad :Pin name
|
||||
* @param trig:唤醒触发模式
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_pwr_set_stop_sleep_wakeup_pin(io_pad_e pad, pwr_wakeup_trigger_e trig);
|
||||
|
||||
/**
|
||||
* @brief 进入deep sleep mode 模式, 等待AP_RSTN 或者TD_INT 唤醒
|
||||
* 待机下只需要通过AP RSTN跟TD INT引脚唤醒使用时使用此模式,唤醒后重启,通过hal_pwr_get_reset_flag确定唤醒源
|
||||
* 注意, 如果需要使用deep sleep mode,TD INT引脚不能悬空,必须有上拉或者下拉保证确定电平,否则会导致误唤醒
|
||||
* @param polarity true:上升沿唤醒 false:下降沿唤醒
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwr_enter_deep_sleep_mode(pwr_wakeup_trigger_e ap_rstn_trig, pwr_wakeup_trigger_e td_int_trig);
|
||||
|
||||
/**
|
||||
* @brief 退出sleep mode, normal/stop sleep mode都需要通过此接口退出
|
||||
* @param none
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_pwr_exit_sleep_mode(void);
|
||||
|
||||
/**
|
||||
* @brief 获取系统复位原因
|
||||
* @param none
|
||||
* @retval reset flag,见pwr_reset_flag_e
|
||||
*/
|
||||
pwr_reset_flag_e hal_pwr_get_reset_flag(void);
|
||||
|
||||
/**
|
||||
* @brief 打开ELVCC作为供电电源
|
||||
* @param none
|
||||
* @retval
|
||||
*/
|
||||
void hal_pwr_elvcc_ldo_en(bool enable);
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @param HV LDO输出电压配置
|
||||
=0000:1.20V,
|
||||
=0001:1.26V,
|
||||
=0010:1.32V,
|
||||
=0011:1.38V,
|
||||
=0100:1.44V,
|
||||
=0101:1.50V,
|
||||
=0110:1.56V,
|
||||
=0111:1.62V,
|
||||
=1000:1.68V,
|
||||
=1001:1.74V,
|
||||
=1010:1.80V,
|
||||
=1011:1.86V,
|
||||
=1100:2.04V,
|
||||
=1101:2.46V,
|
||||
=1110:3.00V,
|
||||
=1111:3.30V
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwr_elvcc_vol_set(pwr_hv_ldo_e voltage);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @param LDO18_S模块使能控制,=0关闭,默认关闭;=1开启
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwr_ldo18s_en(bool enable);
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @param LDO18_S输出电压配置,
|
||||
000=1.61V
|
||||
001=1.64V
|
||||
010=1.67V
|
||||
011=1.70V
|
||||
100=1.74V
|
||||
101=1.77V
|
||||
110=1.80V
|
||||
111=1.83V
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwr_ldo18s_set(pwr_ldo_18s_e voltage);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @param LDO13_S模块使能控制,=0关闭,默认关闭;=1开启
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwr_ldo13s_en(bool enable);
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @param LDO13_S输出电压配置,
|
||||
000=1.22V,
|
||||
001=1.25V,
|
||||
010=1.27V,
|
||||
011=1.30V,
|
||||
100=1.33V,
|
||||
101=1.37V,
|
||||
110=1.40V,
|
||||
111=1.43V
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwr_ldo13s_set(pwr_ldo_13s_e voltage);
|
||||
|
||||
/**
|
||||
* @brief PVD(电源检查)开关接口,
|
||||
* PVD默认均为打开,注意!电源切换(如主供电切换,进出sleep mode)必须打开PVD!
|
||||
* @param index: PVD选择 IOVCC/VCI
|
||||
* @param enable: PVD开关
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwr_set_pvd(pwr_pvd_index_e index, bool enable);
|
||||
|
||||
/**
|
||||
* @brief 使能TP18给VDD18供电
|
||||
* @warning info!!! 1:进入休眠的电源要选择TP18供电 eg: hal_pwr_set_sleep_mode_power(PWR_SLEEP_IN_TP18);
|
||||
* @warning info!!! 2:唤醒之后,关闭改使能 eg: hal_pwr_sw_tp18_en(DISENABLE);
|
||||
* @param enable:
|
||||
* @retval none
|
||||
*/
|
||||
void hal_pwr_sw_tp18_en(bool enable);
|
||||
|
||||
|
||||
|
||||
#endif /* __HAL_PWR_H__ */
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2021-2025, All Rights Reserved.
|
||||
*
|
||||
* File: hal_spi_master.h
|
||||
* Description hal spi masrer模块头文件
|
||||
* Version V0.1
|
||||
* Date 2023-07-27
|
||||
* Author swx
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_SPI_MASTER_H__
|
||||
#define __HAL_SPI_MASTER_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_device_datatype.h"
|
||||
#include "tau_common.h"
|
||||
#include "string.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief 初始化spi master 模块
|
||||
* @param speed: 传输速度
|
||||
* @param cpha: 相位配置
|
||||
* @param cpol: 极性配置
|
||||
* @retval none
|
||||
*/
|
||||
void hal_spim_init(uint32_t speed, uint8_t cpha, uint8_t cpol);
|
||||
|
||||
/**
|
||||
* @brief spi master 去初始化
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void hal_spim_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief spi master自定义CS脚
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void hal_spim_set_csio_byself(bool enable);
|
||||
|
||||
/**
|
||||
* @brief 获取dma tx 传输状态
|
||||
* @param none
|
||||
* @retval true:传输完成, false:传输数据中,不可操作spim接口
|
||||
*/
|
||||
bool hal_spim_get_transfer_complete(void);
|
||||
|
||||
/**
|
||||
* @brief spim flush fifo
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void hal_spim_flush(void);
|
||||
|
||||
/**
|
||||
* @brief spim 发送数据,函数返回即传输完成,阻塞函数
|
||||
* @param tx_buffer:tx buffer地址
|
||||
* @param tx_size: tx size
|
||||
* @retval none
|
||||
*/
|
||||
void hal_spim_write(const uint8_t *data_buffer, uint32_t data_size);
|
||||
|
||||
/**
|
||||
* @brief spi master读写数据,函数返回即传输完成,阻塞函数
|
||||
* @param cmd : 传输过程汇总需要发送command的地址
|
||||
* @param cmd_size: 传输过程汇总需要发送command的数据长度
|
||||
* @param rx_buffer:rx buffer地址
|
||||
* @param rx_size: rx buffer size
|
||||
* @retval none
|
||||
*/
|
||||
void hal_spim_read(const uint8_t *cmd, uint32_t cmd_size, uint8_t *data_buffer, uint32_t data_size);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2021-2025, All Rights Reserved.
|
||||
*
|
||||
* File: hal_spi_slave.h
|
||||
* Description hal spi slave 模块头文件
|
||||
* Version V0.1
|
||||
* Date 2023-07-27
|
||||
* Author swx
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_SPI_SLAVE_H__
|
||||
#define __HAL_SPI_SLAVE_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_dsi_datatype.h"
|
||||
#include "tau_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief spi slave event type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SPIS_EVENT_RCV_FULL = 0x2, /* 数据接收完全 */
|
||||
SPIS_EVENT_RCV_CNT = 0x4, /* 数据接收指定阈值 */
|
||||
SPIS_EVENT_RCV_CS_RISE = 0x40, /* CS上升沿 */
|
||||
SPIS_EVENT_RCV_CS_FALL = 0x80, /* CS下降沿 */
|
||||
SPIS_EVENT_ALL_MISS = 0X100, /* ALL MISS中断*/
|
||||
} hal_spis_event_e;
|
||||
|
||||
/**
|
||||
* @brief spi 硬件快速回复配置结构体
|
||||
*/
|
||||
typedef struct hal_spis_hw_ack_info_t
|
||||
{
|
||||
uint8_t index;
|
||||
uint8_t cmp_data[4]; /* 匹配最长4byte */
|
||||
uint8_t cmp_len; /* 0 - 3 */
|
||||
bool cmp_en; /* 匹配enable */
|
||||
uint8_t delay_clk; /* 匹配成功后延迟数据恢复的clk数量,最小设置0,延迟1 clk */
|
||||
uint8_t *ack_address; /* 匹配成功回复数据地址 */
|
||||
uint32_t ack_length; /* 匹配成功回复数据长度 */
|
||||
} hal_spis_hw_ack_info_t;
|
||||
|
||||
/**
|
||||
* @brief spi 事件 packet info
|
||||
*/
|
||||
typedef struct hal_spis_packet_info_t
|
||||
{
|
||||
uint8_t *rx_buffer; /* 接收buffer */
|
||||
uint32_t rx_buffer_size; /* 接收buffer size */
|
||||
const uint8_t *tx_buffer; /* 发送buffer */
|
||||
uint32_t tx_buffer_size; /* 发送buffer size */
|
||||
bool tx_circle; /* 发送circle mode */
|
||||
uint32_t packet_size; /* packet size : RCV FULL事件 = rx buffer size, CS_RISE事件时为整个传输过程中SPIM发送packet的总量 */
|
||||
} hal_spis_packet_info_t;
|
||||
|
||||
typedef void (*hal_spis_cb)(hal_spis_event_e event, hal_spis_packet_info_t *packet_info);
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/*
|
||||
SPIS启动流程:
|
||||
1:hal_spis_init
|
||||
2:hal_spis_update_rx_buffer & hal_spis_update_tx_buffer
|
||||
3:hal_spis_register_callback
|
||||
4:hal_spis_start
|
||||
等待回调函数并从packet_info获取数据
|
||||
|
||||
Event:
|
||||
SPI_EVENT_RCV_FULL,表示RX buffer接收满 , packet_info.packet_size = rx_buffer_size
|
||||
SPI_EVENT_RCV_CS_HIGH,表示CS 拉高,一帧传输数据结束,此时packet_info.packet_size 为当前packet传输的所有byte数量
|
||||
|
||||
有可能存在只有SPI_EVENT_RCV_CS_HIGH而没有SPI_EVENT_RCV_FULL的情况,此时表示SPIM发送的数据不足于填满RX buffer
|
||||
eg: rx_buffer_size = 10, SPIM实际只发送了2byte数据
|
||||
|
||||
接收到SPI_EVENT_RCV_CS_HIGH后可通过hal_spis_update_tx_buffer更新下一帧需要发送的数据
|
||||
也可以通过hal_spis_update_rx_buffer更新接收数据的buffer
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief 初始化spi slave 模块
|
||||
* @param cpha: 相位配置
|
||||
* @param cpol: 极性配置
|
||||
* @param
|
||||
* @retval none
|
||||
*/
|
||||
void hal_spis_init(uint8_t cpha, uint8_t cpol);
|
||||
|
||||
/**
|
||||
* @brief spi slave 模块去初始化
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void hal_spis_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief spi slave 注册回调函数
|
||||
* @param cb:call back
|
||||
* @param event_mask:接收事件掩码(eg:SPIS_EVENT_RCV_FULL|SPIS_EVENT_RCV_CS_RISE)
|
||||
* @param data_intcnt:SPIS_EVENT_RCV_CNT事件触发参数,当rx buffer接收到data_intcnt数据时.产生RCV_CNT事件
|
||||
* @retval
|
||||
*/
|
||||
void hal_spis_register_callback(hal_spis_cb cb, uint32_t event_mask, uint16_t data_intcnt);
|
||||
|
||||
/**
|
||||
* @brief spi slave 设置RX DMA传输数据中断阈值
|
||||
* @param data_intcnt:SPIS_EVENT_RCV_CNT事件触发参数,当rx buffer接收到data_intcnt数据时.产生RCV_CNT事件
|
||||
* @retval none
|
||||
*/
|
||||
void hal_spis_set_rx_dma_intcnt(uint16_t data_intcnt);
|
||||
|
||||
/**
|
||||
* @brief spi slave 配置接收buffer, 底层自动接收数据后调用callback
|
||||
* @param buffer:自动模式数据接收buffer
|
||||
* @param size: 自动模式数据接收buffer size
|
||||
* @retval
|
||||
*/
|
||||
void hal_spis_update_rx_buffer(uint8_t *buffer, uint32_t size);
|
||||
|
||||
/**
|
||||
* @brief spi slave 配置自动发送buffer
|
||||
* @param buffer:自动模式数据发送buffer
|
||||
* @param size: 自动模式数据发收buffer size
|
||||
* @param circle:circle mode,重复发送buffer的数据
|
||||
* @retval
|
||||
*/
|
||||
void hal_spis_update_tx_buffer(const uint8_t *buffer, uint32_t size, bool circle);
|
||||
|
||||
/**
|
||||
* @brief spi slave 启动
|
||||
* @param none
|
||||
* @retval
|
||||
*/
|
||||
void hal_spis_start(void);
|
||||
|
||||
/**
|
||||
* @brief spi slave 停止
|
||||
* @param none
|
||||
* @retval true/false
|
||||
*/
|
||||
void hal_spis_stop(void);
|
||||
|
||||
/**
|
||||
* @brief spi slave flush fifo
|
||||
* @param none
|
||||
* @retval true/false
|
||||
*/
|
||||
void hal_spis_flush(void);
|
||||
|
||||
/**
|
||||
* @brief 获取SPIS busy状态
|
||||
* @param none
|
||||
* @retval true: CS拉低状态, false:CS拉高状态
|
||||
*/
|
||||
bool hal_spis_busy(void);
|
||||
|
||||
/**
|
||||
* @brief 读取rx fifo缓冲数据
|
||||
* @param buffer:读取数据的缓冲区
|
||||
* @param count:需要读取的字节数
|
||||
* @retval uint8_t:实际读取的字节数
|
||||
*/
|
||||
uint8_t hal_spis_read_data(uint8_t *buffer, uint8_t count);
|
||||
|
||||
/**
|
||||
* @brief spi slave cpu写一个数据
|
||||
* @param data:写的数据
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_spis_write_data(uint8_t data);
|
||||
|
||||
/**
|
||||
* @brief 获取rx fifo状态
|
||||
* @param none
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_spis_get_rxfifo(void);
|
||||
|
||||
/**
|
||||
* @brief 设置SPIS硬件快速回复功能使能状态
|
||||
* @param en:硬件快速回复功能使能
|
||||
* @param header_default:硬件快速回复功能的默认回复值
|
||||
* @retval none
|
||||
*/
|
||||
void hal_spis_set_hw_ack_enable(bool en, uint8_t header_default);
|
||||
|
||||
/**
|
||||
* @brief 获取SPIS硬件快速回复功能使能状态
|
||||
* @param void
|
||||
* @retval bool
|
||||
*/
|
||||
bool hal_spis_get_hw_ack_enable(void);
|
||||
|
||||
/**
|
||||
* @brief 设置SPIS硬件快速回复header参数
|
||||
* @param info:spi硬件快速回复配置结构体数组
|
||||
* @param size:设置size组参数
|
||||
* @retval none
|
||||
*/
|
||||
void hal_spis_set_hw_ack_info(hal_spis_hw_ack_info_t *info, uint8_t size);
|
||||
|
||||
#endif /* __HAL_SPI_SLAVE_H__*/
|
||||
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_swire.h
|
||||
* Description: swire HAL层头文件
|
||||
* Version: V0.1
|
||||
* Date: 2021-03-17
|
||||
* Author: jaya
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_SWIRE_H__
|
||||
#define __HAL_SWIRE_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_device_datatype.h"
|
||||
#include "tau_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief SWIRE初始化
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_swire_init(void);
|
||||
|
||||
/**
|
||||
* @brief SWIRE去初始化
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_swire_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief 配置SWIRE波形
|
||||
* @param start_time:起始时长,单位us
|
||||
* @param stop_time:结束时长,单位us,必须大于300us
|
||||
* @param high_time:高电平时长,单位us
|
||||
* @param low_time:低电平时长,单位us
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_swire_set_waveform(uint32_t start_time, uint32_t stop_time,
|
||||
uint32_t high_time, uint32_t low_time);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 配置SWIRE脉冲个数
|
||||
* @param pulse:脉冲数
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_swire_set_pulse(uint32_t pulse);
|
||||
|
||||
/**
|
||||
* @brief 开关swire输出,不绑定timer的情况下,每次调用hal_swire_set_pulse产生一个swire波形
|
||||
* @param state:开关控制
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_swire_enable(bool state);
|
||||
|
||||
/**
|
||||
* @brief 配置swire选择的timer
|
||||
* @param timer_num_e index:定时器编号
|
||||
* @param uint32_t ms:超时时间
|
||||
* @param repeat :是否重复
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_swire_set_timer(timer_num_e index, uint32_t ms, bool repeat);
|
||||
|
||||
/**
|
||||
* @brief 注册回调函数,每次swire 发送完成后会产生回调
|
||||
* @param cb_func:回调函数地址
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_swire_register_callback(fcb_type cb_func);
|
||||
|
||||
#endif /* __HAL_SWIRE_H__ */
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_system.h
|
||||
* Description hal 通用系统接口头文件
|
||||
* Version V0.1
|
||||
* Date 2021-05-21
|
||||
* Author lzy
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_SYSTEM_H__
|
||||
#define __HAL_SYSTEM_H__
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_common.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "tau_log.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief 系统时钟配置
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_SYSCLK_80M = 80000000,
|
||||
HAL_SYSCLK_100M = 100000000,
|
||||
HAL_SYSCLK_150M = 150000000
|
||||
} hal_system_clk_e;
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief system 初始化
|
||||
* @param sysclk:系统时钟
|
||||
* @retval none
|
||||
*/
|
||||
void hal_system_init(hal_system_clk_e sysclk);
|
||||
|
||||
/**
|
||||
* @brief mcu进入idle模式,等待中断唤醒
|
||||
* @param disable_systick: 进入idle时是否关闭systick(退出idle 恢复systick)
|
||||
* @retval none
|
||||
*/
|
||||
void hal_system_idle_mode(bool disable_systick);
|
||||
|
||||
/**
|
||||
* @brief 注册systick回调函数
|
||||
* @param cb_func:回调函数地址
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_system_register_systick_cb(fcb_type cb_func);
|
||||
|
||||
/**
|
||||
* @brief 启动sys tickt
|
||||
* @param ms: sys tickt 间隔, 范围1-10ms
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_system_enable_systick(uint8_t ms);
|
||||
|
||||
/**
|
||||
* @brief 获取systickt
|
||||
* @param none
|
||||
* @retval 当前systickt值
|
||||
*/
|
||||
bool hal_system_disable_systick(void);
|
||||
|
||||
/**
|
||||
* @brief 获取systickt
|
||||
* @param none
|
||||
* @retval 当前systickt值
|
||||
*/
|
||||
uint32_t hal_system_get_tick(void);
|
||||
|
||||
/**
|
||||
* @brief reset chip
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void hal_system_reset_chip(void);
|
||||
|
||||
/**
|
||||
* @brief 获取上位机设置的debug state(debug only)
|
||||
* @param none
|
||||
* @retval debug state
|
||||
*/
|
||||
uint32_t hal_system_get_debug_state(void);
|
||||
|
||||
/**
|
||||
* @brief clear debug state(debug only)
|
||||
* @param none
|
||||
* @retval none
|
||||
*/
|
||||
void hal_system_clear_debug_state(void);
|
||||
|
||||
/**
|
||||
* @brief 更新MCU时钟
|
||||
* @param sysclk:系统时钟
|
||||
* @retval true/false
|
||||
*/
|
||||
bool hal_system_updata_sysclk(hal_system_clk_e sysclk);
|
||||
|
||||
#endif //__HAL_SYSTEM_H__
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_timer.h
|
||||
* Description: timer HAL层头文件
|
||||
* Version: V0.1
|
||||
* Date: 2021-03-16
|
||||
* Author: jaya
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_TIMER_H__
|
||||
#define __HAL_TIMER_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_device_datatype.h"
|
||||
#include "tau_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief 指定定时器初始化
|
||||
* @param index:实例序号(0~3),参考枚举类型timer_num_e
|
||||
* @retval None
|
||||
*/
|
||||
void hal_timer_init(timer_num_e index);
|
||||
|
||||
/**
|
||||
* @brief 指定定时器反初始化
|
||||
* @param index:实例序号(0~3),参考枚举类型timer_num_e
|
||||
* @retval None
|
||||
*/
|
||||
void hal_timer_deinit(timer_num_e index);
|
||||
|
||||
/**
|
||||
* @brief 启动指定定时器
|
||||
* @param index:实例序号(0~3),参考枚举类型timer_num_e
|
||||
* @param ms:超时时间,单位ms。由于应用场景一般是ms级别的,应用开发不需要计数具体时针数,
|
||||
故直接输入时间,在接口内部换算成时钟数进行寄存器设置。
|
||||
* @param cb_func:回调函数地址,不需要则填NULL
|
||||
* @param data:回调函数的参数地址,不需要则填NULL
|
||||
* @retval None
|
||||
*/
|
||||
void hal_timer_start(timer_num_e index, uint32_t ms, fcb_type cb_func, void *data);
|
||||
|
||||
/**
|
||||
* @brief 启动指定定时器
|
||||
* @param index:实例序号(0~3),参考枚举类型timer_num_e
|
||||
* @param us:超时时间,单位us。由于应用场景一般是us级别的,应用开发不需要计数具体时针数,
|
||||
故直接输入时间,在接口内部换算成时钟数进行寄存器设置。
|
||||
* @param cb_func:回调函数地址,不需要则填NULL
|
||||
* @param data:回调函数的参数地址,不需要则填NULL
|
||||
* @retval None
|
||||
*/
|
||||
void hal_timer_start_ex(timer_num_e index, uint32_t us, fcb_type cb_func, void *data);
|
||||
|
||||
/**
|
||||
* @brief 停止指定定时器
|
||||
* @param index:实例序号(0~3),参考枚举类型timer_num_e
|
||||
* @retval None
|
||||
*/
|
||||
void hal_timer_stop(timer_num_e index);
|
||||
|
||||
/**
|
||||
* @brief 设置定时器是否循环超时
|
||||
* @param index:实例序号(0~3),参考枚举类型timer_num_e
|
||||
* @param bool enable:循环超时使能
|
||||
* @retval None
|
||||
*/
|
||||
void hal_timer_set_repeat(timer_num_e index, bool repeat);
|
||||
|
||||
/**
|
||||
* @brief 获取指定指示器状态
|
||||
* @param index:实例序号(0~3),参考枚举类型timer_num_e
|
||||
* @retval 参考timer_status_e
|
||||
*/
|
||||
timer_status_e hal_timer_get_status(timer_num_e index);
|
||||
|
||||
#endif /* __HAL_TIMER_H__ */
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_uart.h
|
||||
* Description
|
||||
* Version V0.1
|
||||
* Date 2021-11-24
|
||||
* Author kc
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __HAL_UART_H__
|
||||
#define __HAL_UART_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_device_datatype.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief UART停止位
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_UART_STOPBIT_1 = 0,
|
||||
HAL_UART_STOPBIT_1P5 = 1,
|
||||
HAL_UART_STOPBIT_2 = 1
|
||||
} hal_uart_stopbit_e;
|
||||
|
||||
/**
|
||||
* @brief UART极性
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_UART_PARITY_NO = 0,
|
||||
HAL_UART_PARITY_ODD = 0x01,
|
||||
HAL_UART_PARITY_EVEN = 0x03,
|
||||
} hal_uart_parity_e;
|
||||
|
||||
/**
|
||||
* @brief UART数据宽度
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_UART_DATAWIDTH_5 = 0,
|
||||
HAL_UART_DATAWIDTH_6 = 1,
|
||||
HAL_UART_DATAWIDTH_7 = 2,
|
||||
HAL_UART_DATAWIDTH_8 = 3
|
||||
} hal_uart_datawidth_e;
|
||||
|
||||
/**
|
||||
* @brief UART编号
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_UART_0,
|
||||
HAL_UART_1,
|
||||
HAL_UART_MAX
|
||||
} hal_uart_num_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t baudrate;
|
||||
hal_uart_stopbit_e stopbits;
|
||||
hal_uart_datawidth_e data_width;
|
||||
hal_uart_parity_e parity;
|
||||
uart_trans_cb callback;
|
||||
void *user_data;
|
||||
} hal_uart_config_t;
|
||||
|
||||
/**
|
||||
* @brief UART DMA 通道TX/RX方向选择
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_UART0_DMA_PATH_TX,
|
||||
HAL_UART0_DMA_PATH_RX,
|
||||
HAL_UART1_DMA_PATH_TX,
|
||||
HAL_UART1_DMA_PATH_RX,
|
||||
HAL_UART_DMA_PATH_MAX
|
||||
} hal_uart_dma_path_e;
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief 初始化设置uart 传输的波特率、位宽等参数
|
||||
* @param hal_uart_config_t
|
||||
* @retval hal_uart_status
|
||||
*/
|
||||
void hal_uart_init(hal_uart_num_e num, hal_uart_config_t *huart);
|
||||
|
||||
/**
|
||||
* @brief 关闭uart口
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_uart_deinit(hal_uart_num_e num);
|
||||
|
||||
/**
|
||||
* @brief 阻塞式发送数据
|
||||
* @param pdata:传输数据指针
|
||||
* @param size:传输数据大小
|
||||
* @retval hal_uart_status
|
||||
*/
|
||||
bool hal_uart_send_blocking(hal_uart_num_e num, uint8_t *pdata, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief 阻塞式接收数据
|
||||
* @param pdata:传输数据指针
|
||||
* @param size:传输数据大小
|
||||
* @retval hal_uart_status
|
||||
*/
|
||||
bool hal_uart_recv_blocking(hal_uart_num_e num, uint8_t *pdata, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief 中断非阻塞式发送数据
|
||||
* @param pdata:传输数据指针
|
||||
* @param size:传输数据大小
|
||||
* @retval 状态
|
||||
*/
|
||||
bool hal_uart_send_none_blocking(hal_uart_num_e num, uint8_t *pdata, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief 中断非阻塞式接收数据
|
||||
* @param pdata:传输数据指针
|
||||
* @param size:传输数据大小
|
||||
* @retval hal_uart_status
|
||||
*/
|
||||
bool hal_uart_recv_none_blocking(hal_uart_num_e num, uint8_t *pdata, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief 使用DMA通道发送数据
|
||||
* @param num: 串口编号 串口0或串口1
|
||||
* @param pdata:传输数据指针
|
||||
* @param size:传输数据大小
|
||||
* @retval true or false
|
||||
*/
|
||||
bool hal_uart_dma_send(hal_uart_num_e num, uint8_t *pdata, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief 使用DMA接收数据
|
||||
* @param num: 串口编号 串口0或串口1
|
||||
* @param pdata:传输数据指针
|
||||
* @param size:传输数据大小
|
||||
* @retval true or false
|
||||
*/
|
||||
bool hal_uart_dma_recv(hal_uart_num_e num, uint8_t *pdata, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief UART DMA通道不再使用后关闭释放UART DMA资源
|
||||
* @param path:TX通道或RX通道
|
||||
* @retval void
|
||||
*/
|
||||
void hal_uart_dma_path_close(hal_uart_dma_path_e path);
|
||||
#endif /* __HAL_UART_H__ */
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/*******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: hal_wdg.h
|
||||
* Description: wdg HAL层头文件
|
||||
* Version: V0.1
|
||||
* Date: 2021-03-16
|
||||
* Author: jaya
|
||||
*******************************************************************************/
|
||||
#ifndef __HAL_WDG_H__
|
||||
#define __HAL_WDG_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* 1.Included files
|
||||
*******************************************************************************/
|
||||
#include "tau_device_datatype.h"
|
||||
#include "tau_common.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* 2.Global constant and macro definitions using #define
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 3.Global structures, unions and enumerations using typedef
|
||||
*******************************************************************************/
|
||||
/*!
|
||||
* @brief watch dog模式
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
WDG_MODE_RESET = 0, //复位模式,跑飞复位
|
||||
WDG_MODE_INTERRUPT = 1 //中断模式,跑飞进入中断
|
||||
} wdg_mode_e;
|
||||
|
||||
/*******************************************************************************
|
||||
* 4.Global variable extern declarations
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* 5.Global function prototypes
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @brief 看门狗初始化
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_wdg_init(void);
|
||||
|
||||
/**
|
||||
* @brief 看门狗反初始化
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_wdg_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief 启动看门狗
|
||||
* @param wdg_mode_e modeSel: 复位或中断模式
|
||||
* @param uint32_t load: 超时时间,单位ms
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_wdg_start(wdg_mode_e modeSel, uint32_t load);
|
||||
|
||||
/**
|
||||
* @brief 停止看门狗
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_wdg_stop(void);
|
||||
|
||||
/**
|
||||
* @brief 设置WDG是否循环超时
|
||||
* @param enable:循环超时使能
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_wdg_set_repeat(bool repeat);
|
||||
|
||||
/**
|
||||
* @brief 注册中断回调函数
|
||||
* @param cb_func:回调函数地址
|
||||
* @param data:回调参数地址
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_wdg_register_callback(fcb_type cb_func, void *data);
|
||||
|
||||
/**
|
||||
* @brief 喂狗
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
void hal_wdg_kick_dog(void);
|
||||
|
||||
#endif /* __HAL_WDG_H__ */
|
||||
|
|
@ -0,0 +1 @@
|
|||
#define SDK_REVISION 6000
|
||||
Loading…
Reference in New Issue