1
0
This commit is contained in:
2025-10-27 17:07:20 +01:00
parent 7e264d691c
commit bd24f1fb79
576 changed files with 240919 additions and 0 deletions

187
P3_SETR2/.cproject Normal file
View File

@@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.875270721">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.875270721" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/P3_SETR2"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/P3_SETR2/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="P3_SETR2" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.875270721" name="Debug" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug">
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.875270721." name="/" resourcePath="">
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.842865950" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.320197293" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32L475VGTx" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.987760925" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.769147958" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.2010254166" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv4-sp-d16" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.1292755719" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1617257168" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="B-L475E-IOT01A2" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.4195474" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || B-L475E-IOT01A2 || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32L4xx_HAL_Driver/Inc | ../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32L4xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32L475xx || || || || || ${workspace_loc:/${ProjName}/STM32L475VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.887067644" name="Use float with printf from newlib-nano (-u _printf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<targetPlatform archList="all" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1153704244" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/P3_SETR2}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.382752746" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1145655333" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.1645761174" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.preprocessassembler.154325286" name="Always preprocess assembler (-x assembler-with-cpp)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.preprocessassembler" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.1916962999" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.1898354464" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.2040877885" name="MCU/MPU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.1370874377" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.284159734" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.582397979" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="STM32L475xx"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.597668358" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../Core/Inc"/>
<listOptionValue builtIn="false" value="../Components"/>
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc"/>
<listOptionValue builtIn="false" value="../BSP"/>
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L4xx/Include"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1110571297" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.330964422" name="MCU/MPU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.657350226" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.2072964355" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.185902036" name="MCU/MPU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.1685691662" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32L475VGTX_FLASH.ld}" valueType="string"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.2039141522" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.1704392970" name="MCU/MPU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.489820896" name="MCU/MPU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.151544317" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.1669033776" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.1971174448" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.1332578682" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.1190183654" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.206176350" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.1522532979" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="BSP"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Components"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1760162880">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1760162880" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1760162880" name="Release" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release">
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1760162880." name="/" resourcePath="">
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release.2131445139" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1815592003" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32L475VGTx" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.1275587579" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1857019598" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.452610928" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv4-sp-d16" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.27462059" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1926726534" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="B-L475E-IOT01A2" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1025749685" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || B-L475E-IOT01A2 || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32L4xx_HAL_Driver/Inc | ../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32L4xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32L475xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32L475VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.395630181" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="80" valueType="string"/>
<targetPlatform archList="all" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1650589661" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/P3_SETR2}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1084159300" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.2114597539" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.1746526168" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g0" valueType="enumerated"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.1206299943" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1379391638" name="MCU/MPU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.1580944397" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.343598745" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1430306277" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="STM32L475xx"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.1619729879" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../Core/Inc"/>
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc"/>
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L4xx/Include"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.2120200471" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.729452894" name="MCU/MPU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.1390844402" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.83152171" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.value.os" valueType="enumerated"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.866892501" name="MCU/MPU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.1680325127" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32L475VGTX_FLASH.ld}" valueType="string"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.337779558" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.1050738491" name="MCU/MPU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.744293106" name="MCU/MPU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.1491445476" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.1502311486" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.688805636" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.1306937766" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.1939466022" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.351350846" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.2145448913" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.pathentry"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="P3_SETR2.null.1537861134" name="P3_SETR2"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1760162880;com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1760162880.;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1379391638;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.2120200471">
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.875270721;com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.875270721.;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.2040877885;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1110571297">
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>

25
P3_SETR2/.mxproject Normal file

File diff suppressed because one or more lines are too long

32
P3_SETR2/.project Normal file
View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>P3_SETR2</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.st.stm32cube.ide.mcu.MCUProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUCubeProjectNature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCURootProjectNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.875270721" name="Debug">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-696352624643696132" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1760162880" name="Release">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-696352624643696132" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
</project>

View File

@@ -0,0 +1,6 @@
doxygen/doxygen_new_line_after_brief=true
doxygen/doxygen_use_brief_tag=false
doxygen/doxygen_use_javadoc_tags=true
doxygen/doxygen_use_pre_tag=false
doxygen/doxygen_use_structural_commands=false
eclipse.preferences.version=1

View File

@@ -0,0 +1,5 @@
635E684B79701B039C64EA45C3F84D30=148B39F5C8E660B250DE15501797F200
66BE74F758C12D739921AEA421D593D3=0
8DF89ED150041C4CBC7CB9A9CAA90856=D61A9D5E0823FD3A26503CBA2CCE68C1
DC22A860405A8BF2F2C095E5B6529F12=D61A9D5E0823FD3A26503CBA2CCE68C1
eclipse.preferences.version=1

Binary file not shown.

View File

@@ -0,0 +1,118 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for B-L475E-IOT01A Board Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-b-l475e-iot01a-board-drivers"><small>Release Notes for</small> <mark>B-L475E-IOT01A Board Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the board drivers to demonstrate the capabilities of the B-L475E-IOT01A Kit.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section21" checked aria-hidden="true"> <label for="collapse-section21" aria-hidden="true">V1.1.6 / 22-November-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Enable the Sample Shift (SSHIFT) feature in <em>BSP_QSPI_Init()</em> to ensure the read data isnt corrupted when prescaler is div/1</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.1.5 / 18-October-2019</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Minor update in release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.1.4 / 03-April-2019</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>Rewrite stm32l475e_iot01.c to correct B-L475E-IOT01_BSP_User_Manual.chm documentation issue</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.1.3 / 27-July-2018</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>Release notes update to new format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.1.2 / 20-April-2018</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>Header functions description cleanup</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section16" aria-hidden="true"> <label for="collapse-section16" aria-hidden="true">V1.1.1 / 13-October-2017</label>
<div>
<h2 id="main-changes-5">Main Changes</h2>
<ul>
<li>Fix compilation warning with armcc gnu</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section15" aria-hidden="true"> <label for="collapse-section15" aria-hidden="true">V1.1.0 / 21-April-2017</label>
<div>
<h2 id="main-changes-6">Main Changes</h2>
<ul>
<li>Add support of NFC via M24SR component.</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section12" aria-hidden="true"> <label for="collapse-section12" aria-hidden="true">V1.0.0 / 17-March-2017</label>
<div>
<h2 id="main-changes-7">Main Changes</h2>
<ul>
<li>First official release of <strong>B-L475E-IOT01</strong> BSP drivers</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -0,0 +1,806 @@
/**
******************************************************************************
* @file stm32l475e_iot01.c
* @author MCD Application Team
* @brief STM32L475E-IOT01 board support package
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01.h"
/** @defgroup BSP BSP
* @{
*/
/** @defgroup STM32L475E_IOT01 STM32L475E_IOT01
* @{
*/
/** @defgroup STM32L475E_IOT01_LOW_LEVEL LOW LEVEL
* @{
*/
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Private_Defines LOW LEVEL Private Def
* @{
*/
/**
* @brief STM32L475E IOT01 BSP Driver version number
*/
#define __STM32L475E_IOT01_BSP_VERSION_MAIN (0x01) /*!< [31:24] main version */
#define __STM32L475E_IOT01_BSP_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */
#define __STM32L475E_IOT01_BSP_VERSION_SUB2 (0x06) /*!< [15:8] sub2 version */
#define __STM32L475E_IOT01_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */
#define __STM32L475E_IOT01_BSP_VERSION ((__STM32L475E_IOT01_BSP_VERSION_MAIN << 24)\
|(__STM32L475E_IOT01_BSP_VERSION_SUB1 << 16)\
|(__STM32L475E_IOT01_BSP_VERSION_SUB2 << 8 )\
|(__STM32L475E_IOT01_BSP_VERSION_RC))
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Private_Variables LOW LEVEL Variables
* @{
*/
const uint32_t GPIO_PIN[LEDn] = {LED2_PIN};
GPIO_TypeDef* GPIO_PORT[LEDn] = {LED2_GPIO_PORT};
GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {USER_BUTTON_GPIO_PORT};
const uint16_t BUTTON_PIN[BUTTONn] = {USER_BUTTON_PIN};
const uint16_t BUTTON_IRQn[BUTTONn] = {USER_BUTTON_EXTI_IRQn};
USART_TypeDef* COM_USART[COMn] = {DISCOVERY_COM1};
GPIO_TypeDef* COM_TX_PORT[COMn] = {DISCOVERY_COM1_TX_GPIO_PORT};
GPIO_TypeDef* COM_RX_PORT[COMn] = {DISCOVERY_COM1_RX_GPIO_PORT};
const uint16_t COM_TX_PIN[COMn] = {DISCOVERY_COM1_TX_PIN};
const uint16_t COM_RX_PIN[COMn] = {DISCOVERY_COM1_RX_PIN};
const uint16_t COM_TX_AF[COMn] = {DISCOVERY_COM1_TX_AF};
const uint16_t COM_RX_AF[COMn] = {DISCOVERY_COM1_RX_AF};
I2C_HandleTypeDef hI2cHandler;
UART_HandleTypeDef hDiscoUart;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Private_FunctionPrototypes LOW LEVEL Private Function Prototypes
* @{
*/
static void I2Cx_MspInit(I2C_HandleTypeDef *i2c_handler);
static void I2Cx_MspDeInit(I2C_HandleTypeDef *i2c_handler);
static void I2Cx_Init(I2C_HandleTypeDef *i2c_handler);
static void I2Cx_DeInit(I2C_HandleTypeDef *i2c_handler);
static HAL_StatusTypeDef I2Cx_ReadMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length);
static HAL_StatusTypeDef I2Cx_WriteMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length);
static HAL_StatusTypeDef I2Cx_IsDeviceReady(I2C_HandleTypeDef *i2c_handler, uint16_t DevAddress, uint32_t Trials);
static void I2Cx_Error(I2C_HandleTypeDef *i2c_handler, uint8_t Addr);
/* Sensors IO functions */
void SENSOR_IO_Init(void);
void SENSOR_IO_DeInit(void);
void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg);
uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
HAL_StatusTypeDef SENSOR_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials);
void SENSOR_IO_Delay(uint32_t Delay);
void NFC_IO_Init(uint8_t GpoIrqEnable);
void NFC_IO_DeInit(void);
uint16_t NFC_IO_ReadMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length );
uint16_t NFC_IO_WriteMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length);
uint16_t NFC_IO_IsDeviceReady (uint8_t Addr, uint32_t Trials);
void NFC_IO_ReadState(uint8_t * pPinState);
void NFC_IO_RfDisable(uint8_t PinState);
void NFC_IO_Delay(uint32_t Delay);
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Private_Functions LOW LEVEL Private Functions
* @{
*/
/**
* @brief This method returns the STM32L475E IOT01 BSP Driver revision
* @retval version 0xXYZR (8bits for each decimal, R for RC)
*/
uint32_t BSP_GetVersion(void)
{
return __STM32L475E_IOT01_BSP_VERSION;
}
/**
* @brief Initializes LED GPIO.
* @param Led LED to be initialized.
* This parameter can be one of the following values:
* @arg LED2
*/
void BSP_LED_Init(Led_TypeDef Led)
{
GPIO_InitTypeDef gpio_init_structure;
LEDx_GPIO_CLK_ENABLE(Led);
/* Configure the GPIO_LED pin */
gpio_init_structure.Pin = GPIO_PIN[Led];
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIO_PORT[Led], &gpio_init_structure);
}
/**
* @brief DeInitializes LED GPIO.
* @param Led LED to be deinitialized.
* This parameter can be one of the following values:
* @arg LED2
*/
void BSP_LED_DeInit(Led_TypeDef Led)
{
GPIO_InitTypeDef gpio_init_structure;
/* DeInit the GPIO_LED pin */
gpio_init_structure.Pin = GPIO_PIN[Led];
/* Turn off LED */
HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_RESET);
HAL_GPIO_DeInit(GPIO_PORT[Led], gpio_init_structure.Pin);
}
/**
* @brief Turns the selected LED On.
* @param Led LED to be set on
* This parameter can be one of the following values:
* @arg LED2
*/
void BSP_LED_On(Led_TypeDef Led)
{
HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_SET);
}
/**
* @brief Turns the selected LED Off.
* @param Led LED to be set off
* This parameter can be one of the following values:
* @arg LED2
*/
void BSP_LED_Off(Led_TypeDef Led)
{
HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_RESET);
}
/**
* @brief Toggles the selected LED.
* @param Led LED to be toggled
* This parameter can be one of the following values:
* @arg LED2
*/
void BSP_LED_Toggle(Led_TypeDef Led)
{
HAL_GPIO_TogglePin(GPIO_PORT[Led], GPIO_PIN[Led]);
}
/**
* @brief Initializes push button GPIO and EXTI Line.
* @param Button Button to be configured
* This parameter can be one of the following values:
* @arg BUTTON_USER User Push Button
* @param ButtonMode Button mode
* This parameter can be one of the following values:
* @arg BUTTON_MODE_GPIO Button will be used as simple IO
* @arg BUTTON_MODE_EXTI Button will be connected to EXTI line
* with interrupt generation capability
*/
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
{
GPIO_InitTypeDef gpio_init_structure;
/* Enable the BUTTON clock */
USER_BUTTON_GPIO_CLK_ENABLE();
if(ButtonMode == BUTTON_MODE_GPIO)
{
/* Configure Button pin as input */
gpio_init_structure.Pin = BUTTON_PIN[Button];
gpio_init_structure.Mode = GPIO_MODE_INPUT;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
}
if(ButtonMode == BUTTON_MODE_EXTI)
{
/* Configure Button pin as input with External interrupt */
gpio_init_structure.Pin = BUTTON_PIN[Button];
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
gpio_init_structure.Mode = GPIO_MODE_IT_RISING;
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
/* Enable and set Button EXTI Interrupt to the lowest priority */
HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00);
HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
}
}
/**
* @brief DeInitializes push button.
* @param Button Button to be configured
* This parameter can be one of the following values:
* @arg BUTTON_USER User Push Button
* @note PB DeInit does not disable the GPIO clock
*/
void BSP_PB_DeInit(Button_TypeDef Button)
{
GPIO_InitTypeDef gpio_init_structure;
gpio_init_structure.Pin = BUTTON_PIN[Button];
HAL_NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
HAL_GPIO_DeInit(BUTTON_PORT[Button], gpio_init_structure.Pin);
}
/**
* @brief Returns the selected button state.
* @param Button Button to be checked
* This parameter can be one of the following values:
* @arg BUTTON_USER User Push Button
* @retval The Button GPIO pin value (GPIO_PIN_RESET = button pressed)
*/
uint32_t BSP_PB_GetState(Button_TypeDef Button)
{
return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
}
/**
* @brief Configures COM port.
* @param COM COM port to be initialized.
* This parameter can be one of the following values:
* @arg COM1
* @param huart Pointer to a UART_HandleTypeDef structure that contains the
* configuration information for the specified USART peripheral.
*/
void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *huart)
{
GPIO_InitTypeDef gpio_init_structure;
/* Enable GPIO clock */
DISCOVERY_COMx_TX_GPIO_CLK_ENABLE(COM);
DISCOVERY_COMx_RX_GPIO_CLK_ENABLE(COM);
/* Enable USART clock */
DISCOVERY_COMx_CLK_ENABLE(COM);
/* Configure USART Tx as alternate function */
gpio_init_structure.Pin = COM_TX_PIN[COM];
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Alternate = COM_TX_AF[COM];
HAL_GPIO_Init(COM_TX_PORT[COM], &gpio_init_structure);
/* Configure USART Rx as alternate function */
gpio_init_structure.Pin = COM_RX_PIN[COM];
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
gpio_init_structure.Alternate = COM_RX_AF[COM];
HAL_GPIO_Init(COM_RX_PORT[COM], &gpio_init_structure);
/* USART configuration */
huart->Instance = COM_USART[COM];
HAL_UART_Init(huart);
}
/**
* @brief DeInitializes COM port.
* @param COM COM port to be deinitialized.
* This parameter can be one of the following values:
* @arg COM1
* @param huart Pointer to a UART_HandleTypeDef structure that contains the
* configuration information for the specified USART peripheral.
*/
void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart)
{
/* USART configuration */
huart->Instance = COM_USART[COM];
HAL_UART_DeInit(huart);
/* Enable USART clock */
DISCOVERY_COMx_CLK_DISABLE(COM);
/* DeInit GPIO pins can be done in the application
(by surcharging this __weak function) */
/* GPIO pins clock, FMC clock and DMA clock can be shut down in the application
by surcharging this __weak function */
}
/*******************************************************************************
BUS OPERATIONS
*******************************************************************************/
/******************************* I2C Routines *********************************/
/**
* @brief Initializes I2C MSP.
* @param i2c_handler I2C handler
* @retval None
*/
static void I2Cx_MspInit(I2C_HandleTypeDef *i2c_handler)
{
GPIO_InitTypeDef gpio_init_structure;
/*** Configure the GPIOs ***/
/* Enable GPIO clock */
DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE();
/* Configure I2C Tx, Rx as alternate function */
gpio_init_structure.Pin = DISCOVERY_I2Cx_SCL_PIN | DISCOVERY_I2Cx_SDA_PIN;
gpio_init_structure.Mode = GPIO_MODE_AF_OD;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
gpio_init_structure.Alternate = DISCOVERY_I2Cx_SCL_SDA_AF;
HAL_GPIO_Init(DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
HAL_GPIO_Init(DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
/*** Configure the I2C peripheral ***/
/* Enable I2C clock */
DISCOVERY_I2Cx_CLK_ENABLE();
/* Force the I2C peripheral clock reset */
DISCOVERY_I2Cx_FORCE_RESET();
/* Release the I2C peripheral clock reset */
DISCOVERY_I2Cx_RELEASE_RESET();
/* Enable and set I2Cx Interrupt to a lower priority */
HAL_NVIC_SetPriority(DISCOVERY_I2Cx_EV_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(DISCOVERY_I2Cx_EV_IRQn);
/* Enable and set I2Cx Interrupt to a lower priority */
HAL_NVIC_SetPriority(DISCOVERY_I2Cx_ER_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(DISCOVERY_I2Cx_ER_IRQn);
}
/**
* @brief DeInitializes I2C MSP.
* @param i2c_handler I2C handler
* @retval None
*/
static void I2Cx_MspDeInit(I2C_HandleTypeDef *i2c_handler)
{
GPIO_InitTypeDef gpio_init_structure;
/* Configure I2C Tx, Rx as alternate function */
gpio_init_structure.Pin = DISCOVERY_I2Cx_SCL_PIN | DISCOVERY_I2Cx_SDA_PIN;
HAL_GPIO_DeInit(DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT, gpio_init_structure.Pin);
/* Disable GPIO clock */
DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_DISABLE();
/* Disable I2C clock */
DISCOVERY_I2Cx_CLK_DISABLE();
}
/**
* @brief Initializes I2C HAL.
* @param i2c_handler I2C handler
* @retval None
*/
static void I2Cx_Init(I2C_HandleTypeDef *i2c_handler)
{
/* I2C configuration */
i2c_handler->Instance = DISCOVERY_I2Cx;
i2c_handler->Init.Timing = DISCOVERY_I2Cx_TIMING;
i2c_handler->Init.OwnAddress1 = 0;
i2c_handler->Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
i2c_handler->Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
i2c_handler->Init.OwnAddress2 = 0;
i2c_handler->Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
i2c_handler->Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
/* Init the I2C */
I2Cx_MspInit(i2c_handler);
HAL_I2C_Init(i2c_handler);
/**Configure Analogue filter */
HAL_I2CEx_ConfigAnalogFilter(i2c_handler, I2C_ANALOGFILTER_ENABLE);
}
/**
* @brief DeInitializes I2C HAL.
* @param i2c_handler I2C handler
* @retval None
*/
static void I2Cx_DeInit(I2C_HandleTypeDef *i2c_handler)
{ /* DeInit the I2C */
I2Cx_MspDeInit(i2c_handler);
HAL_I2C_DeInit(i2c_handler);
}
/**
* @brief Reads multiple data.
* @param i2c_handler I2C handler
* @param Addr I2C address
* @param Reg Reg address
* @param MemAddress memory address
* @param Buffer Pointer to data buffer
* @param Length Length of the data
* @retval HAL status
*/
static HAL_StatusTypeDef I2Cx_ReadMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length)
{
HAL_StatusTypeDef status = HAL_OK;
status = HAL_I2C_Mem_Read(i2c_handler, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, 1000);
/* Check the communication status */
if(status != HAL_OK)
{
/* I2C error occured */
I2Cx_Error(i2c_handler, Addr);
}
return status;
}
/**
* @brief Writes a value in a register of the device through BUS in using DMA mode.
* @param i2c_handler I2C handler
* @param Addr Device address on BUS Bus.
* @param Reg The target register address to write
* @param MemAddress memory address
* @param Buffer The target register value to be written
* @param Length buffer size to be written
* @retval HAL status
*/
static HAL_StatusTypeDef I2Cx_WriteMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length)
{
HAL_StatusTypeDef status = HAL_OK;
status = HAL_I2C_Mem_Write(i2c_handler, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, 1000);
/* Check the communication status */
if(status != HAL_OK)
{
/* Re-Initiaize the I2C Bus */
I2Cx_Error(i2c_handler, Addr);
}
return status;
}
/**
* @brief Checks if target device is ready for communication.
* @note This function is used with Memory devices
* @param i2c_handler I2C handler
* @param DevAddress Target device address
* @param Trials Number of trials
* @retval HAL status
*/
static HAL_StatusTypeDef I2Cx_IsDeviceReady(I2C_HandleTypeDef *i2c_handler, uint16_t DevAddress, uint32_t Trials)
{
return (HAL_I2C_IsDeviceReady(i2c_handler, DevAddress, Trials, 1000));
}
/**
* @brief Manages error callback by re-initializing I2C.
* @param i2c_handler I2C handler
* @param Addr I2C Address
* @retval None
*/
static void I2Cx_Error(I2C_HandleTypeDef *i2c_handler, uint8_t Addr)
{
/* De-initialize the I2C communication bus */
HAL_I2C_DeInit(i2c_handler);
/* Re-Initialize the I2C communication bus */
I2Cx_Init(i2c_handler);
}
/**
* @}
*/
/*******************************************************************************
LINK OPERATIONS
*******************************************************************************/
/******************************** LINK Sensors ********************************/
/**
* @brief Initializes Sensors low level.
* @retval None
*/
void SENSOR_IO_Init(void)
{
I2Cx_Init(&hI2cHandler);
}
/**
* @brief DeInitializes Sensors low level.
* @retval None
*/
void SENSOR_IO_DeInit(void)
{
I2Cx_DeInit(&hI2cHandler);
}
/**
* @brief Writes a single data.
* @param Addr I2C address
* @param Reg Reg address
* @param Value Data to be written
* @retval None
*/
void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
{
I2Cx_WriteMultiple(&hI2cHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT,(uint8_t*)&Value, 1);
}
/**
* @brief Reads a single data.
* @param Addr I2C address
* @param Reg Reg address
* @retval Data to be read
*/
uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg)
{
uint8_t read_value = 0;
I2Cx_ReadMultiple(&hI2cHandler, Addr, Reg, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&read_value, 1);
return read_value;
}
/**
* @brief Reads multiple data with I2C communication
* channel from TouchScreen.
* @param Addr I2C address
* @param Reg Register address
* @param Buffer Pointer to data buffer
* @param Length Length of the data
* @retval HAL status
*/
uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
{
return I2Cx_ReadMultiple(&hI2cHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
}
/**
* @brief Writes multiple data with I2C communication
* channel from MCU to TouchScreen.
* @param Addr I2C address
* @param Reg Register address
* @param Buffer Pointer to data buffer
* @param Length Length of the data
* @retval None
*/
void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
{
I2Cx_WriteMultiple(&hI2cHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
}
/**
* @brief Checks if target device is ready for communication.
* @note This function is used with Memory devices
* @param DevAddress Target device address
* @param Trials Number of trials
* @retval HAL status
*/
HAL_StatusTypeDef SENSOR_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials)
{
return (I2Cx_IsDeviceReady(&hI2cHandler, DevAddress, Trials));
}
/**
* @brief Delay function used in Sensor low level driver.
* @param Delay Delay in ms
* @retval None
*/
void SENSOR_IO_Delay(uint32_t Delay)
{
HAL_Delay(Delay);
}
/******************************** LINK NFC ********************************/
/**
* @brief Initializes Sensors low level.
* @param GpoIrqEnable 0x0 is disable, otherwise enabled
* @retval None
*/
void NFC_IO_Init(uint8_t GpoIrqEnable)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* I2C init */
I2Cx_Init(&hI2cHandler);
/* GPIO Ports Clock Enable */
NFC_GPIO_CLK_ENABLE();
/* Configure GPIO pins for GPO (PE4) */
if(GpoIrqEnable == 0)
{
GPIO_InitStruct.Pin = NFC_GPIO_GPO_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(NFC_GPIO_GPO_PIN_PORT, &GPIO_InitStruct);
}
else
{
GPIO_InitStruct.Pin = NFC_GPIO_GPO_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(NFC_GPIO_GPO_PIN_PORT, &GPIO_InitStruct);
/* Enable and set EXTI4_IRQn Interrupt to the lowest priority */
HAL_NVIC_SetPriority(EXTI4_IRQn, 3, 0);
HAL_NVIC_EnableIRQ(EXTI4_IRQn);
}
/* Configure GPIO pins for DISABLE (PE2)*/
GPIO_InitStruct.Pin = NFC_GPIO_RFDISABLE_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(NFC_GPIO_RFDISABLE_PIN_PORT, &GPIO_InitStruct);
}
/**
* @brief DeInitializes Sensors low level.
* @retval None
*/
void NFC_IO_DeInit(void)
{
I2Cx_DeInit(&hI2cHandler);
}
/**
* @brief This functions reads a response of the M24SR device
* @param Addr M24SR I2C address
* @param pBuffer Pointer on the buffer to retrieve M24SR response
* @param Length Length of the data
* @retval Status Success or Timeout
*/
uint16_t NFC_IO_ReadMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length )
{
uint16_t status ;
/* Before calling this function M24SR must be ready: check to detect potential issues */
status = NFC_IO_IsDeviceReady(Addr, NFC_I2C_TRIALS);
if (status != NFC_I2C_STATUS_SUCCESS)
{
return NFC_I2C_ERROR_TIMEOUT;
}
if( HAL_I2C_Master_Receive(&hI2cHandler, Addr, (uint8_t*)pBuffer, Length, NFC_I2C_TIMEOUT_STD) != HAL_OK)
{
return NFC_I2C_ERROR_TIMEOUT;
}
return NFC_I2C_STATUS_SUCCESS;
}
/**
* @brief This functions sends the command buffer
* @param Addr M24SR I2C address
* @param pBuffer pointer to the buffer to send to the M24SR
* @param Length Length of the data
* @retval Status Success or Timeout
*/
uint16_t NFC_IO_WriteMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length)
{
uint16_t status ;
/* Before calling this function M24SR must be ready: check to detect potential issues */
status = NFC_IO_IsDeviceReady(Addr, NFC_I2C_TRIALS);
if (status != NFC_I2C_STATUS_SUCCESS)
{
return NFC_I2C_ERROR_TIMEOUT;
}
if( HAL_I2C_Master_Transmit(&hI2cHandler, Addr, (uint8_t*)pBuffer, Length, NFC_I2C_TIMEOUT_STD) != HAL_OK)
{
return NFC_I2C_ERROR_TIMEOUT;
}
return NFC_I2C_STATUS_SUCCESS;
}
/**
* @brief Checks if target device is ready for communication.
* @param Addr M24SR I2C address
* @param Trials Number of trials (currently not present in M24sr)
* @retval Status Success or Timeout
*/
uint16_t NFC_IO_IsDeviceReady (uint8_t Addr, uint32_t Trials)
{
HAL_StatusTypeDef status;
uint32_t tickstart = 0;
uint32_t currenttick = 0;
/* Get tick */
tickstart = HAL_GetTick();
/* Wait until M24SR is ready or timeout occurs */
do
{
status = HAL_I2C_IsDeviceReady(&hI2cHandler, Addr, Trials, NFC_I2C_TIMEOUT_STD);
currenttick = HAL_GetTick();
} while( ( (currenttick - tickstart) < NFC_I2C_TIMEOUT_MAX) && (status != HAL_OK) );
if (status != HAL_OK)
{
return NFC_I2C_ERROR_TIMEOUT;
}
return NFC_I2C_STATUS_SUCCESS;
}
/**
* @brief This function read the state of the M24SR GPO
* @retval GPIO_PinState state of the M24SR GPO
*/
void NFC_IO_ReadState(uint8_t * pPinState)
{
*pPinState = (uint8_t)HAL_GPIO_ReadPin(NFC_GPIO_GPO_PIN_PORT,NFC_GPIO_GPO_PIN);
}
/**
* @brief This function sets the state of the M24SR RF disable pin
* @param PinState put RF disable pin of M24SR in PinState (1 or 0)
*/
void NFC_IO_RfDisable(uint8_t PinState)
{
HAL_GPIO_WritePin(NFC_GPIO_RFDISABLE_PIN_PORT,NFC_GPIO_RFDISABLE_PIN,(GPIO_PinState)PinState);
}
/**
* @brief Delay function used in M24SR low level driver.
* @param Delay Delay in ms
* @retval None
*/
void NFC_IO_Delay(uint32_t Delay)
{
HAL_Delay(Delay);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,257 @@
/**
******************************************************************************
* @file stm32l475e_iot01.h
* @author MCD Application Team
* @brief STM32L475E IOT01 board support package
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L475E_IOT01_H
#define __STM32L475E_IOT01_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l4xx_hal.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @addtogroup STM32L475E_IOT01_LOW_LEVEL
* @{
*/
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Exported_Types LOW LEVEL Exported Types
* @{
*/
typedef enum
{
LED2 = 0,
LED_GREEN = LED2,
}Led_TypeDef;
typedef enum
{
BUTTON_USER = 0
}Button_TypeDef;
typedef enum
{
BUTTON_MODE_GPIO = 0,
BUTTON_MODE_EXTI = 1
}ButtonMode_TypeDef;
typedef enum
{
COM1 = 0,
COM2 = 0,
}COM_TypeDef;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Exported_Constants LOW LEVEL Exported Constants
* @{
*/
/**
* @brief Define for STM32L475E_IOT01 board
*/
#if !defined (USE_STM32L475E_IOT01)
#define USE_STM32L475E_IOT01
#endif
#define LEDn ((uint8_t)1)
#define LED2_PIN GPIO_PIN_14
#define LED2_GPIO_PORT GPIOB
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED2_GPIO_CLK_ENABLE();}while(0)
#define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED2_GPIO_CLK_DISABLE();}while(0)
/* Only one User/Wakeup button */
#define BUTTONn ((uint8_t)1)
/**
* @brief Wakeup push-button
*/
#define USER_BUTTON_PIN GPIO_PIN_13
#define USER_BUTTON_GPIO_PORT GPIOC
#define USER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define USER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define USER_BUTTON_EXTI_IRQn EXTI15_10_IRQn
/**
* @brief NFC Gpio PINs
*/
#define NFC_GPIO_GPO_PIN GPIO_PIN_4
#define NFC_GPIO_GPO_PIN_PORT GPIOE
#define NFC_GPIO_RFDISABLE_PIN GPIO_PIN_2
#define NFC_GPIO_RFDISABLE_PIN_PORT GPIOE
#define NFC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE();
#define NFC_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE();
#define COMn ((uint8_t)1)
/**
* @brief Definition for COM port1, connected to USART1
*/
#define DISCOVERY_COM1 USART1
#define DISCOVERY_COM1_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE()
#define DISCOVERY_COM1_CLK_DISABLE() __HAL_RCC_USART1_CLK_DISABLE()
#define DISCOVERY_COM1_TX_PIN GPIO_PIN_6
#define DISCOVERY_COM1_TX_GPIO_PORT GPIOB
#define DISCOVERY_COM1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define DISCOVERY_COM1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define DISCOVERY_COM1_TX_AF GPIO_AF7_USART1
#define DISCOVERY_COM1_RX_PIN GPIO_PIN_7
#define DISCOVERY_COM1_RX_GPIO_PORT GPIOB
#define DISCOVERY_COM1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define DISCOVERY_COM1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define DISCOVERY_COM1_RX_AF GPIO_AF7_USART1
#define DISCOVERY_COM1_IRQn USART1_IRQn
#define DISCOVERY_COMx_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_CLK_ENABLE();}} while(0)
#define DISCOVERY_COMx_CLK_DISABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_CLK_DISABLE();}} while(0)
#define DISCOVERY_COMx_TX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_TX_GPIO_CLK_ENABLE();}} while(0)
#define DISCOVERY_COMx_TX_GPIO_CLK_DISABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_TX_GPIO_CLK_DISABLE();}} while(0)
#define DISCOVERY_COMx_RX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_RX_GPIO_CLK_ENABLE();}} while(0)
#define DISCOVERY_COMx_RX_GPIO_CLK_DISABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_RX_GPIO_CLK_DISABLE();}} while(0)
/* User can use this section to tailor I2Cx instance used and associated resources */
/* Definition for I2Cx resources */
#define DISCOVERY_I2Cx I2C2
#define DISCOVERY_I2Cx_CLK_ENABLE() __HAL_RCC_I2C2_CLK_ENABLE()
#define DISCOVERY_I2Cx_CLK_DISABLE() __HAL_RCC_I2C2_CLK_DISABLE()
#define DISCOVERY_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
#define DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define DISCOVERY_I2Cx_FORCE_RESET() __HAL_RCC_I2C2_FORCE_RESET()
#define DISCOVERY_I2Cx_RELEASE_RESET() __HAL_RCC_I2C2_RELEASE_RESET()
/* Definition for I2Cx Pins */
#define DISCOVERY_I2Cx_SCL_PIN GPIO_PIN_10
#define DISCOVERY_I2Cx_SDA_PIN GPIO_PIN_11
#define DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT GPIOB
#define DISCOVERY_I2Cx_SCL_SDA_AF GPIO_AF4_I2C2
/* I2C interrupt requests */
#define DISCOVERY_I2Cx_EV_IRQn I2C2_EV_IRQn
#define DISCOVERY_I2Cx_ER_IRQn I2C2_ER_IRQn
/* I2C clock speed configuration (in Hz)
WARNING:
Make sure that this define is not already declared in other files.
It can be used in parallel by other modules. */
#ifndef DISCOVERY_I2C_SPEED
#define DISCOVERY_I2C_SPEED 100000
#endif /* DISCOVERY_I2C_SPEED */
#ifndef DISCOVERY_I2Cx_TIMING
#define DISCOVERY_I2Cx_TIMING ((uint32_t)0x00702681)
#endif /* DISCOVERY_I2Cx_TIMING */
/* I2C Sensors address */
/* LPS22HB (Pressure) I2C Address */
#define LPS22HB_I2C_ADDRESS (uint8_t)0xBA
/* HTS221 (Humidity) I2C Address */
#define HTS221_I2C_ADDRESS (uint8_t)0xBE
#ifdef USE_LPS22HB_TEMP
/* LPS22HB Sensor hardware I2C address */
#define TSENSOR_I2C_ADDRESS LPS22HB_I2C_ADDRESS
#else /* USE_HTS221_TEMP */
/* HTS221 Sensor hardware I2C address */
#define TSENSOR_I2C_ADDRESS HTS221_I2C_ADDRESS
#endif
/* NFC I2C address and specific config parameters */
#define M24SR_I2C_ADDR (uint8_t) 0xAC /*!< M24SR address */
#define NFC_I2C_STATUS_SUCCESS (uint16_t) 0x0000
#define NFC_I2C_ERROR_TIMEOUT (uint16_t) 0x0011
#define NFC_I2C_TIMEOUT_STD (uint32_t) 8 /* I2C Time out (ms), used to call Transmit/Receive HAL functions */
#define NFC_I2C_TIMEOUT_MAX (uint32_t) 200 /* I2C Time out (ms), this is the maximum time needed by M24SR to complete any command */
#define NFC_I2C_TRIALS (uint32_t) 1 /* In case M24SR will reply ACK failed allow to perform retry before returning error (HAL option not used) */
/**
* @}
*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Exported_Functions LOW LEVEL Exported Functions
* @{
*/
uint32_t BSP_GetVersion(void);
void BSP_LED_Init(Led_TypeDef Led);
void BSP_LED_DeInit(Led_TypeDef Led);
void BSP_LED_On(Led_TypeDef Led);
void BSP_LED_Off(Led_TypeDef Led);
void BSP_LED_Toggle(Led_TypeDef Led);
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
void BSP_PB_DeInit(Button_TypeDef Button);
uint32_t BSP_PB_GetState(Button_TypeDef Button);
void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *husart);
void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STM32L475E_IOT01_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,151 @@
/**
******************************************************************************
* @file stm32l475e_iot01_accelero.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the accelerometer sensor
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01_accelero.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @defgroup STM32L475E_IOT01_ACCELERO ACCELERO
* @{
*/
/** @defgroup STM32L475E_IOT01_ACCELERO_Private_Variables ACCELERO Private Variables
* @{
*/
static ACCELERO_DrvTypeDef *AccelerometerDrv;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_ACCELERO_Private_Functions ACCELERO Private Functions
* @{
*/
/**
* @brief Initialize the ACCELERO.
* @retval ACCELERO_OK or ACCELERO_ERROR
*/
ACCELERO_StatusTypeDef BSP_ACCELERO_Init(void)
{
ACCELERO_StatusTypeDef ret = ACCELERO_OK;
uint16_t ctrl = 0x0000;
ACCELERO_InitTypeDef LSM6DSL_InitStructure;
if(Lsm6dslAccDrv.ReadID() != LSM6DSL_ACC_GYRO_WHO_AM_I)
{
ret = ACCELERO_ERROR;
}
else
{
/* Initialize the ACCELERO accelerometer driver structure */
AccelerometerDrv = &Lsm6dslAccDrv;
/* MEMS configuration ------------------------------------------------------*/
/* Fill the ACCELERO accelerometer structure */
LSM6DSL_InitStructure.AccOutput_DataRate = LSM6DSL_ODR_52Hz;
LSM6DSL_InitStructure.Axes_Enable = 0;
LSM6DSL_InitStructure.AccFull_Scale = LSM6DSL_ACC_FULLSCALE_2G;
LSM6DSL_InitStructure.BlockData_Update = LSM6DSL_BDU_BLOCK_UPDATE;
LSM6DSL_InitStructure.High_Resolution = 0;
LSM6DSL_InitStructure.Communication_Mode = 0;
/* Configure MEMS: data rate, full scale */
ctrl = (LSM6DSL_InitStructure.AccOutput_DataRate | LSM6DSL_InitStructure.AccFull_Scale);
/* Configure MEMS: BDU and Auto-increment for multi read/write */
ctrl |= ((LSM6DSL_InitStructure.BlockData_Update | LSM6DSL_ACC_GYRO_IF_INC_ENABLED) << 8);
/* Configure the ACCELERO accelerometer main parameters */
AccelerometerDrv->Init(ctrl);
}
return ret;
}
/**
* @brief DeInitialize the ACCELERO.
* @retval None.
*/
void BSP_ACCELERO_DeInit(void)
{
/* DeInitialize the accelerometer IO interfaces */
if(AccelerometerDrv != NULL)
{
if(AccelerometerDrv->DeInit != NULL)
{
AccelerometerDrv->DeInit();
}
}
}
/**
* @brief Set/Unset the ACCELERO in low power mode.
* @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
* @retval None
*/
void BSP_ACCELERO_LowPower(uint16_t status)
{
/* Set/Unset the ACCELERO in low power mode */
if(AccelerometerDrv != NULL)
{
if(AccelerometerDrv->LowPower != NULL)
{
AccelerometerDrv->LowPower(status);
}
}
}
/**
* @brief Get XYZ acceleration values.
* @param pDataXYZ Pointer on 3 angular accelerations table with
* pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis
* @retval None
*/
void BSP_ACCELERO_AccGetXYZ(int16_t *pDataXYZ)
{
if(AccelerometerDrv != NULL)
{
if(AccelerometerDrv->GetXYZ != NULL)
{
AccelerometerDrv->GetXYZ(pDataXYZ);
}
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,89 @@
/**
******************************************************************************
* @file stm32l475e_iot01_accelero.h
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the accelerometer sensor
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L475E_IOT01_ACCELERO_H
#define __STM32L475E_IOT01_ACCELERO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01.h"
/* Include Accelero component driver */
#include "../Components/lsm6dsl/lsm6dsl.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @addtogroup STM32L475E_IOT01_ACCELERO
* @{
*/
/** @defgroup STM32L475_DISCOVERY_ACCELERO_Exported_Types ACCELERO Exported Types
* @{
*/
typedef enum
{
ACCELERO_OK = 0,
ACCELERO_ERROR = 1,
ACCELERO_TIMEOUT = 2
}
ACCELERO_StatusTypeDef;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_ACCELERO_Exported_Functions ACCELERO Exported Functions
* @{
*/
/* Sensor Configuration Functions */
ACCELERO_StatusTypeDef BSP_ACCELERO_Init(void);
void BSP_ACCELERO_DeInit(void);
void BSP_ACCELERO_LowPower(uint16_t status); /* 0 Means Disable Low Power Mode, otherwise Low Power Mode is enabled */
void BSP_ACCELERO_AccGetXYZ(int16_t *pDataXYZ);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STM32L475E_IOT01_ACCELERO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,155 @@
/**
******************************************************************************
* @file stm32l475e_iot01_gyro.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the gyroscope sensor
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01_gyro.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @defgroup STM32L475E_IOT01_GYROSCOPE GYROSCOPE
* @{
*/
/** @defgroup STM32L475E_IOT01_GYROSCOPE_Private_Variables GYROSCOPE Private Variables
* @{
*/
static GYRO_DrvTypeDef *GyroscopeDrv;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_GYROSCOPE_Private_Functions GYROSCOPE Private Functions
* @{
*/
/**
* @brief Initialize Gyroscope.
* @retval GYRO_OK or GYRO_ERROR
*/
uint8_t BSP_GYRO_Init(void)
{
uint8_t ret = GYRO_ERROR;
uint16_t ctrl = 0x0000;
GYRO_InitTypeDef LSM6DSL_InitStructure;
if(Lsm6dslGyroDrv.ReadID() != LSM6DSL_ACC_GYRO_WHO_AM_I)
{
ret = GYRO_ERROR;
}
else
{
/* Initialize the gyroscope driver structure */
GyroscopeDrv = &Lsm6dslGyroDrv;
/* Configure Mems : data rate, power mode, full scale and axes */
LSM6DSL_InitStructure.Power_Mode = 0;
LSM6DSL_InitStructure.Output_DataRate = LSM6DSL_ODR_52Hz;
LSM6DSL_InitStructure.Axes_Enable = 0;
LSM6DSL_InitStructure.Band_Width = 0;
LSM6DSL_InitStructure.BlockData_Update = LSM6DSL_BDU_BLOCK_UPDATE;
LSM6DSL_InitStructure.Endianness = 0;
LSM6DSL_InitStructure.Full_Scale = LSM6DSL_GYRO_FS_2000;
/* Configure MEMS: data rate, full scale */
ctrl = (LSM6DSL_InitStructure.Full_Scale | LSM6DSL_InitStructure.Output_DataRate);
/* Configure MEMS: BDU and Auto-increment for multi read/write */
ctrl |= ((LSM6DSL_InitStructure.BlockData_Update | LSM6DSL_ACC_GYRO_IF_INC_ENABLED) << 8);
/* Initialize component */
GyroscopeDrv->Init(ctrl);
ret = GYRO_OK;
}
return ret;
}
/**
* @brief DeInitialize Gyroscope.
*/
void BSP_GYRO_DeInit(void)
{
/* DeInitialize the Gyroscope IO interfaces */
if(GyroscopeDrv != NULL)
{
if(GyroscopeDrv->DeInit!= NULL)
{
GyroscopeDrv->DeInit();
}
}
}
/**
* @brief Set/Unset Gyroscope in low power mode.
* @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
*/
void BSP_GYRO_LowPower(uint16_t status)
{
/* Set/Unset component in low-power mode */
if(GyroscopeDrv != NULL)
{
if(GyroscopeDrv->LowPower!= NULL)
{
GyroscopeDrv->LowPower(status);
}
}
}
/**
* @brief Get XYZ angular acceleration from the Gyroscope.
* @param pfData: pointer on floating array
*/
void BSP_GYRO_GetXYZ(float* pfData)
{
if(GyroscopeDrv != NULL)
{
if(GyroscopeDrv->GetXYZ!= NULL)
{
GyroscopeDrv->GetXYZ(pfData);
}
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,88 @@
/**
******************************************************************************
* @file stm32l475e_iot01_gyro.h
* @author MCD Application Team
* @brief This file contains definitions for the stm32l475e_iot01_gyro.c
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L475E_IOT01_GYRO_H
#define __STM32L475E_IOT01_GYRO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01.h"
/* Include Gyro component driver */
#include "../Components/lsm6dsl/lsm6dsl.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @addtogroup STM32L475E_IOT01_GYROSCOPE
* @{
*/
/** @defgroup STM32L475_IOT01_GYROSCOPE_Exported_Constants GYROSCOPE Exported Constants
* @{
*/
typedef enum
{
GYRO_OK = 0,
GYRO_ERROR = 1,
GYRO_TIMEOUT = 2
}
GYRO_StatusTypeDef;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_GYROSCOPE_Exported_Functions GYROSCOPE Exported Functions
* @{
*/
uint8_t BSP_GYRO_Init(void);
void BSP_GYRO_DeInit(void);
void BSP_GYRO_LowPower(uint16_t status); /* 0 Means Disable Low Power Mode, otherwise Low Power Mode is enabled */
void BSP_GYRO_GetXYZ(float* pfData);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STM32L475E_IOT01_GYRO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,102 @@
/**
******************************************************************************
* @file stm32l475e_iot01_hsensor.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the humidity sensor
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01_hsensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @defgroup STM32L475E_IOT01_HUMIDITY HUMIDITY
* @{
*/
/** @defgroup STM32L475E_IOT01_HUMIDITY_Private_Variables HUMIDITY Private Variables
* @{
*/
static HSENSOR_DrvTypeDef *Hsensor_drv;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_HUMIDITY_Private_Functions HUMIDITY Private Functions
* @{
*/
/**
* @brief Initializes peripherals used by the I2C Humidity Sensor driver.
* @retval HSENSOR status
*/
uint32_t BSP_HSENSOR_Init(void)
{
uint32_t ret;
if(HTS221_H_Drv.ReadID(HTS221_I2C_ADDRESS) != HTS221_WHO_AM_I_VAL)
{
ret = HSENSOR_ERROR;
}
else
{
Hsensor_drv = &HTS221_H_Drv;
/* HSENSOR Init */
Hsensor_drv->Init(HTS221_I2C_ADDRESS);
ret = HSENSOR_OK;
}
return ret;
}
/**
* @brief Read ID of HTS221.
* @retval HTS221 ID value.
*/
uint8_t BSP_HSENSOR_ReadID(void)
{
return Hsensor_drv->ReadID(HTS221_I2C_ADDRESS);
}
/**
* @brief Read Humidity register of HTS221.
* @retval HTS221 measured humidity value.
*/
float BSP_HSENSOR_ReadHumidity(void)
{
return Hsensor_drv->ReadHumidity(HTS221_I2C_ADDRESS);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,91 @@
/**
******************************************************************************
* @file stm32l475e_iot01_hsensor.h
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the humidity sensor
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L475E_IOT01_HSENSOR_H
#define __STM32L475E_IOT01_HSENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01.h"
#include "../Components/hts221/hts221.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @addtogroup STM32L475E_IOT01_HUMIDITY
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup STM32L475E_IOT01_HUMIDITY_Exported_Types HUMIDITY Exported Types
* @{
*/
/**
* @brief HSENSOR Status
*/
typedef enum
{
HSENSOR_OK = 0,
HSENSOR_ERROR
}HSENSOR_Status_TypDef;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_HUMIDITY_Exported_Functions HUMIDITY Exported Functions
* @{
*/
/* Sensor Configuration Functions */
uint32_t BSP_HSENSOR_Init(void);
uint8_t BSP_HSENSOR_ReadID(void);
float BSP_HSENSOR_ReadHumidity(void);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* __STM32L475E_IOT01_HSENSOR_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,141 @@
/**
******************************************************************************
* @file stm32l475e_iot01_magneto.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the magnetometer sensor
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01_magneto.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @defgroup STM32L475E_IOT01_MAGNETO MAGNETO
* @{
*/
/** @defgroup STM32L475E_IOT01_MAGNETO_Private_Variables MAGNETO Private Variables
* @{
*/
static MAGNETO_DrvTypeDef *MagnetoDrv;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_MAGNETO_Private_Functions MAGNETO Private Functions
* @{
*/
/**
* @brief Initialize a magnetometer sensor
* @retval COMPONENT_ERROR in case of failure
*/
MAGNETO_StatusTypeDef BSP_MAGNETO_Init(void)
{
MAGNETO_StatusTypeDef ret = MAGNETO_OK;
MAGNETO_InitTypeDef LIS3MDL_InitStructureMag;
if(Lis3mdlMagDrv.ReadID() != I_AM_LIS3MDL)
{
ret = MAGNETO_ERROR;
}
else
{
/* Initialize the MAGNETO magnetometer driver structure */
MagnetoDrv = &Lis3mdlMagDrv;
/* MEMS configuration ------------------------------------------------------*/
/* Fill the MAGNETO magnetometer structure */
LIS3MDL_InitStructureMag.Register1 = LIS3MDL_MAG_TEMPSENSOR_DISABLE | LIS3MDL_MAG_OM_XY_HIGH | LIS3MDL_MAG_ODR_40_HZ;
LIS3MDL_InitStructureMag.Register2 = LIS3MDL_MAG_FS_4_GA | LIS3MDL_MAG_REBOOT_DEFAULT | LIS3MDL_MAG_SOFT_RESET_DEFAULT;
LIS3MDL_InitStructureMag.Register3 = LIS3MDL_MAG_CONFIG_NORMAL_MODE | LIS3MDL_MAG_CONTINUOUS_MODE;
LIS3MDL_InitStructureMag.Register4 = LIS3MDL_MAG_OM_Z_HIGH | LIS3MDL_MAG_BLE_LSB;
LIS3MDL_InitStructureMag.Register5 = LIS3MDL_MAG_BDU_MSBLSB;
/* Configure the MAGNETO magnetometer main parameters */
MagnetoDrv->Init(LIS3MDL_InitStructureMag);
}
return ret;
}
/**
* @brief DeInitialize the MAGNETO.
*/
void BSP_MAGNETO_DeInit(void)
{
/* DeInitialize the magnetometer IO interfaces */
if(MagnetoDrv != NULL)
{
if(MagnetoDrv->DeInit != NULL)
{
MagnetoDrv->DeInit();
}
}
}
/**
* @brief Set/Unset the MAGNETO in low power mode.
*/
void BSP_MAGNETO_LowPower(uint16_t status)
{
/* Put the magnetometer in low power mode */
if(MagnetoDrv != NULL)
{
if(MagnetoDrv->LowPower != NULL)
{
MagnetoDrv->LowPower(status);
}
}
}
/**
* @brief Get XYZ magnetometer values.
* @param pDataXYZ Pointer on 3 magnetometer values table with
* pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis
*/
void BSP_MAGNETO_GetXYZ(int16_t *pDataXYZ)
{
if(MagnetoDrv != NULL)
{
if(MagnetoDrv->GetXYZ != NULL)
{
MagnetoDrv->GetXYZ(pDataXYZ);
}
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,89 @@
/**
******************************************************************************
* @file stm32l475e_iot01_magneto.h
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the magnetometer sensor
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L475E_IOT01_MAGNETO_H
#define __STM32L475E_IOT01_MAGNETO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01.h"
/* Include Magnetometer component driver */
#include "../Components/lis3mdl/lis3mdl.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @addtogroup STM32L475E_IOT01_MAGNETO
* @{
*/
/** @defgroup STM32L475_IOT01_MAGNETO_Exported_Types MAGNETO Exported Types
* @{
*/
/* Exported types ------------------------------------------------------------*/
typedef enum
{
MAGNETO_OK = 0,
MAGNETO_ERROR = 1,
MAGNETO_TIMEOUT = 2
}
MAGNETO_StatusTypeDef;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_MAGNETO_Exported_Functions MAGNETO Exported Functions
* @{
*/
MAGNETO_StatusTypeDef BSP_MAGNETO_Init(void);
void BSP_MAGNETO_DeInit(void);
void BSP_MAGNETO_LowPower(uint16_t status); /* 0 Means Disable Low Power Mode, otherwise Low Power Mode is enabled */
void BSP_MAGNETO_GetXYZ(int16_t *pDataXYZ);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STM32L475E_IOT01_MAGNETO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,103 @@
/**
******************************************************************************
* @file stm32l475e_iot01_psensor.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the pressure sensor
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01_psensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @defgroup STM32L475E_IOT01_PRESSURE PRESSURE
* @{
*/
/** @defgroup STM32L475E_IOT01_PRESSURE_Private_Variables PRESSURE Private Variables
* @{
*/
static PSENSOR_DrvTypeDef *Psensor_drv;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_PRESSURE_Private_Functions PRESSURE Private Functions
* @{
*/
/**
* @brief Initializes peripherals used by the I2C Pressure Sensor driver.
* @retval PSENSOR status
*/
uint32_t BSP_PSENSOR_Init(void)
{
uint32_t ret;
if(LPS22HB_P_Drv.ReadID(LPS22HB_I2C_ADDRESS) != LPS22HB_WHO_AM_I_VAL)
{
ret = PSENSOR_ERROR;
}
else
{
Psensor_drv = &LPS22HB_P_Drv;
/* PSENSOR Init */
Psensor_drv->Init(LPS22HB_I2C_ADDRESS);
ret = PSENSOR_OK;
}
return ret;
}
/**
* @brief Read ID of LPS22HB.
* @retval LPS22HB ID value.
*/
uint8_t BSP_PSENSOR_ReadID(void)
{
return Psensor_drv->ReadID(LPS22HB_I2C_ADDRESS);
}
/**
* @brief Read Pressure register of LPS22HB.
* @retval LPS22HB measured pressure value.
*/
float BSP_PSENSOR_ReadPressure(void)
{
return Psensor_drv->ReadPressure(LPS22HB_I2C_ADDRESS);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,91 @@
/**
******************************************************************************
* @file stm32l475e_iot01_psensor.h
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the pressure sensor
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L475E_IOT01_PSENSOR_H
#define __STM32L475E_IOT01_PSENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01.h"
#include "../Components/lps22hb/lps22hb.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @addtogroup STM32L475E_IOT01_PRESSURE
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup STM32L475E_IOT01_PRESSURE_Exported_Types PRESSURE Exported Types
* @{
*/
/**
* @brief PSENSOR Status
*/
typedef enum
{
PSENSOR_OK = 0,
PSENSOR_ERROR
}PSENSOR_Status_TypDef;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_PRESSURE_Exported_Functions PRESSURE Exported Functions
* @{
*/
/* Sensor Configuration Functions */
uint32_t BSP_PSENSOR_Init(void);
uint8_t BSP_PSENSOR_ReadID(void);
float BSP_PSENSOR_ReadPressure(void);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STM32L475E_IOT01_PSENSOR_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,120 @@
/**
******************************************************************************
* @file stm32l475e_iot01_qspi.h
* @author MCD Application Team
* @brief This file contains the common defines and functions prototypes for
* the stm32l475e_iot01_qspi.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L475E_IOT01_QSPI_H
#define __STM32L475E_IOT01_QSPI_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l4xx_hal.h"
#include "../Components/mx25r6435f/mx25r6435f.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @addtogroup STM32L475E_IOT01_QSPI
* @{
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup STM32L475E_IOT01_QSPI_Exported_Constants QSPI Exported Constants
* @{
*/
/* QSPI Error codes */
#define QSPI_OK ((uint8_t)0x00)
#define QSPI_ERROR ((uint8_t)0x01)
#define QSPI_BUSY ((uint8_t)0x02)
#define QSPI_NOT_SUPPORTED ((uint8_t)0x04)
#define QSPI_SUSPENDED ((uint8_t)0x08)
/**
* @}
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup STM32L475E_IOT01_QSPI_Exported_Types QSPI Exported Types
* @{
*/
/* QSPI Info */
typedef struct {
uint32_t FlashSize; /*!< Size of the flash */
uint32_t EraseSectorSize; /*!< Size of sectors for the erase operation */
uint32_t EraseSectorsNumber; /*!< Number of sectors for the erase operation */
uint32_t ProgPageSize; /*!< Size of pages for the program operation */
uint32_t ProgPagesNumber; /*!< Number of pages for the program operation */
} QSPI_Info;
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup STM32L475E_IOT01_QSPI_Exported_Functions QSPI Exported Functions
* @{
*/
uint8_t BSP_QSPI_Init (void);
uint8_t BSP_QSPI_DeInit (void);
uint8_t BSP_QSPI_Read (uint8_t* pData, uint32_t ReadAddr, uint32_t Size);
uint8_t BSP_QSPI_Write (uint8_t* pData, uint32_t WriteAddr, uint32_t Size);
uint8_t BSP_QSPI_Erase_Block (uint32_t BlockAddress);
uint8_t BSP_QSPI_Erase_Sector (uint32_t Sector);
uint8_t BSP_QSPI_Erase_Chip (void);
uint8_t BSP_QSPI_GetStatus (void);
uint8_t BSP_QSPI_GetInfo (QSPI_Info* pInfo);
uint8_t BSP_QSPI_EnableMemoryMappedMode(void);
uint8_t BSP_QSPI_SuspendErase (void);
uint8_t BSP_QSPI_ResumeErase (void);
uint8_t BSP_QSPI_EnterDeepPowerDown (void);
uint8_t BSP_QSPI_LeaveDeepPowerDown (void);
void BSP_QSPI_MspInit(void);
void BSP_QSPI_MspDeInit(void);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STM32L475E_IOT01_QSPI_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,96 @@
/**
******************************************************************************
* @file stm32l475e_iot01_tsensor.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the temperature sensor
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01_tsensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @defgroup STM32L475E_IOT01_TEMPERATURE TEMPERATURE
* @{
*/
/** @defgroup STM32L475E_IOT01_TEMPERATURE_Private_Variables TEMPERATURE Private Variables
* @{
*/
static TSENSOR_DrvTypeDef *tsensor_drv;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_TEMPERATURE_Private_Functions TEMPERATURE Private Functions
* @{
*/
/**
* @brief Initializes peripherals used by the I2C Temperature Sensor driver.
* @retval TSENSOR status
*/
uint32_t BSP_TSENSOR_Init(void)
{
uint8_t ret = TSENSOR_ERROR;
#ifdef USE_LPS22HB_TEMP
tsensor_drv = &LPS22HB_T_Drv;
#else /* USE_HTS221_TEMP */
tsensor_drv = &HTS221_T_Drv;
#endif
/* Low level init */
SENSOR_IO_Init();
/* TSENSOR Init */
tsensor_drv->Init(TSENSOR_I2C_ADDRESS, NULL);
ret = TSENSOR_OK;
return ret;
}
/**
* @brief Read Temperature register of TS751.
* @retval STTS751 measured temperature value.
*/
float BSP_TSENSOR_ReadTemp(void)
{
return tsensor_drv->ReadTemp(TSENSOR_I2C_ADDRESS);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,97 @@
/**
******************************************************************************
* @file stm32l475e_iot01_tsensor.h
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the temperature sensor
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L475E_IOT01_TSENSOR_H
#define __STM32L475E_IOT01_TSENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01.h"
#ifdef USE_LPS22HB_TEMP
#include "../Components/lps22hb/lps22hb.h"
#else /* USE_HTS221_TEMP */
#include "../Components/hts221/hts221.h"
#endif
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @addtogroup STM32L475E_IOT01_TEMPERATURE
* @{
*/
/** @defgroup STM32L475E_IOT01_TEMPERATURE_Exported_Types TEMPERATURE Exported Types
* @{
*/
/**
* @brief TSENSOR Status
*/
typedef enum
{
TSENSOR_OK = 0,
TSENSOR_ERROR
}TSENSOR_Status_TypDef;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_TEMPERATURE_Exported_Functions TEMPERATURE Exported Constants
* @{
*/
/* Exported macros -----------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/* Sensor Configuration Functions */
uint32_t BSP_TSENSOR_Init(void);
float BSP_TSENSOR_ReadTemp(void);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* __STM32L475E_IOT01_TSENSOR_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,212 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for BSP Components Common Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-bsp-components-common-drivers"><small>Release Notes for</small> <mark>BSP Components Common Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the BSP components common drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V5.1.2 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section21" aria-hidden="true"> <label for="collapse-section21" aria-hidden="true">V5.1.1 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
<li>Correct sensor names in headers files hsensor.h and psensor.h</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V5.1.0 / 21-November-2017</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>Add dpredriver.h: support of DP redriver class</li>
<li>Add pwrmon.h: support of power monitor class</li>
<li>Add usbtypecswitch.h: support of USB type C switch class</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V5.0.0 / 01-March-2017</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>Add hsensor.h: support of humidity class</li>
<li>Add psensor.h: support of pressure class</li>
<li>Update tsensor.h: Temperature can be negative</li>
<li>Update accelero.h: LowPower API can enable or disable the low power mode</li>
<li>Update magneto.h: LowPower API can enable or disable the low power mode</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">Notes:</span></span></strong></p>
<p>This version breaks the compatibility with previous versions.</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V4.0.1 / 21-July-2015</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>tsensor.h: Fix compilation issue on TSENSOR_InitTypeDef</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V4.0.0 / 22-June-2015</label>
<div>
<h2 id="main-changes-5">Main Changes</h2>
<ul>
<li>accelero.h: add *DeInit field in ACCELERO_DrvTypeDef structure</li>
<li>audio.h: add *DeInit field in AUDIO_DrvTypeDef structure</li>
<li>idd.h:
<ul>
<li>add Shunt0StabDelay, Shunt1StabDelay, Shunt2StabDelay, Shunt3StabDelay, Shunt4StabDelay and ShuntNbOnBoard fields in IDD_ConfigTypeDef structure</li>
<li>rename ShuntNumber field to ShuntNbUsed in IDD_ConfigTypeDef structure</li>
</ul></li>
<li>magneto.h: add *DeInit field in MAGNETO_DrvTypeDef structure</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">Important Note:</span></span></strong></p>
<p>This release V4.0.0 is not backward compatible with V3.0.0.</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section16" aria-hidden="true"> <label for="collapse-section16" aria-hidden="true">V3.0.0 / 28-April-2015</label>
<div>
<h2 id="main-changes-6">Main Changes</h2>
<ul>
<li>accelero.h: add <em>LowPower</em> field in ACCELERO_DrvTypeDef structure</li>
<li>magneto.h: add <em>LowPower</em> field in MAGNETO_DrvTypeDef structure</li>
<li>gyro.h: add <em>DeInit</em> and <em>LowPower</em> fields in GYRO_DrvTypeDef structure</li>
<li>camera.h: add CAMERA_COLOR_EFFECT_NONE define</li>
<li>idd.h:
<ul>
<li>add MeasureNb, DeltaDelayUnit and DeltaDelayValue fields in IDD_ConfigTypeDef structure</li>
<li>rename PreDelay field to PreDelayUnit in IDD_ConfigTypeDef structure</li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">Important Note:</span></span></strong></p>
<p>This release V3.0.0 is not backward compatible with V2.2.0.</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section155" aria-hidden="true"> <label for="collapse-section155" aria-hidden="true">V2.2.0 / 09-February-2015</label>
<div>
<h2 id="main-changes-7">Main Changes</h2>
<ul>
<li>Magnetometer driver function prototypes added (magneto.h file)</li>
<li>Update “idd.h” file to provide DeInit() and WakeUp() services in IDD current measurement driver</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section15" aria-hidden="true"> <label for="collapse-section15" aria-hidden="true">V2.1.0 / 06-February-2015</label>
<div>
<h2 id="main-changes-8">Main Changes</h2>
<ul>
<li>IDD current measurement driver function prototypes added (idd.h file)</li>
<li>io.h: add new typedef enum IO_PinState with IO_PIN_RESET and IO_PIN_SET values</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section12" aria-hidden="true"> <label for="collapse-section12" aria-hidden="true">V2.0.0 / 15-December-2014</label>
<div>
<h2 id="main-changes-9">Main Changes</h2>
<ul>
<li>Update “io.h” file to support MFX (Multi Function eXpander) device available on some STM32 boards
<ul>
<li>add new entries for IO_ModeTypedef enumeration structure</li>
<li>update the IO_DrvTypeDef structure
<ul>
<li>Update all return values and function parameters to uint32_t</li>
<li>Add a return value for Config field</li>
</ul></li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">Important Note:</span></span></strong></p>
<p>This version V2.0.0 is not backward compatible with V1.2.1.</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section9" aria-hidden="true"> <label for="collapse-section9" aria-hidden="true">V1.2.1 / 02-December-2014</label>
<div>
<h2 id="main-changes-10">Main Changes</h2>
<ul>
<li>gyro.h: change “__GIRO_H” by “__GYRO_H” to fix compilation issue under Mac OS</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section8" aria-hidden="true"> <label for="collapse-section8" aria-hidden="true">V1.2.0 / 18-June-2014</label>
<div>
<h2 id="main-changes-11">Main Changes</h2>
<ul>
<li>EPD (E Paper Display) driver function prototype added (epd.h file)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section7" aria-hidden="true"> <label for="collapse-section7" aria-hidden="true">V1.1.0 / 21-March-2014</label>
<div>
<h2 id="main-changes-12">Main Changes</h2>
<ul>
<li>Temperature Sensor driver function prototype added</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section7" aria-hidden="true"> <label for="collapse-section7" aria-hidden="true">V1.0.0 / 18-February-2014</label>
<div>
<h2 id="main-changes-13">Main Changes</h2>
<ul>
<li>First official release with Accelerometer, Audio, Camera, Gyroscope, IO, LCD and Touch Screen drivers function prototypes</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,125 @@
/**
******************************************************************************
* @file accelero.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the Accelerometer driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ACCELERO_H
#define __ACCELERO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ACCELERO
* @{
*/
/** @defgroup ACCELERO_Exported_Types
* @{
*/
/** @defgroup ACCELERO_Driver_structure Accelerometer Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
void (*DeInit)(void);
uint8_t (*ReadID)(void);
void (*Reset)(void);
void (*LowPower)(uint16_t);
void (*ConfigIT)(void);
void (*EnableIT)(uint8_t);
void (*DisableIT)(uint8_t);
uint8_t (*ITStatus)(uint16_t);
void (*ClearIT)(void);
void (*FilterConfig)(uint8_t);
void (*FilterCmd)(uint8_t);
void (*GetXYZ)(int16_t *);
}ACCELERO_DrvTypeDef;
/**
* @}
*/
/** @defgroup ACCELERO_Configuration_structure Accelerometer Configuration structure
* @{
*/
/* ACCELERO struct */
typedef struct
{
uint8_t Power_Mode; /* Power-down/Normal Mode */
uint8_t AccOutput_DataRate; /* OUT data rate */
uint8_t Axes_Enable; /* Axes enable */
uint8_t High_Resolution; /* High Resolution enabling/disabling */
uint8_t BlockData_Update; /* Block Data Update */
uint8_t Endianness; /* Endian Data selection */
uint8_t AccFull_Scale; /* Full Scale selection */
uint8_t Communication_Mode;
}ACCELERO_InitTypeDef;
/* ACCELERO High Pass Filter struct */
typedef struct
{
uint8_t HighPassFilter_Mode_Selection; /* Internal filter mode */
uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */
uint8_t HighPassFilter_AOI1; /* HPF_enabling/disabling for AOI function on interrupt 1 */
uint8_t HighPassFilter_AOI2; /* HPF_enabling/disabling for AOI function on interrupt 2 */
uint8_t HighPassFilter_Data_Sel;
uint8_t HighPassFilter_Stat;
}ACCELERO_FilterConfigTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __ACCELERO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,104 @@
/**
******************************************************************************
* @file audio.h
* @author MCD Application Team
* @brief This header file contains the common defines and functions prototypes
* for the Audio driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __AUDIO_H
#define __AUDIO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup AUDIO
* @{
*/
/** @defgroup AUDIO_Exported_Constants
* @{
*/
/* Codec audio Standards */
#define CODEC_STANDARD 0x04
#define I2S_STANDARD I2S_STANDARD_PHILIPS
/**
* @}
*/
/** @defgroup AUDIO_Exported_Types
* @{
*/
/** @defgroup AUDIO_Driver_structure Audio Driver structure
* @{
*/
typedef struct
{
uint32_t (*Init)(uint16_t, uint16_t, uint8_t, uint32_t);
void (*DeInit)(void);
uint32_t (*ReadID)(uint16_t);
uint32_t (*Play)(uint16_t, uint16_t*, uint16_t);
uint32_t (*Pause)(uint16_t);
uint32_t (*Resume)(uint16_t);
uint32_t (*Stop)(uint16_t, uint32_t);
uint32_t (*SetFrequency)(uint16_t, uint32_t);
uint32_t (*SetVolume)(uint16_t, uint8_t);
uint32_t (*SetMute)(uint16_t, uint32_t);
uint32_t (*SetOutputMode)(uint16_t, uint8_t);
uint32_t (*Reset)(uint16_t);
}AUDIO_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __AUDIO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,123 @@
/**
******************************************************************************
* @file camera.h
* @author MCD Application Team
* @brief This header file contains the common defines and functions prototypes
* for the camera driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CAMERA_H
#define __CAMERA_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup CAMERA
* @{
*/
/** @defgroup CAMERA_Exported_Types
* @{
*/
/** @defgroup CAMERA_Driver_structure Camera Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t, uint32_t);
uint16_t (*ReadID)(uint16_t);
void (*Config)(uint16_t, uint32_t, uint32_t, uint32_t);
}CAMERA_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/** @defgroup CAMERA_Exported_Constants
* @{
*/
#define CAMERA_R160x120 0x00 /* QQVGA Resolution */
#define CAMERA_R320x240 0x01 /* QVGA Resolution */
#define CAMERA_R480x272 0x02 /* 480x272 Resolution */
#define CAMERA_R640x480 0x03 /* VGA Resolution */
#define CAMERA_CONTRAST_BRIGHTNESS 0x00 /* Camera contrast brightness features */
#define CAMERA_BLACK_WHITE 0x01 /* Camera black white feature */
#define CAMERA_COLOR_EFFECT 0x03 /* Camera color effect feature */
#define CAMERA_BRIGHTNESS_LEVEL0 0x00 /* Brightness level -2 */
#define CAMERA_BRIGHTNESS_LEVEL1 0x01 /* Brightness level -1 */
#define CAMERA_BRIGHTNESS_LEVEL2 0x02 /* Brightness level 0 */
#define CAMERA_BRIGHTNESS_LEVEL3 0x03 /* Brightness level +1 */
#define CAMERA_BRIGHTNESS_LEVEL4 0x04 /* Brightness level +2 */
#define CAMERA_CONTRAST_LEVEL0 0x05 /* Contrast level -2 */
#define CAMERA_CONTRAST_LEVEL1 0x06 /* Contrast level -1 */
#define CAMERA_CONTRAST_LEVEL2 0x07 /* Contrast level 0 */
#define CAMERA_CONTRAST_LEVEL3 0x08 /* Contrast level +1 */
#define CAMERA_CONTRAST_LEVEL4 0x09 /* Contrast level +2 */
#define CAMERA_BLACK_WHITE_BW 0x00 /* Black and white effect */
#define CAMERA_BLACK_WHITE_NEGATIVE 0x01 /* Negative effect */
#define CAMERA_BLACK_WHITE_BW_NEGATIVE 0x02 /* BW and Negative effect */
#define CAMERA_BLACK_WHITE_NORMAL 0x03 /* Normal effect */
#define CAMERA_COLOR_EFFECT_NONE 0x00 /* No effects */
#define CAMERA_COLOR_EFFECT_BLUE 0x01 /* Blue effect */
#define CAMERA_COLOR_EFFECT_GREEN 0x02 /* Green effect */
#define CAMERA_COLOR_EFFECT_RED 0x03 /* Red effect */
#define CAMERA_COLOR_EFFECT_ANTIQUE 0x04 /* Antique effect */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __CAMERA_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,104 @@
/**
******************************************************************************
* @file dpredriver.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* DisplayPort Linear Redriver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __DPREDRIVER_H
#define __DPREDRIVER_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup DPREDRIVER
* @{
*/
/** @defgroup DPREDRIVER_Exported_Types
* @{
*/
/** @defgroup DPREDRIVER_Channel_Identifier Channel Identifier
* @{
*/
typedef enum {
CHANNEL_DP0 = 0,
CHANNEL_DP1,
CHANNEL_DP2,
CHANNEL_DP3,
CHANNEL_RX1,
CHANNEL_RX2,
CHANNEL_SSTX
} DPREDRIVER_ChannelId_t;
/**
* @}
*/
/** @defgroup DPREDRIVER_Driver_structure DisplayPort Linear Redriver Driver structure
* @{
*/
typedef struct
{
uint32_t (*Init)(uint16_t);
void (*DeInit)(uint16_t);
uint32_t (*PowerOn)(uint16_t);
uint32_t (*PowerOff)(uint16_t);
uint32_t (*SetEQGain)(uint16_t, DPREDRIVER_ChannelId_t, uint8_t);
uint32_t (*EnableChannel)(uint16_t, DPREDRIVER_ChannelId_t);
uint32_t (*DisableChannel)(uint16_t, DPREDRIVER_ChannelId_t);
}DPREDRIVER_Drv_t;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __DPREDRIVER_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,97 @@
/**
******************************************************************************
* @file epd.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* EPD (E Paper Display) driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __EPD_H
#define __EPD_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup Common
* @{
*/
/** @addtogroup EPD
* @{
*/
/** @defgroup EPD_Exported_Types
* @{
*/
/** @defgroup EPD_Driver_structure E Paper Display Driver structure
* @{
*/
typedef struct
{
void (*Init)(void);
void (*WritePixel)(uint8_t);
/* Optimized operation */
void (*SetDisplayWindow)(uint16_t, uint16_t, uint16_t, uint16_t);
void (*RefreshDisplay)(void);
void (*CloseChargePump)(void);
uint16_t (*GetEpdPixelWidth)(void);
uint16_t (*GetEpdPixelHeight)(void);
void (*DrawImage)(uint16_t, uint16_t, uint16_t, uint16_t, uint8_t*);
}
EPD_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* EPD_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,127 @@
/**
******************************************************************************
* @file gyro.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the gyroscope driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __GYRO_H
#define __GYRO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup GYRO
* @{
*/
/** @defgroup GYRO_Exported_Types
* @{
*/
/** @defgroup GYRO_Driver_structure Gyroscope Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
void (*DeInit)(void);
uint8_t (*ReadID)(void);
void (*Reset)(void);
void (*LowPower)(uint16_t);
void (*ConfigIT)(uint16_t);
void (*EnableIT)(uint8_t);
void (*DisableIT)(uint8_t);
uint8_t (*ITStatus)(uint16_t, uint16_t);
void (*ClearIT)(uint16_t, uint16_t);
void (*FilterConfig)(uint8_t);
void (*FilterCmd)(uint8_t);
void (*GetXYZ)(float *);
}GYRO_DrvTypeDef;
/**
* @}
*/
/** @defgroup GYRO_Config_structure Gyroscope Configuration structure
* @{
*/
typedef struct
{
uint8_t Power_Mode; /* Power-down/Sleep/Normal Mode */
uint8_t Output_DataRate; /* OUT data rate */
uint8_t Axes_Enable; /* Axes enable */
uint8_t Band_Width; /* Bandwidth selection */
uint8_t BlockData_Update; /* Block Data Update */
uint8_t Endianness; /* Endian Data selection */
uint8_t Full_Scale; /* Full Scale selection */
}GYRO_InitTypeDef;
/* GYRO High Pass Filter struct */
typedef struct
{
uint8_t HighPassFilter_Mode_Selection; /* Internal filter mode */
uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */
}GYRO_FilterConfigTypeDef;
/*GYRO Interrupt struct */
typedef struct
{
uint8_t Latch_Request; /* Latch interrupt request into CLICK_SRC register */
uint8_t Interrupt_Axes; /* X, Y, Z Axes Interrupts */
uint8_t Interrupt_ActiveEdge; /* Interrupt Active edge */
}GYRO_InterruptConfigTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __GYRO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,83 @@
/**
******************************************************************************
* @file hsensor.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* Humidity Sensor driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HSENSOR_H
#define __HSENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup HSENSOR
* @{
*/
/** @defgroup HSENSOR_Exported_Types
* @{
*/
/** @defgroup HSENSOR_Driver_structure Humidity Sensor Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
uint8_t (*ReadID)(uint16_t);
float (*ReadHumidity)(uint16_t);
}HSENSOR_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __HSENSOR_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,150 @@
/**
******************************************************************************
* @file idd.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the IDD driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __IDD_H
#define __IDD_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup IDD
* @{
*/
/** @defgroup IDD_Exported_Types IDD Exported Types
* @{
*/
/** @defgroup IDD_Config_structure IDD Configuration structure
* @{
*/
typedef struct
{
uint16_t AmpliGain; /*!< Specifies ampli gain value
*/
uint16_t VddMin; /*!< Specifies minimum MCU VDD can reach to protect MCU from reset
*/
uint16_t Shunt0Value; /*!< Specifies value of Shunt 0 if existing
*/
uint16_t Shunt1Value; /*!< Specifies value of Shunt 1 if existing
*/
uint16_t Shunt2Value; /*!< Specifies value of Shunt 2 if existing
*/
uint16_t Shunt3Value; /*!< Specifies value of Shunt 3 if existing
*/
uint16_t Shunt4Value; /*!< Specifies value of Shunt 4 if existing
*/
uint16_t Shunt0StabDelay; /*!< Specifies delay of Shunt 0 stabilization if existing
*/
uint16_t Shunt1StabDelay; /*!< Specifies delay of Shunt 1 stabilization if existing
*/
uint16_t Shunt2StabDelay; /*!< Specifies delay of Shunt 2 stabilization if existing
*/
uint16_t Shunt3StabDelay; /*!< Specifies delay of Shunt 3 stabilization if existing
*/
uint16_t Shunt4StabDelay; /*!< Specifies delay of Shunt 4 stabilization if existing
*/
uint8_t ShuntNbOnBoard; /*!< Specifies number of shunts that are present on board
This parameter can be a value of @ref IDD_shunt_number */
uint8_t ShuntNbUsed; /*!< Specifies number of shunts used for measurement
This parameter can be a value of @ref IDD_shunt_number */
uint8_t VrefMeasurement; /*!< Specifies if Vref is automatically measured before each Idd measurement
This parameter can be a value of @ref IDD_Vref_Measurement */
uint8_t Calibration; /*!< Specifies if calibration is done before each Idd measurement
*/
uint8_t PreDelayUnit; /*!< Specifies Pre delay unit
This parameter can be a value of @ref IDD_PreDelay */
uint8_t PreDelayValue; /*!< Specifies Pre delay value in selected unit
*/
uint8_t MeasureNb; /*!< Specifies number of Measure to be performed
This parameter can be a value between 1 and 256 */
uint8_t DeltaDelayUnit; /*!< Specifies Delta delay unit
This parameter can be a value of @ref IDD_DeltaDelay */
uint8_t DeltaDelayValue; /*!< Specifies Delta delay between 2 measures
value can be between 1 and 128 */
}IDD_ConfigTypeDef;
/**
* @}
*/
/** @defgroup IDD_Driver_structure IDD Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
void (*DeInit)(uint16_t);
uint16_t (*ReadID)(uint16_t);
void (*Reset)(uint16_t);
void (*LowPower)(uint16_t);
void (*WakeUp)(uint16_t);
void (*Start)(uint16_t);
void (*Config)(uint16_t,IDD_ConfigTypeDef);
void (*GetValue)(uint16_t, uint32_t *);
void (*EnableIT)(uint16_t);
void (*ClearIT)(uint16_t);
uint8_t (*GetITStatus)(uint16_t);
void (*DisableIT)(uint16_t);
void (*ErrorEnableIT)(uint16_t);
void (*ErrorClearIT)(uint16_t);
uint8_t (*ErrorGetITStatus)(uint16_t);
void (*ErrorDisableIT)(uint16_t);
uint8_t (*ErrorGetSrc)(uint16_t);
uint8_t (*ErrorGetCode)(uint16_t);
}IDD_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __IDD_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,132 @@
/**
******************************************************************************
* @file io.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the IO driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __IO_H
#define __IO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup IO
* @{
*/
/** @defgroup IO_Exported_Types
* @{
*/
/**
* @brief IO Bit SET and Bit RESET enumeration
*/
typedef enum
{
IO_PIN_RESET = 0,
IO_PIN_SET
}IO_PinState;
typedef enum
{
IO_MODE_INPUT = 0, /* input floating */
IO_MODE_OUTPUT, /* output Push Pull */
IO_MODE_IT_RISING_EDGE, /* float input - irq detect on rising edge */
IO_MODE_IT_FALLING_EDGE, /* float input - irq detect on falling edge */
IO_MODE_IT_LOW_LEVEL, /* float input - irq detect on low level */
IO_MODE_IT_HIGH_LEVEL, /* float input - irq detect on high level */
/* following modes only available on MFX*/
IO_MODE_ANALOG, /* analog mode */
IO_MODE_OFF, /* when pin isn't used*/
IO_MODE_INPUT_PU, /* input with internal pull up resistor */
IO_MODE_INPUT_PD, /* input with internal pull down resistor */
IO_MODE_OUTPUT_OD, /* Open Drain output without internal resistor */
IO_MODE_OUTPUT_OD_PU, /* Open Drain output with internal pullup resistor */
IO_MODE_OUTPUT_OD_PD, /* Open Drain output with internal pulldown resistor */
IO_MODE_OUTPUT_PP, /* PushPull output without internal resistor */
IO_MODE_OUTPUT_PP_PU, /* PushPull output with internal pullup resistor */
IO_MODE_OUTPUT_PP_PD, /* PushPull output with internal pulldown resistor */
IO_MODE_IT_RISING_EDGE_PU, /* push up resistor input - irq on rising edge */
IO_MODE_IT_RISING_EDGE_PD, /* push dw resistor input - irq on rising edge */
IO_MODE_IT_FALLING_EDGE_PU, /* push up resistor input - irq on falling edge */
IO_MODE_IT_FALLING_EDGE_PD, /* push dw resistor input - irq on falling edge */
IO_MODE_IT_LOW_LEVEL_PU, /* push up resistor input - irq detect on low level */
IO_MODE_IT_LOW_LEVEL_PD, /* push dw resistor input - irq detect on low level */
IO_MODE_IT_HIGH_LEVEL_PU, /* push up resistor input - irq detect on high level */
IO_MODE_IT_HIGH_LEVEL_PD, /* push dw resistor input - irq detect on high level */
}IO_ModeTypedef;
/** @defgroup IO_Driver_structure IO Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
uint16_t (*ReadID)(uint16_t);
void (*Reset)(uint16_t);
void (*Start)(uint16_t, uint32_t);
uint8_t (*Config)(uint16_t, uint32_t, IO_ModeTypedef);
void (*WritePin)(uint16_t, uint32_t, uint8_t);
uint32_t (*ReadPin)(uint16_t, uint32_t);
void (*EnableIT)(uint16_t);
void (*DisableIT)(uint16_t);
uint32_t (*ITStatus)(uint16_t, uint32_t);
void (*ClearIT)(uint16_t, uint32_t);
}IO_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __IO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,96 @@
/**
******************************************************************************
* @file lcd.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the LCD driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LCD_H
#define __LCD_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LCD
* @{
*/
/** @defgroup LCD_Exported_Types
* @{
*/
/** @defgroup LCD_Driver_structure LCD Driver structure
* @{
*/
typedef struct
{
void (*Init)(void);
uint16_t (*ReadID)(void);
void (*DisplayOn)(void);
void (*DisplayOff)(void);
void (*SetCursor)(uint16_t, uint16_t);
void (*WritePixel)(uint16_t, uint16_t, uint16_t);
uint16_t (*ReadPixel)(uint16_t, uint16_t);
/* Optimized operation */
void (*SetDisplayWindow)(uint16_t, uint16_t, uint16_t, uint16_t);
void (*DrawHLine)(uint16_t, uint16_t, uint16_t, uint16_t);
void (*DrawVLine)(uint16_t, uint16_t, uint16_t, uint16_t);
uint16_t (*GetLcdPixelWidth)(void);
uint16_t (*GetLcdPixelHeight)(void);
void (*DrawBitmap)(uint16_t, uint16_t, uint8_t*);
void (*DrawRGBImage)(uint16_t, uint16_t, uint16_t, uint16_t, uint8_t*);
}LCD_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LCD_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,107 @@
/**
******************************************************************************
* @file magneto.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the MAGNETO driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAGNETO_H
#define __MAGNETO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup MAGNETO
* @{
*/
/** @defgroup MAGNETO_Exported_Types
* @{
*/
/** @defgroup MAGNETO_Config_structure Magnetometer Configuration structure
* @{
*/
typedef struct
{
uint8_t Register1;
uint8_t Register2;
uint8_t Register3;
uint8_t Register4;
uint8_t Register5;
}MAGNETO_InitTypeDef;
/**
* @}
*/
/** @defgroup MAGNETO_Driver_structure Magnetometer Driver structure
* @{
*/
typedef struct
{
void (*Init)(MAGNETO_InitTypeDef);
void (*DeInit)(void);
uint8_t (*ReadID)(void);
void (*Reset)(void);
void (*LowPower)(uint16_t);
void (*ConfigIT)(void);
void (*EnableIT)(uint8_t);
void (*DisableIT)(uint8_t);
uint8_t (*ITStatus)(uint16_t);
void (*ClearIT)(void);
void (*FilterConfig)(uint8_t);
void (*FilterCmd)(uint8_t);
void (*GetXYZ)(int16_t *);
}MAGNETO_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __MAGNETO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,83 @@
/**
******************************************************************************
* @file psensor.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* Pressure Sensor driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __PSENSOR_H
#define __PSENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup PSENSOR
* @{
*/
/** @defgroup PSENSOR_Exported_Types
* @{
*/
/** @defgroup PSENSOR_Driver_structure Pressure Sensor Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
uint8_t (*ReadID)(uint16_t);
float (*ReadPressure)(uint16_t);
}PSENSOR_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __PSENSOR_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,246 @@
/**
******************************************************************************
* @file pwrmon.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* Current/Power Monitor device driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __PWRMON_H
#define __PWRMON_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup PWRMON
* @{
*/
/** @defgroup PWRMON_Exported_Types
* @{
*/
/** @defgroup PWRMON_Operating_Mode_enum Power Monitor Operating Mode enums
* @{
*/
typedef enum {
OPERATING_MODE_TRIGGERED = 0,
OPERATING_MODE_CONTINUOUS,
OPERATING_MODE_NB
} PWRMON_OperatingMode_t;
/**
* @}
*/
/** @defgroup PWRMON_Conversion_Time_enum Power Monitor Conversion_Time enums
* @{
*/
typedef enum {
CONVERT_TIME_140 = 0,
CONVERT_TIME_204,
CONVERT_TIME_332,
CONVERT_TIME_588,
CONVERT_TIME_1100,
CONVERT_TIME_2116,
CONVERT_TIME_4156,
CONVERT_TIME_8244,
CONVERT_TIME_NB
} PWRMON_ConvertTime_t;
/**
* @}
*/
/** @defgroup PWRMON_Conversion_Time_enum Power Monitor Conversion_Time enums
* @{
*/
typedef enum {
AVERAGING_MODE_1 = 0,
AVERAGING_MODE_4,
AVERAGING_MODE_16,
AVERAGING_MODE_64,
AVERAGING_MODE_128,
AVERAGING_MODE_256,
AVERAGING_MODE_512,
AVERAGING_MODE_1024,
AVERAGING_MODE_NB
} PWRMON_AveragingMode_t;
/**
* @}
*/
/** @defgroup PWRMON_Device_Configuration_structure Power Monitor Device Configuration structure
* @{
*/
typedef struct
{
PWRMON_ConvertTime_t ShuntConvertTime;
PWRMON_ConvertTime_t BusConvertTime;
PWRMON_AveragingMode_t AveragingMode;
} PWRMON_Config_t;
/**
* @}
*/
/** @defgroup PWRMON_Alert_Polarity_enum Power Monitor Alert Polarity enums
* @{
*/
typedef enum {
ALERT_POLARITY_NORMAL = 0,
ALERT_POLARITY_INVERTED,
ALERT_POLARITY_NB
} PWRMON_AlertPolarity_t;
/**
* @}
*/
/** @defgroup PWRMON_Alert_Latch_Enable_enum Power Monitor Alert Latch Enable enums
* @{
*/
typedef enum {
ALERT_LATCH_DISABLE = 0,
ALERT_LATCH_ENABLE,
ALERT_LATCH_NB
} PWRMON_AlertLatchEnable_t;
/**
* @}
*/
/** @defgroup PWRMON_Alert_Function_enum Power Monitor Alert Function enums
* @{
*/
typedef enum {
ALERT_FUNCTION_NONE = 0,
ALERT_FUNCTION_SOL,
ALERT_FUNCTION_SUL,
ALERT_FUNCTION_BOL,
ALERT_FUNCTION_BUL,
ALERT_FUNCTION_POL,
ALERT_FUNCTION_NB,
} PWRMON_AlertFunction_t;
/**
* @}
*/
/** @defgroup PWRMON_Alert_Configuration_structure Power Monitor Alert Configuration structure
* @{
*/
typedef struct
{
PWRMON_AlertPolarity_t Polarity;
PWRMON_AlertLatchEnable_t LatchEnable;
} PWRMON_AlertPinConfig_t;
/**
* @}
*/
/** @defgroup PWRMON_Voltage_Input_enum Power Monitor Voltage Input enums
* @{
*/
typedef enum {
VOLTAGE_INPUT_SHUNT = 0,
VOLTAGE_INPUT_BUS,
VOLTAGE_INPUT_ALL,
VOLTAGE_INPUT_NB
} PWRMON_InputSignal_t;
/**
* @}
*/
/** @defgroup PWRMON_Flag_enum Power Monitor Flag enums
* @{
*/
typedef enum {
FLAG_ALERT_FUNCTION = 0,
FLAG_CONVERSION_READY,
FLAG_MATH_OVERFLOW,
FLAG_NB
} PWRMON_Flag_t;
/**
* @}
*/
/** @defgroup PWRMON_Driver_structure Power Monitor Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t, PWRMON_Config_t *);
void (*DeInit)(uint16_t);
uint16_t (*ReadId)(uint16_t);
void (*Reset)(uint16_t);
void (*SetCalibration)(uint16_t, uint16_t);
uint16_t (*GetCalibration)(uint16_t);
void (*SetAlertFunction)(uint16_t, PWRMON_AlertFunction_t);
PWRMON_AlertFunction_t (*GetAlertFunction)(uint16_t);
void (*AlertPinConfig)(uint16_t, PWRMON_AlertPinConfig_t *);
void (*SetVBusThreshold)(uint16_t, uint16_t);
uint16_t (*GetVBusThreshold)(uint16_t);
void (*SetVShuntThreshold)(uint16_t, int16_t);
int16_t (*GetVShuntThreshold)(uint16_t);
void (*SetPowerThreshold)(uint16_t, uint32_t);
uint32_t (*GetPowerThreshold)(uint16_t);
void (*AlertThresholdEnableIT)(uint16_t);
void (*AlertThresholdDisableIT)(uint16_t);
void (*ConversionReadyEnableIT)(uint16_t);
void (*ConversionReadyDisableIT)(uint16_t);
void (*StartConversion)(uint16_t, PWRMON_InputSignal_t, PWRMON_OperatingMode_t);
void (*StopConversion)(uint16_t);
uint16_t (*GetVBus)(uint16_t);
int16_t (*GetVShunt)(uint16_t);
uint16_t (*GetPower)(uint16_t);
int16_t (*GetCurrent)(uint16_t);
uint8_t (*GetFlag)(uint16_t, PWRMON_Flag_t);
} PWRMON_Drv_t;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __PWRMON_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,89 @@
/**
******************************************************************************
* @file ts.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the Touch Screen driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TS_H
#define __TS_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup TS
* @{
*/
/** @defgroup TS_Exported_Types
* @{
*/
/** @defgroup TS_Driver_structure Touch Sensor Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
uint16_t (*ReadID)(uint16_t);
void (*Reset)(uint16_t);
void (*Start)(uint16_t);
uint8_t (*DetectTouch)(uint16_t);
void (*GetXY)(uint16_t, uint16_t*, uint16_t*);
void (*EnableIT)(uint16_t);
void (*ClearIT)(uint16_t);
uint8_t (*GetITStatus)(uint16_t);
void (*DisableIT)(uint16_t);
}TS_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __TS_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,100 @@
/**
******************************************************************************
* @file tsensor.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* Temperature Sensor driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TSENSOR_H
#define __TSENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup TSENSOR
* @{
*/
/** @defgroup TSENSOR_Exported_Types
* @{
*/
/** @defgroup TSENSOR_Config_structure Temperature Sensor Configuration structure
* @{
*/
typedef struct
{
uint8_t AlertMode; /* Alert Mode Temperature out of range*/
uint8_t ConversionMode; /* Continuous/One Shot Mode */
uint8_t ConversionResolution; /* Temperature Resolution */
uint8_t ConversionRate; /* Number of measure per second */
int8_t TemperatureLimitHigh; /* High Temperature Limit Range */
int8_t TemperatureLimitLow; /* Low Temperature Limit Range */
}TSENSOR_InitTypeDef;
/**
* @}
*/
/** @defgroup TSENSOR_Driver_structure Temperature Sensor Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t, TSENSOR_InitTypeDef *);
uint8_t (*IsReady)(uint16_t, uint32_t);
uint8_t (*ReadStatus)(uint16_t);
float (*ReadTemp)(uint16_t);
}TSENSOR_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __TSENSOR_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,114 @@
/**
******************************************************************************
* @file usbtypecswitch.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* crossbar switch device for USB Type-C systems.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBTYPECSWITCH_H
#define __USBTYPECSWITCH_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup TYPECSWITCH
* @{
*/
/** @defgroup TYPECSWITCH_Exported_Types
* @{
*/
typedef enum {
USB_NORMAL = 0,
USB_FLIPPED,
DFP_D_PIN_ASSIGNMENT_A_NORMAL,
DFP_D_PIN_ASSIGNMENT_A_FLIPPED,
DFP_D_PIN_ASSIGNMENT_B_NORMAL,
DFP_D_PIN_ASSIGNMENT_B_FLIPPED,
DFP_D_PIN_ASSIGNMENT_C_NORMAL,
DFP_D_PIN_ASSIGNMENT_C_FLIPPED,
DFP_D_PIN_ASSIGNMENT_D_NORMAL,
DFP_D_PIN_ASSIGNMENT_D_FLIPPED,
DFP_D_PIN_ASSIGNMENT_E_NORMAL,
DFP_D_PIN_ASSIGNMENT_E_FLIPPED,
DFP_D_PIN_ASSIGNMENT_F_NORMAL,
DFP_D_PIN_ASSIGNMENT_F_FLIPPED,
UFP_D_PIN_ASSIGNMENT_A_NORMAL,
UFP_D_PIN_ASSIGNMENT_A_FLIPPED,
UFP_D_PIN_ASSIGNMENT_B_NORMAL,
UFP_D_PIN_ASSIGNMENT_B_FLIPPED,
UFP_D_PIN_ASSIGNMENT_C_NORMAL,
UFP_D_PIN_ASSIGNMENT_C_FLIPPED,
UFP_D_PIN_ASSIGNMENT_D_NORMAL,
UFP_D_PIN_ASSIGNMENT_D_FLIPPED,
UFP_D_PIN_ASSIGNMENT_E_NORMAL,
UFP_D_PIN_ASSIGNMENT_E_FLIPPED,
UFP_D_PIN_ASSIGNMENT_F_NORMAL,
UFP_D_PIN_ASSIGNMENT_F_FLIPPED
} TYPECSWITCH_Mode_t;
/** @defgroup TYPECSWITCH_Driver_structure USB Type-C Crossbar Switch Driver structure
* @{
*/
typedef struct
{
uint32_t (*Init)(uint16_t);
void (*DeInit)(uint16_t);
uint32_t (*PowerOn)(uint16_t);
uint32_t (*PowerOff)(uint16_t);
uint32_t (*SetMode)(uint16_t, TYPECSWITCH_Mode_t);
uint32_t (*IsSupportedMode)(TYPECSWITCH_Mode_t);
} TYPECSWITCH_Drv_t;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __USBTYPECSWITCH_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for CS42L51 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-cs42l51-component-drivers"><small>Release Notes for</small> <mark>CS42L51 Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the CS42L51 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.0.0 / 17-February-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of CS42L51 Audio codec Component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,504 @@
/**
******************************************************************************
* @file cs42l51.c
* @author MCD Application Team
* @brief This file provides the CS42L51 Audio Codec driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "cs42l51.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup CS42L51
* @brief This file provides a set of functions needed to drive the
* CS42L51 audio codec.
* @{
*/
/** @defgroup CS42L51_Exported_Variables
* @{
*/
/* Audio codec driver structure initialization */
AUDIO_DrvTypeDef cs42l51_drv =
{
cs42l51_Init,
cs42l51_DeInit,
cs42l51_ReadID,
cs42l51_Play,
cs42l51_Pause,
cs42l51_Resume,
cs42l51_Stop,
cs42l51_SetFrequency,
cs42l51_SetVolume,
cs42l51_SetMute,
cs42l51_SetOutputMode,
cs42l51_Reset,
};
/**
* @}
*/
/** @defgroup CS42L51_Private_Types
* @{
*/
/**
* @}
*/
/** @defgroup CS42L51_Private_Defines
* @{
*/
/* Uncomment this line to enable verifying data sent to codec after each write
operation (for debug purpose) */
#if !defined (VERIFY_WRITTENDATA)
#define VERIFY_WRITTENDATA
#endif /* VERIFY_WRITTENDATA */
/**
* @}
*/
/** @defgroup CS42L51_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup CS42L51_Private_Variables
* @{
*/
static uint8_t Is_CS42L51_Initialized = 0;
static uint8_t Is_CS42L51_Stop = 1;
static uint16_t CS42L51_Device = OUTPUT_DEVICE_HEADPHONE;
/**
* @}
*/
/** @defgroup CS42L51_Private_Functions
* @{
*/
static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
/**
* @}
*/
/** @addtogroup CS42L51_Exported_Functions
* @{
*/
/**
* @brief Initialize the audio codec and the control interface.
* @param DeviceAddr: Device address on communication bus.
* @param Device: Can be combination values of OUTPUT_DEVICE_HEADPHONE and
* INPUT_DEVICE_MIC1.
* @param Volume: Initial output volume level (from 0 (-100dB) to 100 (0dB)).
* @param AudioFreq: Initial audio frequency (currently not used).
* @retval 0 if correct communication, else wrong communication.
*/
uint32_t cs42l51_Init(uint16_t DeviceAddr, uint16_t Device, uint8_t Volume, uint32_t AudioFreq)
{
uint32_t counter = 0;
uint8_t Value;
/* Check if codec is already initialized */
if(Is_CS42L51_Initialized == 0)
{
/* Initialize the Control interface of the Audio Codec */
AUDIO_IO_Init();
Is_CS42L51_Initialized = 1;
}
else
{
/* Set all power down bits to 1 exept PDN to mute ADCs and DACs*/
counter += CODEC_IO_Write(DeviceAddr, 0x02, 0x7E);
Value = AUDIO_IO_Read(DeviceAddr, 0x03);
counter += CODEC_IO_Write(DeviceAddr, 0x03, (Value | 0x0E));
/* Disable zero cross and soft ramp */
Value = AUDIO_IO_Read(DeviceAddr, 0x09);
counter += CODEC_IO_Write(DeviceAddr, 0x09, (Value & 0xFC));
/* Power control : Enter standby (PDN = 1) */
Value = AUDIO_IO_Read(DeviceAddr, 0x02);
counter += CODEC_IO_Write(DeviceAddr, 0x02, (Value | 0x01));
}
/* Mic Power and Speed Control : Auto detect on, Speed mode SSM, tri state off, MCLK divide by 2 off */
Value = AUDIO_IO_Read(DeviceAddr, 0x03);
counter += CODEC_IO_Write(DeviceAddr, 0x03, ((Value & 0x0E) | 0xA0));
/* Interface control : Loopback off, Slave, I2S (SDIN and SOUT), Digital mix off, Mic mix off */
counter += CODEC_IO_Write(DeviceAddr, 0x04, 0x0C);
/* Mic control : ADC single volume off, ADCB boost off, ADCA boost off, MicBias on AIN3B/MICIN2 pin, MicBias level 0.8xVA, MICB boost 16db, MICA boost 16dB */
counter += CODEC_IO_Write(DeviceAddr, 0x05, 0x00);
/* ADC control : ADCB HPF off, ADCB HPF freeze off, ADCA HPF off, ADCA HPF freeze off, Soft ramp B off, Zero cross B off, Soft ramp A off, Zero cross A off */
counter += CODEC_IO_Write(DeviceAddr, 0x06, 0x00);
/* ADC Input Select, Invert and Mute : AIN1B to PGAB, AIN3A to PreAmp to PGAA, ADCB invert off, ADCA invert off, ADCB mute on, ADCA mute off */
counter += CODEC_IO_Write(DeviceAddr, 0x07, 0x32);
/* DAC output control : HP Gain to 1, Single volume control off, PCM invert signals polarity off, DAC channels mute on */
counter += CODEC_IO_Write(DeviceAddr, 0x08, 0xC3);
/* DAC control : Signal processing to DAC, Freeze off, De-emphasis off, Analog output auto mute off, DAC soft ramp */
counter += CODEC_IO_Write(DeviceAddr, 0x09, 0x42);
/* ALCA and PGAA Control : ALCA soft ramp disable on, ALCA zero cross disable on, PGA A Gain 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0A, 0xC0);
/* ALCB and PGAB Control : ALCB soft ramp disable on, ALCB zero cross disable on, PGA B Gain 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0B, 0xC0);
/* ADCA Attenuator : 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0C, 0x00);
/* ADCB Attenuator : 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0D, 0x00);
/* ADCA mixer volume control : ADCA mixer channel mute on, ADCA mixer volume 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0E, 0x80);
/* ADCB mixer volume control : ADCB mixer channel mute on, ADCB mixer volume 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0F, 0x80);
/* PCMA mixer volume control : PCMA mixer channel mute off, PCMA mixer volume 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x10, 0x00);
/* PCMB mixer volume control : PCMB mixer channel mute off, PCMB mixer volume 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x11, 0x00);
/* PCM channel mixer : AOUTA Left, AOUTB Right */
counter += CODEC_IO_Write(DeviceAddr, 0x18, 0x00);
if(Device & OUTPUT_DEVICE_HEADPHONE)
{
Value = VOLUME_CONVERT(Volume);
/* AOUTA volume control : AOUTA volume */
counter += CODEC_IO_Write(DeviceAddr, 0x16, Value);
/* AOUTB volume control : AOUTB volume */
counter += CODEC_IO_Write(DeviceAddr, 0x17, Value);
}
/* Store device */
CS42L51_Device = Device;
/* Return communication control value */
return counter;
}
/**
* @brief Deinitialize the audio codec.
* @param None
* @retval None
*/
void cs42l51_DeInit(void)
{
/* Deinitialize Audio Codec interface */
AUDIO_IO_DeInit();
Is_CS42L51_Initialized = 0;
}
/**
* @brief Get the CS42L51 ID.
* @param DeviceAddr: Device address on communication Bus.
* @retval The CS42L51 ID
*/
uint32_t cs42l51_ReadID(uint16_t DeviceAddr)
{
uint8_t Value;
if(Is_CS42L51_Initialized == 0)
{
/* Initialize the Control interface of the Audio Codec */
AUDIO_IO_Init();
Value = AUDIO_IO_Read(DeviceAddr, CS42L51_CHIPID_ADDR);
Value = (Value & CS42L51_ID_MASK);
/* Deinitialize Audio Codec interface */
AUDIO_IO_DeInit();
}
else
{
Value = AUDIO_IO_Read(DeviceAddr, CS42L51_CHIPID_ADDR);
Value = (Value & CS42L51_ID_MASK);
}
return((uint32_t) Value);
}
/**
* @brief Start the audio Codec play feature.
* @note For this codec no Play options are required.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size)
{
uint32_t counter = 0;
uint8_t Value;
if(Is_CS42L51_Stop == 1)
{
/* Unmute output device */
counter += cs42l51_SetMute(DeviceAddr, AUDIO_MUTE_OFF);
if(CS42L51_Device & OUTPUT_DEVICE_HEADPHONE)
{
/* DAC control : Signal processing to DAC, Freeze off, De-emphasis off, Analog output auto mute off, DAC soft ramp */
counter += CODEC_IO_Write(DeviceAddr, 0x09, 0x42);
/* Power control 1 : PDN_DACA, PDN_DACB disable. */
Value = AUDIO_IO_Read(DeviceAddr, 0x02);
counter += CODEC_IO_Write(DeviceAddr, 0x02, (Value & 0x9F));
}
if(CS42L51_Device & INPUT_DEVICE_MIC1)
{
/* Power control 1 : PDN_PGAA, PDN_ADCA disable. */
Value = AUDIO_IO_Read(DeviceAddr, 0x02);
counter += CODEC_IO_Write(DeviceAddr, 0x02, (Value & 0xF5));
/* Mic Power and Speed Control : PDN_MICA, PDN_MIC_BIAS disable. */
Value = AUDIO_IO_Read(DeviceAddr, 0x03);
counter += CODEC_IO_Write(DeviceAddr, 0x03, (Value & 0xF9));
}
/* Power control : Exit standby (PDN = 0) */
Value = AUDIO_IO_Read(DeviceAddr, 0x02);
counter += CODEC_IO_Write(DeviceAddr, 0x02, (Value & 0xFE));
Is_CS42L51_Stop = 0;
}
/* Return communication control value */
return counter;
}
/**
* @brief Pause playing on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_Pause(uint16_t DeviceAddr)
{
uint32_t counter = 0;
/* Pause the audio file playing */
/* Mute the output first */
counter += cs42l51_SetMute(DeviceAddr, AUDIO_MUTE_ON);
return counter;
}
/**
* @brief Resume playing on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_Resume(uint16_t DeviceAddr)
{
uint32_t counter = 0;
/* Unmute the output */
counter += cs42l51_SetMute(DeviceAddr, AUDIO_MUTE_OFF);
return counter;
}
/**
* @brief Stop audio Codec playing. It powers down the codec.
* @param DeviceAddr: Device address on communication Bus.
* @param CodecPdwnMode: selects the power down mode (currently not used).
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_Stop(uint16_t DeviceAddr, uint32_t CodecPdwnMode)
{
uint32_t counter = 0;
uint8_t Value;
/* Set all power down bits to 1 exept PDN to mute ADCs and DACs*/
counter += CODEC_IO_Write(DeviceAddr, 0x02, 0x7E);
Value = AUDIO_IO_Read(DeviceAddr, 0x03);
counter += CODEC_IO_Write(DeviceAddr, 0x03, (Value | 0x0E));
/* Disable zero cross and soft ramp */
Value = AUDIO_IO_Read(DeviceAddr, 0x09);
counter += CODEC_IO_Write(DeviceAddr, 0x09, (Value & 0xFC));
/* Power control : Enter standby (PDN = 1) */
Value = AUDIO_IO_Read(DeviceAddr, 0x02);
counter += CODEC_IO_Write(DeviceAddr, 0x02, (Value | 0x01));
Is_CS42L51_Stop = 1;
return counter;
}
/**
* @brief Set higher or lower the codec volume level.
* @param DeviceAddr: Device address on communication Bus.
* @param Volume: output volume level (from 0 (-100dB) to 100 (0dB)).
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_SetVolume(uint16_t DeviceAddr, uint8_t Volume)
{
uint32_t counter = 0;
uint8_t convertedvol = VOLUME_CONVERT(Volume);
/* AOUTA volume control : AOUTA volume */
counter += CODEC_IO_Write(DeviceAddr, 0x16, convertedvol);
/* AOUTB volume control : AOUTB volume */
counter += CODEC_IO_Write(DeviceAddr, 0x17, convertedvol);
return counter;
}
/**
* @brief Set new frequency.
* @param DeviceAddr: Device address on communication Bus.
* @param AudioFreq: Audio frequency used to play the audio stream.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq)
{
return 0;
}
/**
* @brief Enable or disable the mute feature on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @param Cmd: AUDIO_MUTE_ON to enable the mute or AUDIO_MUTE_OFF to disable the
* mute mode.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_SetMute(uint16_t DeviceAddr, uint32_t Cmd)
{
uint32_t counter = 0;
uint8_t Value;
/* Read DAC output control register */
Value = AUDIO_IO_Read(DeviceAddr, 0x08);
/* Set the Mute mode */
if(Cmd == AUDIO_MUTE_ON)
{
/* Mute DAC channels */
counter += CODEC_IO_Write(DeviceAddr, 0x08, (Value | 0x03));
}
else /* AUDIO_MUTE_OFF Disable the Mute */
{
/* Unmute DAC channels */
counter += CODEC_IO_Write(DeviceAddr, 0x08, (Value & 0xFC));
}
return counter;
}
/**
* @brief Switch dynamically (while audio file is played) the output target
* (speaker, headphone, etc).
* @note This function is currently not used (only headphone output device).
* @param DeviceAddr: Device address on communication Bus.
* @param Output: specifies the audio output device target.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_SetOutputMode(uint16_t DeviceAddr, uint8_t Output)
{
return 0;
}
/**
* @brief Reset CS42L51 registers.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_Reset(uint16_t DeviceAddr)
{
if(Is_CS42L51_Initialized == 1)
{
/* Deinitialize Audio Codec interface */
AUDIO_IO_DeInit();
/* Initialize the Control interface of the Audio Codec */
AUDIO_IO_Init();
}
return 0;
}
/**
* @}
*/
/** @addtogroup CS42L51_Private_Functions
* @{
*/
/**
* @brief Write and optionally read back a single data.
* @param Addr: I2C address
* @param Reg: Reg address
* @param Value: Data to be written
* @retval None
*/
static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
{
uint32_t result = 0;
AUDIO_IO_Write(Addr, Reg, Value);
#ifdef VERIFY_WRITTENDATA
/* Verify that the data has been correctly written */
result = (AUDIO_IO_Read(Addr, Reg) == Value)? 0:1;
#endif /* VERIFY_WRITTENDATA */
return result;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,171 @@
/**
******************************************************************************
* @file cs42l51.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the cs42l51.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CS42L51_H
#define __CS42L51_H
/* Includes ------------------------------------------------------------------*/
#include "../Common/audio.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup CS42L51
* @{
*/
/** @defgroup CS42L51_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup CS42L51_Exported_Constants
* @{
*/
/******************************************************************************/
/*************************** Codec User defines ******************************/
/******************************************************************************/
/* Codec output devices */
#define OUTPUT_DEVICE_HEADPHONE 0x01
/* Codec input devices */
#define INPUT_DEVICE_MIC1 0x10
/* Volume Levels values */
#define DEFAULT_VOLMIN 0x00
#define DEFAULT_VOLMAX 0xFF
#define DEFAULT_VOLSTEP 0x04
#define AUDIO_PAUSE 0
#define AUDIO_RESUME 1
/* Codec POWER DOWN modes */
#define CODEC_PDWN_HW 1
#define CODEC_PDWN_SW 2
/* MUTE commands */
#define AUDIO_MUTE_ON 1
#define AUDIO_MUTE_OFF 0
/* AUDIO FREQUENCY */
#define AUDIO_FREQUENCY_192K ((uint32_t)192000)
#define AUDIO_FREQUENCY_96K ((uint32_t)96000)
#define AUDIO_FREQUENCY_48K ((uint32_t)48000)
#define AUDIO_FREQUENCY_44K ((uint32_t)44100)
#define AUDIO_FREQUENCY_32K ((uint32_t)32000)
#define AUDIO_FREQUENCY_22K ((uint32_t)22050)
#define AUDIO_FREQUENCY_16K ((uint32_t)16000)
#define AUDIO_FREQUENCY_11K ((uint32_t)11025)
#define AUDIO_FREQUENCY_8K ((uint32_t)8000)
/******************************************************************************/
/****************************** REGISTER MAPPING ******************************/
/******************************************************************************/
/**
* @brief CS42L51 ID
*/
#define CS42L51_ID 0xD8
#define CS42L51_ID_MASK 0xF8
/**
* @brief Chip ID Register: Chip I.D. and Revision Register
* Read only register
* Default value: 0x01
* [7:3] CHIPID[4:0]: I.D. code for the CS42L51.
* Default value: 11100b
* [2:0] REVID[2:0]: CS42L51 revision level.
* Default value:
* 000 - Rev A0
* 001 - Rev A1
* 010 - Rev B0
* 011 - Rev B1
*/
#define CS42L51_CHIPID_ADDR 0x01
/**
* @}
*/
/** @defgroup CS42L51_Exported_Macros
* @{
*/
#define VOLUME_CONVERT(Volume) ((Volume >= 100) ? 0 : ((uint8_t)(((Volume * 2) + 56))))
/**
* @}
*/
/** @defgroup CS42L51_Exported_Functions
* @{
*/
/*------------------------------------------------------------------------------
Audio Codec functions
------------------------------------------------------------------------------*/
/* High Layer codec functions */
uint32_t cs42l51_Init(uint16_t DeviceAddr, uint16_t Device, uint8_t Volume, uint32_t AudioFreq);
void cs42l51_DeInit(void);
uint32_t cs42l51_ReadID(uint16_t DeviceAddr);
uint32_t cs42l51_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size);
uint32_t cs42l51_Pause(uint16_t DeviceAddr);
uint32_t cs42l51_Resume(uint16_t DeviceAddr);
uint32_t cs42l51_Stop(uint16_t DeviceAddr, uint32_t Cmd);
uint32_t cs42l51_SetVolume(uint16_t DeviceAddr, uint8_t Volume);
uint32_t cs42l51_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq);
uint32_t cs42l51_SetMute(uint16_t DeviceAddr, uint32_t Cmd);
uint32_t cs42l51_SetOutputMode(uint16_t DeviceAddr, uint8_t Output);
uint32_t cs42l51_Reset(uint16_t DeviceAddr);
/* AUDIO IO functions */
void AUDIO_IO_Init(void);
void AUDIO_IO_DeInit(void);
void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg);
void AUDIO_IO_Delay(uint32_t Delay);
/* Audio driver structure */
extern AUDIO_DrvTypeDef cs42l51_drv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* __CS42L51_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,136 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for CS43L22 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-cs43l22-component-drivers"><small>Release Notes for</small> <mark>CS43L22 Component Drivers</mark></h1>
<p>Copyright © 2014 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the CS43L22 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V2.0.4 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V2.0.3 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V2.0.2 / 02-October-2015</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>cs43l22.c/.h:
<ul>
<li>Move VOLUME_CONVERT macro from cs43l22.h to cs43l22.c as internally used to convert volume.</li>
<li>Add literals instead of magic number for cs34l22 registers</li>
</ul></li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V2.0.1 / 16-September-2015</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>cs43l22.c:
<ul>
<li>Enable the digital soft ramp to avoid clac noise</li>
<li>Improve mute/unmute by muting/unmuting also the DAC inputs</li>
</ul></li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V2.0.0 / 24-June-2015</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>cs43l22.c/.h:
<ul>
<li>Add codec de-initialization function: cs43l22_DeInit()</li>
<li>Add Audio IO de-initialization function prototype: AUDIO_IO_DeInit()</li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong><br />
This release must be used with BSP Common driver V4.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.1.0 / 10-February-2015</label>
<div>
<h2 id="main-changes-5">Main Changes</h2>
<ul>
<li>cs43l22.c/.h:
<ul>
<li>Add AUDIO_FREQUENCY_xxx defines for frequencies capabilities (8K to 192K)</li>
<li>Add codec reset function: cs43l22_Reset()</li>
</ul></li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section16" aria-hidden="true"> <label for="collapse-section16" aria-hidden="true">V1.0.1 / 02-December-2014</label>
<div>
<h2 id="main-changes-6">Main Changes</h2>
<ul>
<li>cs43l22.c: change “\” by “/” in the include path to fix compilation issue under Linux</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section15" aria-hidden="true"> <label for="collapse-section15" aria-hidden="true">V1.0.0 / 18-February-2014</label>
<div>
<h2 id="main-changes-7">Main Changes</h2>
<ul>
<li>First official release of CS43L22 audio codec</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,477 @@
/**
******************************************************************************
* @file cs43l22.c
* @author MCD Application Team
* @brief This file provides the CS43L22 Audio Codec driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "cs43l22.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup CS43L22
* @brief This file provides a set of functions needed to drive the
* CS43L22 audio codec.
* @{
*/
/** @defgroup CS43L22_Private_Types
* @{
*/
/**
* @}
*/
/** @defgroup CS43L22_Private_Defines
* @{
*/
#define VOLUME_CONVERT(Volume) (((Volume) > 100)? 255:((uint8_t)(((Volume) * 255) / 100)))
/* Uncomment this line to enable verifying data sent to codec after each write
operation (for debug purpose) */
#if !defined (VERIFY_WRITTENDATA)
/* #define VERIFY_WRITTENDATA */
#endif /* VERIFY_WRITTENDATA */
/**
* @}
*/
/** @defgroup CS43L22_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup CS43L22_Private_Variables
* @{
*/
/* Audio codec driver structure initialization */
AUDIO_DrvTypeDef cs43l22_drv =
{
cs43l22_Init,
cs43l22_DeInit,
cs43l22_ReadID,
cs43l22_Play,
cs43l22_Pause,
cs43l22_Resume,
cs43l22_Stop,
cs43l22_SetFrequency,
cs43l22_SetVolume,
cs43l22_SetMute,
cs43l22_SetOutputMode,
cs43l22_Reset,
};
static uint8_t Is_cs43l22_Stop = 1;
volatile uint8_t OutputDev = 0;
/**
* @}
*/
/** @defgroup CS43L22_Function_Prototypes
* @{
*/
static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
/**
* @}
*/
/** @defgroup CS43L22_Private_Functions
* @{
*/
/**
* @brief Initializes the audio codec and the control interface.
* @param DeviceAddr: Device address on communication Bus.
* @param OutputDevice: can be OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE,
* OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO .
* @param Volume: Initial volume level (from 0 (Mute) to 100 (Max))
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
{
uint32_t counter = 0;
/* Initialize the Control interface of the Audio Codec */
AUDIO_IO_Init();
/* Keep Codec powered OFF */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x01);
/*Save Output device for mute ON/OFF procedure*/
switch (OutputDevice)
{
case OUTPUT_DEVICE_SPEAKER:
OutputDev = 0xFA;
break;
case OUTPUT_DEVICE_HEADPHONE:
OutputDev = 0xAF;
break;
case OUTPUT_DEVICE_BOTH:
OutputDev = 0xAA;
break;
case OUTPUT_DEVICE_AUTO:
OutputDev = 0x05;
break;
default:
OutputDev = 0x05;
break;
}
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev);
/* Clock configuration: Auto detection */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_CLOCKING_CTL, 0x81);
/* Set the Slave Mode and the audio Standard */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_INTERFACE_CTL1, CODEC_STANDARD);
/* Set the Master volume */
counter += cs43l22_SetVolume(DeviceAddr, Volume);
/* If the Speaker is enabled, set the Mono mode and volume attenuation level */
if(OutputDevice != OUTPUT_DEVICE_HEADPHONE)
{
/* Set the Speaker Mono mode */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PLAYBACK_CTL2, 0x06);
/* Set the Speaker attenuation level */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_SPEAKER_A_VOL, 0x00);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_SPEAKER_B_VOL, 0x00);
}
/* Additional configuration for the CODEC. These configurations are done to reduce
the time needed for the Codec to power off. If these configurations are removed,
then a long delay should be added between powering off the Codec and switching
off the I2S peripheral MCLK clock (which is the operating clock for Codec).
If this delay is not inserted, then the codec will not shut down properly and
it results in high noise after shut down. */
/* Disable the analog soft ramp */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_ANALOG_ZC_SR_SETT, 0x00);
/* Disable the digital soft ramp */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x04);
/* Disable the limiter attack level */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_LIMIT_CTL1, 0x00);
/* Adjust Bass and Treble levels */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_TONE_CTL, 0x0F);
/* Adjust PCM volume level */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PCMA_VOL, 0x0A);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PCMB_VOL, 0x0A);
/* Return communication control value */
return counter;
}
/**
* @brief Deinitializes the audio codec.
* @param None
* @retval None
*/
void cs43l22_DeInit(void)
{
/* Deinitialize Audio Codec interface */
AUDIO_IO_DeInit();
}
/**
* @brief Get the CS43L22 ID.
* @param DeviceAddr: Device address on communication Bus.
* @retval The CS43L22 ID
*/
uint32_t cs43l22_ReadID(uint16_t DeviceAddr)
{
uint8_t Value;
/* Initialize the Control interface of the Audio Codec */
AUDIO_IO_Init();
Value = AUDIO_IO_Read(DeviceAddr, CS43L22_CHIPID_ADDR);
Value = (Value & CS43L22_ID_MASK);
return((uint32_t) Value);
}
/**
* @brief Start the audio Codec play feature.
* @note For this codec no Play options are required.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size)
{
uint32_t counter = 0;
if(Is_cs43l22_Stop == 1)
{
/* Enable the digital soft ramp */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x06);
/* Enable Output device */
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_OFF);
/* Power on the Codec */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9E);
Is_cs43l22_Stop = 0;
}
/* Return communication control value */
return counter;
}
/**
* @brief Pauses playing on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Pause(uint16_t DeviceAddr)
{
uint32_t counter = 0;
/* Pause the audio file playing */
/* Mute the output first */
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_ON);
/* Put the Codec in Power save mode */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x01);
return counter;
}
/**
* @brief Resumes playing on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Resume(uint16_t DeviceAddr)
{
uint32_t counter = 0;
volatile uint32_t index = 0x00;
/* Resumes the audio file playing */
/* Unmute the output first */
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_OFF);
for(index = 0x00; index < 0xFF; index++);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev);
/* Exit the Power save mode */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9E);
return counter;
}
/**
* @brief Stops audio Codec playing. It powers down the codec.
* @param DeviceAddr: Device address on communication Bus.
* @param CodecPdwnMode: selects the power down mode.
* - CODEC_PDWN_HW: Physically power down the codec. When resuming from this
* mode, the codec is set to default configuration
* (user should re-Initialize the codec in order to
* play again the audio stream).
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t CodecPdwnMode)
{
uint32_t counter = 0;
/* Mute the output first */
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_ON);
/* Disable the digital soft ramp */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x04);
/* Power down the DAC and the speaker (PMDAC and PMSPK bits)*/
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9F);
Is_cs43l22_Stop = 1;
return counter;
}
/**
* @brief Sets higher or lower the codec volume level.
* @param DeviceAddr: Device address on communication Bus.
* @param Volume: a byte value from 0 to 255 (refer to codec registers
* description for more details).
*
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume)
{
uint32_t counter = 0;
uint8_t convertedvol = VOLUME_CONVERT(Volume);
if(convertedvol > 0xE6)
{
/* Set the Master volume */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_A_VOL, convertedvol - 0xE7);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_B_VOL, convertedvol - 0xE7);
}
else
{
/* Set the Master volume */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_A_VOL, convertedvol + 0x19);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_B_VOL, convertedvol + 0x19);
}
return counter;
}
/**
* @brief Sets new frequency.
* @param DeviceAddr: Device address on communication Bus.
* @param AudioFreq: Audio frequency used to play the audio stream.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq)
{
return 0;
}
/**
* @brief Enables or disables the mute feature on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @param Cmd: AUDIO_MUTE_ON to enable the mute or AUDIO_MUTE_OFF to disable the
* mute mode.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd)
{
uint32_t counter = 0;
/* Set the Mute mode */
if(Cmd == AUDIO_MUTE_ON)
{
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xFF);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_A_VOL, 0x01);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_B_VOL, 0x01);
}
else /* AUDIO_MUTE_OFF Disable the Mute */
{
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_A_VOL, 0x00);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_B_VOL, 0x00);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev);
}
return counter;
}
/**
* @brief Switch dynamically (while audio file is played) the output target
* (speaker or headphone).
* @note This function modifies a global variable of the audio codec driver: OutputDev.
* @param DeviceAddr: Device address on communication Bus.
* @param Output: specifies the audio output target: OUTPUT_DEVICE_SPEAKER,
* OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output)
{
uint32_t counter = 0;
switch (Output)
{
case OUTPUT_DEVICE_SPEAKER:
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xFA); /* SPK always ON & HP always OFF */
OutputDev = 0xFA;
break;
case OUTPUT_DEVICE_HEADPHONE:
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xAF); /* SPK always OFF & HP always ON */
OutputDev = 0xAF;
break;
case OUTPUT_DEVICE_BOTH:
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xAA); /* SPK always ON & HP always ON */
OutputDev = 0xAA;
break;
case OUTPUT_DEVICE_AUTO:
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0x05); /* Detect the HP or the SPK automatically */
OutputDev = 0x05;
break;
default:
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0x05); /* Detect the HP or the SPK automatically */
OutputDev = 0x05;
break;
}
return counter;
}
/**
* @brief Resets cs43l22 registers.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Reset(uint16_t DeviceAddr)
{
return 0;
}
/**
* @brief Writes/Read a single data.
* @param Addr: I2C address
* @param Reg: Reg address
* @param Value: Data to be written
* @retval None
*/
static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
{
uint32_t result = 0;
AUDIO_IO_Write(Addr, Reg, Value);
#ifdef VERIFY_WRITTENDATA
/* Verify that the data has been correctly written */
result = (AUDIO_IO_Read(Addr, Reg) == Value)? 0:1;
#endif /* VERIFY_WRITTENDATA */
return result;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,210 @@
/**
******************************************************************************
* @file cs43l22.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the cs43l22.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CS43L22_H
#define __CS43L22_H
/* Includes ------------------------------------------------------------------*/
#include "../Common/audio.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup CS43L22
* @{
*/
/** @defgroup CS43L22_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup CS43L22_Exported_Constants
* @{
*/
/******************************************************************************/
/*************************** Codec User defines ******************************/
/******************************************************************************/
/* Codec output DEVICE */
#define OUTPUT_DEVICE_SPEAKER 1
#define OUTPUT_DEVICE_HEADPHONE 2
#define OUTPUT_DEVICE_BOTH 3
#define OUTPUT_DEVICE_AUTO 4
/* Volume Levels values */
#define DEFAULT_VOLMIN 0x00
#define DEFAULT_VOLMAX 0xFF
#define DEFAULT_VOLSTEP 0x04
#define AUDIO_PAUSE 0
#define AUDIO_RESUME 1
/* Codec POWER DOWN modes */
#define CODEC_PDWN_HW 1
#define CODEC_PDWN_SW 2
/* MUTE commands */
#define AUDIO_MUTE_ON 1
#define AUDIO_MUTE_OFF 0
/* AUDIO FREQUENCY */
#define AUDIO_FREQUENCY_192K ((uint32_t)192000)
#define AUDIO_FREQUENCY_96K ((uint32_t)96000)
#define AUDIO_FREQUENCY_48K ((uint32_t)48000)
#define AUDIO_FREQUENCY_44K ((uint32_t)44100)
#define AUDIO_FREQUENCY_32K ((uint32_t)32000)
#define AUDIO_FREQUENCY_22K ((uint32_t)22050)
#define AUDIO_FREQUENCY_16K ((uint32_t)16000)
#define AUDIO_FREQUENCY_11K ((uint32_t)11025)
#define AUDIO_FREQUENCY_8K ((uint32_t)8000)
/** CS43l22 Registers ***/
#define CS43L22_REG_ID 0x01
#define CS43L22_REG_POWER_CTL1 0x02
#define CS43L22_REG_POWER_CTL2 0x04
#define CS43L22_REG_CLOCKING_CTL 0x05
#define CS43L22_REG_INTERFACE_CTL1 0x06
#define CS43L22_REG_INTERFACE_CTL2 0x07
#define CS43L22_REG_PASSTHR_A_SELECT 0x08
#define CS43L22_REG_PASSTHR_B_SELECT 0x09
#define CS43L22_REG_ANALOG_ZC_SR_SETT 0x0A
#define CS43L22_REG_PASSTHR_GANG_CTL 0x0C
#define CS43L22_REG_PLAYBACK_CTL1 0x0D
#define CS43L22_REG_MISC_CTL 0x0E
#define CS43L22_REG_PLAYBACK_CTL2 0x0F
#define CS43L22_REG_PASSTHR_A_VOL 0x14
#define CS43L22_REG_PASSTHR_B_VOL 0x15
#define CS43L22_REG_PCMA_VOL 0x1A
#define CS43L22_REG_PCMB_VOL 0x1B
#define CS43L22_REG_BEEP_FREQ_ON_TIME 0x1C
#define CS43L22_REG_BEEP_VOL_OFF_TIME 0x1D
#define CS43L22_REG_BEEP_TONE_CFG 0x1E
#define CS43L22_REG_TONE_CTL 0x1F
#define CS43L22_REG_MASTER_A_VOL 0x20
#define CS43L22_REG_MASTER_B_VOL 0x21
#define CS43L22_REG_HEADPHONE_A_VOL 0x22
#define CS43L22_REG_HEADPHONE_B_VOL 0x23
#define CS43L22_REG_SPEAKER_A_VOL 0x24
#define CS43L22_REG_SPEAKER_B_VOL 0x25
#define CS43L22_REG_CH_MIXER_SWAP 0x26
#define CS43L22_REG_LIMIT_CTL1 0x27
#define CS43L22_REG_LIMIT_CTL2 0x28
#define CS43L22_REG_LIMIT_ATTACK_RATE 0x29
#define CS43L22_REG_OVF_CLK_STATUS 0x2E
#define CS43L22_REG_BATT_COMPENSATION 0x2F
#define CS43L22_REG_VP_BATTERY_LEVEL 0x30
#define CS43L22_REG_SPEAKER_STATUS 0x31
#define CS43L22_REG_TEMPMONITOR_CTL 0x32
#define CS43L22_REG_THERMAL_FOLDBACK 0x33
#define CS43L22_REG_CHARGE_PUMP_FREQ 0x34
/******************************************************************************/
/****************************** REGISTER MAPPING ******************************/
/******************************************************************************/
/**
* @brief CS43L22 ID
*/
#define CS43L22_ID 0xE0
#define CS43L22_ID_MASK 0xF8
/**
* @brief Chip ID Register: Chip I.D. and Revision Register
* Read only register
* Default value: 0x01
* [7:3] CHIPID[4:0]: I.D. code for the CS43L22.
* Default value: 11100b
* [2:0] REVID[2:0]: CS43L22 revision level.
* Default value:
* 000 - Rev A0
* 001 - Rev A1
* 010 - Rev B0
* 011 - Rev B1
*/
#define CS43L22_CHIPID_ADDR 0x01
/**
* @}
*/
/** @defgroup CS43L22_Exported_Macros
* @{
*/
/**
* @}
*/
/** @defgroup CS43L22_Exported_Functions
* @{
*/
/*------------------------------------------------------------------------------
Audio Codec functions
------------------------------------------------------------------------------*/
/* High Layer codec functions */
uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
void cs43l22_DeInit(void);
uint32_t cs43l22_ReadID(uint16_t DeviceAddr);
uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size);
uint32_t cs43l22_Pause(uint16_t DeviceAddr);
uint32_t cs43l22_Resume(uint16_t DeviceAddr);
uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t Cmd);
uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume);
uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq);
uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd);
uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output);
uint32_t cs43l22_Reset(uint16_t DeviceAddr);
/* AUDIO IO functions */
void AUDIO_IO_Init(void);
void AUDIO_IO_DeInit(void);
void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg);
/* Audio driver structure */
extern AUDIO_DrvTypeDef cs43l22_drv;
#endif /* __CS43L22_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for CY8C4014LQI Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-cy8c4014lqi-component-drivers"><small>Release Notes for</small> <mark>CY8C4014LQI Component Drivers</mark></h1>
<p>Copyright © 2019 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the CY8C4014LQI component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section1" checked aria-hidden="true"> <label for="collapse-section1" aria-hidden="true">V1.0.0 / 05-July-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>First official release of CY8C4014LQI Touch Screen Component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,359 @@
/**
******************************************************************************
* @file cy8c4014lqi.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the CY8C4014LQI
* touch screen devices.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "cy8c4014lqi.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup CY8C4014LQI
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/** @defgroup CY8C4014LQI_Private_Types_Definitions
* @{
*/
/* cy8c4014lqi Handle definition. */
typedef struct
{
uint8_t i2cInitialized;
/* field holding the current number of simultaneous active touches */
uint8_t currActiveTouchNb;
/* field holding the touch index currently managed */
uint8_t currActiveTouchIdx;
} cy8c4014lqi_handle_TypeDef;
/**
* @}
*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
volatile uint8_t is_touch = 0;
/** @defgroup CY8C4014LQI_Private_Variables
* @{
*/
/* Touch screen driver structure initialization */
TS_DrvTypeDef cy8c4014lqi_ts_drv =
{
cy8c4014lqi_Init,
cy8c4014lqi_ReadID,
cy8c4014lqi_Reset,
cy8c4014lqi_TS_Start,
cy8c4014lqi_TS_DetectTouch,
cy8c4014lqi_TS_GetXY,
cy8c4014lqi_TS_EnableIT,
cy8c4014lqi_TS_ClearIT,
cy8c4014lqi_TS_ITStatus,
cy8c4014lqi_TS_DisableIT
};
/* Global cy8c4014lqi handle */
static cy8c4014lqi_handle_TypeDef cy8c4014lqi_handle = { CY8C4014LQI_I2C_NOT_INITIALIZED, 0U, 0U};
/**
* @}
*/
/* Private functions prototypes-----------------------------------------------*/
/** @defgroup CY8C4014LQI_Private_Functions
* @{
*/
static uint8_t cy8c4014lqi_Get_I2C_InitializedStatus(void);
static void cy8c4014lqi_I2C_InitializeIfRequired(void);
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup CY8C4014LQI_Exported_Functions
* @{
*/
/**
* @brief Initialize the cy8c4014lqi communication bus
* from MCU to CY8C4014LQI : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @retval None
*/
void cy8c4014lqi_Init(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
cy8c4014lqi_I2C_InitializeIfRequired();
}
/**
* @brief Software Reset the cy8c4014lqi.
* @note : Not applicable to CY8C4014LQI.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @retval None
*/
void cy8c4014lqi_Reset(uint16_t DeviceAddr)
{
/* Do nothing */
/* No software reset sequence available in CY8C4014LQI IC */
}
/**
* @brief Read the cy8c4014lqi device ID, pre initialize I2C in case of need to be
* able to read the CY8C4014LQI device ID, and verify this is a CY8C4014LQI.
* @param DeviceAddr: I2C CY8C4014LQI Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t cy8c4014lqi_ReadID(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
cy8c4014lqi_I2C_InitializeIfRequired();
/* Return the device ID value */
return(TS_IO_Read(DeviceAddr, CY8C4014LQI_ADEVICE_ID));
}
/**
* @brief Configures the touch Screen IC device to start detecting touches
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void cy8c4014lqi_TS_Start(uint16_t DeviceAddr)
{
/* Do nothing */
/* No software available in CY8C4014LQI IC */
}
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t cy8c4014lqi_TS_DetectTouch(uint16_t DeviceAddr)
{
return is_touch;
}
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'cy8c4014lqi_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void cy8c4014lqi_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
{
*X = TS_IO_Read(CY8C4014LQI_ADDR, CY8C4014LQI_POS_X);
*Y = TS_IO_Read(CY8C4014LQI_ADDR, CY8C4014LQI_POS_Y);
}
/**
* @brief Configure the CY8C4014LQI device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of CY8C4014LQI).
* @retval None
*/
void cy8c4014lqi_TS_EnableIT(uint16_t DeviceAddr)
{
/* Do nothing */
/* Action done by BSP software */
}
/**
* @brief Configure the CY8C4014LQI device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of CY8C4014LQI).
* @retval None
*/
void cy8c4014lqi_TS_DisableIT(uint16_t DeviceAddr)
{
/* Do nothing */
/* Action done by BSP software */
}
/**
* @brief Get IT status from CY8C4014LQI interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @note : This feature is not applicable to CY8C4014LQI.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @retval TS interrupts status : always return 0 here
*/
uint8_t cy8c4014lqi_TS_ITStatus(uint16_t DeviceAddr)
{
/* Always return 0 as feature not applicable to CY8C4014LQI */
return 0U;
}
/**
* @brief Clear IT status in CY8C4014LQI interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @note : This feature is not applicable to CY8C4014LQI.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @retval None
*/
void cy8c4014lqi_TS_ClearIT(uint16_t DeviceAddr)
{
/* Do nothing */
/* Action done by BSP software */
}
/**
* @brief Configure gesture feature (enable/disable).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @param Activation : Enable or disable gesture feature. Possible values are
* CY8C4014LQI_GESTURE_DISABLE or CY8C4014LQI_GESTURE_ENABLE.
* @retval None.
*/
void cy8c4014lqi_TS_GestureConfig(uint16_t DeviceAddr, uint32_t Activation)
{
/* Do nothing */
/* No software available in CY8C4014LQI IC */
}
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void cy8c4014lqi_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
{
/* Do nothing */
/* No software available in CY8C4014LQI IC */
}
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @note Area and Weight features are not supported by CY8C4014LQI. Return always 0 value.
* @retval None.
*/
void cy8c4014lqi_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent)
{
/* Do nothing */
/* No software available in CY8C4014LQI IC */
}
/**
* @}
*/
/* Private functions bodies---------------------------------------------------*/
/** @addtogroup CY8C4014LQI_Private_Functions
* @{
*/
/**
* @brief Return the status of I2C was initialized or not.
* @param None.
* @retval : I2C initialization status.
*/
static uint8_t cy8c4014lqi_Get_I2C_InitializedStatus(void)
{
return(cy8c4014lqi_handle.i2cInitialized);
}
/**
* @brief I2C initialize if needed.
* @param None.
* @retval : None.
*/
static void cy8c4014lqi_I2C_InitializeIfRequired(void)
{
if(cy8c4014lqi_Get_I2C_InitializedStatus() == CY8C4014LQI_I2C_NOT_INITIALIZED)
{
/* Initialize TS IO BUS layer (I2C) */
TS_IO_Init();
/* Set state to initialized */
cy8c4014lqi_handle.i2cInitialized = CY8C4014LQI_I2C_INITIALIZED;
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,165 @@
/**
******************************************************************************
* @file cy8c4014lqi.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* cy8c4014lqi.c touch screen driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CY8C4014LQI_H
#define __CY8C4014LQI_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/ts.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup CY8C4014LQI
* @{
*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup CY8C4014LQI_Exported_Constants
* @{
*/
#define CY8C4014LQI_ADDR (0x08<<1)
#define CY8C4014LQI_ADEVICE_ID (0x00)
#define CY8C4014LQI_VERSION (0x01)
#define CY8C4014LQI_SYSMODE (0x03)
#define CY8C4014LQI_TOUCH_EVENT (0x04)
#define CY8C4014LQI_POS_X (0x06)
#define CY8C4014LQI_POS_Y (0x07)
#define CY8C4014LQI_GESTURE (0x08)
#define CY8C4014LQI_DISTENCE_X (0x09)
#define CY8C4014LQI_DISTENCE_Y (0x0A)
#define DATA_VALUE_FLAG (0x0B)
/* Possible values of global variable 'TS_I2C_Initialized' */
#define CY8C4014LQI_I2C_NOT_INITIALIZED 0x00U
#define CY8C4014LQI_I2C_INITIALIZED 0x01U
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup CY8C4014LQI_Exported_Functions
* @{
*/
void cy8c4014lqi_Init(uint16_t DeviceAddr);
void cy8c4014lqi_Reset(uint16_t DeviceAddr);
uint16_t cy8c4014lqi_ReadID(uint16_t DeviceAddr);
void cy8c4014lqi_TS_Start(uint16_t DeviceAddr);
uint8_t cy8c4014lqi_TS_DetectTouch(uint16_t DeviceAddr);
void cy8c4014lqi_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
void cy8c4014lqi_TS_EnableIT(uint16_t DeviceAddr);
void cy8c4014lqi_TS_DisableIT(uint16_t DeviceAddr);
uint8_t cy8c4014lqi_TS_ITStatus (uint16_t DeviceAddr);
void cy8c4014lqi_TS_ClearIT (uint16_t DeviceAddr);
void cy8c4014lqi_TS_GestureConfig(uint16_t DeviceAddr, uint32_t Activation);
void cy8c4014lqi_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
void cy8c4014lqi_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent);
/**
* @}
*/
/* Imported TS IO functions --------------------------------------------------------*/
/** @defgroup CY8C4014LQI_Imported_Functions
* @{
*/
/* TouchScreen (TS) external IO functions */
extern void TS_IO_Init(void);
extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void TS_IO_Delay(uint32_t Delay);
/**
* @}
*/
/* Imported global variables --------------------------------------------------------*/
/** @defgroup CY8C4014LQI_Imported_Globals
* @{
*/
/* Touch screen driver structure */
extern TS_DrvTypeDef cy8c4014lqi_ts_drv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __CY8C4014LQI_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for FT3X67 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-ft3x67-component-drivers"><small>Release Notes for</small> <mark>FT3X67 Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the FT3X67 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 07-August-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of Touch Screen FT3x67 Component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,443 @@
/**
******************************************************************************
* @file ft3x67.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the FT3X67
* touch screen devices.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "ft3x67.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup FT3X67
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/** @defgroup FT3X67_Private_Types_Definitions
* @{
*/
/* ft3x67 Handle definition. */
typedef struct
{
uint8_t i2cInitialized;
/* field holding the current number of simultaneous active touches */
uint8_t currActiveTouchNb;
/* field holding the touch index currently managed */
uint8_t currActiveTouchIdx;
} ft3x67_handle_TypeDef;
/**
* @}
*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/** @defgroup FT3X67_Private_Variables
* @{
*/
/* Touch screen driver structure initialization */
TS_DrvTypeDef ft3x67_ts_drv =
{
ft3x67_Init,
ft3x67_ReadID,
ft3x67_Reset,
ft3x67_TS_Start,
ft3x67_TS_DetectTouch,
ft3x67_TS_GetXY,
ft3x67_TS_EnableIT,
ft3x67_TS_ClearIT,
ft3x67_TS_ITStatus,
ft3x67_TS_DisableIT
};
/* Global ft3x67 handle */
static ft3x67_handle_TypeDef ft3x67_handle = { FT3X67_I2C_NOT_INITIALIZED, 0U, 0U};
/**
* @}
*/
/* Private functions prototypes-----------------------------------------------*/
/** @defgroup FT3X67_Private_Functions
* @{
*/
static uint8_t ft3x67_Get_I2C_InitializedStatus(void);
static void ft3x67_I2C_InitializeIfRequired(void);
static uint32_t ft3x67_TS_Configure(uint16_t DeviceAddr);
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup FT3X67_Exported_Functions
* @{
*/
/**
* @brief Initialize the ft3x67 communication bus
* from MCU to FT3X67 : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval None
*/
void ft3x67_Init(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
ft3x67_I2C_InitializeIfRequired();
}
/**
* @brief Software Reset the ft3x67.
* @note : Not applicable to FT3X67.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval None
*/
void ft3x67_Reset(uint16_t DeviceAddr)
{
/* Do nothing */
/* No software reset sequence available in FT3X67 IC */
}
/**
* @brief Read the ft3x67 device ID, pre initialize I2C in case of need to be
* able to read the FT3X67 device ID, and verify this is a FT3X67.
* @param DeviceAddr: I2C FT3X67 Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t ft3x67_ReadID(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
ft3x67_I2C_InitializeIfRequired();
/* Return the device ID value */
return(TS_IO_Read(DeviceAddr, FT3X67_CHIP_ID_REG));
}
/**
* @brief Configures the touch Screen IC device to start detecting touches
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void ft3x67_TS_Start(uint16_t DeviceAddr)
{
/* Minimum static configuration of FT3X67 */
ft3x67_TS_Configure(DeviceAddr);
/* By default set FT3X67 IC in Polling mode : no INT generation on FT3X67 for new touch available */
/* Note TS_INT is active low */
ft3x67_TS_DisableIT(DeviceAddr);
}
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t ft3x67_TS_DetectTouch(uint16_t DeviceAddr)
{
volatile uint8_t nbTouch = 0U;
/* Read register FT3X67_TD_STAT_REG to check number of touches detection */
nbTouch = TS_IO_Read(DeviceAddr, FT3X67_TD_STAT_REG);
nbTouch &= FT3X67_TD_STAT_MASK;
if(nbTouch > FT3X67_MAX_DETECTABLE_TOUCH)
{
/* If invalid number of touch detected, set it to zero */
nbTouch = 0U;
}
/* Update ft3x67 driver internal global : current number of active touches */
ft3x67_handle.currActiveTouchNb = nbTouch;
/* Reset current active touch index on which to work on */
ft3x67_handle.currActiveTouchIdx = 0U;
return(nbTouch);
}
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'ft3x67_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void ft3x67_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
{
uint8_t regAddress = 0U;
uint8_t dataxy[4U];
if(ft3x67_handle.currActiveTouchIdx < ft3x67_handle.currActiveTouchNb)
{
switch(ft3x67_handle.currActiveTouchIdx)
{
case 0U :
regAddress = FT3X67_P1_XH_REG;
break;
case 1U :
regAddress = FT3X67_P2_XH_REG;
break;
default :
break;
} /* end switch(ft3x67_handle.currActiveTouchIdx) */
/* Read X and Y positions */
TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy));
/* Send back ready X position to caller */
*X = ((dataxy[0U] & FT3X67_TOUCH_POS_MSB_MASK) << 8U) | dataxy[1U];
/* Send back ready Y position to caller */
*Y = ((dataxy[2U] & FT3X67_TOUCH_POS_MSB_MASK) << 8U) | dataxy[3U];
/* Increment current touch index */
ft3x67_handle.currActiveTouchIdx++;
}
}
/**
* @brief Configure the FT3X67 device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT3X67).
* @retval None
*/
void ft3x67_TS_EnableIT(uint16_t DeviceAddr)
{
/* Set interrupt trigger mode in FT3X67_GMODE_REG */
TS_IO_Write(DeviceAddr, FT3X67_GMODE_REG, FT3X67_G_MODE_INTERRUPT_TRIGGER);
}
/**
* @brief Configure the FT3X67 device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT3X67).
* @retval None
*/
void ft3x67_TS_DisableIT(uint16_t DeviceAddr)
{
/* Set interrupt polling mode in FT3X67_GMODE_REG */
TS_IO_Write(DeviceAddr, FT3X67_GMODE_REG, FT3X67_G_MODE_INTERRUPT_POLLING);
}
/**
* @brief Get IT status from FT3X67 interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @note : This feature is not applicable to FT3X67.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval TS interrupts status : always return 0 here
*/
uint8_t ft3x67_TS_ITStatus(uint16_t DeviceAddr)
{
/* Always return 0 as feature not applicable to FT3X67 */
return 0U;
}
/**
* @brief Clear IT status in FT3X67 interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @note : This feature is not applicable to FT3X67.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval None
*/
void ft3x67_TS_ClearIT(uint16_t DeviceAddr)
{
/* Nothing to be done here for FT3X67 */
}
/**
* @brief Configure gesture feature (enable/disable).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @param Activation : Enable or disable gesture feature. Possible values are
* FT3X67_GESTURE_DISABLE or FT3X67_GESTURE_ENABLE.
* @retval None.
*/
void ft3x67_TS_GestureConfig(uint16_t DeviceAddr, uint32_t Activation)
{
if(Activation == FT3X67_GESTURE_ENABLE)
{
/* Enable gesture feature. */
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_FLAG_REG, FT3X67_GEST_ALL_FLAGS_ENABLE);
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_ENABLE_REG, FT3X67_GESTURE_ENABLE);
}
else
{
/* Disable gesture feature. */
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_FLAG_REG, FT3X67_GEST_ALL_FLAGS_DISABLE);
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_ENABLE_REG, FT3X67_GESTURE_DISABLE);
}
}
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void ft3x67_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
{
volatile uint8_t ucReadData = 0U;
ucReadData = TS_IO_Read(DeviceAddr, FT3X67_GEST_ID_REG);
*pGestureId = ucReadData;
}
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @note Area and Weight features are not supported by FT3X67. Return always 0 value.
* @retval None.
*/
void ft3x67_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent)
{
volatile uint8_t ucReadData = 0U;
uint8_t regAddressXHigh = 0U;
if(touchIdx < ft3x67_handle.currActiveTouchNb)
{
switch(touchIdx)
{
case 0U :
regAddressXHigh = FT3X67_P1_XH_REG;
break;
case 1U :
regAddressXHigh = FT3X67_P2_XH_REG;
break;
default :
break;
} /* end switch(touchIdx) */
/* Read Event Id of touch index */
ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh);
*pEvent = (ucReadData & FT3X67_TOUCH_EVT_FLAG_MASK) >> FT3X67_TOUCH_EVT_FLAG_SHIFT;
/* Weight and area of touch index not supported by FT3X67 */
*pWeight = 0;
*pArea = 0;
} /* of if(touchIdx < ft3x67_handle.currActiveTouchNb) */
}
/**
* @}
*/
/* Private functions bodies---------------------------------------------------*/
/** @addtogroup FT3X67_Private_Functions
* @{
*/
/**
* @brief Return the status of I2C was initialized or not.
* @param None.
* @retval : I2C initialization status.
*/
static uint8_t ft3x67_Get_I2C_InitializedStatus(void)
{
return(ft3x67_handle.i2cInitialized);
}
/**
* @brief I2C initialize if needed.
* @param None.
* @retval : None.
*/
static void ft3x67_I2C_InitializeIfRequired(void)
{
if(ft3x67_Get_I2C_InitializedStatus() == FT3X67_I2C_NOT_INITIALIZED)
{
/* Initialize TS IO BUS layer (I2C) */
TS_IO_Init();
/* Set state to initialized */
ft3x67_handle.i2cInitialized = FT3X67_I2C_INITIALIZED;
}
}
/**
* @brief Basic static configuration of TouchScreen
* @param DeviceAddr: FT3X67 Device address for communication on I2C Bus.
* @retval Status FT3X67_STATUS_OK or FT3X67_STATUS_NOT_OK.
*/
static uint32_t ft3x67_TS_Configure(uint16_t DeviceAddr)
{
uint32_t status = FT3X67_STATUS_OK;
/* Disable gesture feature */
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_ENABLE_REG, FT3X67_GESTURE_DISABLE);
return(status);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,273 @@
/**
******************************************************************************
* @file ft3x67.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* ft3x67.c touch screen driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __FT3X67_H
#define __FT3X67_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/ts.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup FT3X67
* @{
*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup FT3X67_Exported_Constants
* @{
*/
/* Maximum border values of the touchscreen pad */
#define FT3X67_MAX_WIDTH 390U /* Touchscreen pad max width */
#define FT3X67_MAX_HEIGHT 390U /* Touchscreen pad max height */
/* Possible values of driver functions return status */
#define FT3X67_STATUS_OK 0x00U
#define FT3X67_STATUS_NOT_OK 0x01U
/* Possible values of global variable 'TS_I2C_Initialized' */
#define FT3X67_I2C_NOT_INITIALIZED 0x00U
#define FT3X67_I2C_INITIALIZED 0x01U
/* Max detectable simultaneous touches */
#define FT3X67_MAX_DETECTABLE_TOUCH 0x02U
/* Definitions for FT3X67 registers */
/* Current mode register of the FT3X67 (R/W) */
#define FT3X67_DEV_MODE_REG 0x00U
/* Possible values of FT3X67_DEV_MODE_REG */
#define FT3X67_DEV_MODE_WORKING 0x00U
#define FT3X67_DEV_MODE_FACTORY 0x40U
/* Touch Data Status register : gives number of active touch points (0..2) */
#define FT3X67_TD_STAT_REG 0x02U
/* Values related to FT3X67_TD_STAT_REG */
#define FT3X67_TD_STAT_MASK 0x0FU
/* Values Pn_XH and Pn_YH related */
#define FT3X67_TOUCH_EVT_FLAG_PRESS_DOWN 0x00U
#define FT3X67_TOUCH_EVT_FLAG_LIFT_UP 0x01U
#define FT3X67_TOUCH_EVT_FLAG_CONTACT 0x02U
#define FT3X67_TOUCH_EVT_FLAG_NO_EVENT 0x03U
#define FT3X67_TOUCH_EVT_FLAG_SHIFT 0x06U
#define FT3X67_TOUCH_EVT_FLAG_MASK (3U << FT3X67_TOUCH_EVT_FLAG_SHIFT)
#define FT3X67_TOUCH_POS_MSB_MASK 0x0FU
/* Point 1 registers */
#define FT3X67_P1_XH_REG 0x03U
#define FT3X67_P1_XL_REG 0x04U
#define FT3X67_P1_YH_REG 0x05U
#define FT3X67_P1_YL_REG 0x06U
#define FT3X67_P1_WEIGHT_REG 0x07U
#define FT3X67_P1_MISC_REG 0x08U
/* Point 2 registers */
#define FT3X67_P2_XH_REG 0x09U
#define FT3X67_P2_XL_REG 0x0AU
#define FT3X67_P2_YH_REG 0x0BU
#define FT3X67_P2_YL_REG 0x0CU
#define FT3X67_P2_WEIGHT_REG 0x0DU
#define FT3X67_P2_MISC_REG 0x0EU
/* Values related to Pn_MISC register */
#define FT3X67_TOUCH_AREA_MASK (0xFU << FT3X67_TOUCH_AREA_SHIFT)
#define FT3X67_TOUCH_AREA_SHIFT 0x04U
/* Threshold for touch detection register */
#define FT3X67_TH_GROUP_REG 0x80U
/* Filter function coefficients register */
#define FT3X67_TH_DIFF_REG 0x85U
/* Control register */
#define FT3X67_CTRL_REG 0x86U
/* Values related to FT3X67_CTRL_REG */
#define FT3X67_CTRL_KEEP_ACTIVE_MODE 0x00U
#define FT3X67_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE 0x01U
/* The time period of switching from Active mode to Monitor mode when there is no touching */
#define FT3X67_TIMEENTERMONITOR_REG 0x87U
/* Report rate in Active mode */
#define FT3X67_PERIODACTIVE_REG 0x88U
/* Report rate in Monitor mode */
#define FT3X67_PERIODMONITOR_REG 0x89U
/* High 8-bit of LIB Version info */
#define FT3X67_LIB_VER_H_REG 0xA1U
/* Low 8-bit of LIB Version info */
#define FT3X67_LIB_VER_L_REG 0xA2U
/* Chip Selecting */
#define FT3X67_CIPHER_REG 0xA3U
/* Interrupt mode register (used when in interrupt mode) */
#define FT3X67_GMODE_REG 0xA4U
/* Possible values of FT3X67_GMODE_REG */
#define FT3X67_G_MODE_INTERRUPT_POLLING 0x00U
#define FT3X67_G_MODE_INTERRUPT_TRIGGER 0x01U
/* Current power mode */
#define FT3X67_PWR_MODE_REG 0xA5U
/* Firmware version */
#define FT3X67_FIRMID_REG 0xA6U
/* Chip identification register */
#define FT3X67_CHIP_ID_REG 0xA8U
/* Possible values of FT3X67_CHIP_ID_REG */
#define FT3X67_ID_VALUE 0x11U
/* Release code version */
#define FT3X67_RELEASE_CODE_ID_REG 0xAFU
/* Current operating mode register */
#define FT3X67_STATE_REG 0xBCU
/* Possible values of FT3X67_STATE_REG */
#define FT3X67_STATE_INFO_MODE 0x00U
#define FT3X67_STATE_NORMAL_MODE 0x01U
#define FT3X67_STATE_FACTORY_MODE 0x03U
#define FT3X67_STATE_AUTO_CALIB_MODE 0x04U
/* Gesture enable register */
#define FT3X67_GESTURE_ENABLE_REG 0xD0U
/* Possible values of FT3X67_GESTURE_ENABLE_REG */
#define FT3X67_GESTURE_DISABLE 0x00U
#define FT3X67_GESTURE_ENABLE 0x01U
/* Gesture flag register */
#define FT3X67_GESTURE_FLAG_REG 0xD1U
/* Possible values of FT3X67_GESTURE_FLAG_REG can be any combination of following values */
#define FT3X67_GEST_LINE_RIGHT_TO_LEFT_ENABLE 0x01U
#define FT3X67_GEST_LINE_LEFT_TO_RIGHT_ENABLE 0x02U
#define FT3X67_GEST_LINE_DOWN_TO_UP_ENABLE 0x04U
#define FT3X67_GEST_LINE_UP_TO_DOWN_ENABLE 0x08U
#define FT3X67_GEST_DOUBLE_TAP_ENABLE 0x10U
#define FT3X67_GEST_ALL_FLAGS_ENABLE 0x1FU
#define FT3X67_GEST_ALL_FLAGS_DISABLE 0x00U
/* Gesture ID register */
#define FT3X67_GEST_ID_REG 0xD3U
/* Possible values of FT3X67_GEST_ID_REG */
#define FT3X67_GEST_ID_NO_GESTURE 0x00U
#define FT3X67_GEST_ID_MOVE_UP 0x22U
#define FT3X67_GEST_ID_MOVE_RIGHT 0x21U
#define FT3X67_GEST_ID_MOVE_DOWN 0x23U
#define FT3X67_GEST_ID_MOVE_LEFT 0x20U
#define FT3X67_GEST_ID_DOUBLE_CLICK 0x24U
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup FT3X67_Exported_Functions
* @{
*/
void ft3x67_Init(uint16_t DeviceAddr);
void ft3x67_Reset(uint16_t DeviceAddr);
uint16_t ft3x67_ReadID(uint16_t DeviceAddr);
void ft3x67_TS_Start(uint16_t DeviceAddr);
uint8_t ft3x67_TS_DetectTouch(uint16_t DeviceAddr);
void ft3x67_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
void ft3x67_TS_EnableIT(uint16_t DeviceAddr);
void ft3x67_TS_DisableIT(uint16_t DeviceAddr);
uint8_t ft3x67_TS_ITStatus (uint16_t DeviceAddr);
void ft3x67_TS_ClearIT (uint16_t DeviceAddr);
void ft3x67_TS_GestureConfig(uint16_t DeviceAddr, uint32_t Activation);
void ft3x67_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
void ft3x67_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent);
/**
* @}
*/
/* Imported TS IO functions --------------------------------------------------------*/
/** @defgroup FT3X67_Imported_Functions
* @{
*/
/* TouchScreen (TS) external IO functions */
extern void TS_IO_Init(void);
extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void TS_IO_Delay(uint32_t Delay);
/**
* @}
*/
/* Imported global variables --------------------------------------------------------*/
/** @defgroup FT3X67_Imported_Globals
* @{
*/
/* Touch screen driver structure */
extern TS_DrvTypeDef ft3x67_ts_drv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __FT3X67_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for FT5336GQQ Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-ft5336gqq-component-drivers"><small>Release Notes for</small> <mark>FT5336GQQ Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the FT5336GQQ component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.2 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.0.1 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 25-June-2015</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,607 @@
/**
******************************************************************************
* @file ft5336.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the FT5336
* touch screen devices.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "ft5336.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup FT5336
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/** @defgroup FT5336_Private_Types_Definitions
* @{
*/
/* Private define ------------------------------------------------------------*/
/** @defgroup FT5336_Private_Defines
* @{
*/
/* Private macro -------------------------------------------------------------*/
/** @defgroup FT5336_Private_Macros
* @{
*/
/* Private variables ---------------------------------------------------------*/
/** @defgroup FT5336_Private_Variables
* @{
*/
/* Touch screen driver structure initialization */
TS_DrvTypeDef ft5336_ts_drv =
{
ft5336_Init,
ft5336_ReadID,
ft5336_Reset,
ft5336_TS_Start,
ft5336_TS_DetectTouch,
ft5336_TS_GetXY,
ft5336_TS_EnableIT,
ft5336_TS_ClearIT,
ft5336_TS_ITStatus,
ft5336_TS_DisableIT
};
/* Global ft5336 handle */
static ft5336_handle_TypeDef ft5336_handle = { FT5336_I2C_NOT_INITIALIZED, 0, 0};
/**
* @}
*/
/** @defgroup ft5336_Private_Function_Prototypes
* @{
*/
/* Private functions prototypes-----------------------------------------------*/
/**
* @brief Return the status of I2C was initialized or not.
* @param None.
* @retval : I2C initialization status.
*/
static uint8_t ft5336_Get_I2C_InitializedStatus(void);
/**
* @brief I2C initialize if needed.
* @param None.
* @retval : None.
*/
static void ft5336_I2C_InitializeIfRequired(void);
/**
* @brief Basic static configuration of TouchScreen
* @param DeviceAddr: FT5336 Device address for communication on I2C Bus.
* @retval Status FT5336_STATUS_OK or FT5336_STATUS_NOT_OK.
*/
static uint32_t ft5336_TS_Configure(uint16_t DeviceAddr);
/** @defgroup ft5336_Private_Functions
* @{
*/
/** @defgroup ft5336_Public_Function_Body
* @{
*/
/* Public functions bodies-----------------------------------------------*/
/**
* @brief Initialize the ft5336 communication bus
* from MCU to FT5336 : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval None
*/
void ft5336_Init(uint16_t DeviceAddr)
{
/* Wait at least 200ms after power up before accessing registers
* Trsi timing (Time of starting to report point after resetting) from FT5336GQQ datasheet */
TS_IO_Delay(200);
/* Initialize I2C link if needed */
ft5336_I2C_InitializeIfRequired();
}
/**
* @brief Software Reset the ft5336.
* @note : Not applicable to FT5336.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval None
*/
void ft5336_Reset(uint16_t DeviceAddr)
{
/* Do nothing */
/* No software reset sequence available in FT5336 IC */
}
/**
* @brief Read the ft5336 device ID, pre initialize I2C in case of need to be
* able to read the FT5336 device ID, and verify this is a FT5336.
* @param DeviceAddr: I2C FT5336 Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t ft5336_ReadID(uint16_t DeviceAddr)
{
volatile uint8_t ucReadId = 0;
uint8_t nbReadAttempts = 0;
uint8_t bFoundDevice = 0; /* Device not found by default */
/* Initialize I2C link if needed */
ft5336_I2C_InitializeIfRequired();
/* At maximum 4 attempts to read ID : exit at first finding of the searched device ID */
for(nbReadAttempts = 0; ((nbReadAttempts < 3) && !(bFoundDevice)); nbReadAttempts++)
{
/* Read register FT5336_CHIP_ID_REG as DeviceID detection */
ucReadId = TS_IO_Read(DeviceAddr, FT5336_CHIP_ID_REG);
/* Found the searched device ID ? */
if(ucReadId == FT5336_ID_VALUE)
{
/* Set device as found */
bFoundDevice = 1;
}
}
/* Return the device ID value */
return (ucReadId);
}
/**
* @brief Configures the touch Screen IC device to start detecting touches
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void ft5336_TS_Start(uint16_t DeviceAddr)
{
/* Minimum static configuration of FT5336 */
FT5336_ASSERT(ft5336_TS_Configure(DeviceAddr));
/* By default set FT5336 IC in Polling mode : no INT generation on FT5336 for new touch available */
/* Note TS_INT is active low */
ft5336_TS_DisableIT(DeviceAddr);
}
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t ft5336_TS_DetectTouch(uint16_t DeviceAddr)
{
volatile uint8_t nbTouch = 0;
/* Read register FT5336_TD_STAT_REG to check number of touches detection */
nbTouch = TS_IO_Read(DeviceAddr, FT5336_TD_STAT_REG);
nbTouch &= FT5336_TD_STAT_MASK;
if(nbTouch > FT5336_MAX_DETECTABLE_TOUCH)
{
/* If invalid number of touch detected, set it to zero */
nbTouch = 0;
}
/* Update ft5336 driver internal global : current number of active touches */
ft5336_handle.currActiveTouchNb = nbTouch;
/* Reset current active touch index on which to work on */
ft5336_handle.currActiveTouchIdx = 0;
return(nbTouch);
}
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'ft5336_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void ft5336_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
{
volatile uint8_t ucReadData = 0;
static uint16_t coord;
uint8_t regAddressXLow = 0;
uint8_t regAddressXHigh = 0;
uint8_t regAddressYLow = 0;
uint8_t regAddressYHigh = 0;
if(ft5336_handle.currActiveTouchIdx < ft5336_handle.currActiveTouchNb)
{
switch(ft5336_handle.currActiveTouchIdx)
{
case 0 :
regAddressXLow = FT5336_P1_XL_REG;
regAddressXHigh = FT5336_P1_XH_REG;
regAddressYLow = FT5336_P1_YL_REG;
regAddressYHigh = FT5336_P1_YH_REG;
break;
case 1 :
regAddressXLow = FT5336_P2_XL_REG;
regAddressXHigh = FT5336_P2_XH_REG;
regAddressYLow = FT5336_P2_YL_REG;
regAddressYHigh = FT5336_P2_YH_REG;
break;
case 2 :
regAddressXLow = FT5336_P3_XL_REG;
regAddressXHigh = FT5336_P3_XH_REG;
regAddressYLow = FT5336_P3_YL_REG;
regAddressYHigh = FT5336_P3_YH_REG;
break;
case 3 :
regAddressXLow = FT5336_P4_XL_REG;
regAddressXHigh = FT5336_P4_XH_REG;
regAddressYLow = FT5336_P4_YL_REG;
regAddressYHigh = FT5336_P4_YH_REG;
break;
case 4 :
regAddressXLow = FT5336_P5_XL_REG;
regAddressXHigh = FT5336_P5_XH_REG;
regAddressYLow = FT5336_P5_YL_REG;
regAddressYHigh = FT5336_P5_YH_REG;
break;
case 5 :
regAddressXLow = FT5336_P6_XL_REG;
regAddressXHigh = FT5336_P6_XH_REG;
regAddressYLow = FT5336_P6_YL_REG;
regAddressYHigh = FT5336_P6_YH_REG;
break;
case 6 :
regAddressXLow = FT5336_P7_XL_REG;
regAddressXHigh = FT5336_P7_XH_REG;
regAddressYLow = FT5336_P7_YL_REG;
regAddressYHigh = FT5336_P7_YH_REG;
break;
case 7 :
regAddressXLow = FT5336_P8_XL_REG;
regAddressXHigh = FT5336_P8_XH_REG;
regAddressYLow = FT5336_P8_YL_REG;
regAddressYHigh = FT5336_P8_YH_REG;
break;
case 8 :
regAddressXLow = FT5336_P9_XL_REG;
regAddressXHigh = FT5336_P9_XH_REG;
regAddressYLow = FT5336_P9_YL_REG;
regAddressYHigh = FT5336_P9_YH_REG;
break;
case 9 :
regAddressXLow = FT5336_P10_XL_REG;
regAddressXHigh = FT5336_P10_XH_REG;
regAddressYLow = FT5336_P10_YL_REG;
regAddressYHigh = FT5336_P10_YH_REG;
break;
default :
break;
} /* end switch(ft5336_handle.currActiveTouchIdx) */
/* Read low part of X position */
ucReadData = TS_IO_Read(DeviceAddr, regAddressXLow);
coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT;
/* Read high part of X position */
ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh);
coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8;
/* Send back ready X position to caller */
*X = coord;
/* Read low part of Y position */
ucReadData = TS_IO_Read(DeviceAddr, regAddressYLow);
coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT;
/* Read high part of Y position */
ucReadData = TS_IO_Read(DeviceAddr, regAddressYHigh);
coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8;
/* Send back ready Y position to caller */
*Y = coord;
ft5336_handle.currActiveTouchIdx++; /* next call will work on next touch */
} /* of if(ft5336_handle.currActiveTouchIdx < ft5336_handle.currActiveTouchNb) */
}
/**
* @brief Configure the FT5336 device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
* @retval None
*/
void ft5336_TS_EnableIT(uint16_t DeviceAddr)
{
uint8_t regValue = 0;
regValue = (FT5336_G_MODE_INTERRUPT_TRIGGER & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT;
/* Set interrupt trigger mode in FT5336_GMODE_REG */
TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue);
}
/**
* @brief Configure the FT5336 device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
* @retval None
*/
void ft5336_TS_DisableIT(uint16_t DeviceAddr)
{
uint8_t regValue = 0;
regValue = (FT5336_G_MODE_INTERRUPT_POLLING & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT;
/* Set interrupt polling mode in FT5336_GMODE_REG */
TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue);
}
/**
* @brief Get IT status from FT5336 interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @note : This feature is not applicable to FT5336.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval TS interrupts status : always return 0 here
*/
uint8_t ft5336_TS_ITStatus(uint16_t DeviceAddr)
{
/* Always return 0 as feature not applicable to FT5336 */
return 0;
}
/**
* @brief Clear IT status in FT5336 interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @note : This feature is not applicable to FT5336.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval None
*/
void ft5336_TS_ClearIT(uint16_t DeviceAddr)
{
/* Nothing to be done here for FT5336 */
}
/**** NEW FEATURES enabled when Multi-touch support is enabled ****/
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void ft5336_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
{
volatile uint8_t ucReadData = 0;
ucReadData = TS_IO_Read(DeviceAddr, FT5336_GEST_ID_REG);
* pGestureId = ucReadData;
}
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @retval None.
*/
void ft5336_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent)
{
volatile uint8_t ucReadData = 0;
uint8_t regAddressXHigh = 0;
uint8_t regAddressPWeight = 0;
uint8_t regAddressPMisc = 0;
if(touchIdx < ft5336_handle.currActiveTouchNb)
{
switch(touchIdx)
{
case 0 :
regAddressXHigh = FT5336_P1_XH_REG;
regAddressPWeight = FT5336_P1_WEIGHT_REG;
regAddressPMisc = FT5336_P1_MISC_REG;
break;
case 1 :
regAddressXHigh = FT5336_P2_XH_REG;
regAddressPWeight = FT5336_P2_WEIGHT_REG;
regAddressPMisc = FT5336_P2_MISC_REG;
break;
case 2 :
regAddressXHigh = FT5336_P3_XH_REG;
regAddressPWeight = FT5336_P3_WEIGHT_REG;
regAddressPMisc = FT5336_P3_MISC_REG;
break;
case 3 :
regAddressXHigh = FT5336_P4_XH_REG;
regAddressPWeight = FT5336_P4_WEIGHT_REG;
regAddressPMisc = FT5336_P4_MISC_REG;
break;
case 4 :
regAddressXHigh = FT5336_P5_XH_REG;
regAddressPWeight = FT5336_P5_WEIGHT_REG;
regAddressPMisc = FT5336_P5_MISC_REG;
break;
case 5 :
regAddressXHigh = FT5336_P6_XH_REG;
regAddressPWeight = FT5336_P6_WEIGHT_REG;
regAddressPMisc = FT5336_P6_MISC_REG;
break;
case 6 :
regAddressXHigh = FT5336_P7_XH_REG;
regAddressPWeight = FT5336_P7_WEIGHT_REG;
regAddressPMisc = FT5336_P7_MISC_REG;
break;
case 7 :
regAddressXHigh = FT5336_P8_XH_REG;
regAddressPWeight = FT5336_P8_WEIGHT_REG;
regAddressPMisc = FT5336_P8_MISC_REG;
break;
case 8 :
regAddressXHigh = FT5336_P9_XH_REG;
regAddressPWeight = FT5336_P9_WEIGHT_REG;
regAddressPMisc = FT5336_P9_MISC_REG;
break;
case 9 :
regAddressXHigh = FT5336_P10_XH_REG;
regAddressPWeight = FT5336_P10_WEIGHT_REG;
regAddressPMisc = FT5336_P10_MISC_REG;
break;
default :
break;
} /* end switch(touchIdx) */
/* Read Event Id of touch index */
ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh);
* pEvent = (ucReadData & FT5336_TOUCH_EVT_FLAG_MASK) >> FT5336_TOUCH_EVT_FLAG_SHIFT;
/* Read weight of touch index */
ucReadData = TS_IO_Read(DeviceAddr, regAddressPWeight);
* pWeight = (ucReadData & FT5336_TOUCH_WEIGHT_MASK) >> FT5336_TOUCH_WEIGHT_SHIFT;
/* Read area of touch index */
ucReadData = TS_IO_Read(DeviceAddr, regAddressPMisc);
* pArea = (ucReadData & FT5336_TOUCH_AREA_MASK) >> FT5336_TOUCH_AREA_SHIFT;
} /* of if(touchIdx < ft5336_handle.currActiveTouchNb) */
}
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
/** @defgroup ft5336_Static_Function_Body
* @{
*/
/* Static functions bodies-----------------------------------------------*/
/**
* @brief Return the status of I2C was initialized or not.
* @param None.
* @retval : I2C initialization status.
*/
static uint8_t ft5336_Get_I2C_InitializedStatus(void)
{
return(ft5336_handle.i2cInitialized);
}
/**
* @brief I2C initialize if needed.
* @param None.
* @retval : None.
*/
static void ft5336_I2C_InitializeIfRequired(void)
{
if(ft5336_Get_I2C_InitializedStatus() == FT5336_I2C_NOT_INITIALIZED)
{
/* Initialize TS IO BUS layer (I2C) */
TS_IO_Init();
/* Set state to initialized */
ft5336_handle.i2cInitialized = FT5336_I2C_INITIALIZED;
}
}
/**
* @brief Basic static configuration of TouchScreen
* @param DeviceAddr: FT5336 Device address for communication on I2C Bus.
* @retval Status FT5336_STATUS_OK or FT5336_STATUS_NOT_OK.
*/
static uint32_t ft5336_TS_Configure(uint16_t DeviceAddr)
{
uint32_t status = FT5336_STATUS_OK;
/* Nothing special to be done for FT5336 */
return(status);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,522 @@
/**
******************************************************************************
* @file ft5336.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* ft5336.c Touch screen driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __FT5336_H
#define __FT5336_H
#ifdef __cplusplus
extern "C" {
#endif
/* Set Multi-touch as supported */
#if !defined(TS_MONO_TOUCH_SUPPORTED)
#define TS_MULTI_TOUCH_SUPPORTED 1
#endif /* TS_MONO_TOUCH_SUPPORTED */
/* Includes ------------------------------------------------------------------*/
#include "../Common/ts.h"
/* Macros --------------------------------------------------------------------*/
#if defined(FT5336_ENABLE_ASSERT)
/* Assert activated */
#define FT5336_ASSERT(__condition__) do { if(__condition__) \
{ \
while(1); \
} \
}while(0)
#else
/* Assert not activated : macro has no effect */
#define FT5336_ASSERT(__condition__) do { if(__condition__) \
{ \
; \
} \
}while(0)
#endif /* FT5336_ENABLE_ASSERT == 1 */
/** @typedef ft5336_handle_TypeDef
* ft5336 Handle definition.
*/
typedef struct
{
uint8_t i2cInitialized;
/* field holding the current number of simultaneous active touches */
uint8_t currActiveTouchNb;
/* field holding the touch index currently managed */
uint8_t currActiveTouchIdx;
} ft5336_handle_TypeDef;
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup FT5336
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup FT5336_Exported_Types
* @{
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup FT5336_Exported_Constants
* @{
*/
/* I2C Slave address of touchscreen FocalTech FT5336 */
#define FT5336_I2C_SLAVE_ADDRESS ((uint8_t)0x70)
/* Maximum border values of the touchscreen pad */
#define FT5336_MAX_WIDTH ((uint16_t)480) /* Touchscreen pad max width */
#define FT5336_MAX_HEIGHT ((uint16_t)272) /* Touchscreen pad max height */
/* Possible values of driver functions return status */
#define FT5336_STATUS_OK ((uint8_t)0x00)
#define FT5336_STATUS_NOT_OK ((uint8_t)0x01)
/* Possible values of global variable 'TS_I2C_Initialized' */
#define FT5336_I2C_NOT_INITIALIZED ((uint8_t)0x00)
#define FT5336_I2C_INITIALIZED ((uint8_t)0x01)
/* Max detectable simultaneous touches */
#define FT5336_MAX_DETECTABLE_TOUCH ((uint8_t)0x05)
/**
* @brief : Definitions for FT5336 I2C register addresses on 8 bit
**/
/* Current mode register of the FT5336 (R/W) */
#define FT5336_DEV_MODE_REG ((uint8_t)0x00)
/* Possible values of FT5336_DEV_MODE_REG */
#define FT5336_DEV_MODE_WORKING ((uint8_t)0x00)
#define FT5336_DEV_MODE_FACTORY ((uint8_t)0x04)
#define FT5336_DEV_MODE_MASK ((uint8_t)0x07)
#define FT5336_DEV_MODE_SHIFT ((uint8_t)0x04)
/* Gesture ID register */
#define FT5336_GEST_ID_REG ((uint8_t)0x01)
/* Possible values of FT5336_GEST_ID_REG */
#define FT5336_GEST_ID_NO_GESTURE ((uint8_t)0x00)
#define FT5336_GEST_ID_MOVE_UP ((uint8_t)0x10)
#define FT5336_GEST_ID_MOVE_RIGHT ((uint8_t)0x14)
#define FT5336_GEST_ID_MOVE_DOWN ((uint8_t)0x18)
#define FT5336_GEST_ID_MOVE_LEFT ((uint8_t)0x1C)
#define FT5336_GEST_ID_SINGLE_CLICK ((uint8_t)0x20)
#define FT5336_GEST_ID_DOUBLE_CLICK ((uint8_t)0x22)
#define FT5336_GEST_ID_ROTATE_CLOCKWISE ((uint8_t)0x28)
#define FT5336_GEST_ID_ROTATE_C_CLOCKWISE ((uint8_t)0x29)
#define FT5336_GEST_ID_ZOOM_IN ((uint8_t)0x40)
#define FT5336_GEST_ID_ZOOM_OUT ((uint8_t)0x49)
/* Touch Data Status register : gives number of active touch points (0..5) */
#define FT5336_TD_STAT_REG ((uint8_t)0x02)
/* Values related to FT5336_TD_STAT_REG */
#define FT5336_TD_STAT_MASK ((uint8_t)0x0F)
#define FT5336_TD_STAT_SHIFT ((uint8_t)0x00)
/* Values Pn_XH and Pn_YH related */
#define FT5336_TOUCH_EVT_FLAG_PRESS_DOWN ((uint8_t)0x00)
#define FT5336_TOUCH_EVT_FLAG_LIFT_UP ((uint8_t)0x01)
#define FT5336_TOUCH_EVT_FLAG_CONTACT ((uint8_t)0x02)
#define FT5336_TOUCH_EVT_FLAG_NO_EVENT ((uint8_t)0x03)
#define FT5336_TOUCH_EVT_FLAG_SHIFT ((uint8_t)0x06)
#define FT5336_TOUCH_EVT_FLAG_MASK ((uint8_t)(3 << FT5336_TOUCH_EVT_FLAG_SHIFT))
#define FT5336_TOUCH_POS_MSB_MASK ((uint8_t)0x0F)
#define FT5336_TOUCH_POS_MSB_SHIFT ((uint8_t)0x00)
/* Values Pn_XL and Pn_YL related */
#define FT5336_TOUCH_POS_LSB_MASK ((uint8_t)0xFF)
#define FT5336_TOUCH_POS_LSB_SHIFT ((uint8_t)0x00)
#define FT5336_P1_XH_REG ((uint8_t)0x03)
#define FT5336_P1_XL_REG ((uint8_t)0x04)
#define FT5336_P1_YH_REG ((uint8_t)0x05)
#define FT5336_P1_YL_REG ((uint8_t)0x06)
/* Touch Pressure register value (R) */
#define FT5336_P1_WEIGHT_REG ((uint8_t)0x07)
/* Values Pn_WEIGHT related */
#define FT5336_TOUCH_WEIGHT_MASK ((uint8_t)0xFF)
#define FT5336_TOUCH_WEIGHT_SHIFT ((uint8_t)0x00)
/* Touch area register */
#define FT5336_P1_MISC_REG ((uint8_t)0x08)
/* Values related to FT5336_Pn_MISC_REG */
#define FT5336_TOUCH_AREA_MASK ((uint8_t)(0x04 << 4))
#define FT5336_TOUCH_AREA_SHIFT ((uint8_t)0x04)
#define FT5336_P2_XH_REG ((uint8_t)0x09)
#define FT5336_P2_XL_REG ((uint8_t)0x0A)
#define FT5336_P2_YH_REG ((uint8_t)0x0B)
#define FT5336_P2_YL_REG ((uint8_t)0x0C)
#define FT5336_P2_WEIGHT_REG ((uint8_t)0x0D)
#define FT5336_P2_MISC_REG ((uint8_t)0x0E)
#define FT5336_P3_XH_REG ((uint8_t)0x0F)
#define FT5336_P3_XL_REG ((uint8_t)0x10)
#define FT5336_P3_YH_REG ((uint8_t)0x11)
#define FT5336_P3_YL_REG ((uint8_t)0x12)
#define FT5336_P3_WEIGHT_REG ((uint8_t)0x13)
#define FT5336_P3_MISC_REG ((uint8_t)0x14)
#define FT5336_P4_XH_REG ((uint8_t)0x15)
#define FT5336_P4_XL_REG ((uint8_t)0x16)
#define FT5336_P4_YH_REG ((uint8_t)0x17)
#define FT5336_P4_YL_REG ((uint8_t)0x18)
#define FT5336_P4_WEIGHT_REG ((uint8_t)0x19)
#define FT5336_P4_MISC_REG ((uint8_t)0x1A)
#define FT5336_P5_XH_REG ((uint8_t)0x1B)
#define FT5336_P5_XL_REG ((uint8_t)0x1C)
#define FT5336_P5_YH_REG ((uint8_t)0x1D)
#define FT5336_P5_YL_REG ((uint8_t)0x1E)
#define FT5336_P5_WEIGHT_REG ((uint8_t)0x1F)
#define FT5336_P5_MISC_REG ((uint8_t)0x20)
#define FT5336_P6_XH_REG ((uint8_t)0x21)
#define FT5336_P6_XL_REG ((uint8_t)0x22)
#define FT5336_P6_YH_REG ((uint8_t)0x23)
#define FT5336_P6_YL_REG ((uint8_t)0x24)
#define FT5336_P6_WEIGHT_REG ((uint8_t)0x25)
#define FT5336_P6_MISC_REG ((uint8_t)0x26)
#define FT5336_P7_XH_REG ((uint8_t)0x27)
#define FT5336_P7_XL_REG ((uint8_t)0x28)
#define FT5336_P7_YH_REG ((uint8_t)0x29)
#define FT5336_P7_YL_REG ((uint8_t)0x2A)
#define FT5336_P7_WEIGHT_REG ((uint8_t)0x2B)
#define FT5336_P7_MISC_REG ((uint8_t)0x2C)
#define FT5336_P8_XH_REG ((uint8_t)0x2D)
#define FT5336_P8_XL_REG ((uint8_t)0x2E)
#define FT5336_P8_YH_REG ((uint8_t)0x2F)
#define FT5336_P8_YL_REG ((uint8_t)0x30)
#define FT5336_P8_WEIGHT_REG ((uint8_t)0x31)
#define FT5336_P8_MISC_REG ((uint8_t)0x32)
#define FT5336_P9_XH_REG ((uint8_t)0x33)
#define FT5336_P9_XL_REG ((uint8_t)0x34)
#define FT5336_P9_YH_REG ((uint8_t)0x35)
#define FT5336_P9_YL_REG ((uint8_t)0x36)
#define FT5336_P9_WEIGHT_REG ((uint8_t)0x37)
#define FT5336_P9_MISC_REG ((uint8_t)0x38)
#define FT5336_P10_XH_REG ((uint8_t)0x39)
#define FT5336_P10_XL_REG ((uint8_t)0x3A)
#define FT5336_P10_YH_REG ((uint8_t)0x3B)
#define FT5336_P10_YL_REG ((uint8_t)0x3C)
#define FT5336_P10_WEIGHT_REG ((uint8_t)0x3D)
#define FT5336_P10_MISC_REG ((uint8_t)0x3E)
/* Threshold for touch detection */
#define FT5336_TH_GROUP_REG ((uint8_t)0x80)
/* Values FT5336_TH_GROUP_REG : threshold related */
#define FT5336_THRESHOLD_MASK ((uint8_t)0xFF)
#define FT5336_THRESHOLD_SHIFT ((uint8_t)0x00)
/* Filter function coefficients */
#define FT5336_TH_DIFF_REG ((uint8_t)0x85)
/* Control register */
#define FT5336_CTRL_REG ((uint8_t)0x86)
/* Values related to FT5336_CTRL_REG */
/* Will keep the Active mode when there is no touching */
#define FT5336_CTRL_KEEP_ACTIVE_MODE ((uint8_t)0x00)
/* Switching from Active mode to Monitor mode automatically when there is no touching */
#define FT5336_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE ((uint8_t)0x01
/* The time period of switching from Active mode to Monitor mode when there is no touching */
#define FT5336_TIMEENTERMONITOR_REG ((uint8_t)0x87)
/* Report rate in Active mode */
#define FT5336_PERIODACTIVE_REG ((uint8_t)0x88)
/* Report rate in Monitor mode */
#define FT5336_PERIODMONITOR_REG ((uint8_t)0x89)
/* The value of the minimum allowed angle while Rotating gesture mode */
#define FT5336_RADIAN_VALUE_REG ((uint8_t)0x91)
/* Maximum offset while Moving Left and Moving Right gesture */
#define FT5336_OFFSET_LEFT_RIGHT_REG ((uint8_t)0x92)
/* Maximum offset while Moving Up and Moving Down gesture */
#define FT5336_OFFSET_UP_DOWN_REG ((uint8_t)0x93)
/* Minimum distance while Moving Left and Moving Right gesture */
#define FT5336_DISTANCE_LEFT_RIGHT_REG ((uint8_t)0x94)
/* Minimum distance while Moving Up and Moving Down gesture */
#define FT5336_DISTANCE_UP_DOWN_REG ((uint8_t)0x95)
/* Maximum distance while Zoom In and Zoom Out gesture */
#define FT5336_DISTANCE_ZOOM_REG ((uint8_t)0x96)
/* High 8-bit of LIB Version info */
#define FT5336_LIB_VER_H_REG ((uint8_t)0xA1)
/* Low 8-bit of LIB Version info */
#define FT5336_LIB_VER_L_REG ((uint8_t)0xA2)
/* Chip Selecting */
#define FT5336_CIPHER_REG ((uint8_t)0xA3)
/* Interrupt mode register (used when in interrupt mode) */
#define FT5336_GMODE_REG ((uint8_t)0xA4)
#define FT5336_G_MODE_INTERRUPT_MASK ((uint8_t)0x03)
#define FT5336_G_MODE_INTERRUPT_SHIFT ((uint8_t)0x00)
/* Possible values of FT5336_GMODE_REG */
#define FT5336_G_MODE_INTERRUPT_POLLING ((uint8_t)0x00)
#define FT5336_G_MODE_INTERRUPT_TRIGGER ((uint8_t)0x01)
/* Current power mode the FT5336 system is in (R) */
#define FT5336_PWR_MODE_REG ((uint8_t)0xA5)
/* FT5336 firmware version */
#define FT5336_FIRMID_REG ((uint8_t)0xA6)
/* FT5336 Chip identification register */
#define FT5336_CHIP_ID_REG ((uint8_t)0xA8)
/* Possible values of FT5336_CHIP_ID_REG */
#define FT5336_ID_VALUE ((uint8_t)0x51)
/* Release code version */
#define FT5336_RELEASE_CODE_ID_REG ((uint8_t)0xAF)
/* Current operating mode the FT5336 system is in (R) */
#define FT5336_STATE_REG ((uint8_t)0xBC)
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/** @defgroup ft5336_Exported_Macros
* @{
*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup ft5336_Exported_Functions
* @{
*/
/**
* @brief ft5336 Control functions
*/
/**
* @brief Initialize the ft5336 communication bus
* from MCU to FT5336 : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval None
*/
void ft5336_Init(uint16_t DeviceAddr);
/**
* @brief Software Reset the ft5336.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval None
*/
void ft5336_Reset(uint16_t DeviceAddr);
/**
* @brief Read the ft5336 device ID, pre initialize I2C in case of need to be
* able to read the FT5336 device ID, and verify this is a FT5336.
* @param DeviceAddr: I2C FT5336 Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t ft5336_ReadID(uint16_t DeviceAddr);
/**
* @brief Configures the touch Screen IC device to start detecting touches
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void ft5336_TS_Start(uint16_t DeviceAddr);
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t ft5336_TS_DetectTouch(uint16_t DeviceAddr);
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'ft5336_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void ft5336_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
/**
* @brief Configure the FT5336 device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
* @retval None
*/
void ft5336_TS_EnableIT(uint16_t DeviceAddr);
/**
* @brief Configure the FT5336 device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
* @retval None
*/
void ft5336_TS_DisableIT(uint16_t DeviceAddr);
/**
* @brief Get IT status from FT5336 interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval TS interrupts status
*/
uint8_t ft5336_TS_ITStatus (uint16_t DeviceAddr);
/**
* @brief Clear IT status in FT5336 interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval TS interrupts status
*/
void ft5336_TS_ClearIT (uint16_t DeviceAddr);
/**** NEW FEATURES enabled when Multi-touch support is enabled ****/
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void ft5336_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @retval None.
*/
void ft5336_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent);
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
/* Imported TS IO functions --------------------------------------------------------*/
/** @defgroup ft5336_Imported_Functions
* @{
*/
/* TouchScreen (TS) external IO functions */
extern void TS_IO_Init(void);
extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
extern void TS_IO_Delay(uint32_t Delay);
/**
* @}
*/
/* Imported global variables --------------------------------------------------------*/
/** @defgroup ft5336_Imported_Globals
* @{
*/
/* Touch screen driver structure */
extern TS_DrvTypeDef ft5336_ts_drv;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __FT5336_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for FT6X06 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-ft6x06-component-drivers"><small>Release Notes for</small> <mark>FT6X06 Component Drivers</mark></h1>
<p>Copyright © 2016 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the FT6X06 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.3 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.0.2 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.1 / 03-May-2016</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>Add support of FT6x36 Touch controller</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.0.0 / 03-August-2015</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,496 @@
/**
******************************************************************************
* @file ft6x06.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the FT6X06
* IO Expander devices.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "ft6x06.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup FT6X06
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/** @defgroup FT6X06_Private_Defines FT6X06 Private Defines
* @{
*/
#define FT6x06_MAX_INSTANCE 2
/**
* @}
*/
/* Private macro -------------------------------------------------------------*/
/** @defgroup FT6X06_Private_Variables FT6X06 Private Variables
* @{
*/
/* Touch screen driver structure initialization */
TS_DrvTypeDef ft6x06_ts_drv =
{
ft6x06_Init,
ft6x06_ReadID,
ft6x06_Reset,
ft6x06_TS_Start,
ft6x06_TS_DetectTouch,
ft6x06_TS_GetXY,
ft6x06_TS_EnableIT,
ft6x06_TS_ClearIT,
ft6x06_TS_ITStatus,
ft6x06_TS_DisableIT
};
/* ft6x06 instances by address */
uint8_t ft6x06[FT6x06_MAX_INSTANCE] = {0};
/* Global ft6x06 handle */
static ft6x06_handle_TypeDef ft6x06_handle = { FT6206_I2C_NOT_INITIALIZED, 0, 0};
/**
* @}
*/
/** @defgroup ft6x06_Private_Function_Prototypes ft6x06 Private Function Prototypes
* @{
*/
static uint8_t ft6x06_GetInstance(uint16_t DeviceAddr);
/* Private functions prototypes-----------------------------------------------*/
#if (TS_AUTO_CALIBRATION_SUPPORTED == 1)
/**
* @brief Start TouchScreen calibration phase
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
*/
static uint32_t ft6x06_TS_Calibration(uint16_t DeviceAddr);
#endif /* TS_AUTO_CALIBRATION_SUPPORTED == 1 */
/**
* @brief Basic static configuration of TouchScreen
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
*/
static uint32_t ft6x06_TS_Configure(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup ft6x06_Private_Functions ft6x06 Private Functions
* @{
*/
/**
* @brief Initialize the ft6x06 communication bus
* from MCU to FT6206 : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval None
*/
void ft6x06_Init(uint16_t DeviceAddr)
{
uint8_t instance;
uint8_t empty;
/* Check if device instance already exists */
instance = ft6x06_GetInstance(DeviceAddr);
/* To prevent double initialization */
if(instance == 0xFF)
{
/* Look for empty instance */
empty = ft6x06_GetInstance(0);
if(empty < FT6x06_MAX_INSTANCE)
{
/* Register the current device instance */
ft6x06[empty] = DeviceAddr;
/* Initialize IO BUS layer */
TS_IO_Init();
}
}
}
/**
* @brief Software Reset the ft6x06.
* @note : Not applicable to FT6206.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval None
*/
void ft6x06_Reset(uint16_t DeviceAddr)
{
/* Do nothing */
/* No software reset sequence available in FT6206 IC */
}
/**
* @brief Read the ft6x06 device ID, pre initialize I2C in case of need to be
* able to read the FT6206 device ID, and verify this is a FT6206.
* @param DeviceAddr: I2C FT6x06 Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t ft6x06_ReadID(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
TS_IO_Init();
/* Return the device ID value */
return (TS_IO_Read(DeviceAddr, FT6206_CHIP_ID_REG));
}
/**
* @brief Configures the touch Screen IC device to start detecting touches
* It goes through an internal calibration process (Hw calibration sequence of
* the touch screen).
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void ft6x06_TS_Start(uint16_t DeviceAddr)
{
#if (TS_AUTO_CALIBRATION_SUPPORTED == 1)
/* Hw Calibration sequence start : should be done once after each power up */
/* This is called internal calibration of the touch screen */
ft6x06_TS_Calibration(DeviceAddr);
#endif
/* Minimum static configuration of FT6206 */
ft6x06_TS_Configure(DeviceAddr);
/* By default set FT6206 IC in Polling mode : no INT generation on FT6206 for new touch available */
/* Note TS_INT is active low */
ft6x06_TS_DisableIT(DeviceAddr);
}
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t ft6x06_TS_DetectTouch(uint16_t DeviceAddr)
{
volatile uint8_t nbTouch = 0;
/* Read register FT6206_TD_STAT_REG to check number of touches detection */
nbTouch = TS_IO_Read(DeviceAddr, FT6206_TD_STAT_REG);
nbTouch &= FT6206_TD_STAT_MASK;
if(nbTouch > FT6206_MAX_DETECTABLE_TOUCH)
{
/* If invalid number of touch detected, set it to zero */
nbTouch = 0;
}
/* Update ft6x06 driver internal global : current number of active touches */
ft6x06_handle.currActiveTouchNb = nbTouch;
/* Reset current active touch index on which to work on */
ft6x06_handle.currActiveTouchIdx = 0;
return(nbTouch);
}
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'ft6x06_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void ft6x06_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
{
uint8_t regAddress = 0;
uint8_t dataxy[4];
if(ft6x06_handle.currActiveTouchIdx < ft6x06_handle.currActiveTouchNb)
{
switch(ft6x06_handle.currActiveTouchIdx)
{
case 0 :
regAddress = FT6206_P1_XH_REG;
break;
case 1 :
regAddress = FT6206_P2_XH_REG;
break;
default :
break;
}
/* Read X and Y positions */
TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy));
/* Send back ready X position to caller */
*X = ((dataxy[0] & FT6206_MSB_MASK) << 8) | (dataxy[1] & FT6206_LSB_MASK);
/* Send back ready Y position to caller */
*Y = ((dataxy[2] & FT6206_MSB_MASK) << 8) | (dataxy[3] & FT6206_LSB_MASK);
ft6x06_handle.currActiveTouchIdx++;
}
}
/**
* @brief Configure the FT6206 device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
* @retval None
*/
void ft6x06_TS_EnableIT(uint16_t DeviceAddr)
{
uint8_t regValue = 0;
regValue = (FT6206_G_MODE_INTERRUPT_TRIGGER & (FT6206_G_MODE_INTERRUPT_MASK >> FT6206_G_MODE_INTERRUPT_SHIFT)) << FT6206_G_MODE_INTERRUPT_SHIFT;
/* Set interrupt trigger mode in FT6206_GMODE_REG */
TS_IO_Write(DeviceAddr, FT6206_GMODE_REG, regValue);
}
/**
* @brief Configure the FT6206 device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
* @retval None
*/
void ft6x06_TS_DisableIT(uint16_t DeviceAddr)
{
uint8_t regValue = 0;
regValue = (FT6206_G_MODE_INTERRUPT_POLLING & (FT6206_G_MODE_INTERRUPT_MASK >> FT6206_G_MODE_INTERRUPT_SHIFT)) << FT6206_G_MODE_INTERRUPT_SHIFT;
/* Set interrupt polling mode in FT6206_GMODE_REG */
TS_IO_Write(DeviceAddr, FT6206_GMODE_REG, regValue);
}
/**
* @brief Get IT status from FT6206 interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @note : This feature is not applicable to FT6206.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval TS interrupts status : always return 0 here
*/
uint8_t ft6x06_TS_ITStatus(uint16_t DeviceAddr)
{
/* Always return 0 as feature not applicable to FT6206 */
return 0;
}
/**
* @brief Clear IT status in FT6206 interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @note : This feature is not applicable to FT6206.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval None
*/
void ft6x06_TS_ClearIT(uint16_t DeviceAddr)
{
/* Nothing to be done here for FT6206 */
}
/**** NEW FEATURES enabled when Multi-touch support is enabled ****/
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void ft6x06_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
{
volatile uint8_t ucReadData = 0;
ucReadData = TS_IO_Read(DeviceAddr, FT6206_GEST_ID_REG);
* pGestureId = ucReadData;
}
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @retval None.
*/
void ft6x06_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent)
{
uint8_t regAddress = 0;
uint8_t dataxy[3];
if(touchIdx < ft6x06_handle.currActiveTouchNb)
{
switch(touchIdx)
{
case 0 :
regAddress = FT6206_P1_WEIGHT_REG;
break;
case 1 :
regAddress = FT6206_P2_WEIGHT_REG;
break;
default :
break;
} /* end switch(touchIdx) */
/* Read weight, area and Event Id of touch index */
TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy));
/* Return weight of touch index */
* pWeight = (dataxy[0] & FT6206_TOUCH_WEIGHT_MASK) >> FT6206_TOUCH_WEIGHT_SHIFT;
/* Return area of touch index */
* pArea = (dataxy[1] & FT6206_TOUCH_AREA_MASK) >> FT6206_TOUCH_AREA_SHIFT;
/* Return Event Id of touch index */
* pEvent = (dataxy[2] & FT6206_TOUCH_EVT_FLAG_MASK) >> FT6206_TOUCH_EVT_FLAG_SHIFT;
} /* of if(touchIdx < ft6x06_handle.currActiveTouchNb) */
}
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
#if (TS_AUTO_CALIBRATION_SUPPORTED == 1)
/**
* @brief Start TouchScreen calibration phase
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
*/
static uint32_t ft6x06_TS_Calibration(uint16_t DeviceAddr)
{
uint32_t nbAttempt = 0;
volatile uint8_t ucReadData;
volatile uint8_t regValue;
uint32_t status = FT6206_STATUS_OK;
uint8_t bEndCalibration = 0;
/* >> Calibration sequence start */
/* Switch FT6206 back to factory mode to calibrate */
regValue = (FT6206_DEV_MODE_FACTORY & FT6206_DEV_MODE_MASK) << FT6206_DEV_MODE_SHIFT;
TS_IO_Write(DeviceAddr, FT6206_DEV_MODE_REG, regValue); /* 0x40 */
/* Read back the same register FT6206_DEV_MODE_REG */
ucReadData = TS_IO_Read(DeviceAddr, FT6206_DEV_MODE_REG);
TS_IO_Delay(300); /* Wait 300 ms */
if(((ucReadData & (FT6206_DEV_MODE_MASK << FT6206_DEV_MODE_SHIFT)) >> FT6206_DEV_MODE_SHIFT) != FT6206_DEV_MODE_FACTORY )
{
/* Return error to caller */
return(FT6206_STATUS_NOT_OK);
}
/* Start calibration command */
TS_IO_Write(DeviceAddr, FT6206_TD_STAT_REG, 0x04);
TS_IO_Delay(300); /* Wait 300 ms */
/* 100 attempts to wait switch from factory mode (calibration) to working mode */
for (nbAttempt=0; ((nbAttempt < 100) && (!bEndCalibration)) ; nbAttempt++)
{
ucReadData = TS_IO_Read(DeviceAddr, FT6206_DEV_MODE_REG);
ucReadData = (ucReadData & (FT6206_DEV_MODE_MASK << FT6206_DEV_MODE_SHIFT)) >> FT6206_DEV_MODE_SHIFT;
if(ucReadData == FT6206_DEV_MODE_WORKING)
{
/* Auto Switch to FT6206_DEV_MODE_WORKING : means calibration have ended */
bEndCalibration = 1; /* exit for loop */
}
TS_IO_Delay(200); /* Wait 200 ms */
}
/* Calibration sequence end << */
return(status);
}
#endif /* TS_AUTO_CALIBRATION_SUPPORTED == 1 */
/**
* @brief Basic static configuration of TouchScreen
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
*/
static uint32_t ft6x06_TS_Configure(uint16_t DeviceAddr)
{
uint32_t status = FT6206_STATUS_OK;
/* Nothing special to be done for FT6206 */
return(status);
}
/**
* @brief Check if the device instance of the selected address is already registered
* and return its index
* @param DeviceAddr: Device address on communication Bus.
* @retval Index of the device instance if registered, 0xFF if not.
*/
static uint8_t ft6x06_GetInstance(uint16_t DeviceAddr)
{
uint8_t idx = 0;
/* Check all the registered instances */
for(idx = 0; idx < FT6x06_MAX_INSTANCE ; idx ++)
{
if(ft6x06[idx] == DeviceAddr)
{
return idx;
}
}
return 0xFF;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,453 @@
/**
******************************************************************************
* @file ft6x06.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* ft6x06.c IO expander driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __FT6X06_H
#define __FT6X06_H
#ifdef __cplusplus
extern "C" {
#endif
/* Set Multi-touch as non supported */
#ifndef TS_MULTI_TOUCH_SUPPORTED
#define TS_MULTI_TOUCH_SUPPORTED 0
#endif
/* Set Auto-calibration as non supported */
#ifndef TS_AUTO_CALIBRATION_SUPPORTED
#define TS_AUTO_CALIBRATION_SUPPORTED 0
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/ts.h"
/* Macros --------------------------------------------------------------------*/
/** @typedef ft6x06_handle_TypeDef
* ft6x06 Handle definition.
*/
typedef struct
{
uint8_t i2cInitialized;
/* field holding the current number of simultaneous active touches */
uint8_t currActiveTouchNb;
/* field holding the touch index currently managed */
uint8_t currActiveTouchIdx;
} ft6x06_handle_TypeDef;
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup FT6X06
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup FT6X06_Exported_Types
* @{
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup FT6X06_Exported_Constants
* @{
*/
/* Maximum border values of the touchscreen pad */
#define FT_6206_MAX_WIDTH ((uint16_t)800) /* Touchscreen pad max width */
#define FT_6206_MAX_HEIGHT ((uint16_t)480) /* Touchscreen pad max height */
/* Touchscreen pad max width and height values for FT6x36 Touch*/
#define FT_6206_MAX_WIDTH_HEIGHT ((uint16_t)240)
/* Possible values of driver functions return status */
#define FT6206_STATUS_OK 0
#define FT6206_STATUS_NOT_OK 1
/* Possible values of global variable 'TS_I2C_Initialized' */
#define FT6206_I2C_NOT_INITIALIZED 0
#define FT6206_I2C_INITIALIZED 1
/* Max detectable simultaneous touches */
#define FT6206_MAX_DETECTABLE_TOUCH 2
/**
* @brief : Definitions for FT6206 I2C register addresses on 8 bit
**/
/* Current mode register of the FT6206 (R/W) */
#define FT6206_DEV_MODE_REG 0x00
/* Possible values of FT6206_DEV_MODE_REG */
#define FT6206_DEV_MODE_WORKING 0x00
#define FT6206_DEV_MODE_FACTORY 0x04
#define FT6206_DEV_MODE_MASK 0x7
#define FT6206_DEV_MODE_SHIFT 4
/* Gesture ID register */
#define FT6206_GEST_ID_REG 0x01
/* Possible values of FT6206_GEST_ID_REG */
#define FT6206_GEST_ID_NO_GESTURE 0x00
#define FT6206_GEST_ID_MOVE_UP 0x10
#define FT6206_GEST_ID_MOVE_RIGHT 0x14
#define FT6206_GEST_ID_MOVE_DOWN 0x18
#define FT6206_GEST_ID_MOVE_LEFT 0x1C
#define FT6206_GEST_ID_ZOOM_IN 0x48
#define FT6206_GEST_ID_ZOOM_OUT 0x49
/* Touch Data Status register : gives number of active touch points (0..2) */
#define FT6206_TD_STAT_REG 0x02
/* Values related to FT6206_TD_STAT_REG */
#define FT6206_TD_STAT_MASK 0x0F
#define FT6206_TD_STAT_SHIFT 0x00
/* Values Pn_XH and Pn_YH related */
#define FT6206_TOUCH_EVT_FLAG_PRESS_DOWN 0x00
#define FT6206_TOUCH_EVT_FLAG_LIFT_UP 0x01
#define FT6206_TOUCH_EVT_FLAG_CONTACT 0x02
#define FT6206_TOUCH_EVT_FLAG_NO_EVENT 0x03
#define FT6206_TOUCH_EVT_FLAG_SHIFT 6
#define FT6206_TOUCH_EVT_FLAG_MASK (3 << FT6206_TOUCH_EVT_FLAG_SHIFT)
#define FT6206_MSB_MASK 0x0F
#define FT6206_MSB_SHIFT 0
/* Values Pn_XL and Pn_YL related */
#define FT6206_LSB_MASK 0xFF
#define FT6206_LSB_SHIFT 0
#define FT6206_P1_XH_REG 0x03
#define FT6206_P1_XL_REG 0x04
#define FT6206_P1_YH_REG 0x05
#define FT6206_P1_YL_REG 0x06
/* Touch Pressure register value (R) */
#define FT6206_P1_WEIGHT_REG 0x07
/* Values Pn_WEIGHT related */
#define FT6206_TOUCH_WEIGHT_MASK 0xFF
#define FT6206_TOUCH_WEIGHT_SHIFT 0
/* Touch area register */
#define FT6206_P1_MISC_REG 0x08
/* Values related to FT6206_Pn_MISC_REG */
#define FT6206_TOUCH_AREA_MASK (0x04 << 4)
#define FT6206_TOUCH_AREA_SHIFT 0x04
#define FT6206_P2_XH_REG 0x09
#define FT6206_P2_XL_REG 0x0A
#define FT6206_P2_YH_REG 0x0B
#define FT6206_P2_YL_REG 0x0C
#define FT6206_P2_WEIGHT_REG 0x0D
#define FT6206_P2_MISC_REG 0x0E
/* Threshold for touch detection */
#define FT6206_TH_GROUP_REG 0x80
/* Values FT6206_TH_GROUP_REG : threshold related */
#define FT6206_THRESHOLD_MASK 0xFF
#define FT6206_THRESHOLD_SHIFT 0
/* Filter function coefficients */
#define FT6206_TH_DIFF_REG 0x85
/* Control register */
#define FT6206_CTRL_REG 0x86
/* Values related to FT6206_CTRL_REG */
/* Will keep the Active mode when there is no touching */
#define FT6206_CTRL_KEEP_ACTIVE_MODE 0x00
/* Switching from Active mode to Monitor mode automatically when there is no touching */
#define FT6206_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE 0x01
/* The time period of switching from Active mode to Monitor mode when there is no touching */
#define FT6206_TIMEENTERMONITOR_REG 0x87
/* Report rate in Active mode */
#define FT6206_PERIODACTIVE_REG 0x88
/* Report rate in Monitor mode */
#define FT6206_PERIODMONITOR_REG 0x89
/* The value of the minimum allowed angle while Rotating gesture mode */
#define FT6206_RADIAN_VALUE_REG 0x91
/* Maximum offset while Moving Left and Moving Right gesture */
#define FT6206_OFFSET_LEFT_RIGHT_REG 0x92
/* Maximum offset while Moving Up and Moving Down gesture */
#define FT6206_OFFSET_UP_DOWN_REG 0x93
/* Minimum distance while Moving Left and Moving Right gesture */
#define FT6206_DISTANCE_LEFT_RIGHT_REG 0x94
/* Minimum distance while Moving Up and Moving Down gesture */
#define FT6206_DISTANCE_UP_DOWN_REG 0x95
/* Maximum distance while Zoom In and Zoom Out gesture */
#define FT6206_DISTANCE_ZOOM_REG 0x96
/* High 8-bit of LIB Version info */
#define FT6206_LIB_VER_H_REG 0xA1
/* Low 8-bit of LIB Version info */
#define FT6206_LIB_VER_L_REG 0xA2
/* Chip Selecting */
#define FT6206_CIPHER_REG 0xA3
/* Interrupt mode register (used when in interrupt mode) */
#define FT6206_GMODE_REG 0xA4
#define FT6206_G_MODE_INTERRUPT_MASK 0x03
#define FT6206_G_MODE_INTERRUPT_SHIFT 0x00
/* Possible values of FT6206_GMODE_REG */
#define FT6206_G_MODE_INTERRUPT_POLLING 0x00
#define FT6206_G_MODE_INTERRUPT_TRIGGER 0x01
/* Current power mode the FT6206 system is in (R) */
#define FT6206_PWR_MODE_REG 0xA5
/* FT6206 firmware version */
#define FT6206_FIRMID_REG 0xA6
/* FT6206 Chip identification register */
#define FT6206_CHIP_ID_REG 0xA8
/* Possible values of FT6206_CHIP_ID_REG */
#define FT6206_ID_VALUE 0x11
#define FT6x36_ID_VALUE 0xCD
/* Release code version */
#define FT6206_RELEASE_CODE_ID_REG 0xAF
/* Current operating mode the FT6206 system is in (R) */
#define FT6206_STATE_REG 0xBC
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/** @defgroup ft6x06_Exported_Macros
* @{
*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup ft6x06_Exported_Functions
* @{
*/
/**
* @brief ft6x06 Control functions
*/
/**
* @brief Initialize the ft6x06 communication bus
* from MCU to FT6206 : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval None
*/
void ft6x06_Init(uint16_t DeviceAddr);
/**
* @brief Software Reset the ft6x06.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval None
*/
void ft6x06_Reset(uint16_t DeviceAddr);
/**
* @brief Read the ft6x06 device ID, pre intitalize I2C in case of need to be
* able to read the FT6206 device ID, and verify this is a FT6206.
* @param DeviceAddr: I2C FT6x06 Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t ft6x06_ReadID(uint16_t DeviceAddr);
/**
* @brief Configures the touch Screen IC device to start detecting touches
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void ft6x06_TS_Start(uint16_t DeviceAddr);
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t ft6x06_TS_DetectTouch(uint16_t DeviceAddr);
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'ft6x06_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void ft6x06_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
/**
* @brief Configure the FT6206 device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
* @retval None
*/
void ft6x06_TS_EnableIT(uint16_t DeviceAddr);
/**
* @brief Configure the FT6206 device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
* @retval None
*/
void ft6x06_TS_DisableIT(uint16_t DeviceAddr);
/**
* @brief Get IT status from FT6206 interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval TS interrupts status
*/
uint8_t ft6x06_TS_ITStatus (uint16_t DeviceAddr);
/**
* @brief Clear IT status in FT6206 interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval TS interrupts status
*/
void ft6x06_TS_ClearIT (uint16_t DeviceAddr);
/**** NEW FEATURES enabled when Multi-touch support is enabled ****/
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void ft6x06_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @retval None.
*/
void ft6x06_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent);
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
/* Imported TS IO functions --------------------------------------------------------*/
/** @defgroup ft6x06_Imported_Functions
* @{
*/
/* TouchScreen (TS) external IO functions */
extern void TS_IO_Init(void);
extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void TS_IO_Delay(uint32_t Delay);
/**
* @}
*/
/* Imported global variables --------------------------------------------------------*/
/** @defgroup ft6x06_Imported_Globals
* @{
*/
/* Touch screen driver structure */
extern TS_DrvTypeDef ft6x06_ts_drv;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __FT6X06_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for HTS221 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-hts221-component-drivers"><small>Release Notes for</small> <mark>HTS221 Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the HTS221 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 14-February-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of HTS221 Temperature/Humidity sensor</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,229 @@
/**
******************************************************************************
* @file hts221.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the HTS221
* humidity and temperature devices
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "hts221.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup HTS221 HTS221
* @{
*/
/** @defgroup HTS221_Private_Variables HTS221 Private Variables
* @{
*/
/* HTS221 Humidity Private Variables */
HSENSOR_DrvTypeDef HTS221_H_Drv =
{
HTS221_H_Init,
HTS221_H_ReadID,
HTS221_H_ReadHumidity
};
/* HTS221_Temperature_Private_Variables */
TSENSOR_DrvTypeDef HTS221_T_Drv =
{
HTS221_T_Init,
0,
0,
HTS221_T_ReadTemp
};
/**
* @}
*/
/** @defgroup HTS221_Humidity_Private_Functions HTS221 Humidity Private Functions
* @{
*/
/**
* @brief Set HTS221 humidity sensor Initialization.
*/
void HTS221_H_Init(uint16_t DeviceAddr)
{
uint8_t tmp;
/* Read CTRL_REG1 */
tmp = SENSOR_IO_Read(DeviceAddr, HTS221_CTRL_REG1);
/* Enable BDU */
tmp &= ~HTS221_BDU_MASK;
tmp |= (1 << HTS221_BDU_BIT);
/* Set default ODR */
tmp &= ~HTS221_ODR_MASK;
tmp |= (uint8_t)0x01; /* Set ODR to 1Hz */
/* Activate the device */
tmp |= HTS221_PD_MASK;
/* Apply settings to CTRL_REG1 */
SENSOR_IO_Write(DeviceAddr, HTS221_CTRL_REG1, tmp);
}
/**
* @brief Read HTS221 ID.
* @retval ID
*/
uint8_t HTS221_H_ReadID(uint16_t DeviceAddr)
{
uint8_t ctrl = 0x00;
/* IO interface initialization */
SENSOR_IO_Init();
/* Read value at Who am I register address */
ctrl = SENSOR_IO_Read(DeviceAddr, HTS221_WHO_AM_I_REG);
return ctrl;
}
/**
* @brief Read humidity value of HTS221
* @retval humidity value;
*/
float HTS221_H_ReadHumidity(uint16_t DeviceAddr)
{
int16_t H0_T0_out, H1_T0_out, H_T_out;
int16_t H0_rh, H1_rh;
uint8_t buffer[2];
float tmp_f;
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_H0_RH_X2 | 0x80), buffer, 2);
H0_rh = buffer[0] >> 1;
H1_rh = buffer[1] >> 1;
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_H0_T0_OUT_L | 0x80), buffer, 2);
H0_T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0];
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_H1_T0_OUT_L | 0x80), buffer, 2);
H1_T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0];
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_HR_OUT_L_REG | 0x80), buffer, 2);
H_T_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0];
tmp_f = (float)(H_T_out - H0_T0_out) * (float)(H1_rh - H0_rh) / (float)(H1_T0_out - H0_T0_out) + H0_rh;
tmp_f *= 10.0f;
tmp_f = ( tmp_f > 1000.0f ) ? 1000.0f
: ( tmp_f < 0.0f ) ? 0.0f
: tmp_f;
return (tmp_f / 10.0f);
}
/**
* @}
*/
/** @defgroup HTS221_Temperature_Private_Functions HTS221 Temperature Private Functions
* @{
*/
/**
* @brief Set HTS221 temperature sensor Initialization.
* @param DeviceAddr: I2C device address
* @param InitStruct: pointer to a TSENSOR_InitTypeDef structure
* that contains the configuration setting for the HTS221.
*/
void HTS221_T_Init(uint16_t DeviceAddr, TSENSOR_InitTypeDef *pInitStruct)
{
uint8_t tmp;
/* Read CTRL_REG1 */
tmp = SENSOR_IO_Read(DeviceAddr, HTS221_CTRL_REG1);
/* Enable BDU */
tmp &= ~HTS221_BDU_MASK;
tmp |= (1 << HTS221_BDU_BIT);
/* Set default ODR */
tmp &= ~HTS221_ODR_MASK;
tmp |= (uint8_t)0x01; /* Set ODR to 1Hz */
/* Activate the device */
tmp |= HTS221_PD_MASK;
/* Apply settings to CTRL_REG1 */
SENSOR_IO_Write(DeviceAddr, HTS221_CTRL_REG1, tmp);
}
/**
* @brief Read temperature value of HTS221
* @param DeviceAddr: I2C device address
* @retval temperature value
*/
float HTS221_T_ReadTemp(uint16_t DeviceAddr)
{
int16_t T0_out, T1_out, T_out, T0_degC_x8_u16, T1_degC_x8_u16;
int16_t T0_degC, T1_degC;
uint8_t buffer[4], tmp;
float tmp_f;
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_T0_DEGC_X8 | 0x80), buffer, 2);
tmp = SENSOR_IO_Read(DeviceAddr, HTS221_T0_T1_DEGC_H2);
T0_degC_x8_u16 = (((uint16_t)(tmp & 0x03)) << 8) | ((uint16_t)buffer[0]);
T1_degC_x8_u16 = (((uint16_t)(tmp & 0x0C)) << 6) | ((uint16_t)buffer[1]);
T0_degC = T0_degC_x8_u16 >> 3;
T1_degC = T1_degC_x8_u16 >> 3;
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_T0_OUT_L | 0x80), buffer, 4);
T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0];
T1_out = (((uint16_t)buffer[3]) << 8) | (uint16_t)buffer[2];
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_TEMP_OUT_L_REG | 0x80), buffer, 2);
T_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0];
tmp_f = (float)(T_out - T0_out) * (float)(T1_degC - T0_degC) / (float)(T1_out - T0_out) + T0_degC;
return tmp_f;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,320 @@
/**
******************************************************************************
* @file hts221.h
* @author MCD Application Team
* @brief HTS221 header driver file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HTS221__H
#define __HTS221__H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/hsensor.h"
#include "../Common/tsensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup HTS221
* @{
*/
/** @defgroup HTS221_Exported_Constants HTS221 Exported Constants
* @{
*/
/**
* @brief Bitfield positioning.
*/
#define HTS221_BIT(x) ((uint8_t)x)
/**
* @brief Device Identification register.
* Read
* Default value: 0xBC
* 7:0 This read-only register contains the device identifier for HTS221.
*/
#define HTS221_WHO_AM_I_REG (uint8_t)0x0F
/**
* @brief Device Identification value.
*/
#define HTS221_WHO_AM_I_VAL (uint8_t)0xBC
/**
* @brief Humidity and temperature average mode register.
* Read/write
* Default value: 0x1B
* 7:6 Reserved.
* 5:3 AVGT2-AVGT1-AVGT0: Select the temperature internal average.
*
* AVGT2 | AVGT1 | AVGT0 | Nr. Internal Average
* ----------------------------------------------------
* 0 | 0 | 0 | 2
* 0 | 0 | 1 | 4
* 0 | 1 | 0 | 8
* 0 | 1 | 1 | 16
* 1 | 0 | 0 | 32
* 1 | 0 | 1 | 64
* 1 | 1 | 0 | 128
* 1 | 1 | 1 | 256
*
* 2:0 AVGH2-AVGH1-AVGH0: Select humidity internal average.
* AVGH2 | AVGH1 | AVGH0 | Nr. Internal Average
* ------------------------------------------------------
* 0 | 0 | 0 | 4
* 0 | 0 | 1 | 8
* 0 | 1 | 0 | 16
* 0 | 1 | 1 | 32
* 1 | 0 | 0 | 64
* 1 | 0 | 1 | 128
* 1 | 1 | 0 | 256
* 1 | 1 | 1 | 512
*
*/
#define HTS221_AV_CONF_REG (uint8_t)0x10
#define HTS221_AVGT_BIT HTS221_BIT(3)
#define HTS221_AVGH_BIT HTS221_BIT(0)
#define HTS221_AVGH_MASK (uint8_t)0x07
#define HTS221_AVGT_MASK (uint8_t)0x38
/**
* @brief Control register 1.
* Read/write
* Default value: 0x00
* 7 PD: power down control. 0 - power down mode; 1 - active mode.
* 6:3 Reserved.
* 2 BDU: block data update. 0 - continuous update
* 1 - output registers not updated until MSB and LSB reading.
* 1:0 ODR1, ODR0: output data rate selection.
*
* ODR1 | ODR0 | Humidity output data-rate(Hz) | Pressure output data-rate(Hz)
* ----------------------------------------------------------------------------------
* 0 | 0 | one shot | one shot
* 0 | 1 | 1 | 1
* 1 | 0 | 7 | 7
* 1 | 1 | 12.5 | 12.5
*
*/
#define HTS221_CTRL_REG1 (uint8_t)0x20
#define HTS221_PD_BIT HTS221_BIT(7)
#define HTS221_BDU_BIT HTS221_BIT(2)
#define HTS221_ODR_BIT HTS221_BIT(0)
#define HTS221_PD_MASK (uint8_t)0x80
#define HTS221_BDU_MASK (uint8_t)0x04
#define HTS221_ODR_MASK (uint8_t)0x03
/**
* @brief Control register 2.
* Read/write
* Default value: 0x00
* 7 BOOT: Reboot memory content. 0: normal mode
* 1: reboot memory content. Self-cleared upon completation.
* 6:2 Reserved.
* 1 HEATHER: 0: heater enable; 1: heater disable.
* 0 ONE_SHOT: 0: waiting for start of conversion
* 1: start for a new dataset. Self-cleared upon completation.
*/
#define HTS221_CTRL_REG2 (uint8_t)0x21
#define HTS221_BOOT_BIT HTS221_BIT(7)
#define HTS221_HEATHER_BIT HTS221_BIT(1)
#define HTS221_ONESHOT_BIT HTS221_BIT(0)
#define HTS221_BOOT_MASK (uint8_t)0x80
#define HTS221_HEATHER_MASK (uint8_t)0x02
#define HTS221_ONE_SHOT_MASK (uint8_t)0x01
/**
* @brief Control register 3.
* Read/write
* Default value: 0x00
* 7 DRDY_H_L: Interrupt edge. 0: active high, 1: active low.
* 6 PP_OD: Push-Pull/OpenDrain selection on interrupt pads. 0: push-pull
* 1: open drain.
* 5:3 Reserved.
* 2 DRDY: interrupt config. 0: disable, 1: enable.
*/
#define HTS221_CTRL_REG3 (uint8_t)0x22
#define HTS221_DRDY_H_L_BIT HTS221_BIT(7)
#define HTS221_PP_OD_BIT HTS221_BIT(6)
#define HTS221_DRDY_BIT HTS221_BIT(2)
#define HTS221_DRDY_H_L_MASK (uint8_t)0x80
#define HTS221_PP_OD_MASK (uint8_t)0x40
#define HTS221_DRDY_MASK (uint8_t)0x04
/**
* @brief Status register.
* Read
* Default value: 0x00
* 7:2 Reserved.
* 1 H_DA: Humidity data available. 0: new data for humidity is not yet available
* 1: new data for humidity is available.
* 0 T_DA: Temperature data available. 0: new data for temperature is not yet available
* 1: new data for temperature is available.
*/
#define HTS221_STATUS_REG (uint8_t)0x27
#define HTS221_H_DA_BIT HTS221_BIT(1)
#define HTS221_T_DA_BIT HTS221_BIT(0)
#define HTS221_HDA_MASK (uint8_t)0x02
#define HTS221_TDA_MASK (uint8_t)0x01
/**
* @brief Humidity data (LSB).
* Read
* Default value: 0x00.
* HOUT7 - HOUT0: Humidity data LSB (2's complement).
*/
#define HTS221_HR_OUT_L_REG (uint8_t)0x28
/**
* @brief Humidity data (MSB).
* Read
* Default value: 0x00.
* HOUT15 - HOUT8: Humidity data MSB (2's complement).
*/
#define HTS221_HR_OUT_H_REG (uint8_t)0x29
/**
* @brief Temperature data (LSB).
* Read
* Default value: 0x00.
* TOUT7 - TOUT0: temperature data LSB.
*/
#define HTS221_TEMP_OUT_L_REG (uint8_t)0x2A
/**
* @brief Temperature data (MSB).
* Read
* Default value: 0x00.
* TOUT15 - TOUT8: temperature data MSB.
*/
#define HTS221_TEMP_OUT_H_REG (uint8_t)0x2B
/**
* @brief Calibration registers.
* Read
*/
#define HTS221_H0_RH_X2 (uint8_t)0x30
#define HTS221_H1_RH_X2 (uint8_t)0x31
#define HTS221_T0_DEGC_X8 (uint8_t)0x32
#define HTS221_T1_DEGC_X8 (uint8_t)0x33
#define HTS221_T0_T1_DEGC_H2 (uint8_t)0x35
#define HTS221_H0_T0_OUT_L (uint8_t)0x36
#define HTS221_H0_T0_OUT_H (uint8_t)0x37
#define HTS221_H1_T0_OUT_L (uint8_t)0x3A
#define HTS221_H1_T0_OUT_H (uint8_t)0x3B
#define HTS221_T0_OUT_L (uint8_t)0x3C
#define HTS221_T0_OUT_H (uint8_t)0x3D
#define HTS221_T1_OUT_L (uint8_t)0x3E
#define HTS221_T1_OUT_H (uint8_t)0x3F
/**
* @}
*/
/** @defgroup HTS221_Humidity_Exported_Functions HTS221 Humidity Exported Functions
* @{
*/
/* HUMIDITY functions */
void HTS221_H_Init(uint16_t DeviceAddr);
uint8_t HTS221_H_ReadID(uint16_t DeviceAddr);
float HTS221_H_ReadHumidity(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup HTS221_HumImported_Globals Humidity Imported Globals
* @{
*/
/* Humidity driver structure */
extern HSENSOR_DrvTypeDef HTS221_H_Drv;
/**
* @}
*/
/** @defgroup HTS221_Temperature_Exported_Functions HTS221 Temperature Exported Functions
* @{
*/
/* TEMPERATURE functions */
void HTS221_T_Init(uint16_t DeviceAddr, TSENSOR_InitTypeDef *pInitStruct);
float HTS221_T_ReadTemp(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup HTS221_TempImported_Globals Temperature Imported Globals
* @{
*/
/* Temperature driver structure */
extern TSENSOR_DrvTypeDef HTS221_T_Drv;
/**
* @}
*/
/** @defgroup HTS221_Imported_Functions HTS221 Imported Functions
* @{
*/
/* IO functions */
extern void SENSOR_IO_Init(void);
extern void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __HTS221__H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for HX8347G Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-hx8347g-component-drivers"><small>Release Notes for</small> <mark>HX8347G Component Drivers</mark></h1>
<p>Copyright © 2016 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the HX8347G component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.1.2 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.1.1 / 16-February-2016</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Fix hx8347g_ReadReg() to write Index in Index Register (IR)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.1.0 / 10-February-2015</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>Harmonize all LCD controllers Link usage (Change LCD_IO_WriteData to LCD_IO_WriteMultipleData)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section185" aria-hidden="true"> <label for="collapse-section185" aria-hidden="true">V1.0.1 / 02-December-2014</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>hx8347g.h: change “\” by “/” in the include path to fix compilation issue under Linux</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.0.0 / 06-May-2014</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>First official release of HX8347G LCD component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,473 @@
/**
******************************************************************************
* @file hx8347g.c
* @author MCD Application Team
* @brief This file includes the LCD driver for HX8347G LCD.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "hx8347g.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup HX8347G
* @brief This file provides a set of functions needed to drive the
* HX8347G LCD.
* @{
*/
/** @defgroup HX8347G_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup HX8347G_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup HX8347G_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup HX8347G_Private_Variables
* @{
*/
LCD_DrvTypeDef hx8347g_drv =
{
hx8347g_Init,
hx8347g_ReadID,
hx8347g_DisplayOn,
hx8347g_DisplayOff,
hx8347g_SetCursor,
hx8347g_WritePixel,
hx8347g_ReadPixel,
hx8347g_SetDisplayWindow,
hx8347g_DrawHLine,
hx8347g_DrawVLine,
hx8347g_GetLcdPixelWidth,
hx8347g_GetLcdPixelHeight,
hx8347g_DrawBitmap,
};
static uint8_t Is_hx8347g_Initialized = 0;
static uint16_t ArrayRGB[320] = {0};
/**
* @}
*/
/** @defgroup HX8347G_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup HX8347G_Private_Functions
* @{
*/
/**
* @brief Initialise the HX8347G LCD Component.
* @param None
* @retval None
*/
void hx8347g_Init(void)
{
if(Is_hx8347g_Initialized == 0)
{
Is_hx8347g_Initialized = 1;
/* Initialise HX8347G low level bus layer --------------------------------*/
LCD_IO_Init();
/* HX8347G requests 120ms (worst case) after reset */
LCD_Delay(120);
/* Driving ability setting */
hx8347g_WriteReg(LCD_REG_234, 0x00);
hx8347g_WriteReg(LCD_REG_235, 0x20);
hx8347g_WriteReg(LCD_REG_236, 0x0C);
hx8347g_WriteReg(LCD_REG_237, 0xC4);
hx8347g_WriteReg(LCD_REG_232, 0x40);
hx8347g_WriteReg(LCD_REG_233, 0x38);
hx8347g_WriteReg(LCD_REG_241, 0x01);
hx8347g_WriteReg(LCD_REG_242, 0x10);
hx8347g_WriteReg(LCD_REG_39, 0xA3);
/* Adjust the Gamma Curve */
hx8347g_WriteReg(LCD_REG_64, 0x01);
hx8347g_WriteReg(LCD_REG_65, 0x00);
hx8347g_WriteReg(LCD_REG_66, 0x00);
hx8347g_WriteReg(LCD_REG_67, 0x10);
hx8347g_WriteReg(LCD_REG_68, 0x0E);
hx8347g_WriteReg(LCD_REG_69, 0x24);
hx8347g_WriteReg(LCD_REG_70, 0x04);
hx8347g_WriteReg(LCD_REG_71, 0x50);
hx8347g_WriteReg(LCD_REG_72, 0x02);
hx8347g_WriteReg(LCD_REG_73, 0x13);
hx8347g_WriteReg(LCD_REG_74, 0x19);
hx8347g_WriteReg(LCD_REG_75, 0x19);
hx8347g_WriteReg(LCD_REG_76, 0x16);
hx8347g_WriteReg(LCD_REG_80, 0x1B);
hx8347g_WriteReg(LCD_REG_81, 0x31);
hx8347g_WriteReg(LCD_REG_82, 0x2F);
hx8347g_WriteReg(LCD_REG_83, 0x3F);
hx8347g_WriteReg(LCD_REG_84, 0x3F);
hx8347g_WriteReg(LCD_REG_85, 0x3E);
hx8347g_WriteReg(LCD_REG_86, 0x2F);
hx8347g_WriteReg(LCD_REG_87, 0x7B);
hx8347g_WriteReg(LCD_REG_88, 0x09);
hx8347g_WriteReg(LCD_REG_89, 0x06);
hx8347g_WriteReg(LCD_REG_90, 0x06);
hx8347g_WriteReg(LCD_REG_91, 0x0C);
hx8347g_WriteReg(LCD_REG_92, 0x1D);
hx8347g_WriteReg(LCD_REG_93, 0xCC);
/* Power voltage setting */
hx8347g_WriteReg(LCD_REG_27, 0x1B);
hx8347g_WriteReg(LCD_REG_26, 0x01);
hx8347g_WriteReg(LCD_REG_36, 0x2F);
hx8347g_WriteReg(LCD_REG_37, 0x57);
/*****VCOM offset ****/
hx8347g_WriteReg(LCD_REG_35, 0x86);
hx8347g_DisplayOn();
/* Set GRAM Area - Partial Display Control */
hx8347g_WriteReg(LCD_REG_1, 0x00); /* DP_STB = 0, DP_STB_S = 0, SCROLL = 0, */
hx8347g_SetDisplayWindow(0, 0, hx8347g_GetLcdPixelWidth(), hx8347g_GetLcdPixelHeight());
hx8347g_WriteReg(LCD_REG_22, 0xA0); /* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */
}
/* Set the Cursor */
hx8347g_SetCursor(0, 0);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
}
/**
* @brief Enables the Display.
* @param None
* @retval None
*/
void hx8347g_DisplayOn(void)
{
/* Power On sequence ---------------------------------------------------------*/
hx8347g_WriteReg(LCD_REG_24, 0x36); /* Display frame rate = 70Hz RADJ = '0110' */
hx8347g_WriteReg(LCD_REG_25, 0x01); /* OSC_EN = 1 */
hx8347g_WriteReg(LCD_REG_28, 0x06); /* AP[2:0] = 111 */
hx8347g_WriteReg(LCD_REG_31, 0x90); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
LCD_Delay(10);
/* 262k/65k color selection */
hx8347g_WriteReg(LCD_REG_23, 0x05); /* default 0x06 262k color, 0x05 65k color */
/* SET PANEL */
hx8347g_WriteReg(LCD_REG_54, 0x09); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */
/* Display On */
hx8347g_WriteReg(LCD_REG_40, 0x38);
LCD_Delay(60);
hx8347g_WriteReg(LCD_REG_40, 0x3C);
}
/**
* @brief Disables the Display.
* @param None
* @retval None
*/
void hx8347g_DisplayOff(void)
{
/* Display Off */
hx8347g_WriteReg(LCD_REG_40, 0x38);
LCD_Delay(60);
hx8347g_WriteReg(LCD_REG_40, 0x04);
/* Power Off sequence ---------------------------------------------------------*/
hx8347g_WriteReg(LCD_REG_23, 0x0000); /* default 0x06 262k color, 0x05 65k color */
hx8347g_WriteReg(LCD_REG_24, 0x0000); /* Display frame rate = 70Hz RADJ = '0110' */
hx8347g_WriteReg(LCD_REG_25, 0x0000); /* OSC_EN = 1 */
hx8347g_WriteReg(LCD_REG_28, 0x0000); /* AP[2:0] = 111 */
hx8347g_WriteReg(LCD_REG_31, 0x0000); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
hx8347g_WriteReg(LCD_REG_54, 0x0000); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */
}
/**
* @brief Get the LCD pixel Width.
* @param None
* @retval The Lcd Pixel Width
*/
uint16_t hx8347g_GetLcdPixelWidth(void)
{
return (uint16_t)HX8347G_LCD_PIXEL_WIDTH;
}
/**
* @brief Get the LCD pixel Height.
* @param None
* @retval The Lcd Pixel Height
*/
uint16_t hx8347g_GetLcdPixelHeight(void)
{
return (uint16_t)HX8347G_LCD_PIXEL_HEIGHT;
}
/**
* @brief Get the HX8347G ID.
* @param None
* @retval The HX8347G ID
*/
uint16_t hx8347g_ReadID(void)
{
if(Is_hx8347g_Initialized == 0)
{
LCD_IO_Init();
/* HX8347G requests 120ms (worst case) after reset */
LCD_Delay(120);
}
return (hx8347g_ReadReg(0x00));
}
/**
* @brief Set Cursor position.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval None
*/
void hx8347g_SetCursor(uint16_t Xpos, uint16_t Ypos)
{
hx8347g_WriteReg(LCD_REG_6, 0x00);
hx8347g_WriteReg(LCD_REG_7, Xpos);
hx8347g_WriteReg(LCD_REG_2, Ypos >> 8);
hx8347g_WriteReg(LCD_REG_3, Ypos & 0xFF);
}
/**
* @brief Write pixel.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param RGBCode: the RGB pixel color
* @retval None
*/
void hx8347g_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
{
/* Set Cursor */
hx8347g_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&RGBCode, 2);
}
/**
* @brief Read pixel.
* @param None
* @retval the RGB pixel color
*/
uint16_t hx8347g_ReadPixel(uint16_t Xpos, uint16_t Ypos)
{
/* Set Cursor */
hx8347g_SetCursor(Xpos, Ypos);
/* Dummy read */
LCD_IO_ReadData(LCD_REG_34);
/* Read 16-bit Reg */
return (LCD_IO_ReadData(LCD_REG_34));
}
/**
* @brief Writes to the selected LCD register.
* @param LCDReg: address of the selected register.
* @param LCDRegValue: value to write to the selected register.
* @retval None
*/
void hx8347g_WriteReg(uint8_t LCDReg, uint16_t LCDRegValue)
{
LCD_IO_WriteReg(LCDReg);
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&LCDRegValue, 2);
}
/**
* @brief Reads the selected LCD Register.
* @param LCDReg: address of the selected register.
* @retval LCD Register Value.
*/
uint16_t hx8347g_ReadReg(uint8_t LCDReg)
{
/* Write 16-bit Index (then Read Reg) */
LCD_IO_WriteReg(LCDReg);
/* Read 16-bit Reg */
return (LCD_IO_ReadData(LCDReg));
}
/**
* @brief Sets a display window
* @param Xpos: specifies the X bottom left position.
* @param Ypos: specifies the Y bottom left position.
* @param Height: display window height.
* @param Width: display window width.
* @retval None
*/
void hx8347g_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
/* Horizontal GRAM Start Address */
hx8347g_WriteReg(LCD_REG_6, (Xpos) >> 8); /* SP */
hx8347g_WriteReg(LCD_REG_7, (Xpos) & 0xFF); /* SP */
/* Horizontal GRAM End Address */
hx8347g_WriteReg(LCD_REG_8, (Xpos + Height - 1) >> 8); /* EP */
hx8347g_WriteReg(LCD_REG_9, (Xpos + Height - 1) & 0xFF); /* EP */
/* Vertical GRAM Start Address */
hx8347g_WriteReg(LCD_REG_2, (Ypos) >> 8); /* SC */
hx8347g_WriteReg(LCD_REG_3, (Ypos) & 0xFF); /* SC */
/* Vertical GRAM End Address */
hx8347g_WriteReg(LCD_REG_4, (Ypos + Width - 1) >> 8); /* EC */
hx8347g_WriteReg(LCD_REG_5, (Ypos + Width - 1) & 0xFF); /* EC */
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void hx8347g_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint32_t i = 0;
/* Set Cursor */
hx8347g_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Sent a complete line */
for(i = 0; i < Length; i++)
{
ArrayRGB[i] = RGBCode;
}
LCD_IO_WriteMultipleData((uint8_t*)&ArrayRGB[0], Length * 2);
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void hx8347g_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint16_t counter = 0;
/* Set Cursor */
hx8347g_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Fill a complete vertical line */
for(counter = 0; counter < Length; counter++)
{
ArrayRGB[counter] = RGBCode;
}
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&ArrayRGB[0], Length * 2);
}
/**
* @brief Displays a bitmap picture loaded in the internal Flash.
* @param BmpAddress: Bmp picture address in the internal Flash.
* @retval None
*/
void hx8347g_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp)
{
uint32_t index = 0, size = 0;
/* Read bitmap size */
size = *(volatile uint16_t *) (pbmp + 2);
size |= (*(volatile uint16_t *) (pbmp + 4)) << 16;
/* Get bitmap data address offset */
index = *(volatile uint16_t *) (pbmp + 10);
index |= (*(volatile uint16_t *) (pbmp + 12)) << 16;
size = (size - index)/2;
pbmp += index;
/* Set GRAM write direction and BGR = 0 */
/* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */
hx8347g_WriteReg(LCD_REG_22, 0xE0);
/* Set Cursor */
hx8347g_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
LCD_IO_WriteMultipleData((uint8_t*)pbmp, size*2);
/* Set GRAM write direction and BGR = 0 */
/* Memory access control: MY = 1, MX = 1, MV = 1, ML = 0 */
hx8347g_WriteReg(LCD_REG_22, 0xA0);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,256 @@
/**
******************************************************************************
* @file hx8347g.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the hx8347g.c
* driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HX8347G_H
#define __HX8347G_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/lcd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup hx8347g
* @{
*/
/** @defgroup HX8347G_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup HX8347G_Exported_Constants
* @{
*/
/**
* @brief HX8347G ID
*/
#define HX8347G_ID 0x0075
/**
* @brief HX8347G Size
*/
#define HX8347G_LCD_PIXEL_WIDTH ((uint16_t)320)
#define HX8347G_LCD_PIXEL_HEIGHT ((uint16_t)240)
/**
* @brief HX8347G Registers
*/
#define LCD_REG_0 0x00
#define LCD_REG_1 0x01
#define LCD_REG_2 0x02
#define LCD_REG_3 0x03
#define LCD_REG_4 0x04
#define LCD_REG_5 0x05
#define LCD_REG_6 0x06
#define LCD_REG_7 0x07
#define LCD_REG_8 0x08
#define LCD_REG_9 0x09
#define LCD_REG_10 0x0A
#define LCD_REG_11 0x0B
#define LCD_REG_12 0x0C
#define LCD_REG_13 0x0D
#define LCD_REG_14 0x0E
#define LCD_REG_15 0x0F
#define LCD_REG_16 0x10
#define LCD_REG_17 0x11
#define LCD_REG_18 0x12
#define LCD_REG_19 0x13
#define LCD_REG_20 0x14
#define LCD_REG_21 0x15
#define LCD_REG_22 0x16
#define LCD_REG_23 0x17
#define LCD_REG_24 0x18
#define LCD_REG_25 0x19
#define LCD_REG_26 0x1A
#define LCD_REG_27 0x1B
#define LCD_REG_28 0x1C
#define LCD_REG_29 0x1D
#define LCD_REG_30 0x1E
#define LCD_REG_31 0x1F
#define LCD_REG_32 0x20
#define LCD_REG_33 0x21
#define LCD_REG_34 0x22
#define LCD_REG_35 0x23
#define LCD_REG_36 0x24
#define LCD_REG_37 0x25
#define LCD_REG_38 0x26
#define LCD_REG_39 0x27
#define LCD_REG_40 0x28
#define LCD_REG_41 0x29
#define LCD_REG_42 0x2A
#define LCD_REG_43 0x2B
#define LCD_REG_44 0x2C
#define LCD_REG_45 0x2D
#define LCD_REG_46 0x2E
#define LCD_REG_47 0x2F
#define LCD_REG_48 0x30
#define LCD_REG_49 0x31
#define LCD_REG_50 0x32
#define LCD_REG_51 0x33
#define LCD_REG_52 0x34
#define LCD_REG_53 0x35
#define LCD_REG_54 0x36
#define LCD_REG_55 0x37
#define LCD_REG_56 0x38
#define LCD_REG_57 0x39
#define LCD_REG_58 0x3A
#define LCD_REG_59 0x3B
#define LCD_REG_60 0x3C
#define LCD_REG_61 0x3D
#define LCD_REG_62 0x3E
#define LCD_REG_63 0x3F
#define LCD_REG_64 0x40
#define LCD_REG_65 0x41
#define LCD_REG_66 0x42
#define LCD_REG_67 0x43
#define LCD_REG_68 0x44
#define LCD_REG_69 0x45
#define LCD_REG_70 0x46
#define LCD_REG_71 0x47
#define LCD_REG_72 0x48
#define LCD_REG_73 0x49
#define LCD_REG_74 0x4A
#define LCD_REG_75 0x4B
#define LCD_REG_76 0x4C
#define LCD_REG_77 0x4D
#define LCD_REG_78 0x4E
#define LCD_REG_79 0x4F
#define LCD_REG_80 0x50
#define LCD_REG_81 0x51
#define LCD_REG_82 0x52
#define LCD_REG_83 0x53
#define LCD_REG_84 0x54
#define LCD_REG_85 0x55
#define LCD_REG_86 0x56
#define LCD_REG_87 0x57
#define LCD_REG_88 0x58
#define LCD_REG_89 0x59
#define LCD_REG_90 0x5A
#define LCD_REG_91 0x5B
#define LCD_REG_92 0x5C
#define LCD_REG_93 0x5D
#define LCD_REG_94 0x5E
#define LCD_REG_95 0x5F
#define LCD_REG_96 0x60
#define LCD_REG_97 0x61
#define LCD_REG_98 0x62
#define LCD_REG_99 0x63
#define LCD_REG_104 0x68
#define LCD_REG_105 0x69
#define LCD_REG_112 0x70
#define LCD_REG_113 0x71
#define LCD_REG_132 0x84
#define LCD_REG_133 0x85
#define LCD_REG_195 0xC3
#define LCD_REG_197 0xC5
#define LCD_REG_199 0xC7
#define LCD_REG_203 0xCB
#define LCD_REG_204 0xCC
#define LCD_REG_205 0xCD
#define LCD_REG_206 0xCE
#define LCD_REG_207 0xCF
#define LCD_REG_208 0xD0
#define LCD_REG_209 0xD1
#define LCD_REG_210 0xD2
#define LCD_REG_211 0xD3
#define LCD_REG_232 0xE8
#define LCD_REG_233 0xE9
#define LCD_REG_234 0xEA
#define LCD_REG_235 0xEB
#define LCD_REG_236 0xEC
#define LCD_REG_237 0xED
#define LCD_REG_241 0xF1
#define LCD_REG_242 0xF2
#define LCD_REG_255 0xFF
/**
* @}
*/
/** @defgroup HX8347G_Exported_Functions
* @{
*/
void hx8347g_Init(void);
uint16_t hx8347g_ReadID(void);
void hx8347g_WriteReg(uint8_t LCDReg, uint16_t LCDRegValue);
uint16_t hx8347g_ReadReg(uint8_t LCDReg);
void hx8347g_DisplayOn(void);
void hx8347g_DisplayOff(void);
void hx8347g_SetCursor(uint16_t Xpos, uint16_t Ypos);
void hx8347g_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
uint16_t hx8347g_ReadPixel(uint16_t Xpos, uint16_t Ypos);
void hx8347g_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void hx8347g_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void hx8347g_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
void hx8347g_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
uint16_t hx8347g_GetLcdPixelWidth(void);
uint16_t hx8347g_GetLcdPixelHeight(void);
/* LCD driver structure */
extern LCD_DrvTypeDef hx8347g_drv;
/* LCD IO functions */
void LCD_IO_Init(void);
void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size);
void LCD_IO_WriteReg(uint8_t Reg);
uint16_t LCD_IO_ReadData(uint16_t Reg);
void LCD_Delay (uint32_t delay);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __HX8347G_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for HX8347I Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-hx8347i-component-drivers"><small>Release Notes for</small> <mark>HX8347I Component Drivers</mark></h1>
<p>Copyright © 2019 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the HX8347I component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 28-June-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update HX8347I controller initialization sequence</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section1" checked aria-hidden="true"> <label for="collapse-section1" aria-hidden="true">V1.0.0 / 03-April-2019</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of HX8347I LCD controller component drivers.</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,479 @@
/**
******************************************************************************
* @file hx8347i.c
* @author MCD Application Team
* @brief This file includes the driver for HX8347I LCD.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "hx8347i.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup HX8347I
* @brief This file provides a set of functions needed to drive the
* HX8347I LCD.
* @{
*/
/** @defgroup HX8347I_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup HX8347I_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup HX8347I_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup HX8347I_Private_Variables
* @{
*/
LCD_DrvTypeDef hx8347i_drv =
{
hx8347i_Init,
hx8347i_ReadID,
hx8347i_DisplayOn,
hx8347i_DisplayOff,
hx8347i_SetCursor,
hx8347i_WritePixel,
hx8347i_ReadPixel,
hx8347i_SetDisplayWindow,
hx8347i_DrawHLine,
hx8347i_DrawVLine,
hx8347i_GetLcdPixelWidth,
hx8347i_GetLcdPixelHeight,
hx8347i_DrawBitmap,
};
static uint8_t Is_hx8347i_Initialized = 0;
static uint16_t ArrayRGB[320] = {0};
/**
* @}
*/
/** @defgroup HX8347I_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup HX8347I_Private_Functions
* @{
*/
/**
* @brief Initialize the HX8347I LCD Component.
* @param None
* @retval None
*/
void hx8347i_Init(void)
{
if(Is_hx8347i_Initialized == 0)
{
Is_hx8347i_Initialized = 1;
/* Initialize HX8347I low level bus layer --------------------------------*/
LCD_IO_Init();
/* HX8347I requests 120ms (worst case) after reset */
LCD_Delay(120);
/* Adjust the Gamma Curve */
hx8347i_WriteReg(LCD_REG_64, 0x00);
hx8347i_WriteReg(LCD_REG_65, 0x00);
hx8347i_WriteReg(LCD_REG_66, 0x04);
hx8347i_WriteReg(LCD_REG_67, 0x13);
hx8347i_WriteReg(LCD_REG_68, 0x0E);
hx8347i_WriteReg(LCD_REG_69, 0x2D);
hx8347i_WriteReg(LCD_REG_70, 0x0E);
hx8347i_WriteReg(LCD_REG_71, 0x57);
hx8347i_WriteReg(LCD_REG_72, 0x09);
hx8347i_WriteReg(LCD_REG_73, 0x13);
hx8347i_WriteReg(LCD_REG_74, 0x19);
hx8347i_WriteReg(LCD_REG_75, 0x1A);
hx8347i_WriteReg(LCD_REG_76, 0x1B);
hx8347i_WriteReg(LCD_REG_80, 0x12);
hx8347i_WriteReg(LCD_REG_81, 0x31);
hx8347i_WriteReg(LCD_REG_82, 0x2C);
hx8347i_WriteReg(LCD_REG_83, 0x3B);
hx8347i_WriteReg(LCD_REG_84, 0x3F);
hx8347i_WriteReg(LCD_REG_85, 0x3F);
hx8347i_WriteReg(LCD_REG_86, 0x28);
hx8347i_WriteReg(LCD_REG_87, 0x71);
hx8347i_WriteReg(LCD_REG_88, 0x04);
hx8347i_WriteReg(LCD_REG_89, 0x05);
hx8347i_WriteReg(LCD_REG_90, 0x06);
hx8347i_WriteReg(LCD_REG_91, 0x0C);
hx8347i_WriteReg(LCD_REG_92, 0x16);
hx8347i_WriteReg(LCD_REG_93, 0x88);
/* Power voltage setting */
hx8347i_WriteReg(LCD_REG_27, 0x1E); /* VRH=4.60V */
hx8347i_WriteReg(LCD_REG_28, 0x07); /* AP Crosstalk */
hx8347i_WriteReg(LCD_REG_26, 0x01); /* BT (VGH~15V,VGL~-10V,DDVDH~5V) */
hx8347i_WriteReg(LCD_REG_36, 0x38); /* VMH */
hx8347i_WriteReg(LCD_REG_37, 0x5F); /* VML */
/*****VCOM offset ****/
hx8347i_WriteReg(LCD_REG_35, 0x6B);
/* Driving ability setting */
hx8347i_WriteReg(LCD_REG_232, 0x7C);
hx8347i_WriteReg(LCD_REG_236, 0x14);
hx8347i_WriteReg(LCD_REG_237, 0x0C);
hx8347i_WriteReg(LCD_REG_228, 0x10);
hx8347i_WriteReg(LCD_REG_229, 0x02);
hx8347i_WriteReg(LCD_REG_230, 0x10);
hx8347i_WriteReg(LCD_REG_231, 0x02);
hx8347i_DisplayOn();
/* Set GRAM Area - Partial Display Control */
hx8347i_WriteReg(LCD_REG_1, 0x00); /* DP_STB = 0, DP_STB_S = 0, SCROLL = 0, */
hx8347i_SetDisplayWindow(0, 0, hx8347i_GetLcdPixelWidth(), hx8347i_GetLcdPixelHeight());
hx8347i_WriteReg(LCD_REG_22, 0xA0); /* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */
}
/* Set the Cursor */
hx8347i_SetCursor(0, 0);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
}
/**
* @brief Enables the Display.
* @param None
* @retval None
*/
void hx8347i_DisplayOn(void)
{
/* Power On sequence ---------------------------------------------------------*/
hx8347i_WriteReg(LCD_REG_24, 0x99); /* Display frame rate = 75Hz UADJ */
hx8347i_WriteReg(LCD_REG_25, 0x01); /* OSC_EN = 1 */
hx8347i_WriteReg(LCD_REG_26, 0x04); /* BT[2:0] = 4 before sleep out */
hx8347i_WriteReg(LCD_REG_31, 0x88); /* GAS=1, VOMG=00, PON=0, DK=1, XDK=0, DVDH_TRI=0, STB=0*/
LCD_Delay(5);
hx8347i_WriteReg(LCD_REG_31, 0x80); /* GAS=1, VOMG=00, PON=0, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
LCD_Delay(5);
hx8347i_WriteReg(LCD_REG_31, 0x90); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
LCD_Delay(5);
hx8347i_WriteReg(LCD_REG_31, 0xD0); /* GAS=1, VOMG=10, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0 */
LCD_Delay(5);
/* 262k/65k color selection */
hx8347i_WriteReg(LCD_REG_23, 0x05); /* default 0x06 262k color, 0x05 65k color */
/* SET PANEL */
hx8347i_WriteReg(LCD_REG_54, 0x09); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */
/* Display On */
hx8347i_WriteReg(LCD_REG_40, 0x38);
LCD_Delay(60);
hx8347i_WriteReg(LCD_REG_40, 0x3C);
}
/**
* @brief Disables the Display.
* @param None
* @retval None
*/
void hx8347i_DisplayOff(void)
{
/* Display Off */
hx8347i_WriteReg(LCD_REG_40, 0x38);
LCD_Delay(60);
hx8347i_WriteReg(LCD_REG_40, 0x04);
/* Power Off sequence ---------------------------------------------------------*/
hx8347i_WriteReg(LCD_REG_23, 0x0000); /* default 0x06 262k color, 0x05 65k color */
hx8347i_WriteReg(LCD_REG_24, 0x0000); /* Display frame rate = 70Hz RADJ = '0110' */
hx8347i_WriteReg(LCD_REG_25, 0x0000); /* OSC_EN = 1 */
hx8347i_WriteReg(LCD_REG_28, 0x0000); /* AP[2:0] = 111 */
hx8347i_WriteReg(LCD_REG_31, 0x0000); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
hx8347i_WriteReg(LCD_REG_54, 0x0000); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */
}
/**
* @brief Get the LCD pixel Width.
* @param None
* @retval The Lcd Pixel Width
*/
uint16_t hx8347i_GetLcdPixelWidth(void)
{
return (uint16_t)HX8347I_LCD_PIXEL_WIDTH;
}
/**
* @brief Get the LCD pixel Height.
* @param None
* @retval The Lcd Pixel Height
*/
uint16_t hx8347i_GetLcdPixelHeight(void)
{
return (uint16_t)HX8347I_LCD_PIXEL_HEIGHT;
}
/**
* @brief Get the HX8347I ID.
* @param None
* @retval The HX8347I ID
*/
uint16_t hx8347i_ReadID(void)
{
if(Is_hx8347i_Initialized == 0)
{
LCD_IO_Init();
/* HX8347I requests 120ms (worst case) after reset */
LCD_Delay(120);
}
return (hx8347i_ReadReg(0x00));
}
/**
* @brief Set Cursor position.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval None
*/
void hx8347i_SetCursor(uint16_t Xpos, uint16_t Ypos)
{
hx8347i_WriteReg(LCD_REG_6, 0x00);
hx8347i_WriteReg(LCD_REG_7, Xpos);
hx8347i_WriteReg(LCD_REG_2, Ypos >> 8);
hx8347i_WriteReg(LCD_REG_3, Ypos & 0xFF);
}
/**
* @brief Write pixel.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param RGBCode: the RGB pixel color
* @retval None
*/
void hx8347i_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
{
/* Set Cursor */
hx8347i_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&RGBCode, 2);
}
/**
* @brief Read pixel.
* @param None
* @retval the RGB pixel color
*/
uint16_t hx8347i_ReadPixel(uint16_t Xpos, uint16_t Ypos)
{
/* Set Cursor */
hx8347i_SetCursor(Xpos, Ypos);
/* Dummy read */
LCD_IO_ReadData(LCD_REG_34);
/* Read 16-bit Reg */
return (LCD_IO_ReadData(LCD_REG_34));
}
/**
* @brief Writes to the selected LCD register.
* @param LCDReg: address of the selected register.
* @param LCDRegValue: value to write to the selected register.
* @retval None
*/
void hx8347i_WriteReg(uint8_t LCDReg, uint16_t LCDRegValue)
{
LCD_IO_WriteReg(LCDReg);
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&LCDRegValue, 2);
}
/**
* @brief Reads the selected LCD Register.
* @param LCDReg: address of the selected register.
* @retval LCD Register Value.
*/
uint16_t hx8347i_ReadReg(uint8_t LCDReg)
{
/* Write 16-bit Index (then Read Reg) */
LCD_IO_WriteReg(LCDReg);
/* Read 16-bit Reg */
return (LCD_IO_ReadData(LCDReg));
}
/**
* @brief Sets a display window
* @param Xpos: specifies the X bottom left position.
* @param Ypos: specifies the Y bottom left position.
* @param Height: display window height.
* @param Width: display window width.
* @retval None
*/
void hx8347i_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
/* Horizontal GRAM Start Address */
hx8347i_WriteReg(LCD_REG_6, (Xpos) >> 8); /* SP */
hx8347i_WriteReg(LCD_REG_7, (Xpos) & 0xFF); /* SP */
/* Horizontal GRAM End Address */
hx8347i_WriteReg(LCD_REG_8, (Xpos + Height - 1) >> 8); /* EP */
hx8347i_WriteReg(LCD_REG_9, (Xpos + Height - 1) & 0xFF); /* EP */
/* Vertical GRAM Start Address */
hx8347i_WriteReg(LCD_REG_2, (Ypos) >> 8); /* SC */
hx8347i_WriteReg(LCD_REG_3, (Ypos) & 0xFF); /* SC */
/* Vertical GRAM End Address */
hx8347i_WriteReg(LCD_REG_4, (Ypos + Width - 1) >> 8); /* EC */
hx8347i_WriteReg(LCD_REG_5, (Ypos + Width - 1) & 0xFF); /* EC */
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void hx8347i_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint32_t i = 0;
/* Set Cursor */
hx8347i_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Sent a complete line */
for(i = 0; i < Length; i++)
{
ArrayRGB[i] = RGBCode;
}
LCD_IO_WriteMultipleData((uint8_t*)&ArrayRGB[0], Length * 2);
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void hx8347i_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint16_t counter = 0;
/* Set Cursor */
hx8347i_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Fill a complete vertical line */
for(counter = 0; counter < Length; counter++)
{
ArrayRGB[counter] = RGBCode;
}
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&ArrayRGB[0], Length * 2);
}
/**
* @brief Displays a bitmap picture loaded in the internal Flash.
* @param BmpAddress: Bmp picture address in the internal Flash.
* @retval None
*/
void hx8347i_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp)
{
uint32_t index = 0, size = 0;
/* Read bitmap size */
size = *(volatile uint16_t *) (pbmp + 2);
size |= (*(volatile uint16_t *) (pbmp + 4)) << 16;
/* Get bitmap data address offset */
index = *(volatile uint16_t *) (pbmp + 10);
index |= (*(volatile uint16_t *) (pbmp + 12)) << 16;
size = (size - index)/2;
pbmp += index;
/* Set GRAM write direction and BGR = 0 */
/* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */
hx8347i_WriteReg(LCD_REG_22, 0xE0);
/* Set Cursor */
hx8347i_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
LCD_IO_WriteMultipleData((uint8_t*)pbmp, size*2);
/* Set GRAM write direction and BGR = 0 */
/* Memory access control: MY = 1, MX = 1, MV = 1, ML = 0 */
hx8347i_WriteReg(LCD_REG_22, 0xA0);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,245 @@
/**
******************************************************************************
* @file hx8347i.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the hx8347i.c
* driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef HX8347I_H
#define HX8347I_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/lcd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup hx8347i
* @{
*/
/** @defgroup HX8347I_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup HX8347I_Exported_Constants
* @{
*/
/**
* @brief HX8347I ID
*/
#define HX8347I_ID 0x0095
/**
* @brief HX8347I Size
*/
#define HX8347I_LCD_PIXEL_WIDTH ((uint16_t)320)
#define HX8347I_LCD_PIXEL_HEIGHT ((uint16_t)240)
/**
* @brief HX8347I Registers
*/
#define LCD_REG_0 0x00
#define LCD_REG_1 0x01
#define LCD_REG_2 0x02
#define LCD_REG_3 0x03
#define LCD_REG_4 0x04
#define LCD_REG_5 0x05
#define LCD_REG_6 0x06
#define LCD_REG_7 0x07
#define LCD_REG_8 0x08
#define LCD_REG_9 0x09
#define LCD_REG_10 0x0A
#define LCD_REG_11 0x0B
#define LCD_REG_12 0x0C
#define LCD_REG_13 0x0D
#define LCD_REG_14 0x0E
#define LCD_REG_15 0x0F
#define LCD_REG_16 0x10
#define LCD_REG_17 0x11
#define LCD_REG_18 0x12
#define LCD_REG_19 0x13
#define LCD_REG_20 0x14
#define LCD_REG_21 0x15
#define LCD_REG_22 0x16
#define LCD_REG_23 0x17
#define LCD_REG_24 0x18
#define LCD_REG_25 0x19
#define LCD_REG_26 0x1A
#define LCD_REG_27 0x1B
#define LCD_REG_28 0x1C
#define LCD_REG_29 0x1D
#define LCD_REG_30 0x1E
#define LCD_REG_31 0x1F
#define LCD_REG_32 0x20
#define LCD_REG_33 0x21
#define LCD_REG_34 0x22
#define LCD_REG_35 0x23
#define LCD_REG_36 0x24
#define LCD_REG_37 0x25
#define LCD_REG_38 0x26
#define LCD_REG_39 0x27
#define LCD_REG_40 0x28
#define LCD_REG_41 0x29
#define LCD_REG_42 0x2A
#define LCD_REG_43 0x2B
#define LCD_REG_44 0x2C
#define LCD_REG_45 0x2D
#define LCD_REG_46 0x2E
#define LCD_REG_47 0x2F
#define LCD_REG_48 0x30
#define LCD_REG_49 0x31
#define LCD_REG_50 0x32
#define LCD_REG_51 0x33
#define LCD_REG_52 0x34
#define LCD_REG_53 0x35
#define LCD_REG_54 0x36
#define LCD_REG_55 0x37
#define LCD_REG_56 0x38
#define LCD_REG_57 0x39
#define LCD_REG_58 0x3A
#define LCD_REG_59 0x3B
#define LCD_REG_60 0x3C
#define LCD_REG_61 0x3D
#define LCD_REG_62 0x3E
#define LCD_REG_63 0x3F
#define LCD_REG_64 0x40
#define LCD_REG_65 0x41
#define LCD_REG_66 0x42
#define LCD_REG_67 0x43
#define LCD_REG_68 0x44
#define LCD_REG_69 0x45
#define LCD_REG_70 0x46
#define LCD_REG_71 0x47
#define LCD_REG_72 0x48
#define LCD_REG_73 0x49
#define LCD_REG_74 0x4A
#define LCD_REG_75 0x4B
#define LCD_REG_76 0x4C
#define LCD_REG_77 0x4D
#define LCD_REG_78 0x4E
#define LCD_REG_79 0x4F
#define LCD_REG_80 0x50
#define LCD_REG_81 0x51
#define LCD_REG_82 0x52
#define LCD_REG_83 0x53
#define LCD_REG_84 0x54
#define LCD_REG_85 0x55
#define LCD_REG_86 0x56
#define LCD_REG_87 0x57
#define LCD_REG_88 0x58
#define LCD_REG_89 0x59
#define LCD_REG_90 0x5A
#define LCD_REG_91 0x5B
#define LCD_REG_92 0x5C
#define LCD_REG_93 0x5D
#define LCD_REG_94 0x5E
#define LCD_REG_95 0x5F
#define LCD_REG_96 0x60
#define LCD_REG_97 0x61
#define LCD_REG_98 0x62
#define LCD_REG_129 0x81
#define LCD_REG_130 0x82
#define LCD_REG_132 0x84
#define LCD_REG_133 0x85
#define LCD_REG_228 0xE4
#define LCD_REG_229 0xE5
#define LCD_REG_230 0xE6
#define LCD_REG_231 0xE7
#define LCD_REG_232 0xE8
#define LCD_REG_233 0xE9
#define LCD_REG_234 0xEA
#define LCD_REG_235 0xEB
#define LCD_REG_236 0xEC
#define LCD_REG_237 0xED
#define LCD_REG_243 0xF3
#define LCD_REG_244 0xF4
#define LCD_REG_255 0xFF
/**
* @}
*/
/** @defgroup HX8347I_Exported_Functions
* @{
*/
void hx8347i_Init(void);
uint16_t hx8347i_ReadID(void);
void hx8347i_WriteReg(uint8_t LCDReg, uint16_t LCDRegValue);
uint16_t hx8347i_ReadReg(uint8_t LCDReg);
void hx8347i_DisplayOn(void);
void hx8347i_DisplayOff(void);
void hx8347i_SetCursor(uint16_t Xpos, uint16_t Ypos);
void hx8347i_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
uint16_t hx8347i_ReadPixel(uint16_t Xpos, uint16_t Ypos);
void hx8347i_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void hx8347i_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void hx8347i_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
void hx8347i_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
uint16_t hx8347i_GetLcdPixelWidth(void);
uint16_t hx8347i_GetLcdPixelHeight(void);
/* LCD driver structure */
extern LCD_DrvTypeDef hx8347i_drv;
/* LCD IO functions */
void LCD_IO_Init(void);
void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size);
void LCD_IO_WriteReg(uint8_t Reg);
uint16_t LCD_IO_ReadData(uint16_t Reg);
void LCD_Delay (uint32_t delay);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* HX8347I_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for ISS66WVH8M8 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-iss66wvh8m8-component-drivers"><small>Release Notes for</small> <mark>ISS66WVH8M8 Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the ISS66WVH8M8 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 07-August-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of HyperRAM ISS66WVH8M8 Component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,133 @@
/**
******************************************************************************
* @file iss66wvh8m8.h
* @author MCD Application Team
* @brief This file contains all the description of the ISS66WVH8M8 Octal memory.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ISS66WVH8M8_H
#define __ISS66WVH8M8_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ISS66WVH8M8
* @{
*/
/** @defgroup ISS66WVH8M8_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup ISS66WVH8M8_Exported_Constants
* @{
*/
/**
* @brief ISS66WVH8M8 Configuration
*/
#define ISS66WVH8M8_RAM_SIZE 0x800000 /* 64 MBits => 8 MBytes */
#define ISS66WVH8M8_LATENCY_83M 3
#define ISS66WVH8M8_LATENCY_100M 4
#define ISS66WVH8M8_LATENCY_133M 5
#define ISS66WVH8M8_LATENCY_166M 6
#define ISS66WVH8M8_CR0_LATENCY_83M ISS66WVH8M8_CR0_IL_3_CLOCK
#define ISS66WVH8M8_CR0_LATENCY_100M ISS66WVH8M8_CR0_IL_4_CLOCK
#define ISS66WVH8M8_CR0_LATENCY_133M ISS66WVH8M8_CR0_IL_5_CLOCK
#define ISS66WVH8M8_CR0_LATENCY_166M ISS66WVH8M8_CR0_IL_6_CLOCK
/**
* @brief ISS66WVH8M8 Registers
*/
/* Device Identification Register 0 */
#define ISS66WVH8M8_DIR0_ADDRESS ((uint32_t)0x00000000)
#define ISS66WVH8M8_DIR0_MANUFACTURER ((uint16_t)0x000F) /*!< Manufacturer */
#define ISS66WVH8M8_DIR0_CADC ((uint16_t)0x00F0) /*!< Column Address Bit Count */
#define ISS66WVH8M8_DIR0_RABC ((uint16_t)0x1F00) /*!< Row Address Bit Count */
#define ISS66WVH8M8_DIR0_DADDR ((uint16_t)0xC000) /*!< Die Address */
/* Device Identification Register 1 */
#define ISS66WVH8M8_DIR1_ADDRESS ((uint32_t)0x00000001)
#define ISS66WVH8M8_DIR1_DTYPE ((uint16_t)0x000F) /*!< Device Type */
/* Configuration Register 0 */
#define ISS66WVH8M8_CR0_ADDRESS ((uint32_t)0x00000800)
#define ISS66WVH8M8_CR0_BLENGTH ((uint16_t)0x0003) /*!< Burst length */
#define ISS66WVH8M8_CR0_HBE ((uint16_t)0x0004) /*!< Hybrid burst enable */
#define ISS66WVH8M8_CR0_FLE ((uint16_t)0x0008) /*!< Fixed latency enable */
#define ISS66WVH8M8_CR0_IL ((uint16_t)0x00F0) /*!< Initial latency */
#define ISS66WVH8M8_CR0_IL_5_CLOCK ((uint16_t)0x0000) /*!< 5 clock latency */
#define ISS66WVH8M8_CR0_IL_6_CLOCK ((uint16_t)0x0010) /*!< 6 clock latency */
#define ISS66WVH8M8_CR0_IL_3_CLOCK ((uint16_t)0x00E0) /*!< 3 clock latency */
#define ISS66WVH8M8_CR0_IL_4_CLOCK ((uint16_t)0x00F0) /*!< 4 clock latency */
#define ISS66WVH8M8_CR0_DS ((uint16_t)0x7000) /*!< Drive strength */
#define ISS66WVH8M8_CR0_DPDE ((uint16_t)0x8000) /*!< Deep Power down enable */
/* Configuration Register 1 */
#define ISS66WVH8M8_CR1_ADDRESS ((uint32_t)0x00000801)
#define ISS66WVH8M8_CR1_DRI ((uint16_t)0x0003) /*!< Distributed refresh interval */
/**
* @}
*/
/** @defgroup ISS66WVH8M8_Exported_Functions
* @{
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __ISS66WVH8M8_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for L3GD20 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-l3gd20-component-drivers"><small>Release Notes for</small> <mark>L3GD20 Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the L3GD20 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V2.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V2.0.0 / 24-June-2015</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>l3gd20.h/.c:
<ul>
<li>Add gyroscope de-initialization function: L3GD20_DeInit()</li>
<li>Add gyroscope low power configuration function: L3GD20_LowPower()</li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong> This release must be used with BSP Common driver V4.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.1.1 / 27-November-2014</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>3gd20.h: change “\” by “/” in the include path to fix compilation issue under Linux</li>
<li>Miscellaneous formatting and comments update</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section185" aria-hidden="true"> <label for="collapse-section185" aria-hidden="true">V1.1.0 / 10-June-2014</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>Update to support new revision of L3GD20 component having new device ID 0xD5 (new define added: I_AM_L3GD20_TR)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.0.0 / 18-February-2014</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>First official release of L3GD20 gyroscope</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,398 @@
/**
******************************************************************************
* @file l3gd20.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the L3GD20,
* ST MEMS motion sensor, 3-axis digital output gyroscope.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "l3gd20.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup L3GD20
* @{
*/
/** @defgroup L3GD20_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup L3GD20_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup L3GD20_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup L3GD20_Private_Variables
* @{
*/
GYRO_DrvTypeDef L3gd20Drv =
{
L3GD20_Init,
L3GD20_DeInit,
L3GD20_ReadID,
L3GD20_RebootCmd,
L3GD20_LowPower,
L3GD20_INT1InterruptConfig,
L3GD20_EnableIT,
L3GD20_DisableIT,
0,
0,
L3GD20_FilterConfig,
L3GD20_FilterCmd,
L3GD20_ReadXYZAngRate
};
/**
* @}
*/
/** @defgroup L3GD20_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup L3GD20_Private_Functions
* @{
*/
/**
* @brief Set L3GD20 Initialization.
* @param L3GD20_InitStruct: pointer to a L3GD20_InitTypeDef structure
* that contains the configuration setting for the L3GD20.
* @retval None
*/
void L3GD20_Init(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
/* Configure the low level interface */
GYRO_IO_Init();
/* Write value to MEMS CTRL_REG1 register */
ctrl = (uint8_t) InitStruct;
GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG1_ADDR, 1);
/* Write value to MEMS CTRL_REG4 register */
ctrl = (uint8_t) (InitStruct >> 8);
GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG4_ADDR, 1);
}
/**
* @brief L3GD20 De-initialization
* @param None
* @retval None
*/
void L3GD20_DeInit(void)
{
}
/**
* @brief Read ID address of L3GD20
* @param None
* @retval ID name
*/
uint8_t L3GD20_ReadID(void)
{
uint8_t tmp;
/* Configure the low level interface */
GYRO_IO_Init();
/* Read WHO I AM register */
GYRO_IO_Read(&tmp, L3GD20_WHO_AM_I_ADDR, 1);
/* Return the ID */
return (uint8_t)tmp;
}
/**
* @brief Reboot memory content of L3GD20
* @param None
* @retval None
*/
void L3GD20_RebootCmd(void)
{
uint8_t tmpreg;
/* Read CTRL_REG5 register */
GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1);
/* Enable or Disable the reboot memory */
tmpreg |= L3GD20_BOOT_REBOOTMEMORY;
/* Write value to MEMS CTRL_REG5 register */
GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1);
}
/**
* @brief Set L3GD20 in low-power mode
* @param
* @retval None
*/
void L3GD20_LowPower(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
/* Write value to MEMS CTRL_REG1 register */
ctrl = (uint8_t) InitStruct;
GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG1_ADDR, 1);
}
/**
* @brief Set L3GD20 Interrupt INT1 configuration
* @param Int1Config: the configuration setting for the L3GD20 Interrupt.
* @retval None
*/
void L3GD20_INT1InterruptConfig(uint16_t Int1Config)
{
uint8_t ctrl_cfr = 0x00, ctrl3 = 0x00;
/* Read INT1_CFG register */
GYRO_IO_Read(&ctrl_cfr, L3GD20_INT1_CFG_ADDR, 1);
/* Read CTRL_REG3 register */
GYRO_IO_Read(&ctrl3, L3GD20_CTRL_REG3_ADDR, 1);
ctrl_cfr &= 0x80;
ctrl_cfr |= ((uint8_t) Int1Config >> 8);
ctrl3 &= 0xDF;
ctrl3 |= ((uint8_t) Int1Config);
/* Write value to MEMS INT1_CFG register */
GYRO_IO_Write(&ctrl_cfr, L3GD20_INT1_CFG_ADDR, 1);
/* Write value to MEMS CTRL_REG3 register */
GYRO_IO_Write(&ctrl3, L3GD20_CTRL_REG3_ADDR, 1);
}
/**
* @brief Enable INT1 or INT2 interrupt
* @param IntSel: choice of INT1 or INT2
* This parameter can be:
* @arg L3GD20_INT1
* @arg L3GD20_INT2
* @retval None
*/
void L3GD20_EnableIT(uint8_t IntSel)
{
uint8_t tmpreg;
/* Read CTRL_REG3 register */
GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1);
if(IntSel == L3GD20_INT1)
{
tmpreg &= 0x7F;
tmpreg |= L3GD20_INT1INTERRUPT_ENABLE;
}
else if(IntSel == L3GD20_INT2)
{
tmpreg &= 0xF7;
tmpreg |= L3GD20_INT2INTERRUPT_ENABLE;
}
/* Write value to MEMS CTRL_REG3 register */
GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1);
}
/**
* @brief Disable INT1 or INT2 interrupt
* @param IntSel: choice of INT1 or INT2
* This parameter can be:
* @arg L3GD20_INT1
* @arg L3GD20_INT2
* @retval None
*/
void L3GD20_DisableIT(uint8_t IntSel)
{
uint8_t tmpreg;
/* Read CTRL_REG3 register */
GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1);
if(IntSel == L3GD20_INT1)
{
tmpreg &= 0x7F;
tmpreg |= L3GD20_INT1INTERRUPT_DISABLE;
}
else if(IntSel == L3GD20_INT2)
{
tmpreg &= 0xF7;
tmpreg |= L3GD20_INT2INTERRUPT_DISABLE;
}
/* Write value to MEMS CTRL_REG3 register */
GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1);
}
/**
* @brief Set High Pass Filter Modality
* @param FilterStruct: contains the configuration setting for the L3GD20.
* @retval None
*/
void L3GD20_FilterConfig(uint8_t FilterStruct)
{
uint8_t tmpreg;
/* Read CTRL_REG2 register */
GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG2_ADDR, 1);
tmpreg &= 0xC0;
/* Configure MEMS: mode and cutoff frequency */
tmpreg |= FilterStruct;
/* Write value to MEMS CTRL_REG2 register */
GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG2_ADDR, 1);
}
/**
* @brief Enable or Disable High Pass Filter
* @param HighPassFilterState: new state of the High Pass Filter feature.
* This parameter can be:
* @arg: L3GD20_HIGHPASSFILTER_DISABLE
* @arg: L3GD20_HIGHPASSFILTER_ENABLE
* @retval None
*/
void L3GD20_FilterCmd(uint8_t HighPassFilterState)
{
uint8_t tmpreg;
/* Read CTRL_REG5 register */
GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1);
tmpreg &= 0xEF;
tmpreg |= HighPassFilterState;
/* Write value to MEMS CTRL_REG5 register */
GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1);
}
/**
* @brief Get status for L3GD20 data
* @param None
* @retval Data status in a L3GD20 Data
*/
uint8_t L3GD20_GetDataStatus(void)
{
uint8_t tmpreg;
/* Read STATUS_REG register */
GYRO_IO_Read(&tmpreg, L3GD20_STATUS_REG_ADDR, 1);
return tmpreg;
}
/**
* @brief Calculate the L3GD20 angular data.
* @param pfData: Data out pointer
* @retval None
*/
void L3GD20_ReadXYZAngRate(float *pfData)
{
uint8_t tmpbuffer[6] ={0};
int16_t RawData[3] = {0};
uint8_t tmpreg = 0;
float sensitivity = 0;
int i =0;
GYRO_IO_Read(&tmpreg,L3GD20_CTRL_REG4_ADDR,1);
GYRO_IO_Read(tmpbuffer,L3GD20_OUT_X_L_ADDR,6);
/* check in the control register 4 the data alignment (Big Endian or Little Endian)*/
if(!(tmpreg & L3GD20_BLE_MSB))
{
for(i=0; i<3; i++)
{
RawData[i]=(int16_t)(((uint16_t)tmpbuffer[2*i+1] << 8) + tmpbuffer[2*i]);
}
}
else
{
for(i=0; i<3; i++)
{
RawData[i]=(int16_t)(((uint16_t)tmpbuffer[2*i] << 8) + tmpbuffer[2*i+1]);
}
}
/* Switch the sensitivity value set in the CRTL4 */
switch(tmpreg & L3GD20_FULLSCALE_SELECTION)
{
case L3GD20_FULLSCALE_250:
sensitivity=L3GD20_SENSITIVITY_250DPS;
break;
case L3GD20_FULLSCALE_500:
sensitivity=L3GD20_SENSITIVITY_500DPS;
break;
case L3GD20_FULLSCALE_2000:
sensitivity=L3GD20_SENSITIVITY_2000DPS;
break;
}
/* Divide by sensitivity */
for(i=0; i<3; i++)
{
pfData[i]=(float)(RawData[i] * sensitivity);
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,306 @@
/**
******************************************************************************
* @file l3gd20.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the l3gd20.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __L3GD20_H
#define __L3GD20_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/gyro.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup L3GD20
* @{
*/
/** @defgroup L3GD20_Exported_Constants
* @{
*/
/******************************************************************************/
/*************************** START REGISTER MAPPING **************************/
/******************************************************************************/
#define L3GD20_WHO_AM_I_ADDR 0x0F /* device identification register */
#define L3GD20_CTRL_REG1_ADDR 0x20 /* Control register 1 */
#define L3GD20_CTRL_REG2_ADDR 0x21 /* Control register 2 */
#define L3GD20_CTRL_REG3_ADDR 0x22 /* Control register 3 */
#define L3GD20_CTRL_REG4_ADDR 0x23 /* Control register 4 */
#define L3GD20_CTRL_REG5_ADDR 0x24 /* Control register 5 */
#define L3GD20_REFERENCE_REG_ADDR 0x25 /* Reference register */
#define L3GD20_OUT_TEMP_ADDR 0x26 /* Out temp register */
#define L3GD20_STATUS_REG_ADDR 0x27 /* Status register */
#define L3GD20_OUT_X_L_ADDR 0x28 /* Output Register X */
#define L3GD20_OUT_X_H_ADDR 0x29 /* Output Register X */
#define L3GD20_OUT_Y_L_ADDR 0x2A /* Output Register Y */
#define L3GD20_OUT_Y_H_ADDR 0x2B /* Output Register Y */
#define L3GD20_OUT_Z_L_ADDR 0x2C /* Output Register Z */
#define L3GD20_OUT_Z_H_ADDR 0x2D /* Output Register Z */
#define L3GD20_FIFO_CTRL_REG_ADDR 0x2E /* Fifo control Register */
#define L3GD20_FIFO_SRC_REG_ADDR 0x2F /* Fifo src Register */
#define L3GD20_INT1_CFG_ADDR 0x30 /* Interrupt 1 configuration Register */
#define L3GD20_INT1_SRC_ADDR 0x31 /* Interrupt 1 source Register */
#define L3GD20_INT1_TSH_XH_ADDR 0x32 /* Interrupt 1 Threshold X register */
#define L3GD20_INT1_TSH_XL_ADDR 0x33 /* Interrupt 1 Threshold X register */
#define L3GD20_INT1_TSH_YH_ADDR 0x34 /* Interrupt 1 Threshold Y register */
#define L3GD20_INT1_TSH_YL_ADDR 0x35 /* Interrupt 1 Threshold Y register */
#define L3GD20_INT1_TSH_ZH_ADDR 0x36 /* Interrupt 1 Threshold Z register */
#define L3GD20_INT1_TSH_ZL_ADDR 0x37 /* Interrupt 1 Threshold Z register */
#define L3GD20_INT1_DURATION_ADDR 0x38 /* Interrupt 1 DURATION register */
/******************************************************************************/
/**************************** END REGISTER MAPPING ***************************/
/******************************************************************************/
#define I_AM_L3GD20 ((uint8_t)0xD4)
#define I_AM_L3GD20_TR ((uint8_t)0xD5)
/** @defgroup Power_Mode_selection
* @{
*/
#define L3GD20_MODE_POWERDOWN ((uint8_t)0x00)
#define L3GD20_MODE_ACTIVE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup OutPut_DataRate_Selection
* @{
*/
#define L3GD20_OUTPUT_DATARATE_1 ((uint8_t)0x00)
#define L3GD20_OUTPUT_DATARATE_2 ((uint8_t)0x40)
#define L3GD20_OUTPUT_DATARATE_3 ((uint8_t)0x80)
#define L3GD20_OUTPUT_DATARATE_4 ((uint8_t)0xC0)
/**
* @}
*/
/** @defgroup Axes_Selection
* @{
*/
#define L3GD20_X_ENABLE ((uint8_t)0x02)
#define L3GD20_Y_ENABLE ((uint8_t)0x01)
#define L3GD20_Z_ENABLE ((uint8_t)0x04)
#define L3GD20_AXES_ENABLE ((uint8_t)0x07)
#define L3GD20_AXES_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Bandwidth_Selection
* @{
*/
#define L3GD20_BANDWIDTH_1 ((uint8_t)0x00)
#define L3GD20_BANDWIDTH_2 ((uint8_t)0x10)
#define L3GD20_BANDWIDTH_3 ((uint8_t)0x20)
#define L3GD20_BANDWIDTH_4 ((uint8_t)0x30)
/**
* @}
*/
/** @defgroup Full_Scale_Selection
* @{
*/
#define L3GD20_FULLSCALE_250 ((uint8_t)0x00)
#define L3GD20_FULLSCALE_500 ((uint8_t)0x10)
#define L3GD20_FULLSCALE_2000 ((uint8_t)0x20)
#define L3GD20_FULLSCALE_SELECTION ((uint8_t)0x30)
/**
* @}
*/
/** @defgroup Full_Scale_Sensitivity
* @{
*/
#define L3GD20_SENSITIVITY_250DPS ((float)8.75f) /*!< gyroscope sensitivity with 250 dps full scale [DPS/LSB] */
#define L3GD20_SENSITIVITY_500DPS ((float)17.50f) /*!< gyroscope sensitivity with 500 dps full scale [DPS/LSB] */
#define L3GD20_SENSITIVITY_2000DPS ((float)70.00f) /*!< gyroscope sensitivity with 2000 dps full scale [DPS/LSB] */
/**
* @}
*/
/** @defgroup Block_Data_Update
* @{
*/
#define L3GD20_BlockDataUpdate_Continous ((uint8_t)0x00)
#define L3GD20_BlockDataUpdate_Single ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup Endian_Data_selection
* @{
*/
#define L3GD20_BLE_LSB ((uint8_t)0x00)
#define L3GD20_BLE_MSB ((uint8_t)0x40)
/**
* @}
*/
/** @defgroup High_Pass_Filter_status
* @{
*/
#define L3GD20_HIGHPASSFILTER_DISABLE ((uint8_t)0x00)
#define L3GD20_HIGHPASSFILTER_ENABLE ((uint8_t)0x10)
/**
* @}
*/
/** @defgroup INT1_INT2_selection
* @{
*/
#define L3GD20_INT1 ((uint8_t)0x00)
#define L3GD20_INT2 ((uint8_t)0x01)
/**
* @}
*/
/** @defgroup INT1_Interrupt_status
* @{
*/
#define L3GD20_INT1INTERRUPT_DISABLE ((uint8_t)0x00)
#define L3GD20_INT1INTERRUPT_ENABLE ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup INT2_Interrupt_status
* @{
*/
#define L3GD20_INT2INTERRUPT_DISABLE ((uint8_t)0x00)
#define L3GD20_INT2INTERRUPT_ENABLE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup INT1_Interrupt_ActiveEdge
* @{
*/
#define L3GD20_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20)
#define L3GD20_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Boot_Mode_selection
* @{
*/
#define L3GD20_BOOT_NORMALMODE ((uint8_t)0x00)
#define L3GD20_BOOT_REBOOTMEMORY ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup High_Pass_Filter_Mode
* @{
*/
#define L3GD20_HPM_NORMAL_MODE_RES ((uint8_t)0x00)
#define L3GD20_HPM_REF_SIGNAL ((uint8_t)0x10)
#define L3GD20_HPM_NORMAL_MODE ((uint8_t)0x20)
#define L3GD20_HPM_AUTORESET_INT ((uint8_t)0x30)
/**
* @}
*/
/** @defgroup High_Pass_CUT OFF_Frequency
* @{
*/
#define L3GD20_HPFCF_0 0x00
#define L3GD20_HPFCF_1 0x01
#define L3GD20_HPFCF_2 0x02
#define L3GD20_HPFCF_3 0x03
#define L3GD20_HPFCF_4 0x04
#define L3GD20_HPFCF_5 0x05
#define L3GD20_HPFCF_6 0x06
#define L3GD20_HPFCF_7 0x07
#define L3GD20_HPFCF_8 0x08
#define L3GD20_HPFCF_9 0x09
/**
* @}
*/
/**
* @}
*/
/** @defgroup L3GD20_Exported_Functions
* @{
*/
/* Sensor Configuration Functions */
void L3GD20_Init(uint16_t InitStruct);
void L3GD20_DeInit(void);
void L3GD20_LowPower(uint16_t InitStruct);
uint8_t L3GD20_ReadID(void);
void L3GD20_RebootCmd(void);
/* Interrupt Configuration Functions */
void L3GD20_INT1InterruptConfig(uint16_t Int1Config);
void L3GD20_EnableIT(uint8_t IntSel);
void L3GD20_DisableIT(uint8_t IntSel);
/* High Pass Filter Configuration Functions */
void L3GD20_FilterConfig(uint8_t FilterStruct);
void L3GD20_FilterCmd(uint8_t HighPassFilterState);
void L3GD20_ReadXYZAngRate(float *pfData);
uint8_t L3GD20_GetDataStatus(void);
/* Gyroscope IO functions */
void GYRO_IO_Init(void);
void GYRO_IO_DeInit(void);
void GYRO_IO_Write(uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite);
void GYRO_IO_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead);
/* Gyroscope driver structure */
extern GYRO_DrvTypeDef L3gd20Drv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __L3GD20_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LIS3MDL Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-lis3mdl-component-drivers"><small>Release Notes for</small> <mark>LIS3MDL Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LIS3MDL component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 07-August-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of LIS3MDL Magnetometer sensor</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,202 @@
/**
******************************************************************************
* @file lis3mdl.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the LIS3MDL
* magnetometer devices
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lis3mdl.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup LIS3MDL LIS3MDL
* @{
*/
/** @defgroup LIS3MDL_Mag_Private_Variables LIS3MDL Mag Private Variables
* @{
*/
MAGNETO_DrvTypeDef Lis3mdlMagDrv =
{
LIS3MDL_MagInit,
LIS3MDL_MagDeInit,
LIS3MDL_MagReadID,
0,
LIS3MDL_MagLowPower,
0,
0,
0,
0,
0,
0,
0,
LIS3MDL_MagReadXYZ
};
/**
* @}
*/
/** @defgroup LIS3MDL_Mag_Private_Functions LIS3MDL Mag Private Functions
* @{
*/
/**
* @brief Set LIS3MDL Magnetometer Initialization.
* @param LIS3MDL_InitStruct: pointer to a LIS3MDL_MagInitTypeDef structure
* that contains the configuration setting for the LIS3MDL.
*/
void LIS3MDL_MagInit(MAGNETO_InitTypeDef LIS3MDL_InitStruct)
{
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG1, LIS3MDL_InitStruct.Register1);
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG2, LIS3MDL_InitStruct.Register2);
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG3, LIS3MDL_InitStruct.Register3);
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG4, LIS3MDL_InitStruct.Register4);
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG5, LIS3MDL_InitStruct.Register5);
}
/**
* @brief LIS3MDL Magnetometer De-initialization.
*/
void LIS3MDL_MagDeInit(void)
{
uint8_t ctrl = 0x00;
/* Read control register 1 value */
ctrl = SENSOR_IO_Read(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG3);
/* Clear Selection Mode bits */
ctrl &= ~(LIS3MDL_MAG_SELECTION_MODE);
/* Set Power down */
ctrl |= LIS3MDL_MAG_POWERDOWN2_MODE;
/* write back control register */
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG3, ctrl);
}
/**
* @brief Read LIS3MDL ID.
* @retval ID
*/
uint8_t LIS3MDL_MagReadID(void)
{
/* IO interface initialization */
SENSOR_IO_Init();
/* Read value at Who am I register address */
return (SENSOR_IO_Read(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_WHO_AM_I_REG));
}
/**
* @brief Set/Unset Magnetometer in low power mode.
* @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
*/
void LIS3MDL_MagLowPower(uint16_t status)
{
uint8_t ctrl = 0;
/* Read control register 1 value */
ctrl = SENSOR_IO_Read(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG3);
/* Clear Low Power Mode bit */
ctrl &= ~(0x20);
/* Set Low Power Mode */
if(status)
{
ctrl |= LIS3MDL_MAG_CONFIG_LOWPOWER_MODE;
}else
{
ctrl |= LIS3MDL_MAG_CONFIG_NORMAL_MODE;
}
/* write back control register */
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG3, ctrl);
}
/**
* @brief Read X, Y & Z Magnetometer values
* @param pData: Data out pointer
*/
void LIS3MDL_MagReadXYZ(int16_t* pData)
{
int16_t pnRawData[3];
uint8_t ctrlm= 0;
uint8_t buffer[6];
uint8_t i = 0;
float sensitivity = 0;
/* Read the magnetometer control register content */
ctrlm = SENSOR_IO_Read(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG2);
/* Read output register X, Y & Z acceleration */
SENSOR_IO_ReadMultiple(LIS3MDL_MAG_I2C_ADDRESS_HIGH, (LIS3MDL_MAG_OUTX_L | 0x80), buffer, 6);
for(i=0; i<3; i++)
{
pnRawData[i]=((((uint16_t)buffer[2*i+1]) << 8) + (uint16_t)buffer[2*i]);
}
/* Normal mode */
/* Switch the sensitivity value set in the CRTL_REG2 */
switch(ctrlm & 0x60)
{
case LIS3MDL_MAG_FS_4_GA:
sensitivity = LIS3MDL_MAG_SENSITIVITY_FOR_FS_4GA;
break;
case LIS3MDL_MAG_FS_8_GA:
sensitivity = LIS3MDL_MAG_SENSITIVITY_FOR_FS_8GA;
break;
case LIS3MDL_MAG_FS_12_GA:
sensitivity = LIS3MDL_MAG_SENSITIVITY_FOR_FS_12GA;
break;
case LIS3MDL_MAG_FS_16_GA:
sensitivity = LIS3MDL_MAG_SENSITIVITY_FOR_FS_16GA;
break;
}
/* Obtain the mGauss value for the three axis */
for(i=0; i<3; i++)
{
pData[i]=( int16_t )(pnRawData[i] * sensitivity);
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,214 @@
/**
******************************************************************************
* @file lis3mdl.h
* @author MCD Application Team
* @brief LIS3MDL header driver file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LIS3MDL__H
#define __LIS3MDL__H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/magneto.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup LIS3MDL
* @{
*/
/** @defgroup LIS3MDL_Exported_Constants LIS3MDL Exported Constants
* @{
*/
/************** I2C Address *****************/
#define LIS3MDL_MAG_I2C_ADDRESS_LOW ((uint8_t)0x38) // SAD[0] = 0
#define LIS3MDL_MAG_I2C_ADDRESS_HIGH ((uint8_t)0x3C) // SAD[0] = 1
/************** Who am I *******************/
#define I_AM_LIS3MDL ((uint8_t)0x3D)
/************** Device Register *******************/
#define LIS3MDL_MAG_WHO_AM_I_REG 0x0F
#define LIS3MDL_MAG_CTRL_REG1 0x20
#define LIS3MDL_MAG_CTRL_REG2 0x21
#define LIS3MDL_MAG_CTRL_REG3 0x22
#define LIS3MDL_MAG_CTRL_REG4 0x23
#define LIS3MDL_MAG_CTRL_REG5 0x24
#define LIS3MDL_MAG_STATUS_REG 0x27
#define LIS3MDL_MAG_OUTX_L 0x28
#define LIS3MDL_MAG_OUTX_H 0x29
#define LIS3MDL_MAG_OUTY_L 0x2A
#define LIS3MDL_MAG_OUTY_H 0x2B
#define LIS3MDL_MAG_OUTZ_L 0x2C
#define LIS3MDL_MAG_OUTZ_H 0x2D
#define LIS3MDL_MAG_TEMP_OUT_L 0x2E
#define LIS3MDL_MAG_TEMP_OUT_H 0x2F
#define LIS3MDL_MAG_INT_CFG 0x30
#define LIS3MDL_MAG_INT_SRC 0x31
#define LIS3MDL_MAG_INT_THS_L 0x32
#define LIS3MDL_MAG_INT_THS_H 0x33
/* Mag Temperature Sensor Control*/
#define LIS3MDL_MAG_TEMPSENSOR_ENABLE ((uint8_t) 0x80) /*!< Temp sensor Enable */
#define LIS3MDL_MAG_TEMPSENSOR_DISABLE ((uint8_t) 0x00) /*!< Temp sensor Disable */
/* Mag_XY-axis Operating Mode */
#define LIS3MDL_MAG_OM_XY_LOWPOWER ((uint8_t) 0x00)
#define LIS3MDL_MAG_OM_XY_MEDIUM ((uint8_t) 0x20)
#define LIS3MDL_MAG_OM_XY_HIGH ((uint8_t) 0x40)
#define LIS3MDL_MAG_OM_XY_ULTRAHIGH ((uint8_t) 0x60)
/* Mag Data Rate */
#define LIS3MDL_MAG_ODR_0_625_HZ ((uint8_t) 0x00) /*!< Output Data Rate = 0.625 Hz */
#define LIS3MDL_MAG_ODR_1_25_HZ ((uint8_t) 0x04) /*!< Output Data Rate = 1.25 Hz */
#define LIS3MDL_MAG_ODR_2_5_HZ ((uint8_t) 0x08) /*!< Output Data Rate = 2.5 Hz */
#define LIS3MDL_MAG_ODR_5_0_HZ ((uint8_t) 0x0C) /*!< Output Data Rate = 5.0 Hz */
#define LIS3MDL_MAG_ODR_10_HZ ((uint8_t) 0x10) /*!< Output Data Rate = 10 Hz */
#define LIS3MDL_MAG_ODR_20_HZ ((uint8_t) 0x14) /*!< Output Data Rate = 20 Hz */
#define LIS3MDL_MAG_ODR_40_HZ ((uint8_t) 0x18) /*!< Output Data Rate = 40 Hz */
#define LIS3MDL_MAG_ODR_80_HZ ((uint8_t) 0x1C) /*!< Output Data Rate = 80 Hz */
/* Mag Data Rate */
#define LMS303C_MAG_SELFTEST_DISABLE ((uint8_t 0x00)
#define LMS303C_MAG_SELFTEST_ENABLE ((uint8_t 0x01)
/* Mag Full Scale */
#define LIS3MDL_MAG_FS_DEFAULT ((uint8_t) 0x00)
#define LIS3MDL_MAG_FS_4_GA ((uint8_t) 0x00)
#define LIS3MDL_MAG_FS_8_GA ((uint8_t) 0x20)
#define LIS3MDL_MAG_FS_12_GA ((uint8_t) 0x40)
#define LIS3MDL_MAG_FS_16_GA ((uint8_t) 0x60) /*!< Full scale = <20>16 Gauss */
/* Mag_Reboot */
#define LIS3MDL_MAG_REBOOT_DEFAULT ((uint8_t) 0x00)
#define LIS3MDL_MAG_REBOOT_ENABLE ((uint8_t) 0x08)
/* Mag Soft reset */
#define LIS3MDL_MAG_SOFT_RESET_DEFAULT ((uint8_t) 0x00)
#define LIS3MDL_MAG_SOFT_RESET_ENABLE ((uint8_t) 0x04)
/* Mag_Communication_Mode */
#define LIS3MDL_MAG_SIM_4_WIRE ((uint8_t) 0x00)
#define LIS3MDL_MAG_SIM_3_WIRE ((uint8_t) 0x04)
/* Mag Lowpower mode config */
#define LIS3MDL_MAG_CONFIG_NORMAL_MODE ((uint8_t) 0x00)
#define LIS3MDL_MAG_CONFIG_LOWPOWER_MODE ((uint8_t) 0x20)
/* Mag Operation Mode */
#define LIS3MDL_MAG_SELECTION_MODE ((uint8_t) 0x03) /* CTRL_REG3 */
#define LIS3MDL_MAG_CONTINUOUS_MODE ((uint8_t) 0x00)
#define LIS3MDL_MAG_SINGLE_MODE ((uint8_t) 0x01)
#define LIS3MDL_MAG_POWERDOWN1_MODE ((uint8_t) 0x02)
#define LIS3MDL_MAG_POWERDOWN2_MODE ((uint8_t) 0x03)
/* Mag_Z-axis Operation Mode */
#define LIS3MDL_MAG_OM_Z_LOWPOWER ((uint8_t) 0x00)
#define LIS3MDL_MAG_OM_Z_MEDIUM ((uint8_t) 0x04)
#define LIS3MDL_MAG_OM_Z_HIGH ((uint8_t) 0x08)
#define LIS3MDL_MAG_OM_Z_ULTRAHIGH ((uint8_t) 0x0C)
/* Mag Big little-endian selection */
#define LIS3MDL_MAG_BLE_LSB ((uint8_t) 0x00)
#define LIS3MDL_MAG_BLE_MSB ((uint8_t) 0x02)
/* Mag_Bloc_update_magnetic_data */
#define LIS3MDL_MAG_BDU_CONTINUOUS ((uint8_t) 0x00)
#define LIS3MDL_MAG_BDU_MSBLSB ((uint8_t) 0x40)
/* Magnetometer_Sensitivity */
#define LIS3MDL_MAG_SENSITIVITY_FOR_FS_4GA ((float)0.14f) /**< Sensitivity value for 4 gauss full scale [mgauss/LSB] */
#define LIS3MDL_MAG_SENSITIVITY_FOR_FS_8GA ((float)0.29f) /**< Sensitivity value for 8 gauss full scale [mgauss/LSB] */
#define LIS3MDL_MAG_SENSITIVITY_FOR_FS_12GA ((float)0.43f) /**< Sensitivity value for 12 gauss full scale [mgauss/LSB] */
#define LIS3MDL_MAG_SENSITIVITY_FOR_FS_16GA ((float)0.58f) /**< Sensitivity value for 16 gauss full scale [mgauss/LSB] */
/**
* @}
*/
/** @defgroup LIS3MDL_Exported_Functions LIS3MDL Exported Functions
* @{
*/
void LIS3MDL_MagInit(MAGNETO_InitTypeDef LIS3MDL_InitStruct);
void LIS3MDL_MagDeInit(void);
uint8_t LIS3MDL_MagReadID(void);
void LIS3MDL_MagLowPower(uint16_t status);
void LIS3MDL_MagReadXYZ(int16_t* pData);
/**
* @}
*/
/** @defgroup LIS3MDL_Imported_Functions LIS3MDL Imported Functions
* @{
*/
/* IO functions */
extern void SENSOR_IO_Init(void);
extern void SENSOR_IO_DeInit(void);
extern void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
/**
* @}
*/
/** @defgroup LIS3MDL_Imported_Globals Imported Globals
* @{
*/
/* MAG driver structure */
extern MAGNETO_DrvTypeDef Lis3mdlMagDrv;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LIS3MDL__H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LPS22HB Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-lps22hb-component-drivers"><small>Release Notes for</small> <mark>LPS22HB Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LPS22HB component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 14-February-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of LPS22HB Temperature/Pressure sensor</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,228 @@
/**
******************************************************************************
* @file lps22hb.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the LPS22HB
* pressure and temperature devices
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lps22hb.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup LPS22HB LPS22HB
* @{
*/
/** @defgroup LPS22HB_Private_FunctionsPrototypes LPS22HB Private Functions Prototypes
* @{
*/
static void LPS22HB_Init(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup LPS22HB_Private_Variables LPS22HB Private Variables
* @{
*/
/* Pressure Private Variables */
PSENSOR_DrvTypeDef LPS22HB_P_Drv =
{
LPS22HB_P_Init,
LPS22HB_P_ReadID,
LPS22HB_P_ReadPressure
};
/* Temperature Private Variables */
TSENSOR_DrvTypeDef LPS22HB_T_Drv =
{
LPS22HB_T_Init,
0,
0,
LPS22HB_T_ReadTemp
};
/**
* @}
*/
/** @defgroup LPS22HB_Pressure_Private_Functions LPS22HB Pressure Private Functions
* @{
*/
/**
* @brief Set LPS22HB pressure sensor Initialization.
*/
void LPS22HB_P_Init(uint16_t DeviceAddr)
{
LPS22HB_Init(DeviceAddr);
}
/**
* @brief Read LPS22HB ID.
* @retval ID
*/
uint8_t LPS22HB_P_ReadID(uint16_t DeviceAddr)
{
uint8_t ctrl = 0x00;
/* IO interface initialization */
SENSOR_IO_Init();
/* Read value at Who am I register address */
ctrl = SENSOR_IO_Read(DeviceAddr, LPS22HB_WHO_AM_I_REG);
return ctrl;
}
/**
* @brief Read pressure value of LPS22HB
* @retval pressure value
*/
float LPS22HB_P_ReadPressure(uint16_t DeviceAddr)
{
int32_t raw_press;
uint8_t buffer[3];
uint32_t tmp = 0;
uint8_t i;
for(i = 0; i < 3; i++)
{
buffer[i] = SENSOR_IO_Read(DeviceAddr, (LPS22HB_PRESS_OUT_XL_REG + i));
}
/* Build the raw data */
for(i = 0; i < 3; i++)
tmp |= (((uint32_t)buffer[i]) << (8 * i));
/* convert the 2's complement 24 bit to 2's complement 32 bit */
if(tmp & 0x00800000)
tmp |= 0xFF000000;
raw_press = ((int32_t)tmp);
raw_press = (raw_press * 100) / 4096;
return (float)((float)raw_press / 100.0f);
}
/**
* @}
*/
/** @defgroup LPS22HB_Temperature_Private_Functions LPS22HB Temperature Private Functions
* @{
*/
/**
* @brief Set LPS22HB temperature sensor Initialization.
* @param DeviceAddr: I2C device address
* @param InitStruct: pointer to a TSENSOR_InitTypeDef structure
* that contains the configuration setting for the HTS221.
* @retval None
*/
void LPS22HB_T_Init(uint16_t DeviceAddr, TSENSOR_InitTypeDef *pInitStruct)
{
LPS22HB_Init(DeviceAddr);
}
/**
* @brief Read temperature value of LPS22HB
* @param DeviceAddr: I2C device address
* @retval temperature value
*/
float LPS22HB_T_ReadTemp(uint16_t DeviceAddr)
{
int16_t raw_data;
uint8_t buffer[2];
uint16_t tmp;
uint8_t i;
for(i = 0; i < 2; i++)
{
buffer[i] = SENSOR_IO_Read(DeviceAddr, (LPS22HB_TEMP_OUT_L_REG + i));
}
/* Build the raw tmp */
tmp = (((uint16_t)buffer[1]) << 8) + (uint16_t)buffer[0];
raw_data = (tmp * 10) / 100;
return ((float)(raw_data / 10.0f));
}
/**
* @}
*/
/** @addtogroup LPS22HB_Private_Functions LPS22HB Private functions
* @{
*/
/**
* @brief Set LPS22HB Initialization.
* @param DeviceAddr: I2C device address
* @retval None
*/
static void LPS22HB_Init(uint16_t DeviceAddr)
{
uint8_t tmp;
/* Set Power mode */
tmp = SENSOR_IO_Read(DeviceAddr, LPS22HB_RES_CONF_REG);
tmp &= ~LPS22HB_LCEN_MASK;
tmp |= (uint8_t)0x01; /* Set low current mode */
SENSOR_IO_Write(DeviceAddr, LPS22HB_RES_CONF_REG, tmp);
/* Read CTRL_REG1 */
tmp = SENSOR_IO_Read(DeviceAddr, LPS22HB_CTRL_REG1);
/* Set default ODR */
tmp &= ~LPS22HB_ODR_MASK;
tmp |= (uint8_t)0x30; /* Set ODR to 25Hz */
/* Enable BDU */
tmp &= ~LPS22HB_BDU_MASK;
tmp |= ((uint8_t)0x02);
/* Apply settings to CTRL_REG1 */
SENSOR_IO_Write(DeviceAddr, LPS22HB_CTRL_REG1, tmp);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,516 @@
/**
******************************************************************************
* @file lps22hb.h
* @author MCD Application Team
* @brief LPS22HB header driver file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LPS22HB__H
#define __LPS22HB__H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/psensor.h"
#include "../Common/tsensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup LPS22HB
* @{
*/
/** @defgroup LPS22HB_Exported_Macros LPS22HB Exported Macros
* @{
*/
/**
* @brief Bitfield positioning.
*/
#define LPS22HB_BIT(x) ((uint8_t)x)
/**
* @}
*/
/** @defgroup LPS22HB_Exported_Constants LPS22HB Exported Constants
* @{
*/
/**
* @brief Device Identification register.
* Read
* Default value: 0xB1
* 7:0 This read-only register contains the device identifier that, for LPS22HB, is set to B1h.
*/
#define LPS22HB_WHO_AM_I_REG (uint8_t)0x0F
/**
* @brief Device Identification value.
*/
#define LPS22HB_WHO_AM_I_VAL (uint8_t)0xB1
/**
* @brief Reference Pressure Register(LSB data)
* Read/write
* Default value: 0x00
* 7:0 REFL7-0: Lower part of the reference pressure value that
* is sum to the sensor output pressure.
*/
#define LPS22HB_REF_P_XL_REG (uint8_t)0x15
/**
* @brief Reference Pressure Register (Middle data)
* Read/write
* Default value: 0x00
* 7:0 REFL15-8: Middle part of the reference pressure value that
* is sum to the sensor output pressure.
*/
#define LPS22HB_REF_P_L_REG (uint8_t)0x16
/**
* @brief Reference Pressure Register (MSB data)
* Read/write
* Default value: 0x00
* 7:0 REFL23-16 Higest part of the reference pressure value that
* is sum to the sensor output pressure.
*/
#define LPS22HB_REF_P_H_REG (uint8_t)0x17
/**
* @brief Pressure and temperature resolution mode Register
* Read/write
* Default value: 0x05
* 7:2 These bits must be set to 0 for proper operation of the device
* 1: Reserved
* 0 LC_EN: Low Current Mode Enable. Default 0
*/
#define LPS22HB_RES_CONF_REG (uint8_t)0x1A
#define LPS22HB_LCEN_MASK (uint8_t)0x01
/**
* @brief Control Register 1
* Read/write
* Default value: 0x00
* 7: This bit must be set to 0 for proper operation of the device
* 6:4 ODR2, ODR1, ODR0: output data rate selection.Default 000
* ODR2 | ODR1 | ODR0 | Pressure output data-rate(Hz) | Pressure output data-rate(Hz)
* ----------------------------------------------------------------------------------
* 0 | 0 | 0 | one shot | one shot
* 0 | 0 | 1 | 1 | 1
* 0 | 1 | 0 | 10 | 10
* 0 | 1 | 1 | 25 | 25
* 1 | 0 | 0 | 50 | 50
* 1 | 0 | 1 | 75 | 75
* 1 | 1 | 0 | Reserved | Reserved
* 1 | 1 | 1 | Reserved | Reserved
*
* 3 EN_LPFP: Enable Low Pass filter on Pressure data. Default value:0
* 2:LPF_CFG Low-pass configuration register. (0: Filter cutoff is ODR/9; 1: filter cutoff is ODR/20)
* 1 BDU: block data update. 0 - continuous update; 1 - output registers not updated until MSB and LSB reading.
* 0 SIM: SPI Serial Interface Mode selection. 0 - SPI 4-wire; 1 - SPI 3-wire
*/
#define LPS22HB_CTRL_REG1 (uint8_t)0x10
#define LPS22HB_ODR_MASK (uint8_t)0x70
#define LPS22HB_LPFP_MASK (uint8_t)0x08
#define LPS22HB_LPFP_CUTOFF_MASK (uint8_t)0x04
#define LPS22HB_BDU_MASK (uint8_t)0x02
#define LPS22HB_SIM_MASK (uint8_t)0x01
#define LPS22HB_LPFP_BIT LPS22HB_BIT(3)
/**
* @brief Control Register 2
* Read/write
* Default value: 0x10
* 7 BOOT: Reboot memory content. 0: normal mode; 1: reboot memory content. Self-clearing upon completation
* 6 FIFO_EN: FIFO Enable. 0: disable; 1: enable
* 5 STOP_ON_FTH: Stop on FIFO Threshold FIFO Watermark level use. 0: disable; 1: enable
* 4 IF_ADD_INC: Register address automatically incrementeed during a multiple byte access with a serial interface (I2C or SPI).
* Default value 1.( 0: disable; 1: enable)
* 3 I2C DIS: Disable I2C interface 0: I2C Enabled; 1: I2C disabled
* 2 SWRESET: Software reset. 0: normal mode; 1: SW reset. Self-clearing upon completation
* 1 AUTO_ZERO: Autozero enable. 0: normal mode; 1: autozero enable.
* 0 ONE_SHOT: One shot enable. 0: waiting for start of conversion; 1: start for a new dataset
*/
#define LPS22HB_CTRL_REG2 (uint8_t)0x11
#define LPS22HB_BOOT_BIT LPS22HB_BIT(7)
#define LPS22HB_FIFO_EN_BIT LPS22HB_BIT(6)
#define LPS22HB_WTM_EN_BIT LPS22HB_BIT(5)
#define LPS22HB_ADD_INC_BIT LPS22HB_BIT(4)
#define LPS22HB_I2C_BIT LPS22HB_BIT(3)
#define LPS22HB_SW_RESET_BIT LPS22HB_BIT(2)
#define LPS22HB_FIFO_EN_MASK (uint8_t)0x40
#define LPS22HB_WTM_EN_MASK (uint8_t)0x20
#define LPS22HB_ADD_INC_MASK (uint8_t)0x10
#define LPS22HB_I2C_MASK (uint8_t)0x08
#define LPS22HB_ONE_SHOT_MASK (uint8_t)0x01
/**
* @brief CTRL Reg3 Interrupt Control Register
* Read/write
* Default value: 0x00
* 7 INT_H_L: Interrupt active high, low. 0:active high; 1: active low.
* 6 PP_OD: Push-Pull/OpenDrain selection on interrupt pads. 0: Push-pull; 1: open drain.
* 5 F_FSS5: FIFO full flag on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
* 4 F_FTH: FIFO threshold (watermark) status on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
* 3 F_OVR: FIFO overrun interrupt on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
* 2 DRDY: Data-ready signal on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
* 1:0 INT_S2, INT_S1: data signal on INT pad control bits.
* INT_S2 | INT_S1 | INT pin
* ------------------------------------------------------
* 0 | 0 | Data signal( in order of priority:PTH_DRDY or F_FTH or F_OVR_or F_FSS5
* 0 | 1 | Pressure high (P_high)
* 1 | 0 | Pressure low (P_low)
* 1 | 1 | P_low OR P_high
*/
#define LPS22HB_CTRL_REG3 (uint8_t)0x12
#define LPS22HB_PP_OD_BIT LPS22HB_BIT(6)
#define LPS22HB_FIFO_FULL_BIT LPS22HB_BIT(5)
#define LPS22HB_FIFO_FTH_BIT LPS22HB_BIT(4)
#define LPS22HB_FIFO_OVR_BIT LPS22HB_BIT(3)
#define LPS22HB_DRDY_BIT LPS22HB_BIT(2)
#define LPS22HB_INT_H_L_MASK (uint8_t)0x80
#define LPS22HB_PP_OD_MASK (uint8_t)0x40
#define LPS22HB_FIFO_FULL_MASK (uint8_t)0x20
#define LPS22HB_FIFO_FTH_MASK (uint8_t)0x10
#define LPS22HB_FIFO_OVR_MASK (uint8_t)0x08
#define LPS22HB_DRDY_MASK (uint8_t)0x04
#define LPS22HB_INT_S12_MASK (uint8_t)0x03
/**
* @brief Interrupt Differential configuration Register
* Read/write
* Default value: 0x00.
* 7 AUTORIFP: AutoRifP Enable
* 6 RESET_ARP: Reset AutoRifP function
* 4 AUTOZERO: Autozero enabled
* 5 RESET_AZ: Reset Autozero Function
* 3 DIFF_EN: Interrupt generation enable
* 2 LIR: Latch Interrupt request into INT_SOURCE register. 0 - interrupt request not latched
* 1 - interrupt request latched
* 1 PL_E: Enable interrupt generation on differential pressure low event. 0 - disable; 1 - enable
* 0 PH_E: Enable interrupt generation on differential pressure high event. 0 - disable; 1 - enable
*/
#define LPS22HB_INTERRUPT_CFG_REG (uint8_t)0x0B
#define LPS22HB_DIFF_EN_BIT LPS22HB_BIT(3)
#define LPS22HB_LIR_BIT LPS22HB_BIT(2)
#define LPS22HB_PLE_BIT LPS22HB_BIT(1)
#define LPS22HB_PHE_BIT LPS22HB_BIT(0)
#define LPS22HB_AUTORIFP_MASK (uint8_t)0x80
#define LPS22HB_RESET_ARP_MASK (uint8_t)0x40
#define LPS22HB_AUTOZERO_MASK (uint8_t)0x20
#define LPS22HB_RESET_AZ_MASK (uint8_t)0x10
#define LPS22HB_DIFF_EN_MASK (uint8_t)0x08
#define LPS22HB_LIR_MASK (uint8_t)0x04
#define LPS22HB_PLE_MASK (uint8_t)0x02
#define LPS22HB_PHE_MASK (uint8_t)0x01
/**
* @brief Interrupt source Register (It is cleared by reading it)
* Read
* 7 BOOT_STATUS: If 1 indicates that the Boot (Reboot) phase is running.
* 6:3 Reserved: Keep these bits at 0
* 2 IA: Interrupt Active.0: no interrupt has been generated
* 1: one or more interrupt events have been generated.
* 1 PL: Differential pressure Low. 0: no interrupt has been generated
* 1: Low differential pressure event has occurred.
* 0 PH: Differential pressure High. 0: no interrupt has been generated
* 1: High differential pressure event has occurred.
*/
#define LPS22HB_INTERRUPT_SOURCE_REG (uint8_t)0x25
#define LPS22HB_BOOT_STATUS_BIT LPS22HB_BIT(7)
#define LPS22HB_IA_BIT LPS22HB_BIT(2)
#define LPS22HB_PL_BIT LPS22HB_BIT(1)
#define LPS22HB_PH_BIT LPS22HB_BIT(0)
#define LPS22HB_BOOT_STATUS_MASK (uint8_t)0x80
#define LPS22HB_IA_MASK (uint8_t)0x04
#define LPS22HB_PL_MASK (uint8_t)0x02
#define LPS22HB_PH_MASK (uint8_t)0x01
/**
* @brief Status Register
* Read
* 7:6 Reserved: 0
* 5 T_OR: Temperature data overrun. 0: no overrun has occurred
* 1: a new data for temperature has overwritten the previous one.
* 4 P_OR: Pressure data overrun. 0: no overrun has occurred
* 1: new data for pressure has overwritten the previous one.
* 3:2 Reserved: 0
* 1 T_DA: Temperature data available. 0: new data for temperature is not yet available
* 1: new data for temperature is available.
* 0 P_DA: Pressure data available. 0: new data for pressure is not yet available
* 1: new data for pressure is available.
*/
#define LPS22HB_STATUS_REG (uint8_t)0x27
#define LPS22HB_TOR_BIT LPS22HB_BIT(5)
#define LPS22HB_POR_BIT LPS22HB_BIT(4)
#define LPS22HB_TDA_BIT LPS22HB_BIT(1)
#define LPS22HB_PDA_BIT LPS22HB_BIT(0)
#define LPS22HB_TOR_MASK (uint8_t)0x20
#define LPS22HB_POR_MASK (uint8_t)0x10
#define LPS22HB_TDA_MASK (uint8_t)0x02
#define LPS22HB_PDA_MASK (uint8_t)0x01
/**
* @brief Pressure data (LSB) register.
* Read
* Default value: 0x00.(To be verified)
* POUT7 - POUT0: Pressure data LSB (2's complement).
* Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
* PRESS_OUT_XL)[dec]/4096.
*/
#define LPS22HB_PRESS_OUT_XL_REG (uint8_t)0x28
/**
* @brief Pressure data (Middle part) register.
* Read
* Default value: 0x80.
* POUT15 - POUT8: Pressure data middle part (2's complement).
* Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
* PRESS_OUT_XL)[dec]/4096.
*/
#define LPS22HB_PRESS_OUT_L_REG (uint8_t)0x29
/**
* @brief Pressure data (MSB) register.
* Read
* Default value: 0x2F.
* POUT23 - POUT16: Pressure data MSB (2's complement).
* Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
* PRESS_OUT_XL)[dec]/4096.
*/
#define LPS22HB_PRESS_OUT_H_REG (uint8_t)0x2A
/**
* @brief Temperature data (LSB) register.
* Read
* Default value: 0x00.
* TOUT7 - TOUT0: temperature data LSB.
* Tout(degC)=TEMP_OUT/100
*/
#define LPS22HB_TEMP_OUT_L_REG (uint8_t)0x2B
/**
* @brief Temperature data (MSB) register.
* Read
* Default value: 0x00.
* TOUT15 - TOUT8: temperature data MSB.
* Tout(degC)=TEMP_OUT/100
*/
#define LPS22HBH_TEMP_OUT_H_REG (uint8_t)0x2C
/**
* @brief Threshold pressure (LSB) register.
* Read/write
* Default value: 0x00.
* 7:0 THS7-THS0: LSB Threshold pressure Low part of threshold value for pressure interrupt
* generation. The complete threshold value is given by THS_P_H & THS_P_L and is
* expressed as unsigned number. P_ths(hPA)=(THS_P_H & THS_P_L)[dec]/16.
*/
#define LPS22HB_THS_P_LOW_REG (uint8_t)0x0C
/**
* @brief Threshold pressure (MSB)
* Read/write
* Default value: 0x00.
* 7:0 THS15-THS8: MSB Threshold pressure. High part of threshold value for pressure interrupt
* generation. The complete threshold value is given by THS_P_H & THS_P_L and is
* expressed as unsigned number. P_ths(mbar)=(THS_P_H & THS_P_L)[dec]/16.
*/
#define LPS22HB_THS_P_HIGH_REG (uint8_t)0x0D
/**
* @brief FIFO control register
* Read/write
* Default value: 0x00
* 7:5 F_MODE2, F_MODE1, F_MODE0: FIFO mode selection.
* FM2 | FM1 | FM0 | FIFO MODE
* ---------------------------------------------------
* 0 | 0 | 0 | BYPASS MODE
* 0 | 0 | 1 | FIFO MODE. Stops collecting data when full
* 0 | 1 | 0 | STREAM MODE: Keep the newest measurements in the FIFO
* 0 | 1 | 1 | STREAM MODE until trigger deasserted, then change to FIFO MODE
* 1 | 0 | 0 | BYPASS MODE until trigger deasserted, then STREAM MODE
* 1 | 0 | 1 | Reserved for future use
* 1 | 1 | 0 | Reserved
* 1 | 1 | 1 | BYPASS mode until trigger deasserted, then FIFO MODE
*
* 4:0 WTM_POINT4-0 : FIFO Watermark level selection (0-31)
*/
#define LPS22HB_CTRL_FIFO_REG (uint8_t)0x14
#define LPS22HB_FIFO_MODE_MASK (uint8_t)0xE0
#define LPS22HB_WTM_POINT_MASK (uint8_t)0x1F
/**
* @brief FIFO Status register
* Read
* 7 FTH_FIFO: FIFO threshold status. 0:FIFO filling is lower than FTH level
* 1: FIFO is equal or higher than FTH level.
* 6 OVR: Overrun bit status. 0 - FIFO not full
* 1 - FIFO is full and at least one sample in the FIFO has been overwritten.
* 5:0 FSS: FIFO Stored data level. 000000: FIFO empty, 100000: FIFO is full and has 32 unread samples.
*/
#define LPS22HB_STATUS_FIFO_REG (uint8_t)0x26
#define LPS22HB_FTH_FIFO_BIT LPS22HB_BIT(7)
#define LPS22HB_OVR_FIFO_BIT LPS22HB_BIT(6)
#define LPS22HB_FTH_FIFO_MASK (uint8_t)0x80
#define LPS22HB_OVR_FIFO_MASK (uint8_t)0x40
#define LPS22HB_LEVEL_FIFO_MASK (uint8_t)0x3F
#define LPS22HB_FIFO_EMPTY (uint8_t)0x00
#define LPS22HB_FIFO_FULL (uint8_t)0x20
/**
* @brief Pressure offset register (LSB)
* Read/write
* Default value: 0x00
* 7:0 RPDS7-0:Pressure Offset for 1 point calibration (OPC) after soldering.
* This register contains the low part of the pressure offset value after soldering,for
* differential pressure computing. The complete value is given by RPDS_L & RPDS_H
* and is expressed as signed 2 complement value.
*/
#define LPS22HB_RPDS_L_REG (uint8_t)0x18
/**
* @brief Pressure offset register (MSB)
* Read/write
* Default value: 0x00
* 7:0 RPDS15-8:Pressure Offset for 1 point calibration (OPC) after soldering.
* This register contains the high part of the pressure offset value after soldering (see description RPDS_L)
*/
#define LPS22HB_RPDS_H_REG (uint8_t)0x19
/**
* @brief Clock Tree Configuration register
* Read/write
* Default value: 0x00
* 7:6 Reserved.
* 5: CTE: Clock Tree Enhancement
*/
#define LPS22HB_CLOCK_TREE_CONFIGURATION (uint8_t)0x43
#define LPS22HB_CTE_MASK (uint8_t)0x20
/**
* @}
*/
/** @defgroup LPS22HB_Pressure_Exported_Functions LPS22HB Pressure Exported Functions
* @{
*/
/* PRESSURE functions */
void LPS22HB_P_Init(uint16_t DeviceAddr);
uint8_t LPS22HB_P_ReadID(uint16_t DeviceAddr);
float LPS22HB_P_ReadPressure(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup HTS221_PressImported_Globals PRESSURE Imported Globals
* @{
*/
/* PRESSURE driver structure */
extern PSENSOR_DrvTypeDef LPS22HB_P_Drv;
/**
* @}
*/
/** @defgroup LPS22HB_Temperature_Exported_Functions LPS22HB Temperature Exported Functions
* @{
*/
/* TEMPERATURE functions */
void LPS22HB_T_Init(uint16_t DeviceAddr, TSENSOR_InitTypeDef *pInitStruct);
float LPS22HB_T_ReadTemp(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup HTS221_TempImported_Globals Temperature Imported Globals
* @{
*/
/* Temperature driver structure */
extern TSENSOR_DrvTypeDef LPS22HB_T_Drv;
/**
* @}
*/
/** @defgroup LPS22HB_Imported_Functions LPS22HB Imported Functions
* @{
*/
/* IO functions */
extern void SENSOR_IO_Init(void);
extern void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LPS22HB__H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LS016B8UY Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-ls016b8uy-component-drivers"><small>Release Notes for</small> <mark>LS016B8UY Component Drivers</mark></h1>
<p>Copyright © 2016 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LS016B8UY component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 10-May-2016</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,643 @@
/**
******************************************************************************
* @file ls016b8uy.c
* @author MCD Application Team
* @brief This file includes the LCD driver for LS016B8UY LCD.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "ls016b8uy.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ls016b8uy
* @brief This file provides a set of functions needed to drive the
* LS016B8UY LCD.
* @{
*/
/** @defgroup LS016B8UY_Private_TypesDefinitions
* @{
*/
typedef struct {
uint8_t red;
uint8_t green;
uint8_t blue;
} LS016B8UY_Rgb888;
/**
* @}
*/
/** @defgroup LS016B8UY_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup LS016B8UY_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup LS016B8UY_Private_Variables
* @{
*/
LCD_DrvTypeDef ls016b8uy_drv =
{
ls016b8uy_Init,
ls016b8uy_ReadID,
ls016b8uy_DisplayOn,
ls016b8uy_DisplayOff,
ls016b8uy_SetCursor,
ls016b8uy_WritePixel,
ls016b8uy_ReadPixel,
ls016b8uy_SetDisplayWindow,
ls016b8uy_DrawHLine,
ls016b8uy_DrawVLine,
ls016b8uy_GetLcdPixelWidth,
ls016b8uy_GetLcdPixelHeight,
ls016b8uy_DrawBitmap,
ls016b8uy_DrawRGBImage,
};
static uint16_t WindowsXstart = 0;
static uint16_t WindowsYstart = 0;
static uint16_t WindowsXend = LS016B8UY_LCD_PIXEL_WIDTH-1;
static uint16_t WindowsYend = LS016B8UY_LCD_PIXEL_HEIGHT-1;
/**
* @}
*/
/** @defgroup LS016B8UY_Private_FunctionPrototypes
* @{
*/
static LS016B8UY_Rgb888 ls016b8uy_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos);
static void ls016b8uy_DrawRGBHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint8_t *pdata);
/**
* @}
*/
/** @defgroup LS016B8UY_Private_Functions
* @{
*/
/**
* @brief Initialize the LS016B8UY LCD Component.
* @param None
* @retval None
*/
void ls016b8uy_Init(void)
{
uint8_t parameter[4];
/* Initialize LS016B8UY low level bus layer ----------------------------------*/
LCD_IO_Init();
parameter[0] = 0x00; /* VSYNC output */
ls016b8uy_WriteReg(LCD_CMD_VSYNC_OUTPUT, parameter, 1);
parameter[0] = 0x06; /* 18 bits color mode */
ls016b8uy_WriteReg(LCD_CMD_COLOR_MODE, parameter, 1);
parameter[0] = 0x01; /* Panel setting command <No.1 UN-Lock> */
parameter[1] = 0xFE;
ls016b8uy_WriteReg(LCD_CMD_PANEL_SETTING_1, parameter, 2);
parameter[0] = 0xDE; /* Panel setting command <No.2 UN-Lock> */
parameter[1] = 0x21;
ls016b8uy_WriteReg(LCD_CMD_PANEL_SETTING_2, parameter, 2);
parameter[0] = 0x05; /* V-Porch setting */
parameter[1] = 0x33;
ls016b8uy_WriteReg(LCD_CMD_PANEL_V_PORCH, parameter, 2);
parameter[0] = 0x05; /* Idle mode V-Porch setting */
parameter[1] = 0x33;
ls016b8uy_WriteReg(LCD_CMD_PANEL_IDLE_V_PORCH, parameter, 2);
parameter[0] = 0x04; /* panel timing setting */
parameter[1] = 0x03;
ls016b8uy_WriteReg(LCD_CMD_PANEL_TIMING_1, parameter, 2);
parameter[0] = 0x5E; /* panel timing setting */
parameter[1] = 0x08;
ls016b8uy_WriteReg(LCD_CMD_PANEL_TIMING_2, parameter, 2);
parameter[0] = 0x0A; /* panel timing setting */
parameter[1] = 0x0C;
parameter[2] = 0x02;
ls016b8uy_WriteReg(LCD_CMD_PANEL_TIMING_3, parameter, 3);
parameter[0] = 0x03; /* panel timing setting */
parameter[1] = 0x04;
ls016b8uy_WriteReg(LCD_CMD_PANEL_TIMING_4, parameter, 2);
parameter[0] = 0x0C; /* panel power setting */
ls016b8uy_WriteReg(LCD_CMD_PANEL_POWER, parameter, 1);
parameter[0] = 0x02; /* Oscillator Setting = 2MHz */
ls016b8uy_WriteReg(LCD_CMD_OSCILLATOR, parameter, 1);
parameter[0] = 0x53; /* GVDD = 4.76V setting */
ls016b8uy_WriteReg(LCD_CMD_GVDD, parameter, 1);
parameter[0] = 0x00; /* Reload MTP After SLPOUT */
parameter[1] = 0x45; /* VCOMH=3.76V */
ls016b8uy_WriteReg(LCD_CMD_RELOAD_MTP_VCOMH, parameter, 2);
parameter[0] = 0x03; /* OP-Amp Ability. (Normal) */
parameter[1] = 0x12; /* Step-up Cycle for AVDD Booster Freq./4 */
ls016b8uy_WriteReg(LCD_CMD_OPAMP, parameter, 2);
parameter[0] = 0x00; /* Tearing Effect Option (00h:VSYNC Interface OFF, 01h:VSYNC Interface ON) */
ls016b8uy_WriteReg(LCD_CMD_TEARING_EFFECT, parameter, 1);
ls016b8uy_WriteReg(LCD_CMD_PANEL_SETTING_LOCK, parameter, 0); /* Panel setting command <Lock> */
ls016b8uy_WriteReg(LCD_CMD_SLEEP_OUT, parameter, 0); /* Sleep Out Command */
LCD_IO_Delay(150); /* Wait for 150ms */
parameter[0] = 0x00; /* CASET */
parameter[1] = 0x1E;
parameter[2] = 0x00;
parameter[3] = 0xD1;
ls016b8uy_WriteReg(LCD_CMD_CASET, parameter, 4);
parameter[0] = 0x00; /* RASET */
parameter[1] = 0x00;
parameter[2] = 0x00;
parameter[3] = 0xB3;
ls016b8uy_WriteReg(LCD_CMD_RASET, parameter, 4);
parameter[0] = 0x83; /* Normal display for Driver Down side */
ls016b8uy_WriteReg(LCD_CMD_NORMAL_DISPLAY, parameter, 1);
ls016b8uy_DisplayOn(); /* Display ON command */
}
/**
* @brief Enables the Display.
* @param None
* @retval None
*/
void ls016b8uy_DisplayOn(void)
{
ls016b8uy_WriteReg(LCD_CMD_DISPLAY_ON, (uint8_t*)NULL, 0); /* Display ON command */
ls016b8uy_WriteReg(LCD_CMD_IDLE_MODE_OFF, (uint8_t*)NULL, 0); /* Idle mode OFF command */
}
/**
* @brief Disables the Display.
* @param None
* @retval None
*/
void ls016b8uy_DisplayOff(void)
{
ls016b8uy_WriteReg(LCD_CMD_DISPLAY_OFF, (uint8_t*)NULL, 0); /* Display OFF command */
LCD_IO_Delay(20); /* Wait for 20ms */
ls016b8uy_WriteReg(LCD_CMD_SLEEP_IN, (uint8_t*)NULL, 0); /* Sleep In Command */
LCD_IO_Delay(150); /* Wait for 150ms */
}
/**
* @brief Get the LCD pixel Width.
* @param None
* @retval The Lcd Pixel Width
*/
uint16_t ls016b8uy_GetLcdPixelWidth(void)
{
return (uint16_t)LS016B8UY_LCD_PIXEL_WIDTH;
}
/**
* @brief Get the LCD pixel Height.
* @param None
* @retval The Lcd Pixel Height
*/
uint16_t ls016b8uy_GetLcdPixelHeight(void)
{
return (uint16_t)LS016B8UY_LCD_PIXEL_HEIGHT;
}
/**
* @brief Get the LS016B8UY ID.
* @param None
* @retval The LS016B8UY ID
*/
uint16_t ls016b8uy_ReadID(void)
{
LCD_IO_Init();
/* TODO : LCD read ID command not known for now, so assumption that the connected LCD is LS016B8UY */
return (LS016B8UY_ID);
}
/**
* @brief Set Cursor position.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval None
*/
void ls016b8uy_SetCursor(uint16_t Xpos, uint16_t Ypos)
{
uint8_t parameter[4];
parameter[0] = 0x00; /* CASET */
parameter[1] = 0x1E + Xpos;
parameter[2] = 0x00;
parameter[3] = 0xD1 + Xpos;
ls016b8uy_WriteReg(LCD_CMD_CASET, parameter, 4);
parameter[0] = 0x00; /* RASET */
parameter[1] = 0x00 + Ypos;
parameter[2] = 0x00;
parameter[3] = 0xB3 + Ypos;
ls016b8uy_WriteReg(LCD_CMD_RASET, parameter, 4);
}
/**
* @brief Write pixel.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param RGBCode: the RGB pixel color in RGB565 format
* @retval None
*/
void ls016b8uy_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
{
uint16_t r, g, b;
uint16_t rgb888_part1, rgb888_part2;
r = (RGBCode & 0xF800) >> 11; /* Extract red component from RGB565 pixel data */
g = (RGBCode & 0x07E0) >> 5; /* Extract green component from RGB565 pixel data */
b = (RGBCode & 0x001F) >> 0; /* Extract blue component from RGB565 pixel data */
/* Prepare data to write with new pixel components and read old pixel component */
rgb888_part1 = (r << 11) + (g << 2);
rgb888_part2 = (b << 11);
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, Ypos);
/* Prepare to write to LCD RAM */
ls016b8uy_WriteReg(LCD_CMD_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
/* Write RAM data */
LCD_IO_WriteData(rgb888_part1);
LCD_IO_WriteData(rgb888_part2);
}
/**
* @brief Read pixel.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval The RGB pixel color in RGB565 format
*/
uint16_t ls016b8uy_ReadPixel(uint16_t Xpos, uint16_t Ypos)
{
LS016B8UY_Rgb888 rgb888;
uint8_t r, g, b;
uint16_t rgb565;
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, Ypos);
/* Read RGB888 data from LCD RAM */
rgb888 = ls016b8uy_ReadPixel_rgb888(Xpos, Ypos);
/* Convert RGB888 to RGB565 */
r = ((rgb888.red & 0xF8) >> 3); /* Extract the red component 5 most significant bits */
g = ((rgb888.green & 0xFC) >> 2); /* Extract the green component 6 most significant bits */
b = ((rgb888.blue & 0xF8) >> 3); /* Extract the blue component 5 most significant bits */
rgb565 = ((uint16_t)(r) << 11) + ((uint16_t)(g) << 5) + ((uint16_t)(b) << 0);
return (rgb565);
}
/**
* @brief Writes to the selected LCD register.
* @param Command: command value (or register address as named in LS016B8UY doc).
* @param Parameters: pointer on parameters value (if command uses one or several parameters).
* @param NbParameters: number of command parameters (0 if no parameter)
* @retval None
*/
void ls016b8uy_WriteReg(uint8_t Command, uint8_t *Parameters, uint8_t NbParameters)
{
uint8_t i;
/* Send command */
LCD_IO_WriteReg(Command);
/* Send command's parameters if any */
for (i=0; i<NbParameters; i++)
{
LCD_IO_WriteData(Parameters[i]);
}
}
/**
* @brief Reads the selected LCD Register.
* @param Command: command value (or register address as named in LS016B8UY doc).
* @retval Register Value.
*/
uint8_t ls016b8uy_ReadReg(uint8_t Command)
{
/* Send command */
LCD_IO_WriteReg(Command);
/* Read dummy data */
LCD_IO_ReadData();
/* Read register value */
return (LCD_IO_ReadData());
}
/**
* @brief Sets a display window
* @param Xpos: specifies the X bottom left position.
* @param Ypos: specifies the Y bottom left position.
* @param Height: display window height.
* @param Width: display window width.
* @retval None
*/
void ls016b8uy_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
if (Xpos < LS016B8UY_LCD_PIXEL_WIDTH)
{
WindowsXstart = Xpos;
}
else
{
WindowsXstart = 0;
}
if (Ypos < LS016B8UY_LCD_PIXEL_HEIGHT)
{
WindowsYstart = Ypos;
}
else
{
WindowsYstart = 0;
}
if (Width + Xpos <= LS016B8UY_LCD_PIXEL_WIDTH)
{
WindowsXend = Width + Xpos - 1;
}
else
{
WindowsXend = LS016B8UY_LCD_PIXEL_WIDTH - 1;
}
if (Height + Ypos <= LS016B8UY_LCD_PIXEL_HEIGHT)
{
WindowsYend = Height + Ypos - 1;
}
else
{
WindowsYend = LS016B8UY_LCD_PIXEL_HEIGHT-1;
}
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color in RGB565 format
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void ls016b8uy_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint16_t counter = 0;
uint16_t r, g, b;
uint16_t rgb888_part1, rgb888_part2, rgb888_part3;
r = (RGBCode & 0xF800) >> 11; /* Extract red component from RGB565 pixel data */
g = (RGBCode & 0x07E0) >> 5; /* Extract green component from RGB565 pixel data */
b = (RGBCode & 0x001F) >> 0; /* Extract blue component from RGB565 pixel data */
rgb888_part1 = (r << 11) + (g << 2); /* Build pattern first part to write in LCD RAM */
rgb888_part2 = (b << 11) + (r << 3); /* Build pattern second part to write in LCD RAM */
rgb888_part3 = (g << 10) + (b << 3); /* Build pattern third part to write in LCD RAM */
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, Ypos);
/* Prepare to write to LCD RAM */
ls016b8uy_WriteReg(LCD_CMD_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
/* Sent a complete line */
for(counter = 0; counter < Length; counter+=2)
{
/* Write 2 pixels at a time by performing 3 access (pixels coded on 24 bits in LCD RAM whereas access are coded on 16 bits) */
LCD_IO_WriteData(rgb888_part1);
LCD_IO_WriteData(rgb888_part2);
if (counter != (Length-1)) /* When writing last pixel when Length is odd, the third part is not written */
{
LCD_IO_WriteData(rgb888_part3);
}
}
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void ls016b8uy_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint16_t counter = 0;
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, Ypos);
/* Prepare to write to LCD RAM */
ls016b8uy_WriteReg(LCD_CMD_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
/* Fill a complete vertical line */
for(counter = 0; counter < Length; counter++)
{
ls016b8uy_WritePixel(Xpos, Ypos + counter, RGBCode);
}
}
/**
* @brief Displays a bitmap picture.
* @param BmpAddress: Bmp picture address.
* @param Xpos: Bmp X position in the LCD
* @param Ypos: Bmp Y position in the LCD
* @retval None
*/
void ls016b8uy_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp)
{
uint32_t index = 0, size = 0;
uint32_t posY;
uint32_t nb_line = 0;
uint16_t Xsize = WindowsXend - WindowsXstart + 1;
uint16_t Ysize = WindowsYend - WindowsYstart + 1;
/* Read bitmap size */
size = *(volatile uint16_t *) (pbmp + 2);
size |= (*(volatile uint16_t *) (pbmp + 4)) << 16;
/* Get bitmap data address offset */
index = *(volatile uint16_t *) (pbmp + 10);
index |= (*(volatile uint16_t *) (pbmp + 12)) << 16;
size = (size - index)/2;
pbmp += index;
for (posY = (Ypos + Ysize); posY > Ypos; posY--) /* In BMP files the line order is inverted */
{
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, posY - 1);
/* Draw one line of the picture */
ls016b8uy_DrawRGBHLine(Xpos, posY - 1, Xsize, (pbmp + (nb_line * Xsize * 2)));
nb_line++;
}
}
/**
* @brief Displays picture.
* @param pdata: picture address.
* @param Xpos: Image X position in the LCD
* @param Ypos: Image Y position in the LCD
* @param Xsize: Image X size in the LCD
* @param Ysize: Image Y size in the LCD
* @retval None
*/
void ls016b8uy_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata)
{
uint32_t posY;
uint32_t nb_line = 0;
for (posY = Ypos; posY < (Ypos + Ysize); posY ++)
{
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, posY);
/* Draw one line of the picture */
ls016b8uy_DrawRGBHLine(Xpos, posY, Xsize, (pdata + (nb_line * Xsize * 2)));
nb_line++;
}
}
/******************************************************************************
Static Functions
*******************************************************************************/
/**
* @brief Read pixel from LCD RAM in RGB888 format
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval Each RGB pixel color components in a structure
*/
static LS016B8UY_Rgb888 ls016b8uy_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos)
{
LS016B8UY_Rgb888 rgb888;
uint16_t rgb888_part1, rgb888_part2;
/* In LCD RAM, pixels are 24 bits packed and read with 16 bits access
* Here is the pixels components arrangement in memory :
* bits: 15 14 13 12 11 10 09 08 | 07 06 05 04 03 02 01 00
* address 0 : red pixel 0 X X | green pixel 0 X X
* address 1 : blue pixel 0 X X | red pixel 1 X X
* address 2 : green pixel 1 X X | blue pixel 1 X X
*/
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, Ypos);
/* Prepare to read LCD RAM */
ls016b8uy_WriteReg(LCD_CMD_READ_RAM, (uint8_t*)NULL, 0); /* RAM read data command */
/* Dummy read */
LCD_IO_ReadData();
/* Read first part of the RGB888 data */
rgb888_part1 = LCD_IO_ReadData();
/* Read first part of the RGB888 data */
rgb888_part2 = LCD_IO_ReadData();
/* red component */
rgb888.red = (rgb888_part1 & 0xFC00) >> 8;
/* green component */
rgb888.green = (rgb888_part1 & 0x00FC) >> 0;
/* blue component */
rgb888.blue = (rgb888_part2 & 0xFC00) >> 8;
return rgb888;
}
/**
* @brief Displays a single picture line.
* @param pdata: picture address.
* @param Xpos: Image X position in the LCD
* @param Ypos: Image Y position in the LCD
* @param Xsize: Image X size in the LCD
* @retval None
*/
static void ls016b8uy_DrawRGBHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint8_t *pdata)
{
uint32_t i = 0;
uint32_t posX;
uint16_t r, g, b;
uint16_t rgb888_part;
uint16_t *rgb565 = (uint16_t*)pdata;
/* Prepare to write to LCD RAM */
ls016b8uy_WriteReg(LCD_CMD_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
for (posX = Xpos; posX < (Xsize + Xpos); posX += 2)
{
if ((posX >= WindowsXstart) && (Ypos >= WindowsYstart) && /* Check we are in the defined window */
(posX <= WindowsXend) && (Ypos <= WindowsYend))
{
/* Write pixels in LCD RAM after RGB565 -> RGB888 conversion */
/* As data in LCD RAM are 24bits packed, three 16 bits writes access are needed to transmit 2 pixels data */
r = (rgb565[i] & 0xF800) >> 11; /* Extract red component from first RGB565 pixel data */
g = (rgb565[i] & 0x07E0) >> 5; /* Extract green component from first RGB565 pixel data */
rgb888_part = (r << 11) + (g << 2); /* Build data to be written in LCD RAM */
LCD_IO_WriteData(rgb888_part);
b = (rgb565[i] & 0x001F) >> 0; /* Extract blue component from first RGB565 pixel data */
r = (rgb565[i+1] & 0xF800) >> 11; /* Extract red component from second RGB565 pixel data */
rgb888_part = (b << 11) + (r << 3); /* Build data to be written in LCD RAM */
LCD_IO_WriteData(rgb888_part);
if (posX != (Xsize + Xpos - 1)) /* When writing last pixel when size is odd, the third part is not written */
{
g = (rgb565[i+1] & 0x07E0) >> 5; /* Extract green component from second RGB565 pixel data */
b = (rgb565[i+1] & 0x001F) >> 0; /* Extract blue component from second RGB565 pixel data */
rgb888_part = (g << 10) + (b << 3); /* Build data to be written in LCD RAM */
LCD_IO_WriteData(rgb888_part);
}
i += 2;
}
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,161 @@
/**
******************************************************************************
* @file ls016b8uy.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the ls016b8uy.c
* driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LS016B8UY_H
#define __LS016B8UY_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
#include "../Common/lcd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ls016b8uy
* @{
*/
/** @defgroup LS016B8UY_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup LS016B8UY_Exported_Constants
* @{
*/
/**
* @brief LS016B8UY ID
*/
#define LS016B8UY_ID 0xFFFF
/**
* @brief LS016B8UY Size
*/
#define LS016B8UY_LCD_PIXEL_WIDTH ((uint16_t)180)
#define LS016B8UY_LCD_PIXEL_HEIGHT ((uint16_t)180)
/**
* @brief LS016B8UY Registers
*/
#define LCD_CMD_SLEEP_IN 0x10
#define LCD_CMD_SLEEP_OUT 0x11
#define LCD_CMD_DISPLAY_OFF 0x28
#define LCD_CMD_DISPLAY_ON 0x29
#define LCD_CMD_WRITE_RAM 0x2C
#define LCD_CMD_READ_RAM 0x2E
#define LCD_CMD_CASET 0x2A
#define LCD_CMD_RASET 0x2B
#define LCD_CMD_VSYNC_OUTPUT 0x35
#define LCD_CMD_NORMAL_DISPLAY 0x36
#define LCD_CMD_IDLE_MODE_OFF 0x38
#define LCD_CMD_IDLE_MODE_ON 0x39
#define LCD_CMD_COLOR_MODE 0x3A
#define LCD_CMD_PANEL_SETTING_1 0xB0
#define LCD_CMD_PANEL_SETTING_2 0xB1
#define LCD_CMD_OSCILLATOR 0xB3
#define LCD_CMD_PANEL_SETTING_LOCK 0xB4
#define LCD_CMD_PANEL_V_PORCH 0xB7
#define LCD_CMD_PANEL_IDLE_V_PORCH 0xB8
#define LCD_CMD_GVDD 0xC0
#define LCD_CMD_OPAMP 0xC2
#define LCD_CMD_RELOAD_MTP_VCOMH 0xC5
#define LCD_CMD_PANEL_TIMING_1 0xC8
#define LCD_CMD_PANEL_TIMING_2 0xC9
#define LCD_CMD_PANEL_TIMING_3 0xCA
#define LCD_CMD_PANEL_TIMING_4 0xCC
#define LCD_CMD_PANEL_POWER 0xD0
#define LCD_CMD_TEARING_EFFECT 0xDD
/**
* @}
*/
/** @defgroup LS016B8UY_Exported_Functions
* @{
*/
void ls016b8uy_Init(void);
uint16_t ls016b8uy_ReadID(void);
void ls016b8uy_WriteReg(uint8_t Command, uint8_t *Parameters, uint8_t NbParameters);
uint8_t ls016b8uy_ReadReg(uint8_t Command);
void ls016b8uy_DisplayOn(void);
void ls016b8uy_DisplayOff(void);
void ls016b8uy_SetCursor(uint16_t Xpos, uint16_t Ypos);
void ls016b8uy_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
uint16_t ls016b8uy_ReadPixel(uint16_t Xpos, uint16_t Ypos);
void ls016b8uy_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void ls016b8uy_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void ls016b8uy_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
void ls016b8uy_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata);
void ls016b8uy_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
uint16_t ls016b8uy_GetLcdPixelWidth(void);
uint16_t ls016b8uy_GetLcdPixelHeight(void);
/* LCD driver structure */
extern LCD_DrvTypeDef ls016b8uy_drv;
/* LCD IO functions */
void LCD_IO_Init(void);
void LCD_IO_WriteMultipleData(uint16_t *pData, uint32_t Size);
void LCD_IO_WriteReg(uint8_t Reg);
void LCD_IO_WriteData(uint16_t RegValue);
uint16_t LCD_IO_ReadData(void);
void LCD_IO_Delay(uint32_t delay);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LS016B8UY_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LSM303C Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-lsm303c-component-drivers"><small>Release Notes for</small> <mark>LSM303C Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LSM303C component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V2.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V2.0.0 / 07-April-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>LSM303C_AccLowPower(uint16 Mode) and LSM303C_MagLowPower(uint16_t Mode) API updates to set or not component Low Power mode feature</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong> This release must be used with BSP Common driver V5.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.0.0 / 24-June-2015</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>First official release of LSM303C component driver</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong> This release must be used with BSP Common driver V4.0.0 or later</p>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,390 @@
/**
******************************************************************************
* @file lsm303c.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the LSM303C
* MEMS accelerometer.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lsm303c.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LSM303C
* @{
*/
/** @defgroup LSM303C_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup LSM303C_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup LSM303C_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup LSM303C_Private_Functions
* @{
*/
/**
* @}
*/
/** @defgroup LSM303C_Private_Variables
* @{
*/
ACCELERO_DrvTypeDef Lsm303cDrv_accelero =
{
LSM303C_AccInit,
LSM303C_AccDeInit,
LSM303C_AccReadID,
0,
LSM303C_AccLowPower,
0,
0,
0,
0,
0,
LSM303C_AccFilterConfig,
0,
LSM303C_AccReadXYZ
};
MAGNETO_DrvTypeDef Lsm303cDrv_magneto =
{
LSM303C_MagInit,
LSM303C_MagDeInit,
LSM303C_MagReadID,
0,
LSM303C_MagLowPower,
0,
0,
0,
0,
0,
0,
0,
LSM303C_MagReadXYZ
};
/**
* @}
*/
/**
* @brief Set LSM303C Accelerometer Initialization.
* @param InitStruct: Init parameters
* @retval None
*/
void LSM303C_AccInit(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
/* Low level init */
ACCELERO_IO_Init();
/* Write value to ACC MEMS CTRL_REG1 register */
ctrl = (uint8_t) InitStruct;
ACCELERO_IO_Write(LSM303C_CTRL_REG1_A, ctrl);
/* Write value to ACC MEMS CTRL_REG4 register */
ctrl = ((uint8_t) (InitStruct >> 8));
ACCELERO_IO_Write(LSM303C_CTRL_REG4_A, ctrl);
}
/**
* @brief LSM303C Accelerometer De-initialization.
* @param None
* @retval None
*/
void LSM303C_AccDeInit(void)
{
}
/**
* @brief Read LSM303C ID.
* @param None
* @retval ID
*/
uint8_t LSM303C_AccReadID(void)
{
uint8_t ctrl = 0x00;
/* Low level init */
ACCELERO_IO_Init();
/* Enabled SPI/I2C read communication */
ACCELERO_IO_Write(LSM303C_CTRL_REG4_A, 0x5);
/* Read value at Who am I register address */
ctrl = ACCELERO_IO_Read(LSM303C_WHO_AM_I_ADDR);
return ctrl;
}
/**
* @brief Put Accelerometer in power down mode or not.
* @param Mode equal to LSM303C_ACC_ODR_OFF means enable Low Power Mode, otherwise Output data rate is set.
* This parameter can be a value of @ref Acc_OutPut_DataRate_Selection
* @retval None
*/
void LSM303C_AccLowPower(uint16_t Mode)
{
uint8_t ctrl = 0x00;
/* Read control register 1 value */
ctrl = ACCELERO_IO_Read(LSM303C_CTRL_REG1_A);
/* Clear ODR bits */
ctrl &= ~(LSM303C_ACC_ODR_BITPOSITION);
/* Set Power down */
ctrl |= (uint8_t)Mode;
/* write back control register */
ACCELERO_IO_Write(LSM303C_CTRL_REG1_A, ctrl);
}
/**
* @brief Set High Pass Filter Modality
* @param FilterStruct: contains data for filter config
* @retval None
*/
void LSM303C_AccFilterConfig(uint8_t FilterStruct)
{
uint8_t tmpreg;
// /* Read CTRL_REG2 register */
// tmpreg = ACCELERO_IO_Read(LSM303C_CTRL_REG2_A);
//
// tmpreg &= 0x0C;
tmpreg = FilterStruct;
/* Write value to ACC MEMS CTRL_REG2 register */
ACCELERO_IO_Write(LSM303C_CTRL_REG2_A, tmpreg);
}
/**
* @brief Read X, Y & Z Acceleration values
* @param pData: Data out pointer
* @retval None
*/
void LSM303C_AccReadXYZ(int16_t* pData)
{
int16_t pnRawData[3];
uint8_t ctrlx[2]={0,0};
uint8_t buffer[6];
uint8_t i = 0;
uint8_t sensitivity = LSM303C_ACC_SENSITIVITY_2G;
/* Read the acceleration control register content */
ctrlx[0] = ACCELERO_IO_Read(LSM303C_CTRL_REG4_A);
ctrlx[1] = ACCELERO_IO_Read(LSM303C_CTRL_REG5_A);
/* Read output register X, Y & Z acceleration */
buffer[0] = ACCELERO_IO_Read(LSM303C_OUT_X_L_A);
buffer[1] = ACCELERO_IO_Read(LSM303C_OUT_X_H_A);
buffer[2] = ACCELERO_IO_Read(LSM303C_OUT_Y_L_A);
buffer[3] = ACCELERO_IO_Read(LSM303C_OUT_Y_H_A);
buffer[4] = ACCELERO_IO_Read(LSM303C_OUT_Z_L_A);
buffer[5] = ACCELERO_IO_Read(LSM303C_OUT_Z_H_A);
for(i=0; i<3; i++)
{
pnRawData[i]=((int16_t)((uint16_t)buffer[2*i+1] << 8) + buffer[2*i]);
}
/* Normal mode */
/* Switch the sensitivity value set in the CRTL4 */
switch(ctrlx[0] & LSM303C_ACC_FULLSCALE_8G)
{
case LSM303C_ACC_FULLSCALE_2G:
sensitivity = LSM303C_ACC_SENSITIVITY_2G;
break;
case LSM303C_ACC_FULLSCALE_4G:
sensitivity = LSM303C_ACC_SENSITIVITY_4G;
break;
case LSM303C_ACC_FULLSCALE_8G:
sensitivity = LSM303C_ACC_SENSITIVITY_8G;
break;
}
/* Obtain the mg value for the three axis */
for(i=0; i<3; i++)
{
pData[i]=(pnRawData[i] * sensitivity);
}
}
/***********************************************************************************************
Magnetometer driver
***********************************************************************************************/
/**
* @brief Set LSM303C Magnetometer Initialization.
* @param LSM303C_InitStruct: pointer to a LSM303C_MagInitTypeDef structure
* that contains the configuration setting for the LSM303C.
* @retval None
*/
void LSM303C_MagInit(MAGNETO_InitTypeDef LSM303C_InitStruct)
{
MAGNETO_IO_Write(LSM303C_CTRL_REG1_M, LSM303C_InitStruct.Register1);
MAGNETO_IO_Write(LSM303C_CTRL_REG2_M, LSM303C_InitStruct.Register2);
MAGNETO_IO_Write(LSM303C_CTRL_REG3_M, LSM303C_InitStruct.Register3);
MAGNETO_IO_Write(LSM303C_CTRL_REG4_M, LSM303C_InitStruct.Register4);
MAGNETO_IO_Write(LSM303C_CTRL_REG5_M, LSM303C_InitStruct.Register5);
}
/**
* @brief LSM303C Magnetometer De-initialization.
* @param None
* @retval None
*/
void LSM303C_MagDeInit(void)
{
}
/**
* @brief Read LSM303C ID.
* @param None
* @retval ID
*/
uint8_t LSM303C_MagReadID(void)
{
/* Low level init */
MAGNETO_IO_Init();
/* Enabled the SPI/I2C read operation */
MAGNETO_IO_Write(LSM303C_CTRL_REG3_M, 0x84);
/* Read value at Who am I register address */
return MAGNETO_IO_Read(LSM303C_WHO_AM_I_ADDR);
}
/**
* @brief Put Magnetometer in power down mode or not.
* @param Mode equal to LSM303C_MAG_POWERDOWN2_MODE means enable deepest Low Power Mode, otherwise other mode is set.
* This parameter can be a value of @ref Mag_Operation_Mode
* @retval None
*/
void LSM303C_MagLowPower(uint16_t Mode)
{
uint8_t ctrl = 0x00;
/* Read control register 1 value */
ctrl = MAGNETO_IO_Read(LSM303C_CTRL_REG3_M);
/* Clear ODR bits */
ctrl &= ~(LSM303C_MAG_SELECTION_MODE);
/* Set mode */
ctrl |= (uint8_t)Mode;
/* write back control register */
MAGNETO_IO_Write(LSM303C_CTRL_REG3_M, ctrl);
}
/**
* @brief Get status for Mag LSM303C data
* @param None
* @retval Data status in a LSM303C Data register
*/
uint8_t LSM303C_MagGetDataStatus(void)
{
/* Read Mag STATUS register */
return MAGNETO_IO_Read(LSM303C_STATUS_REG_M);
}
/**
* @brief Read X, Y & Z Magnetometer values
* @param pData: Data out pointer
* @retval None
*/
void LSM303C_MagReadXYZ(int16_t* pData)
{
uint8_t ctrlx;
uint8_t buffer[6];
uint8_t i=0;
/* Read the magnetometer control register content */
ctrlx = MAGNETO_IO_Read(LSM303C_CTRL_REG4_M);
/* Read output register X, Y & Z magnetometer */
buffer[0] = MAGNETO_IO_Read(LSM303C_OUT_X_L_M);
buffer[1] = MAGNETO_IO_Read(LSM303C_OUT_X_H_M);
buffer[2] = MAGNETO_IO_Read(LSM303C_OUT_Y_L_M);
buffer[3] = MAGNETO_IO_Read(LSM303C_OUT_Y_H_M);
buffer[4] = MAGNETO_IO_Read(LSM303C_OUT_Z_L_M);
buffer[5] = MAGNETO_IO_Read(LSM303C_OUT_Z_H_M);
/* Check in the control register4 the data alignment*/
if((ctrlx & LSM303C_MAG_BLE_MSB))
{
for(i=0; i<3; i++)
{
pData[i]=((int16_t)((uint16_t)buffer[2*i] << 8) + buffer[2*i+1]);
}
}
else
{
for(i=0; i<3; i++)
{
pData[i]=((int16_t)((uint16_t)buffer[2*i+1] << 8) + buffer[2*i]);
}
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,601 @@
/**
******************************************************************************
* @file lsm303c.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the LSM303C.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LSM303C_H
#define __LSM303C_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/accelero.h"
#include "../Common/magneto.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LSM303C
* @{
*/
/** @defgroup LSM303C_Exported_Types
* @{
*/
/**
* @}
*/
/******************************************************************************/
/*************************** START REGISTER MAPPING **************************/
/******************************************************************************/
/* Acceleration Registers */
#define LSM303C_WHO_AM_I_ADDR 0x0F /* device identification register */
#define LSM303C_ACT_THS_A 0x1E
#define LSM303C_ACT_DUR_A 0x1F
#define LSM303C_CTRL_REG1_A 0x20 /* Control register 1 acceleration */
#define LSM303C_CTRL_REG2_A 0x21 /* Control register 2 acceleration */
#define LSM303C_CTRL_REG3_A 0x22 /* Control register 3 acceleration */
#define LSM303C_CTRL_REG4_A 0x23 /* Control register 4 acceleration */
#define LSM303C_CTRL_REG5_A 0x24 /* Control register 5 acceleration */
#define LSM303C_CTRL_REG6_A 0x25 /* Control register 6 acceleration */
#define LSM303C_CTRL_REG7_A 0x26 /* Control register 6 acceleration */
#define LSM303C_STATUS_REG_A 0x27 /* Status register acceleration */
#define LSM303C_OUT_X_L_A 0x28 /* Output Register X acceleration */
#define LSM303C_OUT_X_H_A 0x29 /* Output Register X acceleration */
#define LSM303C_OUT_Y_L_A 0x2A /* Output Register Y acceleration */
#define LSM303C_OUT_Y_H_A 0x2B /* Output Register Y acceleration */
#define LSM303C_OUT_Z_L_A 0x2C /* Output Register Z acceleration */
#define LSM303C_OUT_Z_H_A 0x2D /* Output Register Z acceleration */
#define LSM303C_FIFO_CTRL 0x2E /* Fifo control Register acceleration */
#define LSM303C_FIFO_SRC 0x2F /* Fifo src Register acceleration */
#define LSM303C_IG_CFG1_A 0x30 /* Interrupt 1 configuration Register acceleration */
#define LSM303C_IG_SRC1_A 0x31 /* Interrupt 1 source Register acceleration */
#define LSM303C_IG_THS_X1_A 0x32
#define LSM303C_IG_THS_Y1_A 0x33
#define LSM303C_IG_THS_Z1_A 0x34
#define LSM303C_IG_DUR1_A 0x32
#define LSM303C_INT1_DURATION_A 0x33 /* Interrupt 1 DURATION register acceleration */
#define LSM303C_INT2_CFG_A 0x34 /* Interrupt 2 configuration Register acceleration */
#define LSM303C_INT2_SOURCE_A 0x35 /* Interrupt 2 source Register acceleration */
#define LSM303C_INT2_THS_A 0x36 /* Interrupt 2 Threshold register acceleration */
#define LSM303C_INT2_DURATION_A 0x37 /* Interrupt 2 DURATION register acceleration */
#define LSM303C_CLICK_CFG_A 0x38 /* Click configuration Register acceleration */
#define LSM303C_CLICK_SOURCE_A 0x39 /* Click 2 source Register acceleration */
#define LSM303C_CLICK_THS_A 0x3A /* Click 2 Threshold register acceleration */
#define LSM303C_TIME_LIMIT_A 0x3B /* Time Limit Register acceleration */
#define LSM303C_TIME_LATENCY_A 0x3C /* Time Latency Register acceleration */
#define LSM303C_TIME_WINDOW_A 0x3D /* Time window register acceleration */
/* Magnetic field Registers */
#define LSM303C_CTRL_REG1_M 0x20 /* Magnetic control register 1 */
#define LSM303C_CTRL_REG2_M 0x21 /* Magnetic control register 2 */
#define LSM303C_CTRL_REG3_M 0x22 /* Magnetic control register 3 */
#define LSM303C_CTRL_REG4_M 0x23 /* Magnetic control register 4 */
#define LSM303C_CTRL_REG5_M 0x24 /* Magnetic control register 5 */
#define LSM303C_STATUS_REG_M 0x27 /* Magnetic status register M */
#define LSM303C_OUT_X_L_M 0x28 /* Output Register X magnetic field */
#define LSM303C_OUT_X_H_M 0x29 /* Output Register X magnetic field */
#define LSM303C_OUT_Y_L_M 0x2A /* Output Register Y magnetic field */
#define LSM303C_OUT_Y_H_M 0x2B /* Output Register Y magnetic field */
#define LSM303C_OUT_Z_L_M 0x2C /* Output Register Z magnetic field */
#define LSM303C_OUT_Z_H_M 0x2D /* Output Register Z magnetic field */
#define LSM303C_TEMP_OUT_L_M 0x2E /* Temperature Register magnetic field */
#define LSM303C_TEMP_OUT_H_M 0x2F /* Temperature Register magnetic field */
#define LSM303C_INT_CFG_M 0x30 /* Axis interrupt configuration */
#define LSM303C_INT_SRC_M 0x31 /* Axis interrupt source */
#define LSM303C_INT_THS_L_M 0x32 /* Interrupt threshold L */
#define LSM303C_INT_THS_H_M 0x33 /* Interrupt threshold M */
/******************************************************************************/
/**************************** END REGISTER MAPPING ***************************/
/******************************************************************************/
/** @defgroup Power_Mode_selection
* @{
*/
#define LMS303C_ACC_ID ((uint8_t)0x41)
#define LMS303C_MAG_ID ((uint8_t)0x3D)
/**
* @}
*/
/** @defgroup Acc_OutPut_DataRate_Selection
* @{
*/
#define LSM303C_ACC_ODR_BITPOSITION ((uint8_t)0x70) /*!< Output Data Rate bit position */
#define LSM303C_ACC_ODR_OFF ((uint8_t)0x00) /*!< Output Data Rate powerdown */
#define LSM303C_ACC_ODR_10_HZ ((uint8_t)0x10) /*!< Output Data Rate = 10 Hz */
#define LSM303C_ACC_ODR_50_HZ ((uint8_t)0x20) /*!< Output Data Rate = 50 Hz */
#define LSM303C_ACC_ODR_100_HZ ((uint8_t)0x30) /*!< Output Data Rate = 100 Hz */
#define LSM303C_ACC_ODR_200_HZ ((uint8_t)0x40) /*!< Output Data Rate = 200 Hz */
#define LSM303C_ACC_ODR_400_HZ ((uint8_t)0x50) /*!< Output Data Rate = 400 Hz */
#define LSM303C_ACC_ODR_800_HZ ((uint8_t)0x60) /*!< Output Data Rate = 800 Hz */
/**
* @}
*/
/** @defgroup Acc_Axes_Selection
* @{
*/
#define LSM303C_ACC_X_ENABLE ((uint8_t)0x01)
#define LSM303C_ACC_Y_ENABLE ((uint8_t)0x02)
#define LSM303C_ACC_Z_ENABLE ((uint8_t)0x04)
#define LSM303C_ACC_AXES_ENABLE ((uint8_t)0x07)
#define LSM303C_ACC_AXES_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Acc_High_Resolution
* @{
*/
#define LSM303C_ACC_HR_ENABLE ((uint8_t)0x80)
#define LSM303C_ACC_HR_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Communication_Mode
* @{
*/
#define LSM303C_ACC_I2C_MODE ((uint8_t) 0x02)
#define LSM303C_ACC_SPI_MODE ((uint8_t) 0x01)
/**
* @}
*/
/** @defgroup Acc_Full_Scale_Selection
* @{
*/
#define LSM303C_ACC_FULLSCALE_2G ((uint8_t)0x00) /*!< <20>2 g */
#define LSM303C_ACC_FULLSCALE_4G ((uint8_t)0x20) /*!< <20>4 g */
#define LSM303C_ACC_FULLSCALE_8G ((uint8_t)0x30) /*!< <20>8 g */
/**
* @}
*/
/** @defgroup Acc_Full_Scale_Selection
* @{
*/
#define LSM303C_ACC_SENSITIVITY_2G ((uint8_t)1) /*!< accelerometer sensitivity with 2 g full scale [mg/LSB] */
#define LSM303C_ACC_SENSITIVITY_4G ((uint8_t)2) /*!< accelerometer sensitivity with 4 g full scale [mg/LSB] */
#define LSM303C_ACC_SENSITIVITY_8G ((uint8_t)4) /*!< accelerometer sensitivity with 8 g full scale [mg/LSB] */
#define LSM303C_ACC_SENSITIVITY_16G ((uint8_t)12) /*!< accelerometer sensitivity with 12 g full scale [mg/LSB] */
/**
* @}
*/
/** @defgroup Acc_Block_Data_Update
* @{
*/
#define LSM303C_ACC_BDU_CONTINUOUS ((uint8_t)0x00) /*!< Continuos Update */
#define LSM303C_ACC_BDU_MSBLSB ((uint8_t)0x08) /*!< Single Update: output registers not updated until MSB and LSB reading */
/**
* @}
*/
/** @defgroup Acc_Endian_Data_selection
* @{
*/
#define LSM303C_ACC_BLE_LSB ((uint8_t)0x00) /*!< Little Endian: data LSB @ lower address */
#define LSM303C_ACC_BLE_MSB ((uint8_t)0x40) /*!< Big Endian: data MSB @ lower address */
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_Mode
* @{
*/
#define LSM303C_ACC_HPM_REF_SIGNAL ((uint8_t)0x08)
#define LSM303C_ACC_HPM_NORMAL_MODE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Acc_High_Pass_CUT OFF_Frequency
* @{
*/
#define LSM303C_ACC_DFC1_ODRDIV50 ((uint8_t)0x00)
#define LSM303C_ACC_DFC1_ODRDIV100 ((uint8_t)0x20)
#define LSM303C_ACC_DFC1_ODRDIV9 ((uint8_t)0x40)
#define LSM303C_ACC_DFC1_ODRDIV400 ((uint8_t)0x60)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_status
* @{
*/
#define LSM303C_ACC_HPF_DISABLE ((uint8_t)0x00)
#define LSM303C_ACC_HPF_ENABLE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_Click_status
* @{
*/
#define LSM303C_ACC_HPF_CLICK_DISABLE ((uint8_t)0x00)
#define LSM303C_ACC_HPF_CLICK_ENABLE ((uint8_t)0x04)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_HPI2S_status
* @{
*/
#define LSM303C_ACC_HPI2S_INT1_DISABLE ((uint8_t)0x00)
#define LSM303C_ACC_HPI2S_INT1_ENABLE ((uint8_t)0x01)
#define LSM303C_ACC_HPI2S_INT2_DISABLE ((uint8_t)0x00)
#define LSM303C_ACC_HPI2S_INT2_ENABLE ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_Interrupt1_Configuration_definition
* @{
*/
#define LSM303C_IT1_CLICK ((uint8_t)0x80)
#define LSM303C_IT1_AOI1 ((uint8_t)0x40)
#define LSM303C_IT1_AOI2 ((uint8_t)0x20)
#define LSM303C_IT1_DRY1 ((uint8_t)0x10)
#define LSM303C_IT1_DRY2 ((uint8_t)0x08)
#define LSM303C_IT1_WTM ((uint8_t)0x04)
#define LSM303C_IT1_OVERRUN ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_Interrupt2_Configuration_definition
* @{
*/
#define LSM303C_IT2_CLICK ((uint8_t)0x80)
#define LSM303C_IT2_INT1 ((uint8_t)0x40)
#define LSM303C_IT2_INT2 ((uint8_t)0x20)
#define LSM303C_IT2_BOOT ((uint8_t)0x10)
#define LSM303C_IT2_ACT ((uint8_t)0x08)
#define LSM303C_IT2_HLACTIVE ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_INT_Combination_Status
* @{
*/
#define LSM303C_OR_COMBINATION ((uint8_t)0x00) /*!< OR combination of enabled IRQs */
#define LSM303C_AND_COMBINATION ((uint8_t)0x80) /*!< AND combination of enabled IRQs */
#define LSM303C_MOV_RECOGNITION ((uint8_t)0x40) /*!< 6D movement recognition */
#define LSM303C_POS_RECOGNITION ((uint8_t)0xC0) /*!< 6D position recognition */
/**
* @}
*/
/** @defgroup Acc_INT_Axes
* @{
*/
#define LSM303C_Z_HIGH ((uint8_t)0x20) /*!< Z High enabled IRQs */
#define LSM303C_Z_LOW ((uint8_t)0x10) /*!< Z low enabled IRQs */
#define LSM303C_Y_HIGH ((uint8_t)0x08) /*!< Y High enabled IRQs */
#define LSM303C_Y_LOW ((uint8_t)0x04) /*!< Y low enabled IRQs */
#define LSM303C_X_HIGH ((uint8_t)0x02) /*!< X High enabled IRQs */
#define LSM303C_X_LOW ((uint8_t)0x01) /*!< X low enabled IRQs */
/**
* @}
*/
/** @defgroup Acc_INT_Click
* @{
*/
#define LSM303C_Z_DOUBLE_CLICK ((uint8_t)0x20) /*!< Z double click IRQs */
#define LSM303C_Z_SINGLE_CLICK ((uint8_t)0x10) /*!< Z single click IRQs */
#define LSM303C_Y_DOUBLE_CLICK ((uint8_t)0x08) /*!< Y double click IRQs */
#define LSM303C_Y_SINGLE_CLICK ((uint8_t)0x04) /*!< Y single click IRQs */
#define LSM303C_X_DOUBLE_CLICK ((uint8_t)0x02) /*!< X double click IRQs */
#define LSM303C_X_SINGLE_CLICK ((uint8_t)0x01) /*!< X single click IRQs */
/**
* @}
*/
/** @defgroup Acc_INT1_Interrupt_status
* @{
*/
#define LSM303C_INT1INTERRUPT_DISABLE ((uint8_t)0x00)
#define LSM303C_INT1INTERRUPT_ENABLE ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup Acc_INT1_Interrupt_ActiveEdge
* @{
*/
#define LSM303C_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20)
#define LSM303C_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Mag_Temperature_Sensor
* @{
*/
#define LSM303C_MAG_TEMPSENSOR_ENABLE ((uint8_t) 0x80) /*!< Temp sensor Enable */
#define LSM303C_MAG_TEMPSENSOR_DISABLE ((uint8_t) 0x00) /*!< Temp sensor Disable */
/**
* @}
*/
/** @defgroup Mag_XY-axis_Operating_Mode
* @{
*/
#define LSM303C_MAG_OM_XY_LOWPOWER ((uint8_t) 0x00 << 5)
#define LSM303C_MAG_OM_XY_MEDIUM ((uint8_t) 0x01 << 5)
#define LSM303C_MAG_OM_XY_HIGH ((uint8_t) 0x02 << 5)
#define LSM303C_MAG_OM_XY_ULTRAHIGH ((uint8_t) 0x03 << 5)
/**
* @}
*/
/** @defgroup Mag_Data_Rate
* @{
*/
#define LSM303C_MAG_ODR_0_625_HZ ((uint8_t) 0x00 << 2) /*!< Output Data Rate = 0.625 Hz */
#define LSM303C_MAG_ODR_1_25_HZ ((uint8_t) 0x01 << 2) /*!< Output Data Rate = 1.25 Hz */
#define LSM303C_MAG_ODR_2_5_HZ ((uint8_t) 0x02 << 2) /*!< Output Data Rate = 2.5 Hz */
#define LSM303C_MAG_ODR_5_0_HZ ((uint8_t) 0x03 << 2) /*!< Output Data Rate = 5.0 Hz */
#define LSM303C_MAG_ODR_10_HZ ((uint8_t) 0x04 << 2) /*!< Output Data Rate = 10 Hz */
#define LSM303C_MAG_ODR_20_HZ ((uint8_t) 0x05 << 2) /*!< Output Data Rate = 20 Hz */
#define LSM303C_MAG_ODR_40_HZ ((uint8_t) 0x06 << 2) /*!< Output Data Rate = 40 Hz */
#define LSM303C_MAG_ODR_80_HZ ((uint8_t) 0x07 << 2) /*!< Output Data Rate = 80 Hz */
/**
* @}
*/
/** @defgroup Mag_Data_Rate
* @{
*/
#define LMS303C_MAG_SELFTEST_DISABLE ((uint8_t 0x00)
#define LMS303C_MAG_SELFTEST_ENABLE ((uint8_t 0x01)
/**
* @}
*/
/** @defgroup Mag_Full_Scale
* @{
*/
#define LSM303C_MAG_FS_DEFAULT ((uint8_t) 0x00 << 5)
#define LSM303C_MAG_FS_16_GA ((uint8_t) 0x03 << 5) /*!< Full scale = <20>16 Gauss */
/**
* @}
*/
/** @defgroup Mag_Reboot
* @{
*/
#define LSM303C_MAG_REBOOT_DEFAULT ((uint8_t) 0x00 << 3)
#define LSM303C_MAG_REBOOT_ENABLE ((uint8_t) 0x01 << 3)
/**
* @}
*/
/** @defgroup Mag_Soft_reset
* @{
*/
#define LSM303C_MAG_SOFT_RESET_DEFAULT ((uint8_t) 0x00 << 2)
#define LSM303C_MAG_SOFT_RESET_ENABLE ((uint8_t) 0x01 << 2)
/**
* @}
*/
/** @defgroup Mag_Communication_Mode
* @{
*/
#define LSM303C_MAG_I2C_MODE ((uint8_t) 0x80)
#define LSM303C_MAG_SPI_MODE ((uint8_t) 0x04)
/**
* @}
*/
/** @defgroup Mag_Lowpower_mode_config
* @{
*/
#define LSM303C_MAG_CONFIG_NORMAL_MODE ((uint8_t) 0x00)
#define LSM303C_MAG_CONFIG_LOWPOWER_MODE ((uint8_t) 0x20)
/**
* @}
*/
/** @defgroup Mag_Operation_Mode
* @{
*/
#define LSM303C_MAG_SELECTION_MODE ((uint8_t) 0x03)
#define LSM303C_MAG_CONTINUOUS_MODE ((uint8_t) 0x00)
#define LSM303C_MAG_SINGLE_MODE ((uint8_t) 0x01)
#define LSM303C_MAG_POWERDOWN1_MODE ((uint8_t) 0x02)
#define LSM303C_MAG_POWERDOWN2_MODE ((uint8_t) 0x03)
/**
* @}
*/
/** @defgroup Mag_Z-axis_Operation_Mode
* @{
*/
#define LSM303C_MAG_OM_Z_LOWPOWER ((uint8_t) 0x00 << 2)
#define LSM303C_MAG_OM_Z_MEDIUM ((uint8_t) 0x01 << 2)
#define LSM303C_MAG_OM_Z_HIGH ((uint8_t) 0x02 << 2)
#define LSM303C_MAG_OM_Z_ULTRAHIGH ((uint8_t) 0x03 << 2)
/**
* @}
*/
/** @defgroup Mag_Big_little-endian_selection
* @{
*/
#define LSM303C_MAG_BLE_LSB ((uint8_t) 0x00)
#define LSM303C_MAG_BLE_MSB ((uint8_t) 0x02)
/**
* @}
*/
/** @defgroup Mag_Bloc_update_magnetic_data
* @{
*/
#define LSM303C_MAG_BDU_CONTINUOUS ((uint8_t) 0x00)
#define LSM303C_MAG_BDU_MSBLSB ((uint8_t) 0x40)
/**
* @}
*/
/**
* @defgroup Magnetometer_Sensitivity
* @{
*/
#define LSM303C_M_SENSITIVITY_XY_1_3Ga 1100 /*!< magnetometer X Y axes sensitivity for 1.3 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_1_9Ga 855 /*!< magnetometer X Y axes sensitivity for 1.9 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_2_5Ga 670 /*!< magnetometer X Y axes sensitivity for 2.5 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_4Ga 450 /*!< magnetometer X Y axes sensitivity for 4 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_4_7Ga 400 /*!< magnetometer X Y axes sensitivity for 4.7 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_5_6Ga 330 /*!< magnetometer X Y axes sensitivity for 5.6 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_8_1Ga 230 /*!< magnetometer X Y axes sensitivity for 8.1 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_1_3Ga 980 /*!< magnetometer Z axis sensitivity for 1.3 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_1_9Ga 760 /*!< magnetometer Z axis sensitivity for 1.9 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_2_5Ga 600 /*!< magnetometer Z axis sensitivity for 2.5 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_4Ga 400 /*!< magnetometer Z axis sensitivity for 4 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_4_7Ga 355 /*!< magnetometer Z axis sensitivity for 4.7 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_5_6Ga 295 /*!< magnetometer Z axis sensitivity for 5.6 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_8_1Ga 205 /*!< magnetometer Z axis sensitivity for 8.1 Ga full scale [LSB/Ga] */
/**
* @}
*/
/** @defgroup Mag_Working_Mode
* @{
*/
#define LSM303C_CONTINUOUS_CONVERSION ((uint8_t) 0x00) /*!< Continuous-Conversion Mode */
#define LSM303C_SINGLE_CONVERSION ((uint8_t) 0x01) /*!< Single-Conversion Mode */
#define LSM303C_SLEEP ((uint8_t) 0x02) /*!< Sleep Mode */
/**
* @}
*/
/** @defgroup LSM303C_AccExported_Functions ACCELEROMETER Exported functions
* @{
*/
void LSM303C_AccInit(uint16_t InitStruct);
void LSM303C_AccDeInit(void);
uint8_t LSM303C_AccReadID(void);
void LSM303C_AccLowPower(uint16_t Mode);
void LSM303C_AccFilterConfig(uint8_t FilterStruct);
void LSM303C_AccFilterCmd(uint8_t HighPassFilterState);
void LSM303C_AccReadXYZ(int16_t* pData);
void LSM303C_AccFilterClickCmd(uint8_t HighPassFilterClickState);
void LSM303C_AccIT1Enable(uint8_t LSM303C_IT);
void LSM303C_AccIT1Disable(uint8_t LSM303C_IT);
void LSM303C_AccIT2Enable(uint8_t LSM303C_IT);
void LSM303C_AccIT2Disable(uint8_t LSM303C_IT);
void LSM303C_AccClickITEnable(uint8_t ITClick);
void LSM303C_AccClickITDisable(uint8_t ITClick);
void LSM303C_AccZClickITConfig(void);
/**
* @}
*/
/** @defgroup LSM303C_AccImported_Globals ACCELEROMETER Imported Globals
* @{
*/
extern ACCELERO_DrvTypeDef Lsm303cDrv_accelero;
/**
* @}
*/
/** @defgroup LSM303C_MagExported_Functions MAGNETOMETER Exported functions
* @{
*/
void LSM303C_MagInit(MAGNETO_InitTypeDef LSM303C_InitStruct);
void LSM303C_MagDeInit(void);
uint8_t LSM303C_MagReadID(void);
void LSM303C_MagLowPower(uint16_t Mode);
void LSM303C_MagReadXYZ(int16_t* pData);
uint8_t LSM303C_MagGetDataStatus(void);
/**
* @}
*/
/** @defgroup LSM303C_MagImported_Globals MAGNETOMETER Imported Globals
* @{
*/
extern MAGNETO_DrvTypeDef Lsm303cDrv_magneto;
/**
* @}
*/
/** @defgroup LSM303C_Imported_Functions LSM303C IO Imported Functions
* @{
*/
/* ACCELERO IO functions */
extern void ACCELERO_IO_Init(void);
extern void ACCELERO_IO_ITConfig(void);
extern void ACCELERO_IO_Write(uint8_t RegisterAddr, uint8_t Value);
extern uint8_t ACCELERO_IO_Read(uint8_t RegisterAddr);
/* MAGNETO IO function */
extern void MAGNETO_IO_Init(void);
extern void MAGNETO_IO_ITConfig(void);
extern void MAGNETO_IO_Write(uint8_t RegisterAddr, uint8_t Value);
extern uint8_t MAGNETO_IO_Read(uint8_t RegisterAddr);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LSM303C_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,88 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LSM303DLHC Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-lsm303dlhc-component-drivers"><small>Release Notes for</small> <mark>LSM303DLHC Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LSM303DLHC component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V2.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V2.0.0 / 24-June-2015</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>lsm303dlhc.c
<ul>
<li>Add accelerometer de-initialization function: LSM303DLHC_AccDeInit()</li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong> This release must be used with BSP Common driver V4.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.0.1 / 21-November-2014</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>lsm303dlhc.h: change “\” by “/” in the include path to fix compilation issue under Linux</li>
<li>Miscellaneous comments update</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.0.0 / 18-February-2014</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,560 @@
/**
******************************************************************************
* @file lsm303dlhc.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the lsm303dlhc
* MEMS accelerometer.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lsm303dlhc.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LSM303DLHC
* @{
*/
/** @defgroup LSM303DLHC_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup LSM303DLHC_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup LSM303DLHC_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup LSM303DLHC_Private_Variables
* @{
*/
ACCELERO_DrvTypeDef Lsm303dlhcDrv =
{
LSM303DLHC_AccInit,
LSM303DLHC_AccDeInit,
LSM303DLHC_AccReadID,
LSM303DLHC_AccRebootCmd,
0,
LSM303DLHC_AccZClickITConfig,
0,
0,
0,
0,
LSM303DLHC_AccFilterConfig,
LSM303DLHC_AccFilterCmd,
LSM303DLHC_AccReadXYZ
};
/**
* @}
*/
/** @defgroup LSM303DLHC_Private_Functions
* @{
*/
/**
* @brief Set LSM303DLHC Initialization.
* @param InitStruct: Init parameters
* @retval None
*/
void LSM303DLHC_AccInit(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
/* Low level init */
COMPASSACCELERO_IO_Init();
/* Write value to ACC MEMS CTRL_REG1 register */
ctrl = (uint8_t) InitStruct;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG1_A, ctrl);
/* Write value to ACC MEMS CTRL_REG4 register */
ctrl = (uint8_t) (InitStruct << 8);
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG4_A, ctrl);
}
/**
* @brief LSM303DLHC De-initialization.
* @param None
* @retval None
*/
void LSM303DLHC_AccDeInit(void)
{
}
/**
* @brief Read LSM303DLHC ID.
* @param None
* @retval ID
*/
uint8_t LSM303DLHC_AccReadID(void)
{
uint8_t ctrl = 0x00;
/* Low level init */
COMPASSACCELERO_IO_Init();
/* Read value at Who am I register address */
ctrl = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_WHO_AM_I_ADDR);
return ctrl;
}
/**
* @brief Reboot memory content of LSM303DLHC
* @param None
* @retval None
*/
void LSM303DLHC_AccRebootCmd(void)
{
uint8_t tmpreg;
/* Read CTRL_REG5 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG5_A);
/* Enable or Disable the reboot memory */
tmpreg |= LSM303DLHC_BOOT_REBOOTMEMORY;
/* Write value to ACC MEMS CTRL_REG5 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG5_A, tmpreg);
}
/**
* @brief Set High Pass Filter Modality
* @param FilterStruct: contains data for filter config
* @retval None
*/
void LSM303DLHC_AccFilterConfig(uint8_t FilterStruct)
{
uint8_t tmpreg;
/* Read CTRL_REG2 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A);
tmpreg &= 0x0C;
tmpreg |= FilterStruct;
/* Write value to ACC MEMS CTRL_REG2 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A, tmpreg);
}
/**
* @brief Enable or Disable High Pass Filter
* @param HighPassFilterState: new state of the High Pass Filter feature.
* This parameter can be:
* @arg: LSM303DLHC_HIGHPASSFILTER_DISABLE
* @arg: LSM303DLHC_HIGHPASSFILTER_ENABLE
* @retval None
*/
void LSM303DLHC_AccFilterCmd(uint8_t HighPassFilterState)
{
uint8_t tmpreg;
/* Read CTRL_REG2 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A);
tmpreg &= 0xF7;
tmpreg |= HighPassFilterState;
/* Write value to ACC MEMS CTRL_REG2 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A, tmpreg);
}
/**
* @brief Read X, Y & Z Acceleration values
* @param pData: Data out pointer
* @retval None
*/
void LSM303DLHC_AccReadXYZ(int16_t* pData)
{
int16_t pnRawData[3];
uint8_t ctrlx[2]={0,0};
int8_t buffer[6];
uint8_t i = 0;
uint8_t sensitivity = LSM303DLHC_ACC_SENSITIVITY_2G;
/* Read the acceleration control register content */
ctrlx[0] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG4_A);
ctrlx[1] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG5_A);
/* Read output register X, Y & Z acceleration */
buffer[0] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_X_L_A);
buffer[1] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_X_H_A);
buffer[2] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Y_L_A);
buffer[3] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Y_H_A);
buffer[4] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Z_L_A);
buffer[5] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Z_H_A);
/* Check in the control register4 the data alignment*/
if(!(ctrlx[0] & LSM303DLHC_BLE_MSB))
{
for(i=0; i<3; i++)
{
pnRawData[i]=((int16_t)((uint16_t)buffer[2*i+1] << 8) + buffer[2*i]);
}
}
else /* Big Endian Mode */
{
for(i=0; i<3; i++)
{
pnRawData[i]=((int16_t)((uint16_t)buffer[2*i] << 8) + buffer[2*i+1]);
}
}
/* Normal mode */
/* Switch the sensitivity value set in the CRTL4 */
switch(ctrlx[0] & LSM303DLHC_FULLSCALE_16G)
{
case LSM303DLHC_FULLSCALE_2G:
sensitivity = LSM303DLHC_ACC_SENSITIVITY_2G;
break;
case LSM303DLHC_FULLSCALE_4G:
sensitivity = LSM303DLHC_ACC_SENSITIVITY_4G;
break;
case LSM303DLHC_FULLSCALE_8G:
sensitivity = LSM303DLHC_ACC_SENSITIVITY_8G;
break;
case LSM303DLHC_FULLSCALE_16G:
sensitivity = LSM303DLHC_ACC_SENSITIVITY_16G;
break;
}
/* Obtain the mg value for the three axis */
for(i=0; i<3; i++)
{
pData[i]=(pnRawData[i] * sensitivity);
}
}
/**
* @brief Enable or Disable High Pass Filter on CLick
* @param HighPassFilterState: new state of the High Pass Filter feature.
* This parameter can be:
* @arg: LSM303DLHC_HPF_CLICK_DISABLE
* @arg: LSM303DLHC_HPF_CLICK_ENABLE
* @retval None
*/
void LSM303DLHC_AccFilterClickCmd(uint8_t HighPassFilterClickState)
{
uint8_t tmpreg = 0x00;
/* Read CTRL_REG2 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A);
tmpreg &= ~(LSM303DLHC_HPF_CLICK_ENABLE);
tmpreg |= HighPassFilterClickState;
/* Write value to ACC MEMS CTRL_REG2 regsister */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A, tmpreg);
}
/**
* @brief Enable LSM303DLHC Interrupt1
* @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be enabled.
* This parameter can be any combination of the following values:
* @arg LSM303DLHC_IT1_CLICK
* @arg LSM303DLHC_IT1_AOI1
* @arg LSM303DLHC_IT1_AOI2
* @arg LSM303DLHC_IT1_DRY1
* @arg LSM303DLHC_IT1_DRY2
* @arg LSM303DLHC_IT1_WTM
* @arg LSM303DLHC_IT1_OVERRUN
* @retval None
*/
void LSM303DLHC_AccIT1Enable(uint8_t LSM303DLHC_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A);
/* Enable IT1 */
tmpval |= LSM303DLHC_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A, tmpval);
}
/**
* @brief Disable LSM303DLHC Interrupt1
* @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be disabled.
* This parameter can be any combination of the following values:
* @arg LSM303DLHC_IT1_CLICK
* @arg LSM303DLHC_IT1_AOI1
* @arg LSM303DLHC_IT1_AOI2
* @arg LSM303DLHC_IT1_DRY1
* @arg LSM303DLHC_IT1_DRY2
* @arg LSM303DLHC_IT1_WTM
* @arg LSM303DLHC_IT1_OVERRUN
* @retval None
*/
void LSM303DLHC_AccIT1Disable(uint8_t LSM303DLHC_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A);
/* Disable IT1 */
tmpval &= ~LSM303DLHC_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A, tmpval);
}
/**
* @brief Enable LSM303DLHC Interrupt2
* @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be enabled.
* This parameter can be any combination of the following values:
* @arg LSM303DLHC_IT2_CLICK
* @arg LSM303DLHC_IT2_INT1
* @arg LSM303DLHC_IT2_INT2
* @arg LSM303DLHC_IT2_BOOT
* @arg LSM303DLHC_IT2_ACT
* @arg LSM303DLHC_IT2_HLACTIVE
* @retval None
*/
void LSM303DLHC_AccIT2Enable(uint8_t LSM303DLHC_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A);
/* Enable IT2 */
tmpval |= LSM303DLHC_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A, tmpval);
}
/**
* @brief Disable LSM303DLHC Interrupt2
* @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be disabled.
* This parameter can be any combination of the following values:
* @arg LSM303DLHC_IT2_CLICK
* @arg LSM303DLHC_IT2_INT1
* @arg LSM303DLHC_IT2_INT2
* @arg LSM303DLHC_IT2_BOOT
* @arg LSM303DLHC_IT2_ACT
* @arg LSM303DLHC_IT2_HLACTIVE
* @retval None
*/
void LSM303DLHC_AccIT2Disable(uint8_t LSM303DLHC_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A);
/* Disable IT2 */
tmpval &= ~LSM303DLHC_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A, tmpval);
}
/**
* @brief INT1 interrupt enable
* @param ITCombination: Or or And combination
* ITAxes: Axes to be enabled
* @retval None
*/
void LSM303DLHC_AccINT1InterruptEnable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT1_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A);
/* Enable the selected interrupt */
tmpval |= (ITAxes | ITCombination);
/* Write value to MEMS INT1_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A, tmpval);
}
/**
* @brief INT1 interrupt disable
* @param ITCombination: Or or And combination
* ITAxes: Axes to be enabled
* @retval None
*/
void LSM303DLHC_AccINT1InterruptDisable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT1_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A);
/* Disable the selected interrupt */
tmpval &= ~(ITAxes | ITCombination);
/* Write value to MEMS INT1_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A, tmpval);
}
/**
* @brief INT2 interrupt enable
* @param ITCombination: Or or And combination
* ITAxes: axes to be enabled
* @retval None
*/
void LSM303DLHC_AccINT2InterruptEnable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT2_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A);
/* Enable the selected interrupt */
tmpval |= (ITAxes | ITCombination);
/* Write value to MEMS INT2_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A, tmpval);
}
/**
* @brief INT2 interrupt config
* @param ITCombination: Or or And combination
* ITAxes: axes to be enabled
* @retval None
*/
void LSM303DLHC_AccINT2InterruptDisable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT2_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A);
/* Disable the selected interrupt */
tmpval &= ~(ITAxes | ITCombination);
/* Write value to MEMS INT2_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A, tmpval);
}
/**
* @brief Click interrupt enable
* @param ITClick: the selected interrupt to enable
* @retval None
*/
void LSM303DLHC_AccClickITEnable(uint8_t ITClick)
{
uint8_t tmpval = 0x00;
/* Read CLICK_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A);
/* Enable the selected interrupt */
tmpval |= ITClick;
/* Write value to MEMS CLICK CFG register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A, tmpval);
/* Configure Click Threshold on Z axis */
tmpval = 0x0A;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_THS_A, tmpval);
/* Configure Time Limit */
tmpval = 0x05;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_TIME_LIMIT_A, tmpval);
/* Configure Latency */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_TIME_LATENCY_A, tmpval);
/* Configure Click Window */
tmpval = 0x32;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_TIME_WINDOW_A, tmpval);
}
/**
* @brief Click interrupt disable
* @param ITClick: the selected click interrupt to disable
* @retval None
*/
void LSM303DLHC_AccClickITDisable(uint8_t ITClick)
{
uint8_t tmpval = 0x00;
/* Read CLICK_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A);
/* Disable the selected interrupt */
tmpval &= ~ITClick;
/* Write value to MEMS CLICK_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A, tmpval);
}
/**
* @brief Click on Z axis interrupt config
* @param None
* @retval None
*/
void LSM303DLHC_AccZClickITConfig(void)
{
/* Configure low level IT config */
COMPASSACCELERO_IO_ITConfig();
/* Select click IT as INT1 interrupt */
LSM303DLHC_AccIT1Enable(LSM303DLHC_IT1_CLICK);
/* Enable High pass filter for click IT */
LSM303DLHC_AccFilterClickCmd(LSM303DLHC_HPF_CLICK_ENABLE);
/* Enable simple click IT on Z axis, */
LSM303DLHC_AccClickITEnable(LSM303DLHC_Z_SINGLE_CLICK);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,480 @@
/**
******************************************************************************
* @file lsm303dlhc.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the lsm303dlhc.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LSM303DLHC_H
#define __LSM303DLHC_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/accelero.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LSM303DLHC
* @{
*/
/** @defgroup LSM303DLHC_Exported_Types
* @{
*/
/**
* @}
*/
/******************************************************************************/
/*************************** START REGISTER MAPPING **************************/
/******************************************************************************/
/* Exported constant IO ------------------------------------------------------*/
#define ACC_I2C_ADDRESS 0x32
#define MAG_I2C_ADDRESS 0x3C
/* Acceleration Registers */
#define LSM303DLHC_WHO_AM_I_ADDR 0x0F /* device identification register */
#define LSM303DLHC_CTRL_REG1_A 0x20 /* Control register 1 acceleration */
#define LSM303DLHC_CTRL_REG2_A 0x21 /* Control register 2 acceleration */
#define LSM303DLHC_CTRL_REG3_A 0x22 /* Control register 3 acceleration */
#define LSM303DLHC_CTRL_REG4_A 0x23 /* Control register 4 acceleration */
#define LSM303DLHC_CTRL_REG5_A 0x24 /* Control register 5 acceleration */
#define LSM303DLHC_CTRL_REG6_A 0x25 /* Control register 6 acceleration */
#define LSM303DLHC_REFERENCE_A 0x26 /* Reference register acceleration */
#define LSM303DLHC_STATUS_REG_A 0x27 /* Status register acceleration */
#define LSM303DLHC_OUT_X_L_A 0x28 /* Output Register X acceleration */
#define LSM303DLHC_OUT_X_H_A 0x29 /* Output Register X acceleration */
#define LSM303DLHC_OUT_Y_L_A 0x2A /* Output Register Y acceleration */
#define LSM303DLHC_OUT_Y_H_A 0x2B /* Output Register Y acceleration */
#define LSM303DLHC_OUT_Z_L_A 0x2C /* Output Register Z acceleration */
#define LSM303DLHC_OUT_Z_H_A 0x2D /* Output Register Z acceleration */
#define LSM303DLHC_FIFO_CTRL_REG_A 0x2E /* Fifo control Register acceleration */
#define LSM303DLHC_FIFO_SRC_REG_A 0x2F /* Fifo src Register acceleration */
#define LSM303DLHC_INT1_CFG_A 0x30 /* Interrupt 1 configuration Register acceleration */
#define LSM303DLHC_INT1_SOURCE_A 0x31 /* Interrupt 1 source Register acceleration */
#define LSM303DLHC_INT1_THS_A 0x32 /* Interrupt 1 Threshold register acceleration */
#define LSM303DLHC_INT1_DURATION_A 0x33 /* Interrupt 1 DURATION register acceleration */
#define LSM303DLHC_INT2_CFG_A 0x34 /* Interrupt 2 configuration Register acceleration */
#define LSM303DLHC_INT2_SOURCE_A 0x35 /* Interrupt 2 source Register acceleration */
#define LSM303DLHC_INT2_THS_A 0x36 /* Interrupt 2 Threshold register acceleration */
#define LSM303DLHC_INT2_DURATION_A 0x37 /* Interrupt 2 DURATION register acceleration */
#define LSM303DLHC_CLICK_CFG_A 0x38 /* Click configuration Register acceleration */
#define LSM303DLHC_CLICK_SOURCE_A 0x39 /* Click 2 source Register acceleration */
#define LSM303DLHC_CLICK_THS_A 0x3A /* Click 2 Threshold register acceleration */
#define LSM303DLHC_TIME_LIMIT_A 0x3B /* Time Limit Register acceleration */
#define LSM303DLHC_TIME_LATENCY_A 0x3C /* Time Latency Register acceleration */
#define LSM303DLHC_TIME_WINDOW_A 0x3D /* Time window register acceleration */
/* Magnetic field Registers */
#define LSM303DLHC_CRA_REG_M 0x00 /* Control register A magnetic field */
#define LSM303DLHC_CRB_REG_M 0x01 /* Control register B magnetic field */
#define LSM303DLHC_MR_REG_M 0x02 /* Control register MR magnetic field */
#define LSM303DLHC_OUT_X_H_M 0x03 /* Output Register X magnetic field */
#define LSM303DLHC_OUT_X_L_M 0x04 /* Output Register X magnetic field */
#define LSM303DLHC_OUT_Z_H_M 0x05 /* Output Register Z magnetic field */
#define LSM303DLHC_OUT_Z_L_M 0x06 /* Output Register Z magnetic field */
#define LSM303DLHC_OUT_Y_H_M 0x07 /* Output Register Y magnetic field */
#define LSM303DLHC_OUT_Y_L_M 0x08 /* Output Register Y magnetic field */
#define LSM303DLHC_SR_REG_M 0x09 /* Status Register magnetic field */
#define LSM303DLHC_IRA_REG_M 0x0A /* IRA Register magnetic field */
#define LSM303DLHC_IRB_REG_M 0x0B /* IRB Register magnetic field */
#define LSM303DLHC_IRC_REG_M 0x0C /* IRC Register magnetic field */
#define LSM303DLHC_TEMP_OUT_H_M 0x31 /* Temperature Register magnetic field */
#define LSM303DLHC_TEMP_OUT_L_M 0x32 /* Temperature Register magnetic field */
/******************************************************************************/
/**************************** END REGISTER MAPPING ***************************/
/******************************************************************************/
#define I_AM_LMS303DLHC ((uint8_t)0x33)
/** @defgroup Acc_Power_Mode_selection
* @{
*/
#define LSM303DLHC_NORMAL_MODE ((uint8_t)0x00)
#define LSM303DLHC_LOWPOWER_MODE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup Acc_OutPut_DataRate_Selection
* @{
*/
#define LSM303DLHC_ODR_1_HZ ((uint8_t)0x10) /*!< Output Data Rate = 1 Hz */
#define LSM303DLHC_ODR_10_HZ ((uint8_t)0x20) /*!< Output Data Rate = 10 Hz */
#define LSM303DLHC_ODR_25_HZ ((uint8_t)0x30) /*!< Output Data Rate = 25 Hz */
#define LSM303DLHC_ODR_50_HZ ((uint8_t)0x40) /*!< Output Data Rate = 50 Hz */
#define LSM303DLHC_ODR_100_HZ ((uint8_t)0x50) /*!< Output Data Rate = 100 Hz */
#define LSM303DLHC_ODR_200_HZ ((uint8_t)0x60) /*!< Output Data Rate = 200 Hz */
#define LSM303DLHC_ODR_400_HZ ((uint8_t)0x70) /*!< Output Data Rate = 400 Hz */
#define LSM303DLHC_ODR_1620_HZ_LP ((uint8_t)0x80) /*!< Output Data Rate = 1620 Hz only in Low Power Mode */
#define LSM303DLHC_ODR_1344_HZ ((uint8_t)0x90) /*!< Output Data Rate = 1344 Hz in Normal mode and 5376 Hz in Low Power Mode */
/**
* @}
*/
/** @defgroup Acc_Axes_Selection
* @{
*/
#define LSM303DLHC_X_ENABLE ((uint8_t)0x01)
#define LSM303DLHC_Y_ENABLE ((uint8_t)0x02)
#define LSM303DLHC_Z_ENABLE ((uint8_t)0x04)
#define LSM303DLHC_AXES_ENABLE ((uint8_t)0x07)
#define LSM303DLHC_AXES_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Acc_High_Resolution
* @{
*/
#define LSM303DLHC_HR_ENABLE ((uint8_t)0x08)
#define LSM303DLHC_HR_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Acc_Full_Scale_Selection
* @{
*/
#define LSM303DLHC_FULLSCALE_2G ((uint8_t)0x00) /*!< <20>2 g */
#define LSM303DLHC_FULLSCALE_4G ((uint8_t)0x10) /*!< <20>4 g */
#define LSM303DLHC_FULLSCALE_8G ((uint8_t)0x20) /*!< <20>8 g */
#define LSM303DLHC_FULLSCALE_16G ((uint8_t)0x30) /*!< <20>16 g */
/**
* @}
*/
/** @defgroup Acc_Full_Scale_Selection
* @{
*/
#define LSM303DLHC_ACC_SENSITIVITY_2G ((uint8_t)1) /*!< accelerometer sensitivity with 2 g full scale [mg/LSB] */
#define LSM303DLHC_ACC_SENSITIVITY_4G ((uint8_t)2) /*!< accelerometer sensitivity with 4 g full scale [mg/LSB] */
#define LSM303DLHC_ACC_SENSITIVITY_8G ((uint8_t)4) /*!< accelerometer sensitivity with 8 g full scale [mg/LSB] */
#define LSM303DLHC_ACC_SENSITIVITY_16G ((uint8_t)12) /*!< accelerometer sensitivity with 12 g full scale [mg/LSB] */
/**
* @}
*/
/** @defgroup Acc_Block_Data_Update
* @{
*/
#define LSM303DLHC_BlockUpdate_Continous ((uint8_t)0x00) /*!< Continuos Update */
#define LSM303DLHC_BlockUpdate_Single ((uint8_t)0x80) /*!< Single Update: output registers not updated until MSB and LSB reading */
/**
* @}
*/
/** @defgroup Acc_Endian_Data_selection
* @{
*/
#define LSM303DLHC_BLE_LSB ((uint8_t)0x00) /*!< Little Endian: data LSB @ lower address */
#define LSM303DLHC_BLE_MSB ((uint8_t)0x40) /*!< Big Endian: data MSB @ lower address */
/**
* @}
*/
/** @defgroup Acc_Boot_Mode_selection
* @{
*/
#define LSM303DLHC_BOOT_NORMALMODE ((uint8_t)0x00)
#define LSM303DLHC_BOOT_REBOOTMEMORY ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_Mode
* @{
*/
#define LSM303DLHC_HPM_NORMAL_MODE_RES ((uint8_t)0x00)
#define LSM303DLHC_HPM_REF_SIGNAL ((uint8_t)0x40)
#define LSM303DLHC_HPM_NORMAL_MODE ((uint8_t)0x80)
#define LSM303DLHC_HPM_AUTORESET_INT ((uint8_t)0xC0)
/**
* @}
*/
/** @defgroup Acc_High_Pass_CUT OFF_Frequency
* @{
*/
#define LSM303DLHC_HPFCF_8 ((uint8_t)0x00)
#define LSM303DLHC_HPFCF_16 ((uint8_t)0x10)
#define LSM303DLHC_HPFCF_32 ((uint8_t)0x20)
#define LSM303DLHC_HPFCF_64 ((uint8_t)0x30)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_status
* @{
*/
#define LSM303DLHC_HIGHPASSFILTER_DISABLE ((uint8_t)0x00)
#define LSM303DLHC_HIGHPASSFILTER_ENABLE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_Click_status
* @{
*/
#define LSM303DLHC_HPF_CLICK_DISABLE ((uint8_t)0x00)
#define LSM303DLHC_HPF_CLICK_ENABLE ((uint8_t)0x04)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_AOI1_status
* @{
*/
#define LSM303DLHC_HPF_AOI1_DISABLE ((uint8_t)0x00)
#define LSM303DLHC_HPF_AOI1_ENABLE ((uint8_t)0x01)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_AOI2_status
* @{
*/
#define LSM303DLHC_HPF_AOI2_DISABLE ((uint8_t)0x00)
#define LSM303DLHC_HPF_AOI2_ENABLE ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_Interrupt1_Configuration_definition
* @{
*/
#define LSM303DLHC_IT1_CLICK ((uint8_t)0x80)
#define LSM303DLHC_IT1_AOI1 ((uint8_t)0x40)
#define LSM303DLHC_IT1_AOI2 ((uint8_t)0x20)
#define LSM303DLHC_IT1_DRY1 ((uint8_t)0x10)
#define LSM303DLHC_IT1_DRY2 ((uint8_t)0x08)
#define LSM303DLHC_IT1_WTM ((uint8_t)0x04)
#define LSM303DLHC_IT1_OVERRUN ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_Interrupt2_Configuration_definition
* @{
*/
#define LSM303DLHC_IT2_CLICK ((uint8_t)0x80)
#define LSM303DLHC_IT2_INT1 ((uint8_t)0x40)
#define LSM303DLHC_IT2_INT2 ((uint8_t)0x20)
#define LSM303DLHC_IT2_BOOT ((uint8_t)0x10)
#define LSM303DLHC_IT2_ACT ((uint8_t)0x08)
#define LSM303DLHC_IT2_HLACTIVE ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_INT_Combination_Status
* @{
*/
#define LSM303DLHC_OR_COMBINATION ((uint8_t)0x00) /*!< OR combination of enabled IRQs */
#define LSM303DLHC_AND_COMBINATION ((uint8_t)0x80) /*!< AND combination of enabled IRQs */
#define LSM303DLHC_MOV_RECOGNITION ((uint8_t)0x40) /*!< 6D movement recognition */
#define LSM303DLHC_POS_RECOGNITION ((uint8_t)0xC0) /*!< 6D position recognition */
/**
* @}
*/
/** @defgroup Acc_INT_Axes
* @{
*/
#define LSM303DLHC_Z_HIGH ((uint8_t)0x20) /*!< Z High enabled IRQs */
#define LSM303DLHC_Z_LOW ((uint8_t)0x10) /*!< Z low enabled IRQs */
#define LSM303DLHC_Y_HIGH ((uint8_t)0x08) /*!< Y High enabled IRQs */
#define LSM303DLHC_Y_LOW ((uint8_t)0x04) /*!< Y low enabled IRQs */
#define LSM303DLHC_X_HIGH ((uint8_t)0x02) /*!< X High enabled IRQs */
#define LSM303DLHC_X_LOW ((uint8_t)0x01) /*!< X low enabled IRQs */
/**
* @}
*/
/** @defgroup Acc_INT_Click
* @{
*/
#define LSM303DLHC_Z_DOUBLE_CLICK ((uint8_t)0x20) /*!< Z double click IRQs */
#define LSM303DLHC_Z_SINGLE_CLICK ((uint8_t)0x10) /*!< Z single click IRQs */
#define LSM303DLHC_Y_DOUBLE_CLICK ((uint8_t)0x08) /*!< Y double click IRQs */
#define LSM303DLHC_Y_SINGLE_CLICK ((uint8_t)0x04) /*!< Y single click IRQs */
#define LSM303DLHC_X_DOUBLE_CLICK ((uint8_t)0x02) /*!< X double click IRQs */
#define LSM303DLHC_X_SINGLE_CLICK ((uint8_t)0x01) /*!< X single click IRQs */
/**
* @}
*/
/** @defgroup Acc_INT1_Interrupt_status
* @{
*/
#define LSM303DLHC_INT1INTERRUPT_DISABLE ((uint8_t)0x00)
#define LSM303DLHC_INT1INTERRUPT_ENABLE ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup Acc_INT1_Interrupt_ActiveEdge
* @{
*/
#define LSM303DLHC_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20)
#define LSM303DLHC_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Mag_Data_Rate
* @{
*/
#define LSM303DLHC_ODR_0_75_HZ ((uint8_t) 0x00) /*!< Output Data Rate = 0.75 Hz */
#define LSM303DLHC_ODR_1_5_HZ ((uint8_t) 0x04) /*!< Output Data Rate = 1.5 Hz */
#define LSM303DLHC_ODR_3_0_HZ ((uint8_t) 0x08) /*!< Output Data Rate = 3 Hz */
#define LSM303DLHC_ODR_7_5_HZ ((uint8_t) 0x0C) /*!< Output Data Rate = 7.5 Hz */
#define LSM303DLHC_ODR_15_HZ ((uint8_t) 0x10) /*!< Output Data Rate = 15 Hz */
#define LSM303DLHC_ODR_30_HZ ((uint8_t) 0x14) /*!< Output Data Rate = 30 Hz */
#define LSM303DLHC_ODR_75_HZ ((uint8_t) 0x18) /*!< Output Data Rate = 75 Hz */
#define LSM303DLHC_ODR_220_HZ ((uint8_t) 0x1C) /*!< Output Data Rate = 220 Hz */
/**
* @}
*/
/** @defgroup Mag_Full_Scale
* @{
*/
#define LSM303DLHC_FS_1_3_GA ((uint8_t) 0x20) /*!< Full scale = <20>1.3 Gauss */
#define LSM303DLHC_FS_1_9_GA ((uint8_t) 0x40) /*!< Full scale = <20>1.9 Gauss */
#define LSM303DLHC_FS_2_5_GA ((uint8_t) 0x60) /*!< Full scale = <20>2.5 Gauss */
#define LSM303DLHC_FS_4_0_GA ((uint8_t) 0x80) /*!< Full scale = <20>4.0 Gauss */
#define LSM303DLHC_FS_4_7_GA ((uint8_t) 0xA0) /*!< Full scale = <20>4.7 Gauss */
#define LSM303DLHC_FS_5_6_GA ((uint8_t) 0xC0) /*!< Full scale = <20>5.6 Gauss */
#define LSM303DLHC_FS_8_1_GA ((uint8_t) 0xE0) /*!< Full scale = <20>8.1 Gauss */
/**
* @}
*/
/**
* @defgroup Magnetometer_Sensitivity
* @{
*/
#define LSM303DLHC_M_SENSITIVITY_XY_1_3Ga 1100 /*!< magnetometer X Y axes sensitivity for 1.3 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_1_9Ga 855 /*!< magnetometer X Y axes sensitivity for 1.9 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_2_5Ga 670 /*!< magnetometer X Y axes sensitivity for 2.5 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_4Ga 450 /*!< magnetometer X Y axes sensitivity for 4 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_4_7Ga 400 /*!< magnetometer X Y axes sensitivity for 4.7 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_5_6Ga 330 /*!< magnetometer X Y axes sensitivity for 5.6 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_8_1Ga 230 /*!< magnetometer X Y axes sensitivity for 8.1 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_1_3Ga 980 /*!< magnetometer Z axis sensitivity for 1.3 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_1_9Ga 760 /*!< magnetometer Z axis sensitivity for 1.9 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_2_5Ga 600 /*!< magnetometer Z axis sensitivity for 2.5 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_4Ga 400 /*!< magnetometer Z axis sensitivity for 4 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_4_7Ga 355 /*!< magnetometer Z axis sensitivity for 4.7 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_5_6Ga 295 /*!< magnetometer Z axis sensitivity for 5.6 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_8_1Ga 205 /*!< magnetometer Z axis sensitivity for 8.1 Ga full scale [LSB/Ga] */
/**
* @}
*/
/** @defgroup Mag_Working_Mode
* @{
*/
#define LSM303DLHC_CONTINUOS_CONVERSION ((uint8_t) 0x00) /*!< Continuous-Conversion Mode */
#define LSM303DLHC_SINGLE_CONVERSION ((uint8_t) 0x01) /*!< Single-Conversion Mode */
#define LSM303DLHC_SLEEP ((uint8_t) 0x02) /*!< Sleep Mode */
/**
* @}
*/
/** @defgroup Mag_Temperature_Sensor
* @{
*/
#define LSM303DLHC_TEMPSENSOR_ENABLE ((uint8_t) 0x80) /*!< Temp sensor Enable */
#define LSM303DLHC_TEMPSENSOR_DISABLE ((uint8_t) 0x00) /*!< Temp sensor Disable */
/**
* @}
*/
/** @defgroup LSM303DLHC_Exported_Functions
* @{
*/
/* ACC functions */
void LSM303DLHC_AccInit(uint16_t InitStruct);
void LSM303DLHC_AccDeInit(void);
uint8_t LSM303DLHC_AccReadID(void);
void LSM303DLHC_AccRebootCmd(void);
void LSM303DLHC_AccFilterConfig(uint8_t FilterStruct);
void LSM303DLHC_AccFilterCmd(uint8_t HighPassFilterState);
void LSM303DLHC_AccReadXYZ(int16_t* pData);
void LSM303DLHC_AccFilterClickCmd(uint8_t HighPassFilterClickState);
void LSM303DLHC_AccIT1Enable(uint8_t LSM303DLHC_IT);
void LSM303DLHC_AccIT1Disable(uint8_t LSM303DLHC_IT);
void LSM303DLHC_AccIT2Enable(uint8_t LSM303DLHC_IT);
void LSM303DLHC_AccIT2Disable(uint8_t LSM303DLHC_IT);
void LSM303DLHC_AccINT1InterruptEnable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303DLHC_AccINT1InterruptDisable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303DLHC_AccINT2InterruptEnable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303DLHC_AccINT2InterruptDisable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303DLHC_AccClickITEnable(uint8_t ITClick);
void LSM303DLHC_AccClickITDisable(uint8_t ITClick);
void LSM303DLHC_AccZClickITConfig(void);
/* COMPASS / ACCELERO IO functions */
void COMPASSACCELERO_IO_Init(void);
void COMPASSACCELERO_IO_ITConfig(void);
void COMPASSACCELERO_IO_Write(uint16_t DeviceAddr, uint8_t RegisterAddr, uint8_t Value);
uint8_t COMPASSACCELERO_IO_Read(uint16_t DeviceAddr, uint8_t RegisterAddr);
/* ACC driver structure */
extern ACCELERO_DrvTypeDef Lsm303dlhcDrv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LSM303DLHC_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LSM6DSL Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-lsm6dsl-component-drivers"><small>Release Notes for</small> <mark>LSM6DSL Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LSM6DSL component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 14-February-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of LSM6DSL Accelerometer/Gyroscope sensor</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,376 @@
/**
******************************************************************************
* @file lsm6dsl.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the LSM6DSL
* accelero and gyro devices
******************************************************************************
* @attention
*
* <<h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lsm6dsl.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup LSM6DSL LSM6DSL
* @{
*/
/** @defgroup LSM6DSL_Private_Variables LSM6DSL Private Variables
* @{
*/
ACCELERO_DrvTypeDef Lsm6dslAccDrv =
{
LSM6DSL_AccInit,
LSM6DSL_AccDeInit,
LSM6DSL_AccReadID,
0,
LSM6DSL_AccLowPower,
0,
0,
0,
0,
0,
0,
0,
LSM6DSL_AccReadXYZ
};
GYRO_DrvTypeDef Lsm6dslGyroDrv =
{
LSM6DSL_GyroInit,
LSM6DSL_GyroDeInit,
LSM6DSL_GyroReadID,
0,
LSM6DSL_GyroLowPower,
0,
0,
0,
0,
0,
0,
0,
LSM6DSL_GyroReadXYZAngRate
};
/**
* @}
*/
/** @defgroup LSM6DSL_ACC_Private_Functions LSM6DSL ACC Private Functions
* @{
*/
/**
* @brief Set LSM6DSL Accelerometer Initialization.
* @param InitStruct: Init parameters
*/
void LSM6DSL_AccInit(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
uint8_t tmp;
/* Read CTRL1_XL */
tmp = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL1_XL);
/* Write value to ACC MEMS CTRL1_XL register: FS and Data Rate */
ctrl = (uint8_t) InitStruct;
tmp &= ~(0xFC);
tmp |= ctrl;
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL1_XL, tmp);
/* Read CTRL3_C */
tmp = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL3_C);
/* Write value to ACC MEMS CTRL3_C register: BDU and Auto-increment */
ctrl = ((uint8_t) (InitStruct >> 8));
tmp &= ~(0x44);
tmp |= ctrl;
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL3_C, tmp);
}
/**
* @brief LSM6DSL Accelerometer De-initialization.
*/
void LSM6DSL_AccDeInit(void)
{
uint8_t ctrl = 0x00;
/* Read control register 1 value */
ctrl = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL1_XL);
/* Clear ODR bits */
ctrl &= ~(LSM6DSL_ODR_BITPOSITION);
/* Set Power down */
ctrl |= LSM6DSL_ODR_POWER_DOWN;
/* write back control register */
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL1_XL, ctrl);
}
/**
* @brief Read LSM6DSL ID.
* @retval ID
*/
uint8_t LSM6DSL_AccReadID(void)
{
/* IO interface initialization */
SENSOR_IO_Init();
/* Read value at Who am I register address */
return (SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_WHO_AM_I_REG));
}
/**
* @brief Set/Unset Accelerometer in low power mode.
* @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
*/
void LSM6DSL_AccLowPower(uint16_t status)
{
uint8_t ctrl = 0x00;
/* Read CTRL6_C value */
ctrl = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL6_C);
/* Clear Low Power Mode bit */
ctrl &= ~(0x10);
/* Set Low Power Mode */
if(status)
{
ctrl |= LSM6DSL_ACC_GYRO_LP_XL_ENABLED;
}else
{
ctrl |= LSM6DSL_ACC_GYRO_LP_XL_DISABLED;
}
/* write back control register */
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL6_C, ctrl);
}
/**
* @brief Read X, Y & Z Acceleration values
* @param pData: Data out pointer
*/
void LSM6DSL_AccReadXYZ(int16_t* pData)
{
int16_t pnRawData[3];
uint8_t ctrlx= 0;
uint8_t buffer[6];
uint8_t i = 0;
float sensitivity = 0;
/* Read the acceleration control register content */
ctrlx = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL1_XL);
/* Read output register X, Y & Z acceleration */
SENSOR_IO_ReadMultiple(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_OUTX_L_XL, buffer, 6);
for(i=0; i<3; i++)
{
pnRawData[i]=((((uint16_t)buffer[2*i+1]) << 8) + (uint16_t)buffer[2*i]);
}
/* Normal mode */
/* Switch the sensitivity value set in the CRTL1_XL */
switch(ctrlx & 0x0C)
{
case LSM6DSL_ACC_FULLSCALE_2G:
sensitivity = LSM6DSL_ACC_SENSITIVITY_2G;
break;
case LSM6DSL_ACC_FULLSCALE_4G:
sensitivity = LSM6DSL_ACC_SENSITIVITY_4G;
break;
case LSM6DSL_ACC_FULLSCALE_8G:
sensitivity = LSM6DSL_ACC_SENSITIVITY_8G;
break;
case LSM6DSL_ACC_FULLSCALE_16G:
sensitivity = LSM6DSL_ACC_SENSITIVITY_16G;
break;
}
/* Obtain the mg value for the three axis */
for(i=0; i<3; i++)
{
pData[i]=( int16_t )(pnRawData[i] * sensitivity);
}
}
/**
* @}
*/
/** @defgroup LSM6DSL_GYRO_Private_Functions LSM6DSL GYRO Private Functions
* @{
*/
/**
* @brief Set LSM6DSL Gyroscope Initialization.
* @param InitStruct: pointer to a LSM6DSL_InitTypeDef structure
* that contains the configuration setting for the LSM6DSL.
*/
void LSM6DSL_GyroInit(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
uint8_t tmp;
/* Read CTRL2_G */
tmp = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL2_G);
/* Write value to GYRO MEMS CTRL2_G register: FS and Data Rate */
ctrl = (uint8_t) InitStruct;
tmp &= ~(0xFC);
tmp |= ctrl;
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL2_G, tmp);
/* Read CTRL3_C */
tmp = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL3_C);
/* Write value to GYRO MEMS CTRL3_C register: BDU and Auto-increment */
ctrl = ((uint8_t) (InitStruct >> 8));
tmp &= ~(0x44);
tmp |= ctrl;
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL3_C, tmp);
}
/**
* @brief LSM6DSL Gyroscope De-initialization
*/
void LSM6DSL_GyroDeInit(void)
{
uint8_t ctrl = 0x00;
/* Read control register 1 value */
ctrl = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL2_G);
/* Clear ODR bits */
ctrl &= ~(LSM6DSL_ODR_BITPOSITION);
/* Set Power down */
ctrl |= LSM6DSL_ODR_POWER_DOWN;
/* write back control register */
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL2_G, ctrl);
}
/**
* @brief Read ID address of LSM6DSL
* @retval ID
*/
uint8_t LSM6DSL_GyroReadID(void)
{
/* IO interface initialization */
SENSOR_IO_Init();
/* Read value at Who am I register address */
return SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_WHO_AM_I_REG);
}
/**
* @brief Set/Unset LSM6DSL Gyroscope in low power mode
* @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
*/
void LSM6DSL_GyroLowPower(uint16_t status)
{
uint8_t ctrl = 0x00;
/* Read CTRL7_G value */
ctrl = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL7_G);
/* Clear Low Power Mode bit */
ctrl &= ~(0x80);
/* Set Low Power Mode */
if(status)
{
ctrl |= LSM6DSL_ACC_GYRO_LP_G_ENABLED;
}else
{
ctrl |= LSM6DSL_ACC_GYRO_LP_G_DISABLED;
}
/* write back control register */
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL7_G, ctrl);
}
/**
* @brief Calculate the LSM6DSL angular data.
* @param pfData: Data out pointer
*/
void LSM6DSL_GyroReadXYZAngRate(float *pfData)
{
int16_t pnRawData[3];
uint8_t ctrlg= 0;
uint8_t buffer[6];
uint8_t i = 0;
float sensitivity = 0;
/* Read the gyro control register content */
ctrlg = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL2_G);
/* Read output register X, Y & Z acceleration */
SENSOR_IO_ReadMultiple(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_OUTX_L_G, buffer, 6);
for(i=0; i<3; i++)
{
pnRawData[i]=((((uint16_t)buffer[2*i+1]) << 8) + (uint16_t)buffer[2*i]);
}
/* Normal mode */
/* Switch the sensitivity value set in the CRTL2_G */
switch(ctrlg & 0x0C)
{
case LSM6DSL_GYRO_FS_245:
sensitivity = LSM6DSL_GYRO_SENSITIVITY_245DPS;
break;
case LSM6DSL_GYRO_FS_500:
sensitivity = LSM6DSL_GYRO_SENSITIVITY_500DPS;
break;
case LSM6DSL_GYRO_FS_1000:
sensitivity = LSM6DSL_GYRO_SENSITIVITY_1000DPS;
break;
case LSM6DSL_GYRO_FS_2000:
sensitivity = LSM6DSL_GYRO_SENSITIVITY_2000DPS;
break;
}
/* Obtain the mg value for the three axis */
for(i=0; i<3; i++)
{
pfData[i]=( float )(pnRawData[i] * sensitivity);
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,328 @@
/**
******************************************************************************
* @file lsm6dsl.h
* @author MCD Application Team
* @brief LSM6DSL header driver file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LSM6DSL__H
#define __LSM6DSL__H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/accelero.h"
#include "../Common/gyro.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup LSM6DSL
* @{
*/
/** @defgroup LSM6DSL_Exported_Constants LSM6DSL Exported Constants
* @{
*/
/************** I2C Address *****************/
#define LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW 0xD4 // SAD[0] = 0
#define LSM6DSL_ACC_GYRO_I2C_ADDRESS_HIGH 0xD6 // SAD[0] = 1
/************** Who am I *******************/
#define LSM6DSL_ACC_GYRO_WHO_AM_I 0x6A
/************** Device Register *******************/
#define LSM6DSL_ACC_GYRO_FUNC_CFG_ACCESS 0x01
#define LSM6DSL_ACC_GYRO_SENSOR_SYNC_TIME 0x04
#define LSM6DSL_ACC_GYRO_SENSOR_RES_RATIO 0x05
#define LSM6DSL_ACC_GYRO_FIFO_CTRL1 0x06
#define LSM6DSL_ACC_GYRO_FIFO_CTRL2 0x07
#define LSM6DSL_ACC_GYRO_FIFO_CTRL3 0x08
#define LSM6DSL_ACC_GYRO_FIFO_CTRL4 0x09
#define LSM6DSL_ACC_GYRO_FIFO_CTRL5 0x0A
#define LSM6DSL_ACC_GYRO_DRDY_PULSE_CFG_G 0x0B
#define LSM6DSL_ACC_GYRO_INT1_CTRL 0x0D
#define LSM6DSL_ACC_GYRO_INT2_CTRL 0x0E
#define LSM6DSL_ACC_GYRO_WHO_AM_I_REG 0x0F
#define LSM6DSL_ACC_GYRO_CTRL1_XL 0x10
#define LSM6DSL_ACC_GYRO_CTRL2_G 0x11
#define LSM6DSL_ACC_GYRO_CTRL3_C 0x12
#define LSM6DSL_ACC_GYRO_CTRL4_C 0x13
#define LSM6DSL_ACC_GYRO_CTRL5_C 0x14
#define LSM6DSL_ACC_GYRO_CTRL6_C 0x15
#define LSM6DSL_ACC_GYRO_CTRL7_G 0x16
#define LSM6DSL_ACC_GYRO_CTRL8_XL 0x17
#define LSM6DSL_ACC_GYRO_CTRL9_XL 0x18
#define LSM6DSL_ACC_GYRO_CTRL10_C 0x19
#define LSM6DSL_ACC_GYRO_MASTER_CONFIG 0x1A
#define LSM6DSL_ACC_GYRO_WAKE_UP_SRC 0x1B
#define LSM6DSL_ACC_GYRO_TAP_SRC 0x1C
#define LSM6DSL_ACC_GYRO_D6D_SRC 0x1D
#define LSM6DSL_ACC_GYRO_STATUS_REG 0x1E
#define LSM6DSL_ACC_GYRO_OUT_TEMP_L 0x20
#define LSM6DSL_ACC_GYRO_OUT_TEMP_H 0x21
#define LSM6DSL_ACC_GYRO_OUTX_L_G 0x22
#define LSM6DSL_ACC_GYRO_OUTX_H_G 0x23
#define LSM6DSL_ACC_GYRO_OUTY_L_G 0x24
#define LSM6DSL_ACC_GYRO_OUTY_H_G 0x25
#define LSM6DSL_ACC_GYRO_OUTZ_L_G 0x26
#define LSM6DSL_ACC_GYRO_OUTZ_H_G 0x27
#define LSM6DSL_ACC_GYRO_OUTX_L_XL 0x28
#define LSM6DSL_ACC_GYRO_OUTX_H_XL 0x29
#define LSM6DSL_ACC_GYRO_OUTY_L_XL 0x2A
#define LSM6DSL_ACC_GYRO_OUTY_H_XL 0x2B
#define LSM6DSL_ACC_GYRO_OUTZ_L_XL 0x2C
#define LSM6DSL_ACC_GYRO_OUTZ_H_XL 0x2D
#define LSM6DSL_ACC_GYRO_SENSORHUB1_REG 0x2E
#define LSM6DSL_ACC_GYRO_SENSORHUB2_REG 0x2F
#define LSM6DSL_ACC_GYRO_SENSORHUB3_REG 0x30
#define LSM6DSL_ACC_GYRO_SENSORHUB4_REG 0x31
#define LSM6DSL_ACC_GYRO_SENSORHUB5_REG 0x32
#define LSM6DSL_ACC_GYRO_SENSORHUB6_REG 0x33
#define LSM6DSL_ACC_GYRO_SENSORHUB7_REG 0x34
#define LSM6DSL_ACC_GYRO_SENSORHUB8_REG 0x35
#define LSM6DSL_ACC_GYRO_SENSORHUB9_REG 0x36
#define LSM6DSL_ACC_GYRO_SENSORHUB10_REG 0x37
#define LSM6DSL_ACC_GYRO_SENSORHUB11_REG 0x38
#define LSM6DSL_ACC_GYRO_SENSORHUB12_REG 0x39
#define LSM6DSL_ACC_GYRO_FIFO_STATUS1 0x3A
#define LSM6DSL_ACC_GYRO_FIFO_STATUS2 0x3B
#define LSM6DSL_ACC_GYRO_FIFO_STATUS3 0x3C
#define LSM6DSL_ACC_GYRO_FIFO_STATUS4 0x3D
#define LSM6DSL_ACC_GYRO_FIFO_DATA_OUT_L 0x3E
#define LSM6DSL_ACC_GYRO_FIFO_DATA_OUT_H 0x3F
#define LSM6DSL_ACC_GYRO_TIMESTAMP0_REG 0x40
#define LSM6DSL_ACC_GYRO_TIMESTAMP1_REG 0x41
#define LSM6DSL_ACC_GYRO_TIMESTAMP2_REG 0x42
#define LSM6DSL_ACC_GYRO_TIMESTAMP_L 0x49
#define LSM6DSL_ACC_GYRO_TIMESTAMP_H 0x4A
#define LSM6DSL_ACC_GYRO_STEP_COUNTER_L 0x4B
#define LSM6DSL_ACC_GYRO_STEP_COUNTER_H 0x4C
#define LSM6DSL_ACC_GYRO_SENSORHUB13_REG 0x4D
#define LSM6DSL_ACC_GYRO_SENSORHUB14_REG 0x4E
#define LSM6DSL_ACC_GYRO_SENSORHUB15_REG 0x4F
#define LSM6DSL_ACC_GYRO_SENSORHUB16_REG 0x50
#define LSM6DSL_ACC_GYRO_SENSORHUB17_REG 0x51
#define LSM6DSL_ACC_GYRO_SENSORHUB18_REG 0x52
#define LSM6DSL_ACC_GYRO_FUNC_SRC 0x53
#define LSM6DSL_ACC_GYRO_TAP_CFG1 0x58
#define LSM6DSL_ACC_GYRO_TAP_THS_6D 0x59
#define LSM6DSL_ACC_GYRO_INT_DUR2 0x5A
#define LSM6DSL_ACC_GYRO_WAKE_UP_THS 0x5B
#define LSM6DSL_ACC_GYRO_WAKE_UP_DUR 0x5C
#define LSM6DSL_ACC_GYRO_FREE_FALL 0x5D
#define LSM6DSL_ACC_GYRO_MD1_CFG 0x5E
#define LSM6DSL_ACC_GYRO_MD2_CFG 0x5F
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_X_L 0x66
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_X_H 0x67
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_Y_L 0x68
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_Y_H 0x69
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_Z_L 0x6A
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_Z_H 0x6B
#define LSM6DSL_ACC_GYRO_X_OFS_USR 0x73
#define LSM6DSL_ACC_GYRO_Y_OFS_USR 0x74
#define LSM6DSL_ACC_GYRO_Z_OFS_USR 0x75
/************** Embedded functions register mapping *******************/
#define LSM6DSL_ACC_GYRO_SLV0_ADD 0x02
#define LSM6DSL_ACC_GYRO_SLV0_SUBADD 0x03
#define LSM6DSL_ACC_GYRO_SLAVE0_CONFIG 0x04
#define LSM6DSL_ACC_GYRO_SLV1_ADD 0x05
#define LSM6DSL_ACC_GYRO_SLV1_SUBADD 0x06
#define LSM6DSL_ACC_GYRO_SLAVE1_CONFIG 0x07
#define LSM6DSL_ACC_GYRO_SLV2_ADD 0x08
#define LSM6DSL_ACC_GYRO_SLV2_SUBADD 0x09
#define LSM6DSL_ACC_GYRO_SLAVE2_CONFIG 0x0A
#define LSM6DSL_ACC_GYRO_SLV3_ADD 0x0B
#define LSM6DSL_ACC_GYRO_SLV3_SUBADD 0x0C
#define LSM6DSL_ACC_GYRO_SLAVE3_CONFIG 0x0D
#define LSM6DSL_ACC_GYRO_DATAWRITE_SRC_MODE_SUB_SLV0 0x0E
#define LSM6DSL_ACC_GYRO_CONFIG_PEDO_THS_MIN 0x0F
#define LSM6DSL_ACC_GYRO_SM_STEP_THS 0x13
#define LSM6DSL_ACC_GYRO_PEDO_DEB_REG 0x14
#define LSM6DSL_ACC_GYRO_STEP_COUNT_DELTA 0x15
#define LSM6DSL_ACC_GYRO_MAG_SI_XX 0x24
#define LSM6DSL_ACC_GYRO_MAG_SI_XY 0x25
#define LSM6DSL_ACC_GYRO_MAG_SI_XZ 0x26
#define LSM6DSL_ACC_GYRO_MAG_SI_YX 0x27
#define LSM6DSL_ACC_GYRO_MAG_SI_YY 0x28
#define LSM6DSL_ACC_GYRO_MAG_SI_YZ 0x29
#define LSM6DSL_ACC_GYRO_MAG_SI_ZX 0x2A
#define LSM6DSL_ACC_GYRO_MAG_SI_ZY 0x2B
#define LSM6DSL_ACC_GYRO_MAG_SI_ZZ 0x2C
#define LSM6DSL_ACC_GYRO_MAG_OFFX_L 0x2D
#define LSM6DSL_ACC_GYRO_MAG_OFFX_H 0x2E
#define LSM6DSL_ACC_GYRO_MAG_OFFY_L 0x2F
#define LSM6DSL_ACC_GYRO_MAG_OFFY_H 0x30
#define LSM6DSL_ACC_GYRO_MAG_OFFZ_L 0x31
#define LSM6DSL_ACC_GYRO_MAG_OFFZ_H 0x32
/* Accelero Full_ScaleSelection */
#define LSM6DSL_ACC_FULLSCALE_2G ((uint8_t)0x00) /*!< <20>2 g */
#define LSM6DSL_ACC_FULLSCALE_4G ((uint8_t)0x08) /*!< <20>4 g */
#define LSM6DSL_ACC_FULLSCALE_8G ((uint8_t)0x0C) /*!< <20>8 g */
#define LSM6DSL_ACC_FULLSCALE_16G ((uint8_t)0x04) /*!< <20>16 g */
/* Accelero Full Scale Sensitivity */
#define LSM6DSL_ACC_SENSITIVITY_2G ((float)0.061f) /*!< accelerometer sensitivity with 2 g full scale [mgauss/LSB] */
#define LSM6DSL_ACC_SENSITIVITY_4G ((float)0.122f) /*!< accelerometer sensitivity with 4 g full scale [mgauss/LSB] */
#define LSM6DSL_ACC_SENSITIVITY_8G ((float)0.244f) /*!< accelerometer sensitivity with 8 g full scale [mgauss/LSB] */
#define LSM6DSL_ACC_SENSITIVITY_16G ((float)0.488f) /*!< accelerometer sensitivity with 12 g full scale [mgauss/LSB] */
/* Accelero Power Mode selection */
#define LSM6DSL_ACC_GYRO_LP_XL_DISABLED ((uint8_t)0x00) /* LP disabled*/
#define LSM6DSL_ACC_GYRO_LP_XL_ENABLED ((uint8_t)0x10) /* LP enabled*/
/* Output Data Rate */
#define LSM6DSL_ODR_BITPOSITION ((uint8_t)0xF0) /*!< Output Data Rate bit position */
#define LSM6DSL_ODR_POWER_DOWN ((uint8_t)0x00) /* Power Down mode */
#define LSM6DSL_ODR_13Hz ((uint8_t)0x10) /* Low Power mode */
#define LSM6DSL_ODR_26Hz ((uint8_t)0x20) /* Low Power mode */
#define LSM6DSL_ODR_52Hz ((uint8_t)0x30) /* Low Power mode */
#define LSM6DSL_ODR_104Hz ((uint8_t)0x40) /* Normal mode */
#define LSM6DSL_ODR_208Hz ((uint8_t)0x50) /* Normal mode */
#define LSM6DSL_ODR_416Hz ((uint8_t)0x60) /* High Performance mode */
#define LSM6DSL_ODR_833Hz ((uint8_t)0x70) /* High Performance mode */
#define LSM6DSL_ODR_1660Hz ((uint8_t)0x80) /* High Performance mode */
#define LSM6DSL_ODR_3330Hz ((uint8_t)0x90) /* High Performance mode */
#define LSM6DSL_ODR_6660Hz ((uint8_t)0xA0) /* High Performance mode */
/* Gyro Full Scale Selection */
#define LSM6DSL_GYRO_FS_245 ((uint8_t)0x00)
#define LSM6DSL_GYRO_FS_500 ((uint8_t)0x04)
#define LSM6DSL_GYRO_FS_1000 ((uint8_t)0x08)
#define LSM6DSL_GYRO_FS_2000 ((uint8_t)0x0C)
/* Gyro Full Scale Sensitivity */
#define LSM6DSL_GYRO_SENSITIVITY_245DPS ((float)8.750f) /**< Sensitivity value for 245 dps full scale [mdps/LSB] */
#define LSM6DSL_GYRO_SENSITIVITY_500DPS ((float)17.50f) /**< Sensitivity value for 500 dps full scale [mdps/LSB] */
#define LSM6DSL_GYRO_SENSITIVITY_1000DPS ((float)35.00f) /**< Sensitivity value for 1000 dps full scale [mdps/LSB] */
#define LSM6DSL_GYRO_SENSITIVITY_2000DPS ((float)70.00f) /**< Sensitivity value for 2000 dps full scale [mdps/LSB] */
/* Gyro Power Mode selection */
#define LSM6DSL_ACC_GYRO_LP_G_DISABLED ((uint8_t)0x00) /* LP disabled*/
#define LSM6DSL_ACC_GYRO_LP_G_ENABLED ((uint8_t)0x80) /* LP enabled*/
/* Block Data Update */
#define LSM6DSL_BDU_CONTINUOS ((uint8_t)0x00)
#define LSM6DSL_BDU_BLOCK_UPDATE ((uint8_t)0x40)
/* Auto-increment */
#define LSM6DSL_ACC_GYRO_IF_INC_DISABLED ((uint8_t)0x00)
#define LSM6DSL_ACC_GYRO_IF_INC_ENABLED ((uint8_t)0x04)
/**
* @}
*/
/** @defgroup LSM6DSL_AccExported_Functions ACCELEROMETER Exported functions
* @{
*/
void LSM6DSL_AccInit(uint16_t InitStruct);
void LSM6DSL_AccDeInit(void);
uint8_t LSM6DSL_AccReadID(void);
void LSM6DSL_AccLowPower(uint16_t status);
void LSM6DSL_AccReadXYZ(int16_t* pData);
/**
* @}
*/
/** @defgroup LSM6DSL_AccImported_Globals ACCELEROMETER Imported Globals
* @{
*/
extern ACCELERO_DrvTypeDef Lsm6dslAccDrv;
/**
* @}
*/
/** @defgroup LSM6DSL_GyroExported_Functions GYROSCOPE Exported functions
* @{
*/
/* Sensor Configuration Functions */
void LSM6DSL_GyroInit(uint16_t InitStruct);
void LSM6DSL_GyroDeInit(void);
uint8_t LSM6DSL_GyroReadID(void);
void LSM6DSL_GyroLowPower(uint16_t status);
void LSM6DSL_GyroReadXYZAngRate(float *pfData);
/**
* @}
*/
/** @defgroup LSM6DSL_GyroImported_Globals GYROSCOPE Imported Globals
* @{
*/
/* Gyroscope driver structure */
extern GYRO_DrvTypeDef Lsm6dslGyroDrv;
/**
* @}
*/
/** @defgroup LSM6DSL_Imported_Functions LSM6DSL Imported Functions
* @{
*/
/* IO functions */
extern void SENSOR_IO_Init(void);
extern void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LSM6DSL__H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,83 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for M24SR Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-m24sr-component-drivers"><small>Release Notes for</small> <mark>M24SR Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the M24SR component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.1.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.1.0 / 21-April-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Calls BSP IO functions (NFC_IO_xxx) as unique low layer interface.</li>
<li>Made it fully independent by board and device (no external inclusion).</li>
<li>Adapt #defines and m24sr.h accordingly API.</li>
<li>Types renaming uc8 -&gt; uint8_t and uc16 -&gt; uint16_t.</li>
<li>Pass I2C device address as param to all functions that use it.</li>
<li>Remove goto instructions.</li>
<li>Moved here some functions: M24SR_RFConfig(), M24SR_SetI2CSynchroMode(), M24SR_IsAnswerReady().</li>
<li>Added M24SR_GPO_Callback().</li>
<li>Added M24SR_GPO_Callback().</li>
<li>Move lib_M24SR.c/h from driver to application.</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 20-October-2014</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>First official release by STM MMY division</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,157 @@
/**
******************************************************************************
* @file m24sr.h
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage M24SR
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __M24SR_H
#define __M24SR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stdint.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup M24SR
* @{
*/
/** @defgroup M24SR_Exported_Constants M24SR Exported Constants
* @{
*/
/* NFC IO specific config parameters */
#define NFC_IO_STATUS_SUCCESS (uint16_t) 0x0000
#define NFC_IO_ERROR_TIMEOUT (uint16_t) 0x0011
#define NFC_IO_TRIALS (uint32_t) 1 /* In case M24SR will reply ACK failed allow to perform retry */
/* Status and error code -----------------------------------------------------*/
#define M24SR_ACTION_COMPLETED (uint16_t) 0x9000
#define M24SR_STATUS_SUCCESS (uint16_t) 0x0000
#define M24SR_ERROR_DEFAULT (uint16_t) 0x0010
#define M24SR_ERROR_TIMEOUT (uint16_t) 0x0011
#define M24SR_ERROR_CRC (uint16_t) 0x0012
#define M24SR_ERROR_NACK (uint16_t) 0x0013
#define M24SR_ERROR_PARAMETER (uint16_t) 0x0014
#define M24SR_ERROR_NBATEMPT (uint16_t) 0x0015
#define M24SR_ERROR_NOACKNOWLEDGE (uint16_t) 0x0016
#define M24SR_ANSWER_TIMEOUT (uint32_t) 80 /* Timeout used by the component function NFC_IO_IsDeviceReady() */
#define M24SR_ANSWER_STABLE (uint8_t) 5 /* Loop repetition used by the component function NFC_IO_IsDeviceReady() */
/*-------------------------- GPO_Mode ----------------------------*/
#define M24SR_GPO_POLLING (uint8_t) 0x00 /* Normal I²C polling */
#define M24SR_GPO_SYNCHRO (uint8_t) 0x01 /* allow to use GPO polling as I2C synchronization */
#define M24SR_GPO_INTERRUPT (uint8_t) 0x02 /* allow to use GPO interrupt as I2C synchronization */
/*-------------------------- Password_Management ----------------------------*/
#define M24SR_READ_PWD (uint16_t) 0x0001
#define M24SR_WRITE_PWD (uint16_t) 0x0002
#define M24SR_I2C_PWD (uint16_t) 0x0003
/*-------------------------- Verify command answer ----------------------------*/
#define M24SR_PWD_NOT_NEEDED (uint16_t) 0x9000
#define M24SR_PWD_NEEDED (uint16_t) 0x6300
#define M24SR_PWD_CORRECT (uint16_t) 0x9000
/**
* @}
*/
/** @defgroup M24SR_Exported_FunctionsPrototypes M24SR Exported FunctionsPrototypes
* @{
*/
/* public function --------------------------------------------------------------------------*/
void M24SR_Init (uint16_t DeviceAddr, uint8_t GpoMode);
uint16_t M24SR_GetSession (uint16_t DeviceAddr);
uint16_t M24SR_KillSession (uint16_t DeviceAddr);
uint16_t M24SR_Deselect (uint16_t DeviceAddr);
uint16_t M24SR_SelectApplication (uint16_t DeviceAddr);
uint16_t M24SR_SelectCCfile (uint16_t DeviceAddr);
uint16_t M24SR_SelectNDEFfile (uint16_t DeviceAddr, uint16_t NDEFfileId);
uint16_t M24SR_SelectSystemfile (uint16_t DeviceAddr);
uint16_t M24SR_ReadBinary (uint16_t DeviceAddr, uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead);
uint16_t M24SR_STReadBinary (uint16_t DeviceAddr, uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead);
uint16_t M24SR_UpdateBinary (uint16_t DeviceAddr, uint16_t Offset, uint8_t NbByteToWrite, uint8_t *pDataToWrite);
uint16_t M24SR_Verify (uint16_t DeviceAddr, uint16_t uPwdId, uint8_t NbPwdByte, uint8_t *pPwd);
uint16_t M24SR_ChangeReferenceData (uint16_t DeviceAddr, uint16_t uPwdId, uint8_t *pPwd);
uint16_t M24SR_EnableVerificationRequirement (uint16_t DeviceAddr, uint16_t uReadOrWrite);
uint16_t M24SR_DisableVerificationRequirement (uint16_t DeviceAddr, uint16_t uReadOrWrite);
uint16_t M24SR_EnablePermanentState (uint16_t DeviceAddr, uint16_t uReadOrWrite);
uint16_t M24SR_DisablePermanentState (uint16_t DeviceAddr, uint16_t uReadOrWrite);
uint16_t M24SR_SendInterrupt (uint16_t DeviceAddr);
uint16_t M24SR_StateControl (uint16_t DeviceAddr, uint8_t uSetOrReset);
uint16_t M24SR_ManageI2CGPO (uint16_t DeviceAddr, uint8_t GPO_I2Cconfig);
uint16_t M24SR_ManageRFGPO (uint16_t DeviceAddr, uint8_t GPO_RFconfig);
void M24SR_RFConfig (uint8_t OnOffChoice);
void M24SR_GPO_Callback (void );
/**
* @}
*/
/** @defgroup M24SR_Imported_Functions M24SR Imported Functions
* @{
*/
/* IO functions */
extern void NFC_IO_Init(uint8_t GpoIrqEnable);
extern void NFC_IO_DeInit(void);
extern uint16_t NFC_IO_ReadMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length );
extern uint16_t NFC_IO_WriteMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length);
extern uint16_t NFC_IO_IsDeviceReady (uint8_t Addr, uint32_t Trials);
extern void NFC_IO_ReadState(uint8_t * pPinState);
extern void NFC_IO_RfDisable(uint8_t PinState);
extern void NFC_IO_Delay(uint32_t Delay);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __M24SR_H */
/******************* (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,126 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for MFXSTM32L152 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-mfxstm32l152-component-drivers"><small>Release Notes for</small> <mark>MFXSTM32L152 Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the MFXSTM32L152 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V2.0.3 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V2.0.2 / 25-October-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V2.0.1 / 02-June-2017</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>Update comments to be used for PDSC generation</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section185" aria-hidden="true"> <label for="collapse-section185" aria-hidden="true">V2.0.0 / 24-June-2015</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>Add Shunt management of MFXSTM32L152 component
<ul>
<li>new mfxstm32l152_IDD_ConfigShuntNbLimit() and mfxstm32l152_IDD_GetShuntUsed() APIs</li>
</ul></li>
<li>Add mfxstm32l152_WriteReg() API</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong> This release must be used with BSP Common driver V4.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.2.0 / 28-April-2015</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>mfxstm32l152_IO_Config(): remove unnecessary delay</li>
<li>mfxstm32l152_TS_DetectTouch(): improve TouchScreen speed</li>
<li>mfxstm32l152_IDD_Config(): add configuration of number of measure to be performed, with delay between 2 measures</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong><br />
This release must be used with BSP Common driver V3.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.1.0 / 10-February-2015</label>
<div>
<h2 id="main-changes-5">Main Changes</h2>
<ul>
<li>Low Power management of MFXSTM32L152 component:
<ul>
<li>New mfxstm32l152_DeInit() and mfxstm32l152_WakeUp() API</li>
<li>mfxstm32l152_LowPower() API completed to be MFXSTM32L152 in Standby mode</li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong><br />
This release must be used with BSP Common driver V2.2.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section16" aria-hidden="true"> <label for="collapse-section16" aria-hidden="true">V1.0.0 / 05-February-2014</label>
<div>
<h2 id="main-changes-6">Main Changes</h2>
<ul>
<li>First official release of MFXSTM32L152 IO Expander component driver.</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong><br />
This release must be used with BSP Common driver V2.1.0 or later</p>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,650 @@
/**
******************************************************************************
* @file mfxstm32l152.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* mfxstm32l152.c IO expander driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MFXSTM32L152_H
#define __MFXSTM32L152_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/ts.h"
#include "../Common/io.h"
#include "../Common/idd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup MFXSTM32L152
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup MFXSTM32L152_Exported_Types
* @{
*/
typedef struct
{
uint8_t SYS_CTRL;
uint8_t ERROR_SRC;
uint8_t ERROR_MSG;
uint8_t IRQ_OUT;
uint8_t IRQ_SRC_EN;
uint8_t IRQ_PENDING;
uint8_t IDD_CTRL;
uint8_t IDD_PRE_DELAY;
uint8_t IDD_SHUNT0_MSB;
uint8_t IDD_SHUNT0_LSB;
uint8_t IDD_SHUNT1_MSB;
uint8_t IDD_SHUNT1_LSB;
uint8_t IDD_SHUNT2_MSB;
uint8_t IDD_SHUNT2_LSB;
uint8_t IDD_SHUNT3_MSB;
uint8_t IDD_SHUNT3_LSB;
uint8_t IDD_SHUNT4_MSB;
uint8_t IDD_SHUNT4_LSB;
uint8_t IDD_GAIN_MSB;
uint8_t IDD_GAIN_LSB;
uint8_t IDD_VDD_MIN_MSB;
uint8_t IDD_VDD_MIN_LSB;
uint8_t IDD_VALUE_MSB;
uint8_t IDD_VALUE_MID;
uint8_t IDD_VALUE_LSB;
uint8_t IDD_CAL_OFFSET_MSB;
uint8_t IDD_CAL_OFFSET_LSB;
uint8_t IDD_SHUNT_USED;
}IDD_dbgTypeDef;
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup MFXSTM32L152_Exported_Constants
* @{
*/
/**
* @brief MFX COMMON defines
*/
/**
* @brief Register address: chip IDs (R)
*/
#define MFXSTM32L152_REG_ADR_ID ((uint8_t)0x00)
/**
* @brief Register address: chip FW_VERSION (R)
*/
#define MFXSTM32L152_REG_ADR_FW_VERSION_MSB ((uint8_t)0x01)
#define MFXSTM32L152_REG_ADR_FW_VERSION_LSB ((uint8_t)0x00)
/**
* @brief Register address: System Control Register (R/W)
*/
#define MFXSTM32L152_REG_ADR_SYS_CTRL ((uint8_t)0x40)
/**
* @brief Register address: Vdd monitoring (R)
*/
#define MFXSTM32L152_REG_ADR_VDD_REF_MSB ((uint8_t)0x06)
#define MFXSTM32L152_REG_ADR_VDD_REF_LSB ((uint8_t)0x07)
/**
* @brief Register address: Error source
*/
#define MFXSTM32L152_REG_ADR_ERROR_SRC ((uint8_t)0x03)
/**
* @brief Register address: Error Message
*/
#define MFXSTM32L152_REG_ADR_ERROR_MSG ((uint8_t)0x04)
/**
* @brief Reg Addr IRQs: to config the pin that informs Main MCU that MFX events appear
*/
#define MFXSTM32L152_REG_ADR_MFX_IRQ_OUT ((uint8_t)0x41)
/**
* @brief Reg Addr IRQs: to select the events which activate the MFXSTM32L152_IRQ_OUT signal
*/
#define MFXSTM32L152_REG_ADR_IRQ_SRC_EN ((uint8_t)0x42)
/**
* @brief Reg Addr IRQs: the Main MCU must read the IRQ_PENDING register to know the interrupt reason
*/
#define MFXSTM32L152_REG_ADR_IRQ_PENDING ((uint8_t)0x08)
/**
* @brief Reg Addr IRQs: the Main MCU must acknowledge it thanks to a writing access to the IRQ_ACK register
*/
#define MFXSTM32L152_REG_ADR_IRQ_ACK ((uint8_t)0x44)
/**
* @brief MFXSTM32L152_REG_ADR_ID choices
*/
#define MFXSTM32L152_ID_1 ((uint8_t)0x7B)
#define MFXSTM32L152_ID_2 ((uint8_t)0x79)
/**
* @brief MFXSTM32L152_REG_ADR_SYS_CTRL choices
*/
#define MFXSTM32L152_SWRST ((uint8_t)0x80)
#define MFXSTM32L152_STANDBY ((uint8_t)0x40)
#define MFXSTM32L152_ALTERNATE_GPIO_EN ((uint8_t)0x08) /* by the way if IDD and TS are enabled they take automatically the AF pins*/
#define MFXSTM32L152_IDD_EN ((uint8_t)0x04)
#define MFXSTM32L152_TS_EN ((uint8_t)0x02)
#define MFXSTM32L152_GPIO_EN ((uint8_t)0x01)
/**
* @brief MFXSTM32L152_REG_ADR_ERROR_SRC choices
*/
#define MFXSTM32L152_IDD_ERROR_SRC ((uint8_t)0x04) /* Error raised by Idd */
#define MFXSTM32L152_TS_ERROR_SRC ((uint8_t)0x02) /* Error raised by Touch Screen */
#define MFXSTM32L152_GPIO_ERROR_SRC ((uint8_t)0x01) /* Error raised by Gpio */
/**
* @brief MFXSTM32L152_REG_ADR_MFX_IRQ_OUT choices
*/
#define MFXSTM32L152_OUT_PIN_TYPE_OPENDRAIN ((uint8_t)0x00)
#define MFXSTM32L152_OUT_PIN_TYPE_PUSHPULL ((uint8_t)0x01)
#define MFXSTM32L152_OUT_PIN_POLARITY_LOW ((uint8_t)0x00)
#define MFXSTM32L152_OUT_PIN_POLARITY_HIGH ((uint8_t)0x02)
/**
* @brief REG_ADR_IRQ_SRC_EN, REG_ADR_IRQ_PENDING & REG_ADR_IRQ_ACK choices
*/
#define MFXSTM32L152_IRQ_TS_OVF ((uint8_t)0x80) /* TouchScreen FIFO Overflow irq*/
#define MFXSTM32L152_IRQ_TS_FULL ((uint8_t)0x40) /* TouchScreen FIFO Full irq*/
#define MFXSTM32L152_IRQ_TS_TH ((uint8_t)0x20) /* TouchScreen FIFO threshold triggered irq*/
#define MFXSTM32L152_IRQ_TS_NE ((uint8_t)0x10) /* TouchScreen FIFO Not Empty irq*/
#define MFXSTM32L152_IRQ_TS_DET ((uint8_t)0x08) /* TouchScreen Detect irq*/
#define MFXSTM32L152_IRQ_ERROR ((uint8_t)0x04) /* Error message from MFXSTM32L152 firmware irq */
#define MFXSTM32L152_IRQ_IDD ((uint8_t)0x02) /* IDD function irq */
#define MFXSTM32L152_IRQ_GPIO ((uint8_t)0x01) /* General GPIO irq (only for SRC_EN and PENDING) */
#define MFXSTM32L152_IRQ_ALL ((uint8_t)0xFF) /* All global interrupts */
#define MFXSTM32L152_IRQ_TS (MFXSTM32L152_IRQ_TS_DET | MFXSTM32L152_IRQ_TS_NE | MFXSTM32L152_IRQ_TS_TH | MFXSTM32L152_IRQ_TS_FULL | MFXSTM32L152_IRQ_TS_OVF )
/**
* @brief GPIO: 24 programmable input/output called MFXSTM32L152_GPIO[23:0] are provided
*/
/**
* @brief Reg addr: GPIO DIRECTION (R/W): GPIO pins direction: (0) input, (1) output.
*/
#define MFXSTM32L152_REG_ADR_GPIO_DIR1 ((uint8_t)0x60) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPIO_DIR2 ((uint8_t)0x61) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPIO_DIR3 ((uint8_t)0x62) /* agpio [0:7] */
/**
* @brief Reg addr: GPIO TYPE (R/W): If GPIO in output: (0) output push pull, (1) output open drain.
* If GPIO in input: (0) input without pull resistor, (1) input with pull resistor.
*/
#define MFXSTM32L152_REG_ADR_GPIO_TYPE1 ((uint8_t)0x64) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPIO_TYPE2 ((uint8_t)0x65) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPIO_TYPE3 ((uint8_t)0x66) /* agpio [0:7] */
/**
* @brief Reg addr: GPIO PULL_UP_PULL_DOWN (R/W): discussion open with Jean Claude
*/
#define MFXSTM32L152_REG_ADR_GPIO_PUPD1 ((uint8_t)0x68) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPIO_PUPD2 ((uint8_t)0x69) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPIO_PUPD3 ((uint8_t)0x6A) /* agpio [0:7] */
/**
* @brief Reg addr: GPIO SET (W): When GPIO is in output mode, write (1) puts the corresponding GPO in High level.
*/
#define MFXSTM32L152_REG_ADR_GPO_SET1 ((uint8_t)0x6C) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPO_SET2 ((uint8_t)0x6D) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPO_SET3 ((uint8_t)0x6E) /* agpio [0:7] */
/**
* @brief Reg addr: GPIO CLEAR (W): When GPIO is in output mode, write (1) puts the corresponding GPO in Low level.
*/
#define MFXSTM32L152_REG_ADR_GPO_CLR1 ((uint8_t)0x70) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPO_CLR2 ((uint8_t)0x71) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPO_CLR3 ((uint8_t)0x72) /* agpio [0:7] */
/**
* @brief Reg addr: GPIO STATE (R): Give state of the GPIO pin.
*/
#define MFXSTM32L152_REG_ADR_GPIO_STATE1 ((uint8_t)0x10) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPIO_STATE2 ((uint8_t)0x11) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPIO_STATE3 ((uint8_t)0x12) /* agpio [0:7] */
/**
* @brief GPIO IRQ_GPIs
*/
/* GPIOs can INDIVIDUALLY generate interruption to the Main MCU thanks to the MFXSTM32L152_IRQ_OUT signal */
/* the general MFXSTM32L152_IRQ_GPIO_SRC_EN shall be enabled too */
/**
* @brief GPIO IRQ_GPI_SRC1/2/3 (R/W): registers enable or not the feature to generate irq
*/
#define MFXSTM32L152_REG_ADR_IRQ_GPI_SRC1 ((uint8_t)0x48) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_SRC2 ((uint8_t)0x49) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_SRC3 ((uint8_t)0x4A) /* agpio [0:7] */
/**
* @brief GPIO IRQ_GPI_EVT1/2/3 (R/W): Irq generated on level (0) or edge (1).
*/
#define MFXSTM32L152_REG_ADR_IRQ_GPI_EVT1 ((uint8_t)0x4C) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_EVT2 ((uint8_t)0x4D) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_EVT3 ((uint8_t)0x4E) /* agpio [0:7] */
/**
* @brief GPIO IRQ_GPI_TYPE1/2/3 (R/W): Irq generated on (0) : Low level or Falling edge. (1) : High level or Rising edge.
*/
#define MFXSTM32L152_REG_ADR_IRQ_GPI_TYPE1 ((uint8_t)0x50) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_TYPE2 ((uint8_t)0x51) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_TYPE3 ((uint8_t)0x52) /* agpio [0:7] */
/**
* @brief GPIO IRQ_GPI_PENDING1/2/3 (R): irq occurs
*/
#define MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING1 ((uint8_t)0x0C) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING2 ((uint8_t)0x0D) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING3 ((uint8_t)0x0E) /* agpio [0:7] */
/**
* @brief GPIO IRQ_GPI_ACK1/2/3 (W): Write (1) to acknowledge IRQ event
*/
#define MFXSTM32L152_REG_ADR_IRQ_GPI_ACK1 ((uint8_t)0x54) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_ACK2 ((uint8_t)0x55) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_ACK3 ((uint8_t)0x56) /* agpio [0:7] */
/**
* @brief GPIO: IO Pins definition
*/
#define MFXSTM32L152_GPIO_PIN_0 ((uint32_t)0x0001)
#define MFXSTM32L152_GPIO_PIN_1 ((uint32_t)0x0002)
#define MFXSTM32L152_GPIO_PIN_2 ((uint32_t)0x0004)
#define MFXSTM32L152_GPIO_PIN_3 ((uint32_t)0x0008)
#define MFXSTM32L152_GPIO_PIN_4 ((uint32_t)0x0010)
#define MFXSTM32L152_GPIO_PIN_5 ((uint32_t)0x0020)
#define MFXSTM32L152_GPIO_PIN_6 ((uint32_t)0x0040)
#define MFXSTM32L152_GPIO_PIN_7 ((uint32_t)0x0080)
#define MFXSTM32L152_GPIO_PIN_8 ((uint32_t)0x0100)
#define MFXSTM32L152_GPIO_PIN_9 ((uint32_t)0x0200)
#define MFXSTM32L152_GPIO_PIN_10 ((uint32_t)0x0400)
#define MFXSTM32L152_GPIO_PIN_11 ((uint32_t)0x0800)
#define MFXSTM32L152_GPIO_PIN_12 ((uint32_t)0x1000)
#define MFXSTM32L152_GPIO_PIN_13 ((uint32_t)0x2000)
#define MFXSTM32L152_GPIO_PIN_14 ((uint32_t)0x4000)
#define MFXSTM32L152_GPIO_PIN_15 ((uint32_t)0x8000)
#define MFXSTM32L152_GPIO_PIN_16 ((uint32_t)0x010000)
#define MFXSTM32L152_GPIO_PIN_17 ((uint32_t)0x020000)
#define MFXSTM32L152_GPIO_PIN_18 ((uint32_t)0x040000)
#define MFXSTM32L152_GPIO_PIN_19 ((uint32_t)0x080000)
#define MFXSTM32L152_GPIO_PIN_20 ((uint32_t)0x100000)
#define MFXSTM32L152_GPIO_PIN_21 ((uint32_t)0x200000)
#define MFXSTM32L152_GPIO_PIN_22 ((uint32_t)0x400000)
#define MFXSTM32L152_GPIO_PIN_23 ((uint32_t)0x800000)
#define MFXSTM32L152_AGPIO_PIN_0 MFXSTM32L152_GPIO_PIN_16
#define MFXSTM32L152_AGPIO_PIN_1 MFXSTM32L152_GPIO_PIN_17
#define MFXSTM32L152_AGPIO_PIN_2 MFXSTM32L152_GPIO_PIN_18
#define MFXSTM32L152_AGPIO_PIN_3 MFXSTM32L152_GPIO_PIN_19
#define MFXSTM32L152_AGPIO_PIN_4 MFXSTM32L152_GPIO_PIN_20
#define MFXSTM32L152_AGPIO_PIN_5 MFXSTM32L152_GPIO_PIN_21
#define MFXSTM32L152_AGPIO_PIN_6 MFXSTM32L152_GPIO_PIN_22
#define MFXSTM32L152_AGPIO_PIN_7 MFXSTM32L152_GPIO_PIN_23
#define MFXSTM32L152_GPIO_PINS_ALL ((uint32_t)0xFFFFFF)
/**
* @brief GPIO: constant
*/
#define MFXSTM32L152_GPIO_DIR_IN ((uint8_t)0x0)
#define MFXSTM32L152_GPIO_DIR_OUT ((uint8_t)0x1)
#define MFXSTM32L152_IRQ_GPI_EVT_LEVEL ((uint8_t)0x0)
#define MFXSTM32L152_IRQ_GPI_EVT_EDGE ((uint8_t)0x1)
#define MFXSTM32L152_IRQ_GPI_TYPE_LLFE ((uint8_t)0x0) /* Low Level Falling Edge */
#define MFXSTM32L152_IRQ_GPI_TYPE_HLRE ((uint8_t)0x1) /*High Level Raising Edge */
#define MFXSTM32L152_GPI_WITHOUT_PULL_RESISTOR ((uint8_t)0x0)
#define MFXSTM32L152_GPI_WITH_PULL_RESISTOR ((uint8_t)0x1)
#define MFXSTM32L152_GPO_PUSH_PULL ((uint8_t)0x0)
#define MFXSTM32L152_GPO_OPEN_DRAIN ((uint8_t)0x1)
#define MFXSTM32L152_GPIO_PULL_DOWN ((uint8_t)0x0)
#define MFXSTM32L152_GPIO_PULL_UP ((uint8_t)0x1)
/**
* @brief TOUCH SCREEN Registers
*/
/**
* @brief Touch Screen Registers
*/
#define MFXSTM32L152_TS_SETTLING ((uint8_t)0xA0)
#define MFXSTM32L152_TS_TOUCH_DET_DELAY ((uint8_t)0xA1)
#define MFXSTM32L152_TS_AVE ((uint8_t)0xA2)
#define MFXSTM32L152_TS_TRACK ((uint8_t)0xA3)
#define MFXSTM32L152_TS_FIFO_TH ((uint8_t)0xA4)
#define MFXSTM32L152_TS_FIFO_STA ((uint8_t)0x20)
#define MFXSTM32L152_TS_FIFO_LEVEL ((uint8_t)0x21)
#define MFXSTM32L152_TS_XY_DATA ((uint8_t)0x24)
/**
* @brief TS registers masks
*/
#define MFXSTM32L152_TS_CTRL_STATUS ((uint8_t)0x08)
#define MFXSTM32L152_TS_CLEAR_FIFO ((uint8_t)0x80)
/**
* @brief Register address: Idd control register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_CTRL ((uint8_t)0x80)
/**
* @brief Register address: Idd pre delay register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_PRE_DELAY ((uint8_t)0x81)
/**
* @brief Register address: Idd Shunt registers (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_SHUNT0_MSB ((uint8_t)0x82)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT0_LSB ((uint8_t)0x83)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT1_MSB ((uint8_t)0x84)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT1_LSB ((uint8_t)0x85)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT2_MSB ((uint8_t)0x86)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT2_LSB ((uint8_t)0x87)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT3_MSB ((uint8_t)0x88)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT3_LSB ((uint8_t)0x89)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT4_MSB ((uint8_t)0x8A)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT4_LSB ((uint8_t)0x8B)
/**
* @brief Register address: Idd ampli gain register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_GAIN_MSB ((uint8_t)0x8C)
#define MFXSTM32L152_REG_ADR_IDD_GAIN_LSB ((uint8_t)0x8D)
/**
* @brief Register address: Idd VDD min register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_VDD_MIN_MSB ((uint8_t)0x8E)
#define MFXSTM32L152_REG_ADR_IDD_VDD_MIN_LSB ((uint8_t)0x8F)
/**
* @brief Register address: Idd value register (R)
*/
#define MFXSTM32L152_REG_ADR_IDD_VALUE_MSB ((uint8_t)0x14)
#define MFXSTM32L152_REG_ADR_IDD_VALUE_MID ((uint8_t)0x15)
#define MFXSTM32L152_REG_ADR_IDD_VALUE_LSB ((uint8_t)0x16)
/**
* @brief Register address: Idd calibration offset register (R)
*/
#define MFXSTM32L152_REG_ADR_IDD_CAL_OFFSET_MSB ((uint8_t)0x18)
#define MFXSTM32L152_REG_ADR_IDD_CAL_OFFSET_LSB ((uint8_t)0x19)
/**
* @brief Register address: Idd shunt used offset register (R)
*/
#define MFXSTM32L152_REG_ADR_IDD_SHUNT_USED ((uint8_t)0x1A)
/**
* @brief Register address: shunt stabilisation delay registers (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_SH0_STABILIZATION ((uint8_t)0x90)
#define MFXSTM32L152_REG_ADR_IDD_SH1_STABILIZATION ((uint8_t)0x91)
#define MFXSTM32L152_REG_ADR_IDD_SH2_STABILIZATION ((uint8_t)0x92)
#define MFXSTM32L152_REG_ADR_IDD_SH3_STABILIZATION ((uint8_t)0x93)
#define MFXSTM32L152_REG_ADR_IDD_SH4_STABILIZATION ((uint8_t)0x94)
/**
* @brief Register address: Idd number of measurements register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_NBR_OF_MEAS ((uint8_t)0x96)
/**
* @brief Register address: Idd delta delay between 2 measurements register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_MEAS_DELTA_DELAY ((uint8_t)0x97)
/**
* @brief Register address: Idd number of shunt on board register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_SHUNTS_ON_BOARD ((uint8_t)0x98)
/** @defgroup IDD_Control_Register_Defines IDD Control Register Defines
* @{
*/
/**
* @brief IDD control register masks
*/
#define MFXSTM32L152_IDD_CTRL_REQ ((uint8_t)0x01)
#define MFXSTM32L152_IDD_CTRL_SHUNT_NB ((uint8_t)0x0E)
#define MFXSTM32L152_IDD_CTRL_VREF_DIS ((uint8_t)0x40)
#define MFXSTM32L152_IDD_CTRL_CAL_DIS ((uint8_t)0x80)
/**
* @brief IDD Shunt Number
*/
#define MFXSTM32L152_IDD_SHUNT_NB_1 ((uint8_t) 0x01)
#define MFXSTM32L152_IDD_SHUNT_NB_2 ((uint8_t) 0x02)
#define MFXSTM32L152_IDD_SHUNT_NB_3 ((uint8_t) 0x03)
#define MFXSTM32L152_IDD_SHUNT_NB_4 ((uint8_t) 0x04)
#define MFXSTM32L152_IDD_SHUNT_NB_5 ((uint8_t) 0x05)
/**
* @brief Vref Measurement
*/
#define MFXSTM32L152_IDD_VREF_AUTO_MEASUREMENT_ENABLE ((uint8_t) 0x00)
#define MFXSTM32L152_IDD_VREF_AUTO_MEASUREMENT_DISABLE ((uint8_t) 0x70)
/**
* @brief IDD Calibration
*/
#define MFXSTM32L152_IDD_AUTO_CALIBRATION_ENABLE ((uint8_t) 0x00)
#define MFXSTM32L152_IDD_AUTO_CALIBRATION_DISABLE ((uint8_t) 0x80)
/**
* @}
*/
/** @defgroup IDD_PreDelay_Defines IDD PreDelay Defines
* @{
*/
/**
* @brief IDD PreDelay masks
*/
#define MFXSTM32L152_IDD_PREDELAY_UNIT ((uint8_t) 0x80)
#define MFXSTM32L152_IDD_PREDELAY_VALUE ((uint8_t) 0x7F)
/**
* @brief IDD PreDelay unit
*/
#define MFXSTM32L152_IDD_PREDELAY_0_5_MS ((uint8_t) 0x00)
#define MFXSTM32L152_IDD_PREDELAY_20_MS ((uint8_t) 0x80)
/**
* @}
*/
/** @defgroup IDD_DeltaDelay_Defines IDD Delta DElay Defines
* @{
*/
/**
* @brief IDD Delta Delay masks
*/
#define MFXSTM32L152_IDD_DELTADELAY_UNIT ((uint8_t) 0x80)
#define MFXSTM32L152_IDD_DELTADELAY_VALUE ((uint8_t) 0x7F)
/**
* @brief IDD Delta Delay unit
*/
#define MFXSTM32L152_IDD_DELTADELAY_0_5_MS ((uint8_t) 0x00)
#define MFXSTM32L152_IDD_DELTADELAY_20_MS ((uint8_t) 0x80)
/**
* @}
*/
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/** @defgroup MFXSTM32L152_Exported_Macros
* @{
*/
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup MFXSTM32L152_Exported_Functions
* @{
*/
/**
* @brief MFXSTM32L152 Control functions
*/
void mfxstm32l152_Init(uint16_t DeviceAddr);
void mfxstm32l152_DeInit(uint16_t DeviceAddr);
void mfxstm32l152_Reset(uint16_t DeviceAddr);
uint16_t mfxstm32l152_ReadID(uint16_t DeviceAddr);
uint16_t mfxstm32l152_ReadFwVersion(uint16_t DeviceAddr);
void mfxstm32l152_LowPower(uint16_t DeviceAddr);
void mfxstm32l152_WakeUp(uint16_t DeviceAddr);
void mfxstm32l152_EnableITSource(uint16_t DeviceAddr, uint8_t Source);
void mfxstm32l152_DisableITSource(uint16_t DeviceAddr, uint8_t Source);
uint8_t mfxstm32l152_GlobalITStatus(uint16_t DeviceAddr, uint8_t Source);
void mfxstm32l152_ClearGlobalIT(uint16_t DeviceAddr, uint8_t Source);
void mfxstm32l152_SetIrqOutPinPolarity(uint16_t DeviceAddr, uint8_t Polarity);
void mfxstm32l152_SetIrqOutPinType(uint16_t DeviceAddr, uint8_t Type);
/**
* @brief MFXSTM32L152 IO functionalities functions
*/
void mfxstm32l152_IO_Start(uint16_t DeviceAddr, uint32_t IO_Pin);
uint8_t mfxstm32l152_IO_Config(uint16_t DeviceAddr, uint32_t IO_Pin, IO_ModeTypedef IO_Mode);
void mfxstm32l152_IO_WritePin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t PinState);
uint32_t mfxstm32l152_IO_ReadPin(uint16_t DeviceAddr, uint32_t IO_Pin);
void mfxstm32l152_IO_EnableIT(uint16_t DeviceAddr);
void mfxstm32l152_IO_DisableIT(uint16_t DeviceAddr);
uint32_t mfxstm32l152_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin);
void mfxstm32l152_IO_ClearIT(uint16_t DeviceAddr, uint32_t IO_Pin);
void mfxstm32l152_IO_InitPin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Direction);
void mfxstm32l152_IO_EnableAF(uint16_t DeviceAddr);
void mfxstm32l152_IO_DisableAF(uint16_t DeviceAddr);
void mfxstm32l152_IO_SetIrqTypeMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Type);
void mfxstm32l152_IO_SetIrqEvtMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Evt);
void mfxstm32l152_IO_EnablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin);
void mfxstm32l152_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin);
/**
* @brief MFXSTM32L152 Touch screen functionalities functions
*/
void mfxstm32l152_TS_Start(uint16_t DeviceAddr);
uint8_t mfxstm32l152_TS_DetectTouch(uint16_t DeviceAddr);
void mfxstm32l152_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
void mfxstm32l152_TS_EnableIT(uint16_t DeviceAddr);
void mfxstm32l152_TS_DisableIT(uint16_t DeviceAddr);
uint8_t mfxstm32l152_TS_ITStatus (uint16_t DeviceAddr);
void mfxstm32l152_TS_ClearIT (uint16_t DeviceAddr);
/**
* @brief MFXSTM32L152 IDD current measurement functionalities functions
*/
void mfxstm32l152_IDD_Start(uint16_t DeviceAddr);
void mfxstm32l152_IDD_Config(uint16_t DeviceAddr, IDD_ConfigTypeDef MfxIddConfig);
void mfxstm32l152_IDD_ConfigShuntNbLimit(uint16_t DeviceAddr, uint8_t ShuntNbLimit);
void mfxstm32l152_IDD_GetValue(uint16_t DeviceAddr, uint32_t *ReadValue);
uint8_t mfxstm32l152_IDD_GetShuntUsed(uint16_t DeviceAddr);
void mfxstm32l152_IDD_EnableIT(uint16_t DeviceAddr);
void mfxstm32l152_IDD_ClearIT(uint16_t DeviceAddr);
uint8_t mfxstm32l152_IDD_GetITStatus(uint16_t DeviceAddr);
void mfxstm32l152_IDD_DisableIT(uint16_t DeviceAddr);
/**
* @brief MFXSTM32L152 Error management functions
*/
uint8_t mfxstm32l152_Error_ReadSrc(uint16_t DeviceAddr);
uint8_t mfxstm32l152_Error_ReadMsg(uint16_t DeviceAddr);
void mfxstm32l152_Error_EnableIT(uint16_t DeviceAddr);
void mfxstm32l152_Error_ClearIT(uint16_t DeviceAddr);
uint8_t mfxstm32l152_Error_GetITStatus(uint16_t DeviceAddr);
void mfxstm32l152_Error_DisableIT(uint16_t DeviceAddr);
uint8_t mfxstm32l152_ReadReg(uint16_t DeviceAddr, uint8_t RegAddr);
void mfxstm32l152_WriteReg(uint16_t DeviceAddr, uint8_t RegAddr, uint8_t Value);
/**
* @brief iobus prototypes (they should be defined in common/stm32_iobus.h)
*/
void MFX_IO_Init(void);
void MFX_IO_DeInit(void);
void MFX_IO_ITConfig (void);
void MFX_IO_EnableWakeupPin(void);
void MFX_IO_Wakeup(void);
void MFX_IO_Delay(uint32_t delay);
void MFX_IO_Write(uint16_t addr, uint8_t reg, uint8_t value);
uint8_t MFX_IO_Read(uint16_t addr, uint8_t reg);
uint16_t MFX_IO_ReadMultiple(uint16_t addr, uint8_t reg, uint8_t *buffer, uint16_t length);
/**
* @}
*/
/* Touch screen driver structure */
extern TS_DrvTypeDef mfxstm32l152_ts_drv;
/* IO driver structure */
extern IO_DrvTypeDef mfxstm32l152_io_drv;
/* IDD driver structure */
extern IDD_DrvTypeDef mfxstm32l152_idd_drv;
#ifdef __cplusplus
}
#endif
#endif /* __MFXSTM32L152_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for MX25LM51245G Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-mx25lm51245g-component-drivers"><small>Release Notes for</small> <mark>MX25LM51245G Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the MX25LM51245G component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 07-August-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of MX25LM51245G Octal Flash Memory Component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More