mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f3bb4c356 | ||
|
|
0ebaab5847 | ||
|
|
203a7c154b | ||
|
|
ebfe457f65 | ||
|
|
8c73aa0de4 | ||
|
|
53a1b9b7f4 | ||
|
|
c9d0d5bdb3 | ||
|
|
4f9e738501 | ||
|
|
fcaf909a54 | ||
|
|
9b51750a1d | ||
|
|
fceb81287e | ||
|
|
c3d8d246dc | ||
|
|
1f7cdf9694 | ||
|
|
b2db129ab8 | ||
|
|
b7e4249d2e | ||
|
|
0bbdda5b55 | ||
|
|
acb97f1d46 | ||
|
|
0b26e669af |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -4,7 +4,7 @@
|
|||||||
*.obj
|
*.obj
|
||||||
*.elf
|
*.elf
|
||||||
*.d
|
*.d
|
||||||
|
*.DS_Store
|
||||||
# Precompiled Headers
|
# Precompiled Headers
|
||||||
*.gch
|
*.gch
|
||||||
*.pch
|
*.pch
|
||||||
@@ -27,10 +27,13 @@
|
|||||||
*.app
|
*.app
|
||||||
*.i*86
|
*.i*86
|
||||||
*.x86_64
|
*.x86_64
|
||||||
*.hex
|
workspace/*.hex
|
||||||
|
|
||||||
# Debug files
|
# Debug files
|
||||||
*.dSYM/
|
*.dSYM/
|
||||||
*.su
|
*.su
|
||||||
workspace/ts100/Debug/*
|
workspace/ts100/Debug/*
|
||||||
workspace/.metadata/*
|
workspace/.metadata/*
|
||||||
|
|
||||||
|
workspace/ts100/.settings/language.settings.xml
|
||||||
|
workspace/ts100/.cproject
|
||||||
|
|||||||
2113
Flash Backup.hex
Normal file
2113
Flash Backup.hex
Normal file
File diff suppressed because it is too large
Load Diff
54
README.md
54
README.md
@@ -1,12 +1,48 @@
|
|||||||
# TS100
|
# TS100
|
||||||
Source code for the TS100 Soldering Iron
|
This is a complete open source re-write of the software for the ts100 soldering iron.
|
||||||
|
This project is feature complete for use as a soldering iron, but is still open to ideas and suggestions.
|
||||||
## UNTESTED!
|
|
||||||
|
|
||||||
This repository is my attempt (so far) at converting the source code for the TS100 soldering iron to the free System Workbench IDE and gcc based compilers.
|
|
||||||
|
|
||||||
I am also attempting to translate / comment as a go for a reference.
|
|
||||||
|
|
||||||
Untested on actual hardware until noted otherwise.
|
|
||||||
|
|
||||||
|
|
||||||
|
This project was started to remove the need for USB for changing system settings.
|
||||||
|
In the latest official firmware they have also added a settings menu system, so it is still worth comparing the two firmwares to select your preferred option.
|
||||||
|
|
||||||
|
## Features Working
|
||||||
|
* Soldering / Temperature control
|
||||||
|
* Full PID iron temperature control
|
||||||
|
* Adjusting temperature
|
||||||
|
* Automatic sleep
|
||||||
|
* Motion wake support
|
||||||
|
* Settings menu
|
||||||
|
* Input voltage UVLO measurement
|
||||||
|
* Saving settings to flash for persistence
|
||||||
|
* Improved GUI Fonts
|
||||||
|
* Use hardware I2C for communications
|
||||||
|
* Can disable movement detection if desired
|
||||||
|
|
||||||
|
# Upgrading your ts100 iron
|
||||||
|
This is completely safe, if it goes wrong just put the .hex file from the official website onto the unit and your back to the old firmware. Downloads for the hex files to flash are available on the [releases page.](https://github.com/Ralim/ts100/releases)
|
||||||
|
**You will need a windows computer (7,8,10 tested), using the normal windows explorer to load the firmware.
|
||||||
|
The bootloader does not appear to work under mac or linux at the moment.**
|
||||||
|
|
||||||
|
1. Hold the button closest to the tip, and plug in the USB to the computer.
|
||||||
|
2. The unit will appear as a USB drive.
|
||||||
|
3. Drag the .hex file onto the USB drive.
|
||||||
|
4. The unit will disconnect and reconnect.
|
||||||
|
5. The filename will have changed to end in .RDY or .ERR .
|
||||||
|
6. If it ends with .RDY your done! Otherwise something went wrong.
|
||||||
|
7. Disconnect the USB and power up the iron. You're good to go.
|
||||||
|
|
||||||
|
For the more adventurerous out there, you can also load this firmware onto the device using a SWD programmer.
|
||||||
|
On the bottom of the MCU riser pcb, there are 4 pads for programming.
|
||||||
|
There is a complete device flash backup included in this repository. (Note this includes the bootloader, so will need a SWD programmer to load onto the unit). Please do not use the backup of the bootloader for anything malicious, its only saved here for those who are tinkering with their iron and decide to replace it.
|
||||||
|
|
||||||
|
# New Menu System
|
||||||
|
This new firmware uses a new menu system to allow access to the settings on the device.
|
||||||
|
This menu can be accessed as shown in following flow chart, in the settings numbers roll over from top to bottom.
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
# Version Changes:
|
||||||
|
V1.02
|
||||||
|
- Adds hold both buttons on IDLE to access the therometer mode.
|
||||||
|
- Changes the exit soldering mode to be holding both buttons (Like original firmware).
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
# System Design
|
|
||||||
|
|
||||||
# Movement Detection
|
|
||||||
The unit has a MMA8652FC Accelerometer on the small sub board along with the STM32.
|
|
||||||
This is used for motion detection of the soldering iron.
|
|
||||||
|
|
||||||
# USB Disk
|
|
||||||
When the unit is plugged into the computer, it presents a FAT device to the operating system over the usb connection.
|
|
||||||
This is implimented using a ram buffer for the disk.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Future improvements to be made
|
|
||||||
These features are things I would like to add to the firmware
|
|
||||||
|
|
||||||
* Use hardware PWM for driving the heating element.
|
|
||||||
* Use the sysTick hardware for timing of events
|
|
||||||
* Move all the settings to an on device menu system instead of usb link
|
|
||||||
* Move error codes into a unified struct
|
|
||||||
* Rewrite most of the OLED stack to not require hardcoded values
|
|
||||||
* Rework the modes of the unit to be neater
|
|
||||||
|
|
||||||
BIN
TS100 V2.46 Schematics V1.0.pdf
Normal file
BIN
TS100 V2.46 Schematics V1.0.pdf
Normal file
Binary file not shown.
@@ -42,8 +42,8 @@ Mcu.Pin9=PA14
|
|||||||
Mcu.PinsNb=16
|
Mcu.PinsNb=16
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
Mcu.UserName=STM32F103T8Ux
|
Mcu.UserName=STM32F103T8Ux
|
||||||
MxCube.Version=4.16.0
|
MxCube.Version=4.16.1
|
||||||
MxDb.Version=DB.4.0.160
|
MxDb.Version=DB.4.0.161
|
||||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true
|
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true
|
||||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true
|
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true
|
||||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true
|
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true
|
||||||
@@ -107,7 +107,7 @@ PB7.Signal=I2C1_SDA
|
|||||||
PCC.Checker=false
|
PCC.Checker=false
|
||||||
PCC.Line=STM32F103
|
PCC.Line=STM32F103
|
||||||
PCC.MCU=STM32F103T(8-B)Ux
|
PCC.MCU=STM32F103T(8-B)Ux
|
||||||
PCC.MXVersion=4.16.0
|
PCC.MXVersion=4.16.1
|
||||||
PCC.PartNumber=STM32F103T8Ux
|
PCC.PartNumber=STM32F103T8Ux
|
||||||
PCC.Seq0=0
|
PCC.Seq0=0
|
||||||
PCC.Series=STM32F1
|
PCC.Series=STM32F1
|
||||||
@@ -127,13 +127,13 @@ ProjectManager.HeapSize=0x200
|
|||||||
ProjectManager.KeepUserCode=true
|
ProjectManager.KeepUserCode=true
|
||||||
ProjectManager.LastFirmware=true
|
ProjectManager.LastFirmware=true
|
||||||
ProjectManager.LibraryCopy=1
|
ProjectManager.LibraryCopy=1
|
||||||
ProjectManager.PreviousToolchain=
|
ProjectManager.PreviousToolchain=SW4STM32
|
||||||
ProjectManager.ProjectBuild=false
|
ProjectManager.ProjectBuild=false
|
||||||
ProjectManager.ProjectFileName=TS100.ioc
|
ProjectManager.ProjectFileName=TS100.ioc
|
||||||
ProjectManager.ProjectName=TS100
|
ProjectManager.ProjectName=TS100
|
||||||
ProjectManager.StackSize=0x400
|
ProjectManager.StackSize=0x400
|
||||||
ProjectManager.TargetToolchain=SW4STM32
|
ProjectManager.TargetToolchain=SW4STM32
|
||||||
ProjectManager.ToolChainLocation=/home/ralim/Repo/ts100/TS100
|
ProjectManager.ToolChainLocation=C\:\\Users\\Ralim\\Repo\\ts100\\TS100
|
||||||
ProjectManager.UnderRoot=true
|
ProjectManager.UnderRoot=true
|
||||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false,2-MX_I2C1_Init-I2C1-false,3-MX_ADC2_Init-ADC2-false,4-MX_USB_PCD_Init-USB-false,5-MX_ADC1_Init-ADC1-false
|
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false,2-MX_I2C1_Init-I2C1-false,3-MX_ADC2_Init-ADC2-false,4-MX_USB_PCD_Init-USB-false,5-MX_ADC1_Init-ADC1-false
|
||||||
RCC.ADCFreqValue=12000000
|
RCC.ADCFreqValue=12000000
|
||||||
@@ -147,12 +147,13 @@ RCC.APB2TimFreq_Value=48000000
|
|||||||
RCC.FCLKCortexFreq_Value=48000000
|
RCC.FCLKCortexFreq_Value=48000000
|
||||||
RCC.FamilyName=M
|
RCC.FamilyName=M
|
||||||
RCC.HCLKFreq_Value=48000000
|
RCC.HCLKFreq_Value=48000000
|
||||||
RCC.IPParameters=ADCFreqValue,ADCPresc,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,PLLSourceVirtualString,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value
|
RCC.IPParameters=ADCFreqValue,ADCPresc,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,PLLSource,PLLSourceVirtual,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value
|
||||||
RCC.MCOFreq_Value=48000000
|
RCC.MCOFreq_Value=48000000
|
||||||
RCC.PLLCLKFreq_Value=48000000
|
RCC.PLLCLKFreq_Value=48000000
|
||||||
RCC.PLLMCOFreq_Value=24000000
|
RCC.PLLMCOFreq_Value=24000000
|
||||||
RCC.PLLMUL=RCC_PLL_MUL12
|
RCC.PLLMUL=RCC_PLL_MUL12
|
||||||
RCC.PLLSourceVirtualString=RCC_PLLSOURCE_HSI_DIV2
|
RCC.PLLSource=RCC_PLLSOURCE_HSI_DIV2
|
||||||
|
RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSI_DIV2
|
||||||
RCC.SYSCLKFreq_VALUE=48000000
|
RCC.SYSCLKFreq_VALUE=48000000
|
||||||
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
|
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
|
||||||
RCC.TimSysFreq_Value=48000000
|
RCC.TimSysFreq_Value=48000000
|
||||||
|
|||||||
25
VERSION.txt
25
VERSION.txt
@@ -1,25 +0,0 @@
|
|||||||
v2.11 update (2015/08/03)
|
|
||||||
1, optimizing the key for delay;
|
|
||||||
2, optimized display processing
|
|
||||||
3, optimization of high-temperature alarm;
|
|
||||||
4, to increase the maximum voltage alarm;
|
|
||||||
5, the newly added screen protection, enter standby interface for some time, the screen will shut itself down, or move the iron screen button will automatically light up;
|
|
||||||
6, optimizing the movement decision
|
|
||||||
|
|
||||||
v2.10 update (2015/07/14)
|
|
||||||
1, temperature calibration is not refresh bug;
|
|
||||||
2, Cancel USB-powered thermometer into the function;
|
|
||||||
|
|
||||||
---Original --
|
|
||||||
v2.11 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(20150803)
|
|
||||||
1<EFBFBD><EFBFBD> <09>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
2<EFBFBD><EFBFBD> <09>Ż<EFBFBD><C5BB><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|
||||||
3<EFBFBD><EFBFBD> <09>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
4<EFBFBD><EFBFBD> <09><><EFBFBD>߱<EFBFBD><DFB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ѹ<EFBFBD><D1B9>
|
|
||||||
5<EFBFBD><EFBFBD> <09>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD>Լ<EFBFBD><D4BC>رգ<D8B1><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
6<EFBFBD><EFBFBD> <09>Ż<EFBFBD><C5BB>ƶ<EFBFBD><C6B6>ж<EFBFBD>
|
|
||||||
|
|
||||||
v2.10 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(20150714)
|
|
||||||
1<EFBFBD><EFBFBD> <09>¶<EFBFBD>Уʱû<CAB1><C3BB>ˢ<EFBFBD>µ<EFBFBD>bug<75><67>
|
|
||||||
2<EFBFBD><EFBFBD> ȡ<><C8A1>USB<53><42><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>¶ȼƵĹ<C6B5><C4B9>ܣ<EFBFBD>
|
|
||||||
|
|
||||||
@@ -14,22 +14,26 @@
|
|||||||
</extensions>
|
</extensions>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<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.debug" cleanCommand="rm -rf" description="" id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.1236130657" name="Debug" parent="fr.ac6.managedbuild.config.gnu.cross.exe.debug" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.bin"; arm-none-eabi-size "${BuildArtifactFileName}" ">
|
<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.debug" cleanCommand="rm -rf" description="" id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.1236130657" name="Debug" parent="fr.ac6.managedbuild.config.gnu.cross.exe.debug" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.bin"; arm-none-eabi-size "${BuildArtifactFileName}" ;arm-none-eabi-objcopy -O ihex "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.hex"">
|
||||||
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.1236130657." name="/" resourcePath="">
|
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.1236130657." name="/" resourcePath="">
|
||||||
<toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.debug.2123758208" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.debug">
|
<toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.debug.2123758208" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.debug">
|
||||||
<option id="fr.ac6.managedbuild.option.gnu.cross.mcu.1416828544" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" value="STM32F103T8Ux" valueType="string"/>
|
<option id="fr.ac6.managedbuild.option.gnu.cross.mcu.1416828544" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" value="STM32F103T8Ux" valueType="string"/>
|
||||||
<option id="fr.ac6.managedbuild.option.gnu.cross.board.1401196546" name="Board" superClass="fr.ac6.managedbuild.option.gnu.cross.board" value="ts100" valueType="string"/>
|
<option id="fr.ac6.managedbuild.option.gnu.cross.board.1401196546" name="Board" superClass="fr.ac6.managedbuild.option.gnu.cross.board" value="ts100" valueType="string"/>
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="fr.ac6.managedbuild.targetPlatform.gnu.cross.1811524023" isAbstract="false" osList="all" superClass="fr.ac6.managedbuild.targetPlatform.gnu.cross"/>
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="fr.ac6.managedbuild.targetPlatform.gnu.cross.1811524023" isAbstract="false" osList="all" superClass="fr.ac6.managedbuild.targetPlatform.gnu.cross"/>
|
||||||
<builder buildPath="${workspace_loc:/ts100}/Debug" id="fr.ac6.managedbuild.builder.gnu.cross.727350462" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="fr.ac6.managedbuild.builder.gnu.cross"/>
|
<builder buildPath="${workspace_loc:/ts100}/Debug" id="fr.ac6.managedbuild.builder.gnu.cross.727350462" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="fr.ac6.managedbuild.builder.gnu.cross">
|
||||||
|
<outputEntries>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="Debug"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="Release"/>
|
||||||
|
</outputEntries>
|
||||||
|
</builder>
|
||||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.1500724168" name="MCU GCC Compiler" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler">
|
<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.1500724168" name="MCU GCC Compiler" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler">
|
||||||
<option id="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level.963224364" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.c.optimization.level.size" valueType="enumerated"/>
|
<option id="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level.963224364" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.c.optimization.level.more" valueType="enumerated"/>
|
||||||
<option id="gnu.c.compiler.option.debugging.level.400507088" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
<option id="gnu.c.compiler.option.debugging.level.400507088" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||||
<option id="gnu.c.compiler.option.include.paths.1436405353" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
<option id="gnu.c.compiler.option.include.paths.1436405353" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/inc""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/STM32_USB-FS-Device_Driver/inc""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/StdPeriph_Driver/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/StdPeriph_Driver/inc""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/CMSIS/core}""/>
|
||||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/CMSIS/core""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/CMSIS/device}""/>
|
||||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/CMSIS/device""/>
|
|
||||||
</option>
|
</option>
|
||||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1155214152" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1155214152" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="STM32F103T8Ux"/>
|
<listOptionValue builtIn="false" value="STM32F103T8Ux"/>
|
||||||
@@ -45,7 +49,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option id="gnu.c.compiler.option.dialect.std.1983627145" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.c.compiler.dialect.c11" valueType="enumerated"/>
|
<option id="gnu.c.compiler.option.dialect.std.1983627145" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.c.compiler.dialect.c11" valueType="enumerated"/>
|
||||||
<option id="gnu.c.compiler.option.warnings.nowarn.1227270879" name="Inhibit all warnings (-w)" superClass="gnu.c.compiler.option.warnings.nowarn" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
<option id="gnu.c.compiler.option.warnings.nowarn.1227270879" name="Inhibit all warnings (-w)" superClass="gnu.c.compiler.option.warnings.nowarn" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||||
<option id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.fdata.1556802580" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.fdata" value="true" valueType="boolean"/>
|
<option id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.fdata.1556802580" name="Place the data in their own section (-fdata-sections)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.fdata" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c.1635097739" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c"/>
|
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c.1635097739" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c"/>
|
||||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s.211510996" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s"/>
|
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s.211510996" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s"/>
|
||||||
</tool>
|
</tool>
|
||||||
@@ -65,10 +69,10 @@
|
|||||||
<tool id="fr.ac6.managedbuild.tool.gnu.archiver.1926145385" name="MCU GCC Archiver" superClass="fr.ac6.managedbuild.tool.gnu.archiver"/>
|
<tool id="fr.ac6.managedbuild.tool.gnu.archiver.1926145385" name="MCU GCC Archiver" superClass="fr.ac6.managedbuild.tool.gnu.archiver"/>
|
||||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.assembler.104990963" name="MCU GCC Assembler" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler">
|
<tool id="fr.ac6.managedbuild.tool.gnu.cross.assembler.104990963" name="MCU GCC Assembler" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler">
|
||||||
<option id="gnu.both.asm.option.include.paths.834243276" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
|
<option id="gnu.both.asm.option.include.paths.834243276" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
|
||||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/inc""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/StdPeriph_Driver/inc""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/StdPeriph_Driver/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/CMSIS/core""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/CMSIS/core}""/>
|
||||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/CMSIS/device""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/CMSIS/device}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1754789872" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1754789872" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.assembler.input.610009869" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler.input"/>
|
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.assembler.input.610009869" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler.input"/>
|
||||||
@@ -77,7 +81,6 @@
|
|||||||
</folderInfo>
|
</folderInfo>
|
||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="CMSIS"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="CMSIS"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="STM32_USB-FS-Device_Driver"/>
|
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="StdPeriph_Driver"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="StdPeriph_Driver"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||||
@@ -100,7 +103,7 @@
|
|||||||
</extensions>
|
</extensions>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<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="fr.ac6.managedbuild.config.gnu.cross.exe.release.1113492345" name="Release" parent="fr.ac6.managedbuild.config.gnu.cross.exe.release" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.bin"; arm-none-eabi-size -B "${BuildArtifactFileName}"">
|
<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="fr.ac6.managedbuild.config.gnu.cross.exe.release.1113492345" name="Release" parent="fr.ac6.managedbuild.config.gnu.cross.exe.release" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.bin"; arm-none-eabi-size -B "${BuildArtifactFileName}";arm-none-eabi-objcopy -O ihex "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.hex"">
|
||||||
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.release.1113492345." name="/" resourcePath="">
|
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.release.1113492345." name="/" resourcePath="">
|
||||||
<toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release.668479481" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release">
|
<toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release.668479481" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release">
|
||||||
<option id="fr.ac6.managedbuild.option.gnu.cross.mcu.302274410" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" value="STM32F103T8Ux" valueType="string"/>
|
<option id="fr.ac6.managedbuild.option.gnu.cross.mcu.302274410" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" value="STM32F103T8Ux" valueType="string"/>
|
||||||
|
|||||||
2
workspace/ts100/.gitignore
vendored
Normal file
2
workspace/ts100/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/Debug/
|
||||||
|
/Release/
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<project>
|
|
||||||
<configuration id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.1236130657" 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 copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
|
|
||||||
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="-1108237618066810324" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" 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="fr.ac6.managedbuild.config.gnu.cross.exe.release.1113492345" 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 copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
|
|
||||||
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="-1102374516241012504" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
|
||||||
</provider>
|
|
||||||
</extension>
|
|
||||||
</configuration>
|
|
||||||
</project>
|
|
||||||
@@ -62,9 +62,11 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
|
|||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
|
||||||
ROM (rx) : ORIGIN = 0x08004000, LENGTH = 36K
|
ROM (rx) : ORIGIN = 0x08004000, LENGTH = 47K
|
||||||
|
|
||||||
}
|
}
|
||||||
/*^ The rom is shortened as the last ~10K is used for storing the virtual USB Disk, and the offset at the beginning in the bootloader*/
|
/*ROM (rx) : ORIGIN = 0x08004000, LENGTH = 48K*/
|
||||||
|
/*^ The offset at the beginning in the bootloader, 1K at the end for settings (actually 256 bytes, but leaving room for now)*/
|
||||||
/* Sections */
|
/* Sections */
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,259 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_core.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Standard protocol processing functions prototypes
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __USB_CORE_H
|
|
||||||
#define __USB_CORE_H
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
typedef enum _CONTROL_STATE
|
|
||||||
{
|
|
||||||
WAIT_SETUP, /* 0 */
|
|
||||||
SETTING_UP, /* 1 */
|
|
||||||
IN_DATA, /* 2 */
|
|
||||||
OUT_DATA, /* 3 */
|
|
||||||
LAST_IN_DATA, /* 4 */
|
|
||||||
LAST_OUT_DATA, /* 5 */
|
|
||||||
WAIT_STATUS_IN, /* 7 */
|
|
||||||
WAIT_STATUS_OUT, /* 8 */
|
|
||||||
STALLED, /* 9 */
|
|
||||||
PAUSE /* 10 */
|
|
||||||
} CONTROL_STATE; /* The state machine states of a control pipe */
|
|
||||||
|
|
||||||
typedef struct OneDescriptor
|
|
||||||
{
|
|
||||||
uint8_t *Descriptor;
|
|
||||||
uint16_t Descriptor_Size;
|
|
||||||
}
|
|
||||||
ONE_DESCRIPTOR, *PONE_DESCRIPTOR;
|
|
||||||
/* All the request process routines return a value of this type
|
|
||||||
If the return value is not SUCCESS or NOT_READY,
|
|
||||||
the software will STALL the correspond endpoint */
|
|
||||||
typedef enum _RESULT
|
|
||||||
{
|
|
||||||
USB_SUCCESS = 0, /* Process successfully */
|
|
||||||
USB_ERROR,
|
|
||||||
USB_UNSUPPORT,
|
|
||||||
USB_NOT_READY /* The process has not been finished, endpoint will be
|
|
||||||
NAK to further request */
|
|
||||||
} RESULT;
|
|
||||||
|
|
||||||
|
|
||||||
/*-*-*-*-*-*-*-*-*-*-* Definitions for endpoint level -*-*-*-*-*-*-*-*-*-*-*-*/
|
|
||||||
typedef struct _ENDPOINT_INFO
|
|
||||||
{
|
|
||||||
/* When send data out of the device,
|
|
||||||
CopyData() is used to get data buffer 'Length' bytes data
|
|
||||||
if Length is 0,
|
|
||||||
CopyData() returns the total length of the data
|
|
||||||
if the request is not supported, returns 0
|
|
||||||
(NEW Feature )
|
|
||||||
if CopyData() returns -1, the calling routine should not proceed
|
|
||||||
further and will resume the SETUP process by the class device
|
|
||||||
if Length is not 0,
|
|
||||||
CopyData() returns a pointer to indicate the data location
|
|
||||||
Usb_wLength is the data remain to be sent,
|
|
||||||
Usb_wOffset is the Offset of original data
|
|
||||||
When receive data from the host,
|
|
||||||
CopyData() is used to get user data buffer which is capable
|
|
||||||
of Length bytes data to copy data from the endpoint buffer.
|
|
||||||
if Length is 0,
|
|
||||||
CopyData() returns the available data length,
|
|
||||||
if Length is not 0,
|
|
||||||
CopyData() returns user buffer address
|
|
||||||
Usb_rLength is the data remain to be received,
|
|
||||||
Usb_rPointer is the Offset of data buffer
|
|
||||||
*/
|
|
||||||
uint16_t Usb_wLength;
|
|
||||||
uint16_t Usb_wOffset;
|
|
||||||
uint16_t PacketSize;
|
|
||||||
uint8_t *(*CopyData)(uint16_t Length);
|
|
||||||
}ENDPOINT_INFO;
|
|
||||||
|
|
||||||
/*-*-*-*-*-*-*-*-*-*-*-* Definitions for device level -*-*-*-*-*-*-*-*-*-*-*-*/
|
|
||||||
|
|
||||||
typedef struct _DEVICE
|
|
||||||
{
|
|
||||||
uint8_t Total_Endpoint; /* Number of endpoints that are used */
|
|
||||||
uint8_t Total_Configuration;/* Number of configuration available */
|
|
||||||
}
|
|
||||||
DEVICE;
|
|
||||||
|
|
||||||
typedef union
|
|
||||||
{
|
|
||||||
uint16_t w;
|
|
||||||
struct BW
|
|
||||||
{
|
|
||||||
uint8_t bb1;
|
|
||||||
uint8_t bb0;
|
|
||||||
}
|
|
||||||
bw;
|
|
||||||
} uint16_t_uint8_t;
|
|
||||||
|
|
||||||
typedef struct _DEVICE_INFO
|
|
||||||
{
|
|
||||||
uint8_t USBbmRequestType; /* bmRequestType */
|
|
||||||
uint8_t USBbRequest; /* bRequest */
|
|
||||||
uint16_t_uint8_t USBwValues; /* wValue */
|
|
||||||
uint16_t_uint8_t USBwIndexs; /* wIndex */
|
|
||||||
uint16_t_uint8_t USBwLengths; /* wLength */
|
|
||||||
|
|
||||||
uint8_t ControlState; /* of type CONTROL_STATE */
|
|
||||||
uint8_t Current_Feature;
|
|
||||||
uint8_t Current_Configuration; /* Selected configuration */
|
|
||||||
uint8_t Current_Interface; /* Selected interface of current configuration */
|
|
||||||
uint8_t Current_AlternateSetting;/* Selected Alternate Setting of current
|
|
||||||
interface*/
|
|
||||||
|
|
||||||
ENDPOINT_INFO Ctrl_Info;
|
|
||||||
}DEVICE_INFO;
|
|
||||||
|
|
||||||
typedef struct _DEVICE_PROP
|
|
||||||
{
|
|
||||||
void (*Init)(void); /* Initialize the device */
|
|
||||||
void (*Reset)(void); /* Reset routine of this device */
|
|
||||||
|
|
||||||
/* Device dependent process after the status stage */
|
|
||||||
void (*Process_Status_IN)(void);
|
|
||||||
void (*Process_Status_OUT)(void);
|
|
||||||
|
|
||||||
/* Procedure of process on setup stage of a class specified request with data stage */
|
|
||||||
/* All class specified requests with data stage are processed in Class_Data_Setup
|
|
||||||
Class_Data_Setup()
|
|
||||||
responses to check all special requests and fills ENDPOINT_INFO
|
|
||||||
according to the request
|
|
||||||
If IN tokens are expected, then wLength & wOffset will be filled
|
|
||||||
with the total transferring bytes and the starting position
|
|
||||||
If OUT tokens are expected, then rLength & rOffset will be filled
|
|
||||||
with the total expected bytes and the starting position in the buffer
|
|
||||||
|
|
||||||
If the request is valid, Class_Data_Setup returns SUCCESS, else UNSUPPORT
|
|
||||||
|
|
||||||
CAUTION:
|
|
||||||
Since GET_CONFIGURATION & GET_INTERFACE are highly related to
|
|
||||||
the individual classes, they will be checked and processed here.
|
|
||||||
*/
|
|
||||||
RESULT (*Class_Data_Setup)(uint8_t RequestNo);
|
|
||||||
|
|
||||||
/* Procedure of process on setup stage of a class specified request without data stage */
|
|
||||||
/* All class specified requests without data stage are processed in Class_NoData_Setup
|
|
||||||
Class_NoData_Setup
|
|
||||||
responses to check all special requests and perform the request
|
|
||||||
|
|
||||||
CAUTION:
|
|
||||||
Since SET_CONFIGURATION & SET_INTERFACE are highly related to
|
|
||||||
the individual classes, they will be checked and processed here.
|
|
||||||
*/
|
|
||||||
RESULT (*Class_NoData_Setup)(uint8_t RequestNo);
|
|
||||||
|
|
||||||
/*Class_Get_Interface_Setting
|
|
||||||
This function is used by the file usb_core.c to test if the selected Interface
|
|
||||||
and Alternate Setting (uint8_t Interface, uint8_t AlternateSetting) are supported by
|
|
||||||
the application.
|
|
||||||
This function is writing by user. It should return "SUCCESS" if the Interface
|
|
||||||
and Alternate Setting are supported by the application or "UNSUPPORT" if they
|
|
||||||
are not supported. */
|
|
||||||
|
|
||||||
RESULT (*Class_Get_Interface_Setting)(uint8_t Interface, uint8_t AlternateSetting);
|
|
||||||
|
|
||||||
uint8_t* (*GetDeviceDescriptor)(uint16_t Length);
|
|
||||||
uint8_t* (*GetConfigDescriptor)(uint16_t Length);
|
|
||||||
uint8_t* (*GetStringDescriptor)(uint16_t Length);
|
|
||||||
|
|
||||||
/* This field is not used in current library version. It is kept only for
|
|
||||||
compatibility with previous versions */
|
|
||||||
void* RxEP_buffer;
|
|
||||||
|
|
||||||
uint8_t MaxPacketSize;
|
|
||||||
|
|
||||||
}DEVICE_PROP;
|
|
||||||
|
|
||||||
typedef struct _USER_STANDARD_REQUESTS
|
|
||||||
{
|
|
||||||
void (*User_GetConfiguration)(void); /* Get Configuration */
|
|
||||||
void (*User_SetConfiguration)(void); /* Set Configuration */
|
|
||||||
void (*User_GetInterface)(void); /* Get Interface */
|
|
||||||
void (*User_SetInterface)(void); /* Set Interface */
|
|
||||||
void (*User_GetStatus)(void); /* Get Status */
|
|
||||||
void (*User_ClearFeature)(void); /* Clear Feature */
|
|
||||||
void (*User_SetEndPointFeature)(void); /* Set Endpoint Feature */
|
|
||||||
void (*User_SetDeviceFeature)(void); /* Set Device Feature */
|
|
||||||
void (*User_SetDeviceAddress)(void); /* Set Device Address */
|
|
||||||
}
|
|
||||||
USER_STANDARD_REQUESTS;
|
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
#define Type_Recipient (pInformation->USBbmRequestType & (REQUEST_TYPE | RECIPIENT))
|
|
||||||
|
|
||||||
#define Usb_rLength Usb_wLength
|
|
||||||
#define Usb_rOffset Usb_wOffset
|
|
||||||
|
|
||||||
#define USBwValue USBwValues.w
|
|
||||||
#define USBwValue0 USBwValues.bw.bb0
|
|
||||||
#define USBwValue1 USBwValues.bw.bb1
|
|
||||||
#define USBwIndex USBwIndexs.w
|
|
||||||
#define USBwIndex0 USBwIndexs.bw.bb0
|
|
||||||
#define USBwIndex1 USBwIndexs.bw.bb1
|
|
||||||
#define USBwLength USBwLengths.w
|
|
||||||
#define USBwLength0 USBwLengths.bw.bb0
|
|
||||||
#define USBwLength1 USBwLengths.bw.bb1
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
uint8_t Setup0_Process(void);
|
|
||||||
uint8_t Post0_Process(void);
|
|
||||||
uint8_t Out0_Process(void);
|
|
||||||
uint8_t In0_Process(void);
|
|
||||||
|
|
||||||
RESULT Standard_SetEndPointFeature(void);
|
|
||||||
RESULT Standard_SetDeviceFeature(void);
|
|
||||||
|
|
||||||
uint8_t *Standard_GetConfiguration(uint16_t Length);
|
|
||||||
RESULT Standard_SetConfiguration(void);
|
|
||||||
uint8_t *Standard_GetInterface(uint16_t Length);
|
|
||||||
RESULT Standard_SetInterface(void);
|
|
||||||
uint8_t *Standard_GetDescriptorData(uint16_t Length, PONE_DESCRIPTOR pDesc);
|
|
||||||
|
|
||||||
uint8_t *Standard_GetStatus(uint16_t Length);
|
|
||||||
RESULT Standard_ClearFeature(void);
|
|
||||||
void SetDeviceAddress(uint8_t);
|
|
||||||
void NOP_Process(void);
|
|
||||||
|
|
||||||
extern DEVICE_PROP Device_Property;
|
|
||||||
extern USER_STANDARD_REQUESTS User_Standard_Requests;
|
|
||||||
extern DEVICE Device_Table;
|
|
||||||
extern DEVICE_INFO Device_Info;
|
|
||||||
|
|
||||||
/* cells saving status during interrupt servicing */
|
|
||||||
extern volatile uint16_t SaveRState;
|
|
||||||
extern volatile uint16_t SaveTState;
|
|
||||||
|
|
||||||
#endif /* __USB_CORE_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_def.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Definitions related to USB Core
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __USB_DEF_H
|
|
||||||
#define __USB_DEF_H
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
typedef enum _RECIPIENT_TYPE
|
|
||||||
{
|
|
||||||
DEVICE_RECIPIENT, /* Recipient device */
|
|
||||||
INTERFACE_RECIPIENT, /* Recipient interface */
|
|
||||||
ENDPOINT_RECIPIENT, /* Recipient endpoint */
|
|
||||||
OTHER_RECIPIENT
|
|
||||||
} RECIPIENT_TYPE;
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum _STANDARD_REQUESTS
|
|
||||||
{
|
|
||||||
GET_STATUS = 0,
|
|
||||||
CLEAR_FEATURE,
|
|
||||||
RESERVED1,
|
|
||||||
SET_FEATURE,
|
|
||||||
RESERVED2,
|
|
||||||
SET_ADDRESS,
|
|
||||||
GET_DESCRIPTOR,
|
|
||||||
SET_DESCRIPTOR,
|
|
||||||
GET_CONFIGURATION,
|
|
||||||
SET_CONFIGURATION,
|
|
||||||
GET_INTERFACE,
|
|
||||||
SET_INTERFACE,
|
|
||||||
TOTAL_sREQUEST, /* Total number of Standard request */
|
|
||||||
SYNCH_FRAME = 12
|
|
||||||
} STANDARD_REQUESTS;
|
|
||||||
|
|
||||||
/* Definition of "USBwValue" */
|
|
||||||
typedef enum _DESCRIPTOR_TYPE
|
|
||||||
{
|
|
||||||
DEVICE_DESCRIPTOR = 1,
|
|
||||||
CONFIG_DESCRIPTOR,
|
|
||||||
STRING_DESCRIPTOR,
|
|
||||||
INTERFACE_DESCRIPTOR,
|
|
||||||
ENDPOINT_DESCRIPTOR
|
|
||||||
} DESCRIPTOR_TYPE;
|
|
||||||
|
|
||||||
/* Feature selector of a SET_FEATURE or CLEAR_FEATURE */
|
|
||||||
typedef enum _FEATURE_SELECTOR
|
|
||||||
{
|
|
||||||
ENDPOINT_STALL,
|
|
||||||
DEVICE_REMOTE_WAKEUP
|
|
||||||
} FEATURE_SELECTOR;
|
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/* Definition of "USBbmRequestType" */
|
|
||||||
#define REQUEST_TYPE 0x60 /* Mask to get request type */
|
|
||||||
#define STANDARD_REQUEST 0x00 /* Standard request */
|
|
||||||
#define CLASS_REQUEST 0x20 /* Class request */
|
|
||||||
#define VENDOR_REQUEST 0x40 /* Vendor request */
|
|
||||||
|
|
||||||
#define RECIPIENT 0x1F /* Mask to get recipient */
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
|
|
||||||
#endif /* __USB_DEF_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_init.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Initialization routines & global variables
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __USB_INIT_H
|
|
||||||
#define __USB_INIT_H
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
void USB_Init(void);
|
|
||||||
|
|
||||||
/* External variables --------------------------------------------------------*/
|
|
||||||
/* The number of current endpoint, it will be used to specify an endpoint */
|
|
||||||
extern uint8_t EPindex;
|
|
||||||
/* The number of current device, it is an index to the Device_Table */
|
|
||||||
/*extern uint8_t Device_no; */
|
|
||||||
/* Points to the DEVICE_INFO structure of current device */
|
|
||||||
/* The purpose of this register is to speed up the execution */
|
|
||||||
extern DEVICE_INFO* pInformation;
|
|
||||||
/* Points to the DEVICE_PROP structure of current device */
|
|
||||||
/* The purpose of this register is to speed up the execution */
|
|
||||||
extern DEVICE_PROP* pProperty;
|
|
||||||
/* Temporary save the state of Rx & Tx status. */
|
|
||||||
/* Whenever the Rx or Tx state is changed, its value is saved */
|
|
||||||
/* in this variable first and will be set to the EPRB or EPRA */
|
|
||||||
/* at the end of interrupt process */
|
|
||||||
extern USER_STANDARD_REQUESTS *pUser_Standard_Requests;
|
|
||||||
|
|
||||||
extern uint16_t SaveState ;
|
|
||||||
extern uint16_t wInterrupt_Mask;
|
|
||||||
|
|
||||||
#endif /* __USB_INIT_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_int.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Endpoint CTR (Low and High) interrupt's service routines prototypes
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __USB_INT_H
|
|
||||||
#define __USB_INT_H
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
void CTR_LP(void);
|
|
||||||
void CTR_HP(void);
|
|
||||||
|
|
||||||
/* External variables --------------------------------------------------------*/
|
|
||||||
|
|
||||||
#endif /* __USB_INT_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_lib.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief USB library include files
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __USB_LIB_H
|
|
||||||
#define __USB_LIB_H
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "usb_type.h"
|
|
||||||
#include "usb_regs.h"
|
|
||||||
#include "usb_def.h"
|
|
||||||
#include "usb_core.h"
|
|
||||||
#include "usb_init.h"
|
|
||||||
#include "usb_sil.h"
|
|
||||||
#include "usb_mem.h"
|
|
||||||
#include "usb_int.h"
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
/* External variables --------------------------------------------------------*/
|
|
||||||
|
|
||||||
#endif /* __USB_LIB_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_mem.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Utility prototypes functions for memory/PMA transfers
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __USB_MEM_H
|
|
||||||
#define __USB_MEM_H
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
|
|
||||||
void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
|
|
||||||
|
|
||||||
/* External variables --------------------------------------------------------*/
|
|
||||||
|
|
||||||
#endif /*__USB_MEM_H*/
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
|
|
||||||
* File Name : usb_mem.h
|
|
||||||
* Author : MCD Application Team
|
|
||||||
* Version : V1.0
|
|
||||||
* Date : 10/08/2007
|
|
||||||
* Description : Utility prototypes functions for memory/PMA transfers
|
|
||||||
********************************************************************************
|
|
||||||
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
|
||||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
|
||||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
|
||||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
|
||||||
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
|
||||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __USB_MEM_H
|
|
||||||
#define __USB_MEM_H
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
|
|
||||||
void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
|
|
||||||
|
|
||||||
/* External variables --------------------------------------------------------*/
|
|
||||||
|
|
||||||
#endif /*__USB_MEM_H*/
|
|
||||||
|
|
||||||
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,685 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_regs.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Interface prototype functions to USB cell registers
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __USB_REGS_H
|
|
||||||
#define __USB_REGS_H
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#ifdef STM32F30X
|
|
||||||
#include "stm32f30x.h"
|
|
||||||
#else
|
|
||||||
#include "stm32f10x.h"
|
|
||||||
#endif
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
typedef enum _EP_DBUF_DIR
|
|
||||||
{
|
|
||||||
/* double buffered endpoint direction */
|
|
||||||
EP_DBUF_ERR,
|
|
||||||
EP_DBUF_OUT,
|
|
||||||
EP_DBUF_IN
|
|
||||||
}EP_DBUF_DIR;
|
|
||||||
|
|
||||||
/* endpoint buffer number */
|
|
||||||
enum EP_BUF_NUM
|
|
||||||
{
|
|
||||||
EP_NOBUF,
|
|
||||||
EP_BUF0,
|
|
||||||
EP_BUF1
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
#define RegBase (0x40005C00L) /* USB_IP Peripheral Registers base address */
|
|
||||||
#define PMAAddr (0x40006000L) /* USB_IP Packet Memory Area base address */
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* General registers */
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/* Control register */
|
|
||||||
#define CNTR ((__IO unsigned *)(RegBase + 0x40))
|
|
||||||
/* Interrupt status register */
|
|
||||||
#define ISTR ((__IO unsigned *)(RegBase + 0x44))
|
|
||||||
/* Frame number register */
|
|
||||||
#define FNR ((__IO unsigned *)(RegBase + 0x48))
|
|
||||||
/* Device address register */
|
|
||||||
#define DADDR ((__IO unsigned *)(RegBase + 0x4C))
|
|
||||||
/* Buffer Table address register */
|
|
||||||
#define BTABLE ((__IO unsigned *)(RegBase + 0x50))
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Endpoint registers */
|
|
||||||
/******************************************************************************/
|
|
||||||
#define EP0REG ((__IO unsigned *)(RegBase)) /* endpoint 0 register address */
|
|
||||||
|
|
||||||
/* Endpoint Addresses (w/direction) */
|
|
||||||
#define EP0_OUT ((uint8_t)0x00)
|
|
||||||
#define EP0_IN ((uint8_t)0x80)
|
|
||||||
#define EP1_OUT ((uint8_t)0x01)
|
|
||||||
#define EP1_IN ((uint8_t)0x81)
|
|
||||||
#define EP2_OUT ((uint8_t)0x02)
|
|
||||||
#define EP2_IN ((uint8_t)0x82)
|
|
||||||
#define EP3_OUT ((uint8_t)0x03)
|
|
||||||
#define EP3_IN ((uint8_t)0x83)
|
|
||||||
#define EP4_OUT ((uint8_t)0x04)
|
|
||||||
#define EP4_IN ((uint8_t)0x84)
|
|
||||||
#define EP5_OUT ((uint8_t)0x05)
|
|
||||||
#define EP5_IN ((uint8_t)0x85)
|
|
||||||
#define EP6_OUT ((uint8_t)0x06)
|
|
||||||
#define EP6_IN ((uint8_t)0x86)
|
|
||||||
#define EP7_OUT ((uint8_t)0x07)
|
|
||||||
#define EP7_IN ((uint8_t)0x87)
|
|
||||||
|
|
||||||
/* endpoints enumeration */
|
|
||||||
#define ENDP0 ((uint8_t)0)
|
|
||||||
#define ENDP1 ((uint8_t)1)
|
|
||||||
#define ENDP2 ((uint8_t)2)
|
|
||||||
#define ENDP3 ((uint8_t)3)
|
|
||||||
#define ENDP4 ((uint8_t)4)
|
|
||||||
#define ENDP5 ((uint8_t)5)
|
|
||||||
#define ENDP6 ((uint8_t)6)
|
|
||||||
#define ENDP7 ((uint8_t)7)
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* ISTR interrupt events */
|
|
||||||
/******************************************************************************/
|
|
||||||
#define ISTR_CTR (0x8000) /* Correct TRansfer (clear-only bit) */
|
|
||||||
#define ISTR_DOVR (0x4000) /* DMA OVeR/underrun (clear-only bit) */
|
|
||||||
#define ISTR_ERR (0x2000) /* ERRor (clear-only bit) */
|
|
||||||
#define ISTR_WKUP (0x1000) /* WaKe UP (clear-only bit) */
|
|
||||||
#define ISTR_SUSP (0x0800) /* SUSPend (clear-only bit) */
|
|
||||||
#define ISTR_RESET (0x0400) /* RESET (clear-only bit) */
|
|
||||||
#define ISTR_SOF (0x0200) /* Start Of Frame (clear-only bit) */
|
|
||||||
#define ISTR_ESOF (0x0100) /* Expected Start Of Frame (clear-only bit) */
|
|
||||||
|
|
||||||
|
|
||||||
#define ISTR_DIR (0x0010) /* DIRection of transaction (read-only bit) */
|
|
||||||
#define ISTR_EP_ID (0x000F) /* EndPoint IDentifier (read-only bit) */
|
|
||||||
|
|
||||||
#define CLR_CTR (~ISTR_CTR) /* clear Correct TRansfer bit */
|
|
||||||
#define CLR_DOVR (~ISTR_DOVR) /* clear DMA OVeR/underrun bit*/
|
|
||||||
#define CLR_ERR (~ISTR_ERR) /* clear ERRor bit */
|
|
||||||
#define CLR_WKUP (~ISTR_WKUP) /* clear WaKe UP bit */
|
|
||||||
#define CLR_SUSP (~ISTR_SUSP) /* clear SUSPend bit */
|
|
||||||
#define CLR_RESET (~ISTR_RESET) /* clear RESET bit */
|
|
||||||
#define CLR_SOF (~ISTR_SOF) /* clear Start Of Frame bit */
|
|
||||||
#define CLR_ESOF (~ISTR_ESOF) /* clear Expected Start Of Frame bit */
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* CNTR control register bits definitions */
|
|
||||||
/******************************************************************************/
|
|
||||||
#define CNTR_CTRM (0x8000) /* Correct TRansfer Mask */
|
|
||||||
#define CNTR_DOVRM (0x4000) /* DMA OVeR/underrun Mask */
|
|
||||||
#define CNTR_ERRM (0x2000) /* ERRor Mask */
|
|
||||||
#define CNTR_WKUPM (0x1000) /* WaKe UP Mask */
|
|
||||||
#define CNTR_SUSPM (0x0800) /* SUSPend Mask */
|
|
||||||
#define CNTR_RESETM (0x0400) /* RESET Mask */
|
|
||||||
#define CNTR_SOFM (0x0200) /* Start Of Frame Mask */
|
|
||||||
#define CNTR_ESOFM (0x0100) /* Expected Start Of Frame Mask */
|
|
||||||
|
|
||||||
|
|
||||||
#define CNTR_RESUME (0x0010) /* RESUME request */
|
|
||||||
#define CNTR_FSUSP (0x0008) /* Force SUSPend */
|
|
||||||
#define CNTR_LPMODE (0x0004) /* Low-power MODE */
|
|
||||||
#define CNTR_PDWN (0x0002) /* Power DoWN */
|
|
||||||
#define CNTR_FRES (0x0001) /* Force USB RESet */
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* FNR Frame Number Register bit definitions */
|
|
||||||
/******************************************************************************/
|
|
||||||
#define FNR_RXDP (0x8000) /* status of D+ data line */
|
|
||||||
#define FNR_RXDM (0x4000) /* status of D- data line */
|
|
||||||
#define FNR_LCK (0x2000) /* LoCKed */
|
|
||||||
#define FNR_LSOF (0x1800) /* Lost SOF */
|
|
||||||
#define FNR_FN (0x07FF) /* Frame Number */
|
|
||||||
/******************************************************************************/
|
|
||||||
/* DADDR Device ADDRess bit definitions */
|
|
||||||
/******************************************************************************/
|
|
||||||
#define DADDR_EF (0x80)
|
|
||||||
#define DADDR_ADD (0x7F)
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Endpoint register */
|
|
||||||
/******************************************************************************/
|
|
||||||
/* bit positions */
|
|
||||||
#define EP_CTR_RX (0x8000) /* EndPoint Correct TRansfer RX */
|
|
||||||
#define EP_DTOG_RX (0x4000) /* EndPoint Data TOGGLE RX */
|
|
||||||
#define EPRX_STAT (0x3000) /* EndPoint RX STATus bit field */
|
|
||||||
#define EP_SETUP (0x0800) /* EndPoint SETUP */
|
|
||||||
#define EP_T_FIELD (0x0600) /* EndPoint TYPE */
|
|
||||||
#define EP_KIND (0x0100) /* EndPoint KIND */
|
|
||||||
#define EP_CTR_TX (0x0080) /* EndPoint Correct TRansfer TX */
|
|
||||||
#define EP_DTOG_TX (0x0040) /* EndPoint Data TOGGLE TX */
|
|
||||||
#define EPTX_STAT (0x0030) /* EndPoint TX STATus bit field */
|
|
||||||
#define EPADDR_FIELD (0x000F) /* EndPoint ADDRess FIELD */
|
|
||||||
|
|
||||||
/* EndPoint REGister MASK (no toggle fields) */
|
|
||||||
#define EPREG_MASK (EP_CTR_RX|EP_SETUP|EP_T_FIELD|EP_KIND|EP_CTR_TX|EPADDR_FIELD)
|
|
||||||
|
|
||||||
/* EP_TYPE[1:0] EndPoint TYPE */
|
|
||||||
#define EP_TYPE_MASK (0x0600) /* EndPoint TYPE Mask */
|
|
||||||
#define EP_BULK (0x0000) /* EndPoint BULK */
|
|
||||||
#define EP_CONTROL (0x0200) /* EndPoint CONTROL */
|
|
||||||
#define EP_ISOCHRONOUS (0x0400) /* EndPoint ISOCHRONOUS */
|
|
||||||
#define EP_INTERRUPT (0x0600) /* EndPoint INTERRUPT */
|
|
||||||
#define EP_T_MASK (~EP_T_FIELD & EPREG_MASK)
|
|
||||||
|
|
||||||
|
|
||||||
/* EP_KIND EndPoint KIND */
|
|
||||||
#define EPKIND_MASK (~EP_KIND & EPREG_MASK)
|
|
||||||
|
|
||||||
/* STAT_TX[1:0] STATus for TX transfer */
|
|
||||||
#define EP_TX_DIS (0x0000) /* EndPoint TX DISabled */
|
|
||||||
#define EP_TX_STALL (0x0010) /* EndPoint TX STALLed */
|
|
||||||
#define EP_TX_NAK (0x0020) /* EndPoint TX NAKed */
|
|
||||||
#define EP_TX_VALID (0x0030) /* EndPoint TX VALID */
|
|
||||||
#define EPTX_DTOG1 (0x0010) /* EndPoint TX Data TOGgle bit1 */
|
|
||||||
#define EPTX_DTOG2 (0x0020) /* EndPoint TX Data TOGgle bit2 */
|
|
||||||
#define EPTX_DTOGMASK (EPTX_STAT|EPREG_MASK)
|
|
||||||
|
|
||||||
/* STAT_RX[1:0] STATus for RX transfer */
|
|
||||||
#define EP_RX_DIS (0x0000) /* EndPoint RX DISabled */
|
|
||||||
#define EP_RX_STALL (0x1000) /* EndPoint RX STALLed */
|
|
||||||
#define EP_RX_NAK (0x2000) /* EndPoint RX NAKed */
|
|
||||||
#define EP_RX_VALID (0x3000) /* EndPoint RX VALID */
|
|
||||||
#define EPRX_DTOG1 (0x1000) /* EndPoint RX Data TOGgle bit1 */
|
|
||||||
#define EPRX_DTOG2 (0x2000) /* EndPoint RX Data TOGgle bit1 */
|
|
||||||
#define EPRX_DTOGMASK (EPRX_STAT|EPREG_MASK)
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/* SetCNTR */
|
|
||||||
#define _SetCNTR(wRegValue) (*CNTR = (uint16_t)wRegValue)
|
|
||||||
|
|
||||||
/* SetISTR */
|
|
||||||
#define _SetISTR(wRegValue) (*ISTR = (uint16_t)wRegValue)
|
|
||||||
|
|
||||||
/* SetDADDR */
|
|
||||||
#define _SetDADDR(wRegValue) (*DADDR = (uint16_t)wRegValue)
|
|
||||||
|
|
||||||
/* SetBTABLE */
|
|
||||||
#define _SetBTABLE(wRegValue)(*BTABLE = (uint16_t)(wRegValue & 0xFFF8))
|
|
||||||
|
|
||||||
/* GetCNTR */
|
|
||||||
#define _GetCNTR() ((uint16_t) *CNTR)
|
|
||||||
|
|
||||||
/* GetISTR */
|
|
||||||
#define _GetISTR() ((uint16_t) *ISTR)
|
|
||||||
|
|
||||||
/* GetFNR */
|
|
||||||
#define _GetFNR() ((uint16_t) *FNR)
|
|
||||||
|
|
||||||
/* GetDADDR */
|
|
||||||
#define _GetDADDR() ((uint16_t) *DADDR)
|
|
||||||
|
|
||||||
/* GetBTABLE */
|
|
||||||
#define _GetBTABLE() ((uint16_t) *BTABLE)
|
|
||||||
|
|
||||||
/* SetENDPOINT */
|
|
||||||
#define _SetENDPOINT(bEpNum,wRegValue) (*(EP0REG + bEpNum)= \
|
|
||||||
(uint16_t)wRegValue)
|
|
||||||
|
|
||||||
/* GetENDPOINT */
|
|
||||||
#define _GetENDPOINT(bEpNum) ((uint16_t)(*(EP0REG + bEpNum)))
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPType
|
|
||||||
* Description : sets the type in the endpoint register(bits EP_TYPE[1:0])
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wType
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPType(bEpNum,wType) (_SetENDPOINT(bEpNum,\
|
|
||||||
((_GetENDPOINT(bEpNum) & EP_T_MASK) | wType )))
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : GetEPType
|
|
||||||
* Description : gets the type in the endpoint register(bits EP_TYPE[1:0])
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Endpoint Type
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _GetEPType(bEpNum) (_GetENDPOINT(bEpNum) & EP_T_FIELD)
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPTxStatus
|
|
||||||
* Description : sets the status for tx transfer (bits STAT_TX[1:0]).
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wState: new state
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPTxStatus(bEpNum,wState) {\
|
|
||||||
register uint16_t _wRegVal; \
|
|
||||||
_wRegVal = _GetENDPOINT(bEpNum) & EPTX_DTOGMASK;\
|
|
||||||
/* toggle first bit ? */ \
|
|
||||||
if((EPTX_DTOG1 & wState)!= 0) \
|
|
||||||
_wRegVal ^= EPTX_DTOG1; \
|
|
||||||
/* toggle second bit ? */ \
|
|
||||||
if((EPTX_DTOG2 & wState)!= 0) \
|
|
||||||
_wRegVal ^= EPTX_DTOG2; \
|
|
||||||
_SetENDPOINT(bEpNum, (_wRegVal | EP_CTR_RX|EP_CTR_TX)); \
|
|
||||||
} /* _SetEPTxStatus */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPRxStatus
|
|
||||||
* Description : sets the status for rx transfer (bits STAT_TX[1:0])
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wState: new state.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPRxStatus(bEpNum,wState) {\
|
|
||||||
register uint16_t _wRegVal; \
|
|
||||||
\
|
|
||||||
_wRegVal = _GetENDPOINT(bEpNum) & EPRX_DTOGMASK;\
|
|
||||||
/* toggle first bit ? */ \
|
|
||||||
if((EPRX_DTOG1 & wState)!= 0) \
|
|
||||||
_wRegVal ^= EPRX_DTOG1; \
|
|
||||||
/* toggle second bit ? */ \
|
|
||||||
if((EPRX_DTOG2 & wState)!= 0) \
|
|
||||||
_wRegVal ^= EPRX_DTOG2; \
|
|
||||||
_SetENDPOINT(bEpNum, (_wRegVal | EP_CTR_RX|EP_CTR_TX)); \
|
|
||||||
} /* _SetEPRxStatus */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPRxTxStatus
|
|
||||||
* Description : sets the status for rx & tx (bits STAT_TX[1:0] & STAT_RX[1:0])
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wStaterx: new state.
|
|
||||||
* wStatetx: new state.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPRxTxStatus(bEpNum,wStaterx,wStatetx) {\
|
|
||||||
register uint32_t _wRegVal; \
|
|
||||||
\
|
|
||||||
_wRegVal = _GetENDPOINT(bEpNum) & (EPRX_DTOGMASK |EPTX_STAT) ;\
|
|
||||||
/* toggle first bit ? */ \
|
|
||||||
if((EPRX_DTOG1 & wStaterx)!= 0) \
|
|
||||||
_wRegVal ^= EPRX_DTOG1; \
|
|
||||||
/* toggle second bit ? */ \
|
|
||||||
if((EPRX_DTOG2 & wStaterx)!= 0) \
|
|
||||||
_wRegVal ^= EPRX_DTOG2; \
|
|
||||||
/* toggle first bit ? */ \
|
|
||||||
if((EPTX_DTOG1 & wStatetx)!= 0) \
|
|
||||||
_wRegVal ^= EPTX_DTOG1; \
|
|
||||||
/* toggle second bit ? */ \
|
|
||||||
if((EPTX_DTOG2 & wStatetx)!= 0) \
|
|
||||||
_wRegVal ^= EPTX_DTOG2; \
|
|
||||||
_SetENDPOINT(bEpNum, _wRegVal | EP_CTR_RX|EP_CTR_TX); \
|
|
||||||
} /* _SetEPRxTxStatus */
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : GetEPTxStatus / GetEPRxStatus
|
|
||||||
* Description : gets the status for tx/rx transfer (bits STAT_TX[1:0]
|
|
||||||
* /STAT_RX[1:0])
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : status .
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _GetEPTxStatus(bEpNum) ((uint16_t)_GetENDPOINT(bEpNum) & EPTX_STAT)
|
|
||||||
|
|
||||||
#define _GetEPRxStatus(bEpNum) ((uint16_t)_GetENDPOINT(bEpNum) & EPRX_STAT)
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPTxValid / SetEPRxValid
|
|
||||||
* Description : sets directly the VALID tx/rx-status into the enpoint register
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPTxValid(bEpNum) (_SetEPTxStatus(bEpNum, EP_TX_VALID))
|
|
||||||
|
|
||||||
#define _SetEPRxValid(bEpNum) (_SetEPRxStatus(bEpNum, EP_RX_VALID))
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : GetTxStallStatus / GetRxStallStatus.
|
|
||||||
* Description : checks stall condition in an endpoint.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : TRUE = endpoint in stall condition.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _GetTxStallStatus(bEpNum) (_GetEPTxStatus(bEpNum) \
|
|
||||||
== EP_TX_STALL)
|
|
||||||
#define _GetRxStallStatus(bEpNum) (_GetEPRxStatus(bEpNum) \
|
|
||||||
== EP_RX_STALL)
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEP_KIND / ClearEP_KIND.
|
|
||||||
* Description : set & clear EP_KIND bit.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEP_KIND(bEpNum) (_SetENDPOINT(bEpNum, \
|
|
||||||
(EP_CTR_RX|EP_CTR_TX|((_GetENDPOINT(bEpNum) | EP_KIND) & EPREG_MASK))))
|
|
||||||
#define _ClearEP_KIND(bEpNum) (_SetENDPOINT(bEpNum, \
|
|
||||||
(EP_CTR_RX|EP_CTR_TX|(_GetENDPOINT(bEpNum) & EPKIND_MASK))))
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : Set_Status_Out / Clear_Status_Out.
|
|
||||||
* Description : Sets/clears directly STATUS_OUT bit in the endpoint register.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _Set_Status_Out(bEpNum) _SetEP_KIND(bEpNum)
|
|
||||||
#define _Clear_Status_Out(bEpNum) _ClearEP_KIND(bEpNum)
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPDoubleBuff / ClearEPDoubleBuff.
|
|
||||||
* Description : Sets/clears directly EP_KIND bit in the endpoint register.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPDoubleBuff(bEpNum) _SetEP_KIND(bEpNum)
|
|
||||||
#define _ClearEPDoubleBuff(bEpNum) _ClearEP_KIND(bEpNum)
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : ClearEP_CTR_RX / ClearEP_CTR_TX.
|
|
||||||
* Description : Clears bit CTR_RX / CTR_TX in the endpoint register.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _ClearEP_CTR_RX(bEpNum) (_SetENDPOINT(bEpNum,\
|
|
||||||
_GetENDPOINT(bEpNum) & 0x7FFF & EPREG_MASK))
|
|
||||||
#define _ClearEP_CTR_TX(bEpNum) (_SetENDPOINT(bEpNum,\
|
|
||||||
_GetENDPOINT(bEpNum) & 0xFF7F & EPREG_MASK))
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : ToggleDTOG_RX / ToggleDTOG_TX .
|
|
||||||
* Description : Toggles DTOG_RX / DTOG_TX bit in the endpoint register.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _ToggleDTOG_RX(bEpNum) (_SetENDPOINT(bEpNum, \
|
|
||||||
EP_CTR_RX|EP_CTR_TX|EP_DTOG_RX | (_GetENDPOINT(bEpNum) & EPREG_MASK)))
|
|
||||||
#define _ToggleDTOG_TX(bEpNum) (_SetENDPOINT(bEpNum, \
|
|
||||||
EP_CTR_RX|EP_CTR_TX|EP_DTOG_TX | (_GetENDPOINT(bEpNum) & EPREG_MASK)))
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : ClearDTOG_RX / ClearDTOG_TX.
|
|
||||||
* Description : Clears DTOG_RX / DTOG_TX bit in the endpoint register.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _ClearDTOG_RX(bEpNum) if((_GetENDPOINT(bEpNum) & EP_DTOG_RX) != 0)\
|
|
||||||
_ToggleDTOG_RX(bEpNum)
|
|
||||||
#define _ClearDTOG_TX(bEpNum) if((_GetENDPOINT(bEpNum) & EP_DTOG_TX) != 0)\
|
|
||||||
_ToggleDTOG_TX(bEpNum)
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPAddress.
|
|
||||||
* Description : Sets address in an endpoint register.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* bAddr: Address.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPAddress(bEpNum,bAddr) _SetENDPOINT(bEpNum,\
|
|
||||||
EP_CTR_RX|EP_CTR_TX|(_GetENDPOINT(bEpNum) & EPREG_MASK) | bAddr)
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : GetEPAddress.
|
|
||||||
* Description : Gets address in an endpoint register.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _GetEPAddress(bEpNum) ((uint8_t)(_GetENDPOINT(bEpNum) & EPADDR_FIELD))
|
|
||||||
|
|
||||||
#define _pEPTxAddr(bEpNum) ((uint32_t *)((_GetBTABLE()+bEpNum*8 )*2 + PMAAddr))
|
|
||||||
#define _pEPTxCount(bEpNum) ((uint32_t *)((_GetBTABLE()+bEpNum*8+2)*2 + PMAAddr))
|
|
||||||
#define _pEPRxAddr(bEpNum) ((uint32_t *)((_GetBTABLE()+bEpNum*8+4)*2 + PMAAddr))
|
|
||||||
#define _pEPRxCount(bEpNum) ((uint32_t *)((_GetBTABLE()+bEpNum*8+6)*2 + PMAAddr))
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPTxAddr / SetEPRxAddr.
|
|
||||||
* Description : sets address of the tx/rx buffer.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wAddr: address to be set (must be word aligned).
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPTxAddr(bEpNum,wAddr) (*_pEPTxAddr(bEpNum) = ((wAddr >> 1) << 1))
|
|
||||||
#define _SetEPRxAddr(bEpNum,wAddr) (*_pEPRxAddr(bEpNum) = ((wAddr >> 1) << 1))
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : GetEPTxAddr / GetEPRxAddr.
|
|
||||||
* Description : Gets address of the tx/rx buffer.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : address of the buffer.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _GetEPTxAddr(bEpNum) ((uint16_t)*_pEPTxAddr(bEpNum))
|
|
||||||
#define _GetEPRxAddr(bEpNum) ((uint16_t)*_pEPRxAddr(bEpNum))
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPCountRxReg.
|
|
||||||
* Description : Sets counter of rx buffer with no. of blocks.
|
|
||||||
* Input : pdwReg: pointer to counter.
|
|
||||||
* wCount: Counter.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _BlocksOf32(dwReg,wCount,wNBlocks) {\
|
|
||||||
wNBlocks = wCount >> 5;\
|
|
||||||
if((wCount & 0x1f) == 0)\
|
|
||||||
wNBlocks--;\
|
|
||||||
*pdwReg = (uint32_t)((wNBlocks << 10) | 0x8000);\
|
|
||||||
}/* _BlocksOf32 */
|
|
||||||
|
|
||||||
#define _BlocksOf2(dwReg,wCount,wNBlocks) {\
|
|
||||||
wNBlocks = wCount >> 1;\
|
|
||||||
if((wCount & 0x1) != 0)\
|
|
||||||
wNBlocks++;\
|
|
||||||
*pdwReg = (uint32_t)(wNBlocks << 10);\
|
|
||||||
}/* _BlocksOf2 */
|
|
||||||
|
|
||||||
#define _SetEPCountRxReg(dwReg,wCount) {\
|
|
||||||
uint16_t wNBlocks;\
|
|
||||||
if(wCount > 62){_BlocksOf32(dwReg,wCount,wNBlocks);}\
|
|
||||||
else {_BlocksOf2(dwReg,wCount,wNBlocks);}\
|
|
||||||
}/* _SetEPCountRxReg */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define _SetEPRxDblBuf0Count(bEpNum,wCount) {\
|
|
||||||
uint32_t *pdwReg = _pEPTxCount(bEpNum); \
|
|
||||||
_SetEPCountRxReg(pdwReg, wCount);\
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPTxCount / SetEPRxCount.
|
|
||||||
* Description : sets counter for the tx/rx buffer.
|
|
||||||
* Input : bEpNum: endpoint number.
|
|
||||||
* wCount: Counter value.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPTxCount(bEpNum,wCount) (*_pEPTxCount(bEpNum) = wCount)
|
|
||||||
#define _SetEPRxCount(bEpNum,wCount) {\
|
|
||||||
uint32_t *pdwReg = _pEPRxCount(bEpNum); \
|
|
||||||
_SetEPCountRxReg(pdwReg, wCount);\
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : GetEPTxCount / GetEPRxCount.
|
|
||||||
* Description : gets counter of the tx buffer.
|
|
||||||
* Input : bEpNum: endpoint number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Counter value.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _GetEPTxCount(bEpNum)((uint16_t)(*_pEPTxCount(bEpNum)) & 0x3ff)
|
|
||||||
#define _GetEPRxCount(bEpNum)((uint16_t)(*_pEPRxCount(bEpNum)) & 0x3ff)
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPDblBuf0Addr / SetEPDblBuf1Addr.
|
|
||||||
* Description : Sets buffer 0/1 address in a double buffer endpoint.
|
|
||||||
* Input : bEpNum: endpoint number.
|
|
||||||
* : wBuf0Addr: buffer 0 address.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPDblBuf0Addr(bEpNum,wBuf0Addr) {_SetEPTxAddr(bEpNum, wBuf0Addr);}
|
|
||||||
#define _SetEPDblBuf1Addr(bEpNum,wBuf1Addr) {_SetEPRxAddr(bEpNum, wBuf1Addr);}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPDblBuffAddr.
|
|
||||||
* Description : Sets addresses in a double buffer endpoint.
|
|
||||||
* Input : bEpNum: endpoint number.
|
|
||||||
* : wBuf0Addr: buffer 0 address.
|
|
||||||
* : wBuf1Addr = buffer 1 address.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPDblBuffAddr(bEpNum,wBuf0Addr,wBuf1Addr) { \
|
|
||||||
_SetEPDblBuf0Addr(bEpNum, wBuf0Addr);\
|
|
||||||
_SetEPDblBuf1Addr(bEpNum, wBuf1Addr);\
|
|
||||||
} /* _SetEPDblBuffAddr */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : GetEPDblBuf0Addr / GetEPDblBuf1Addr.
|
|
||||||
* Description : Gets buffer 0/1 address of a double buffer endpoint.
|
|
||||||
* Input : bEpNum: endpoint number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _GetEPDblBuf0Addr(bEpNum) (_GetEPTxAddr(bEpNum))
|
|
||||||
#define _GetEPDblBuf1Addr(bEpNum) (_GetEPRxAddr(bEpNum))
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : SetEPDblBuffCount / SetEPDblBuf0Count / SetEPDblBuf1Count.
|
|
||||||
* Description : Gets buffer 0/1 address of a double buffer endpoint.
|
|
||||||
* Input : bEpNum: endpoint number.
|
|
||||||
* : bDir: endpoint dir EP_DBUF_OUT = OUT
|
|
||||||
* EP_DBUF_IN = IN
|
|
||||||
* : wCount: Counter value
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _SetEPDblBuf0Count(bEpNum, bDir, wCount) { \
|
|
||||||
if(bDir == EP_DBUF_OUT)\
|
|
||||||
/* OUT endpoint */ \
|
|
||||||
{_SetEPRxDblBuf0Count(bEpNum,wCount);} \
|
|
||||||
else if(bDir == EP_DBUF_IN)\
|
|
||||||
/* IN endpoint */ \
|
|
||||||
*_pEPTxCount(bEpNum) = (uint32_t)wCount; \
|
|
||||||
} /* SetEPDblBuf0Count*/
|
|
||||||
|
|
||||||
#define _SetEPDblBuf1Count(bEpNum, bDir, wCount) { \
|
|
||||||
if(bDir == EP_DBUF_OUT)\
|
|
||||||
/* OUT endpoint */ \
|
|
||||||
{_SetEPRxCount(bEpNum,wCount);}\
|
|
||||||
else if(bDir == EP_DBUF_IN)\
|
|
||||||
/* IN endpoint */\
|
|
||||||
*_pEPRxCount(bEpNum) = (uint32_t)wCount; \
|
|
||||||
} /* SetEPDblBuf1Count */
|
|
||||||
|
|
||||||
#define _SetEPDblBuffCount(bEpNum, bDir, wCount) {\
|
|
||||||
_SetEPDblBuf0Count(bEpNum, bDir, wCount); \
|
|
||||||
_SetEPDblBuf1Count(bEpNum, bDir, wCount); \
|
|
||||||
} /* _SetEPDblBuffCount */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : GetEPDblBuf0Count / GetEPDblBuf1Count.
|
|
||||||
* Description : Gets buffer 0/1 rx/tx counter for double buffering.
|
|
||||||
* Input : bEpNum: endpoint number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
#define _GetEPDblBuf0Count(bEpNum) (_GetEPTxCount(bEpNum))
|
|
||||||
#define _GetEPDblBuf1Count(bEpNum) (_GetEPRxCount(bEpNum))
|
|
||||||
|
|
||||||
|
|
||||||
/* External variables --------------------------------------------------------*/
|
|
||||||
extern volatile uint16_t wIstr; /* ISTR register last read value */
|
|
||||||
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
void SetCNTR(uint16_t /*wRegValue*/);
|
|
||||||
void SetISTR(uint16_t /*wRegValue*/);
|
|
||||||
void SetDADDR(uint16_t /*wRegValue*/);
|
|
||||||
void SetBTABLE(uint16_t /*wRegValue*/);
|
|
||||||
void SetBTABLE(uint16_t /*wRegValue*/);
|
|
||||||
uint16_t GetCNTR(void);
|
|
||||||
uint16_t GetISTR(void);
|
|
||||||
uint16_t GetFNR(void);
|
|
||||||
uint16_t GetDADDR(void);
|
|
||||||
uint16_t GetBTABLE(void);
|
|
||||||
void SetENDPOINT(uint8_t /*bEpNum*/, uint16_t /*wRegValue*/);
|
|
||||||
uint16_t GetENDPOINT(uint8_t /*bEpNum*/);
|
|
||||||
void SetEPType(uint8_t /*bEpNum*/, uint16_t /*wType*/);
|
|
||||||
uint16_t GetEPType(uint8_t /*bEpNum*/);
|
|
||||||
void SetEPTxStatus(uint8_t /*bEpNum*/, uint16_t /*wState*/);
|
|
||||||
void SetEPRxStatus(uint8_t /*bEpNum*/, uint16_t /*wState*/);
|
|
||||||
void SetDouBleBuffEPStall(uint8_t /*bEpNum*/, uint8_t bDir);
|
|
||||||
uint16_t GetEPTxStatus(uint8_t /*bEpNum*/);
|
|
||||||
uint16_t GetEPRxStatus(uint8_t /*bEpNum*/);
|
|
||||||
void SetEPTxValid(uint8_t /*bEpNum*/);
|
|
||||||
void SetEPRxValid(uint8_t /*bEpNum*/);
|
|
||||||
uint16_t GetTxStallStatus(uint8_t /*bEpNum*/);
|
|
||||||
uint16_t GetRxStallStatus(uint8_t /*bEpNum*/);
|
|
||||||
void SetEP_KIND(uint8_t /*bEpNum*/);
|
|
||||||
void ClearEP_KIND(uint8_t /*bEpNum*/);
|
|
||||||
void Set_Status_Out(uint8_t /*bEpNum*/);
|
|
||||||
void Clear_Status_Out(uint8_t /*bEpNum*/);
|
|
||||||
void SetEPDoubleBuff(uint8_t /*bEpNum*/);
|
|
||||||
void ClearEPDoubleBuff(uint8_t /*bEpNum*/);
|
|
||||||
void ClearEP_CTR_RX(uint8_t /*bEpNum*/);
|
|
||||||
void ClearEP_CTR_TX(uint8_t /*bEpNum*/);
|
|
||||||
void ToggleDTOG_RX(uint8_t /*bEpNum*/);
|
|
||||||
void ToggleDTOG_TX(uint8_t /*bEpNum*/);
|
|
||||||
void ClearDTOG_RX(uint8_t /*bEpNum*/);
|
|
||||||
void ClearDTOG_TX(uint8_t /*bEpNum*/);
|
|
||||||
void SetEPAddress(uint8_t /*bEpNum*/, uint8_t /*bAddr*/);
|
|
||||||
uint8_t GetEPAddress(uint8_t /*bEpNum*/);
|
|
||||||
void SetEPTxAddr(uint8_t /*bEpNum*/, uint16_t /*wAddr*/);
|
|
||||||
void SetEPRxAddr(uint8_t /*bEpNum*/, uint16_t /*wAddr*/);
|
|
||||||
uint16_t GetEPTxAddr(uint8_t /*bEpNum*/);
|
|
||||||
uint16_t GetEPRxAddr(uint8_t /*bEpNum*/);
|
|
||||||
void SetEPCountRxReg(uint32_t * /*pdwReg*/, uint16_t /*wCount*/);
|
|
||||||
void SetEPTxCount(uint8_t /*bEpNum*/, uint16_t /*wCount*/);
|
|
||||||
void SetEPRxCount(uint8_t /*bEpNum*/, uint16_t /*wCount*/);
|
|
||||||
uint16_t GetEPTxCount(uint8_t /*bEpNum*/);
|
|
||||||
uint16_t GetEPRxCount(uint8_t /*bEpNum*/);
|
|
||||||
void SetEPDblBuf0Addr(uint8_t /*bEpNum*/, uint16_t /*wBuf0Addr*/);
|
|
||||||
void SetEPDblBuf1Addr(uint8_t /*bEpNum*/, uint16_t /*wBuf1Addr*/);
|
|
||||||
void SetEPDblBuffAddr(uint8_t /*bEpNum*/, uint16_t /*wBuf0Addr*/, uint16_t /*wBuf1Addr*/);
|
|
||||||
uint16_t GetEPDblBuf0Addr(uint8_t /*bEpNum*/);
|
|
||||||
uint16_t GetEPDblBuf1Addr(uint8_t /*bEpNum*/);
|
|
||||||
void SetEPDblBuffCount(uint8_t /*bEpNum*/, uint8_t /*bDir*/, uint16_t /*wCount*/);
|
|
||||||
void SetEPDblBuf0Count(uint8_t /*bEpNum*/, uint8_t /*bDir*/, uint16_t /*wCount*/);
|
|
||||||
void SetEPDblBuf1Count(uint8_t /*bEpNum*/, uint8_t /*bDir*/, uint16_t /*wCount*/);
|
|
||||||
uint16_t GetEPDblBuf0Count(uint8_t /*bEpNum*/);
|
|
||||||
uint16_t GetEPDblBuf1Count(uint8_t /*bEpNum*/);
|
|
||||||
EP_DBUF_DIR GetEPDblBufDir(uint8_t /*bEpNum*/);
|
|
||||||
void FreeUserBuffer(uint8_t bEpNum/*bEpNum*/, uint8_t bDir);
|
|
||||||
uint16_t ToWord(uint8_t, uint8_t);
|
|
||||||
uint16_t ByteSwap(uint16_t);
|
|
||||||
|
|
||||||
#endif /* __USB_REGS_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_sil.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Simplified Interface Layer function prototypes.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __USB_SIL_H
|
|
||||||
#define __USB_SIL_H
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
|
|
||||||
uint32_t USB_SIL_Init(void);
|
|
||||||
uint32_t USB_SIL_Write(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize);
|
|
||||||
uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer);
|
|
||||||
|
|
||||||
/* External variables --------------------------------------------------------*/
|
|
||||||
|
|
||||||
#endif /* __USB_SIL_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_type.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Type definitions used by the USB Library
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __USB_TYPE_H
|
|
||||||
#define __USB_TYPE_H
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include <usb_conf.h>
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
#ifndef NULL
|
|
||||||
#define NULL ((void *)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
FALSE = 0, TRUE = !FALSE
|
|
||||||
}
|
|
||||||
bool;
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
/* External variables --------------------------------------------------------*/
|
|
||||||
|
|
||||||
#endif /* __USB_TYPE_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,76 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_init.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Initialization routines & global variables
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "usb_lib.h"
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* The number of current endpoint, it will be used to specify an endpoint */
|
|
||||||
uint8_t EPindex;
|
|
||||||
/* The number of current device, it is an index to the Device_Table */
|
|
||||||
/* uint8_t Device_no; */
|
|
||||||
/* Points to the DEVICE_INFO structure of current device */
|
|
||||||
/* The purpose of this register is to speed up the execution */
|
|
||||||
DEVICE_INFO *pInformation;
|
|
||||||
/* Points to the DEVICE_PROP structure of current device */
|
|
||||||
/* The purpose of this register is to speed up the execution */
|
|
||||||
DEVICE_PROP *pProperty;
|
|
||||||
/* Temporary save the state of Rx & Tx status. */
|
|
||||||
/* Whenever the Rx or Tx state is changed, its value is saved */
|
|
||||||
/* in this variable first and will be set to the EPRB or EPRA */
|
|
||||||
/* at the end of interrupt process */
|
|
||||||
uint16_t SaveState ;
|
|
||||||
uint16_t wInterrupt_Mask;
|
|
||||||
DEVICE_INFO Device_Info;
|
|
||||||
USER_STANDARD_REQUESTS *pUser_Standard_Requests;
|
|
||||||
|
|
||||||
/* Extern variables ----------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : USB_Init
|
|
||||||
* Description : USB system initialization
|
|
||||||
* Input : None.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void USB_Init(void)
|
|
||||||
{
|
|
||||||
pInformation = &Device_Info;
|
|
||||||
pInformation->ControlState = 2;
|
|
||||||
pProperty = &Device_Property;
|
|
||||||
pUser_Standard_Requests = &User_Standard_Requests;
|
|
||||||
/* Initialize devices one by one */
|
|
||||||
pProperty->Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_int.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Endpoint CTR (Low and High) interrupt's service routines
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "usb_lib.h"
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
__IO uint16_t SaveRState;
|
|
||||||
__IO uint16_t SaveTState;
|
|
||||||
|
|
||||||
/* Extern variables ----------------------------------------------------------*/
|
|
||||||
extern void (*pEpInt_IN[7])(void); /* Handles IN interrupts */
|
|
||||||
extern void (*pEpInt_OUT[7])(void); /* Handles OUT interrupts */
|
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : CTR_LP.
|
|
||||||
* Description : Low priority Endpoint Correct Transfer interrupt's service
|
|
||||||
* routine.
|
|
||||||
* Input : None.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void CTR_LP(void)
|
|
||||||
{
|
|
||||||
__IO uint16_t wEPVal = 0;
|
|
||||||
/* stay in loop while pending interrupts */
|
|
||||||
while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
|
|
||||||
{
|
|
||||||
/* extract highest priority endpoint number */
|
|
||||||
EPindex = (uint8_t)(wIstr & ISTR_EP_ID);
|
|
||||||
if (EPindex == 0)
|
|
||||||
{
|
|
||||||
/* Decode and service control endpoint interrupt */
|
|
||||||
/* calling related service routine */
|
|
||||||
/* (Setup0_Process, In0_Process, Out0_Process) */
|
|
||||||
|
|
||||||
/* save RX & TX status */
|
|
||||||
/* and set both to NAK */
|
|
||||||
|
|
||||||
SaveRState = _GetENDPOINT(ENDP0);
|
|
||||||
SaveTState = SaveRState & EPTX_STAT;
|
|
||||||
SaveRState &= EPRX_STAT;
|
|
||||||
|
|
||||||
_SetEPRxTxStatus(ENDP0,EP_RX_NAK,EP_TX_NAK);
|
|
||||||
|
|
||||||
/* DIR bit = origin of the interrupt */
|
|
||||||
|
|
||||||
if ((wIstr & ISTR_DIR) == 0)
|
|
||||||
{
|
|
||||||
/* DIR = 0 */
|
|
||||||
|
|
||||||
/* DIR = 0 => IN int */
|
|
||||||
/* DIR = 0 implies that (EP_CTR_TX = 1) always */
|
|
||||||
|
|
||||||
_ClearEP_CTR_TX(ENDP0);
|
|
||||||
In0_Process();
|
|
||||||
|
|
||||||
/* before terminate set Tx & Rx status */
|
|
||||||
|
|
||||||
_SetEPRxTxStatus(ENDP0,SaveRState,SaveTState);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* DIR = 1 */
|
|
||||||
|
|
||||||
/* DIR = 1 & CTR_RX => SETUP or OUT int */
|
|
||||||
/* DIR = 1 & (CTR_TX | CTR_RX) => 2 int pending */
|
|
||||||
|
|
||||||
wEPVal = _GetENDPOINT(ENDP0);
|
|
||||||
|
|
||||||
if ((wEPVal &EP_SETUP) != 0)
|
|
||||||
{
|
|
||||||
_ClearEP_CTR_RX(ENDP0); /* SETUP bit kept frozen while CTR_RX = 1 */
|
|
||||||
Setup0_Process();
|
|
||||||
/* before terminate set Tx & Rx status */
|
|
||||||
|
|
||||||
_SetEPRxTxStatus(ENDP0,SaveRState,SaveTState);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if ((wEPVal & EP_CTR_RX) != 0)
|
|
||||||
{
|
|
||||||
_ClearEP_CTR_RX(ENDP0);
|
|
||||||
Out0_Process();
|
|
||||||
/* before terminate set Tx & Rx status */
|
|
||||||
|
|
||||||
_SetEPRxTxStatus(ENDP0,SaveRState,SaveTState);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}/* if(EPindex == 0) */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Decode and service non control endpoints interrupt */
|
|
||||||
|
|
||||||
/* process related endpoint register */
|
|
||||||
wEPVal = _GetENDPOINT(EPindex);
|
|
||||||
if ((wEPVal & EP_CTR_RX) != 0)
|
|
||||||
{
|
|
||||||
/* clear int flag */
|
|
||||||
_ClearEP_CTR_RX(EPindex);
|
|
||||||
|
|
||||||
/* call OUT service function */
|
|
||||||
(*pEpInt_OUT[EPindex-1])();
|
|
||||||
|
|
||||||
} /* if((wEPVal & EP_CTR_RX) */
|
|
||||||
|
|
||||||
if ((wEPVal & EP_CTR_TX) != 0)
|
|
||||||
{
|
|
||||||
/* clear int flag */
|
|
||||||
_ClearEP_CTR_TX(EPindex);
|
|
||||||
|
|
||||||
/* call IN service function */
|
|
||||||
(*pEpInt_IN[EPindex-1])();
|
|
||||||
} /* if((wEPVal & EP_CTR_TX) != 0) */
|
|
||||||
|
|
||||||
}/* if(EPindex == 0) else */
|
|
||||||
|
|
||||||
}/* while(...) */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : CTR_HP.
|
|
||||||
* Description : High Priority Endpoint Correct Transfer interrupt's service
|
|
||||||
* routine.
|
|
||||||
* Input : None.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void CTR_HP(void)
|
|
||||||
{
|
|
||||||
uint32_t wEPVal = 0;
|
|
||||||
|
|
||||||
while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
|
|
||||||
{
|
|
||||||
_SetISTR((uint16_t)CLR_CTR); /* clear CTR flag */
|
|
||||||
/* extract highest priority endpoint number */
|
|
||||||
EPindex = (uint8_t)(wIstr & ISTR_EP_ID);
|
|
||||||
/* process related endpoint register */
|
|
||||||
wEPVal = _GetENDPOINT(EPindex);
|
|
||||||
if ((wEPVal & EP_CTR_RX) != 0)
|
|
||||||
{
|
|
||||||
/* clear int flag */
|
|
||||||
_ClearEP_CTR_RX(EPindex);
|
|
||||||
|
|
||||||
/* call OUT service function */
|
|
||||||
(*pEpInt_OUT[EPindex-1])();
|
|
||||||
|
|
||||||
} /* if((wEPVal & EP_CTR_RX) */
|
|
||||||
else if ((wEPVal & EP_CTR_TX) != 0)
|
|
||||||
{
|
|
||||||
/* clear int flag */
|
|
||||||
_ClearEP_CTR_TX(EPindex);
|
|
||||||
|
|
||||||
/* call IN service function */
|
|
||||||
(*pEpInt_IN[EPindex-1])();
|
|
||||||
|
|
||||||
|
|
||||||
} /* if((wEPVal & EP_CTR_TX) != 0) */
|
|
||||||
|
|
||||||
}/* while(...) */
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_mem.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Utility functions for memory transfers to/from PMA
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "usb_lib.h"
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Extern variables ----------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : UserToPMABufferCopy
|
|
||||||
* Description : Copy a buffer from user memory area to packet memory area (PMA)
|
|
||||||
* Input : - pbUsrBuf: pointer to user memory area.
|
|
||||||
* - wPMABufAddr: address into PMA.
|
|
||||||
* - wNBytes: no. of bytes to be copied.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None .
|
|
||||||
*******************************************************************************/
|
|
||||||
void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes)
|
|
||||||
{
|
|
||||||
uint32_t n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */
|
|
||||||
uint32_t i, temp1, temp2;
|
|
||||||
uint16_t *pdwVal;
|
|
||||||
pdwVal = (uint16_t *)(wPMABufAddr * 2 + PMAAddr);
|
|
||||||
for (i = n; i != 0; i--)
|
|
||||||
{
|
|
||||||
temp1 = (uint16_t) * pbUsrBuf;
|
|
||||||
pbUsrBuf++;
|
|
||||||
temp2 = temp1 | (uint16_t) * pbUsrBuf << 8;
|
|
||||||
*pdwVal++ = temp2;
|
|
||||||
pdwVal++;
|
|
||||||
pbUsrBuf++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : PMAToUserBufferCopy
|
|
||||||
* Description : Copy a buffer from user memory area to packet memory area (PMA)
|
|
||||||
* Input : - pbUsrBuf = pointer to user memory area.
|
|
||||||
* - wPMABufAddr = address into PMA.
|
|
||||||
* - wNBytes = no. of bytes to be copied.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes)
|
|
||||||
{
|
|
||||||
uint32_t n = (wNBytes + 1) >> 1;/* /2*/
|
|
||||||
uint32_t i;
|
|
||||||
uint32_t *pdwVal;
|
|
||||||
pdwVal = (uint32_t *)(wPMABufAddr * 2 + PMAAddr);
|
|
||||||
for (i = n; i != 0; i--)
|
|
||||||
{
|
|
||||||
*(uint16_t*)pbUsrBuf++ = *pdwVal++;
|
|
||||||
pbUsrBuf++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,760 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_regs.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Interface functions to USB cell registers
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "usb_lib.h"
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Extern variables ----------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetCNTR.
|
|
||||||
* Description : Set the CNTR register value.
|
|
||||||
* Input : wRegValue: new register value.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetCNTR(uint16_t wRegValue)
|
|
||||||
{
|
|
||||||
_SetCNTR(wRegValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetCNTR.
|
|
||||||
* Description : returns the CNTR register value.
|
|
||||||
* Input : None.
|
|
||||||
* Output : None.
|
|
||||||
* Return : CNTR register Value.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetCNTR(void)
|
|
||||||
{
|
|
||||||
return(_GetCNTR());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetISTR.
|
|
||||||
* Description : Set the ISTR register value.
|
|
||||||
* Input : wRegValue: new register value.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetISTR(uint16_t wRegValue)
|
|
||||||
{
|
|
||||||
_SetISTR(wRegValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetISTR
|
|
||||||
* Description : Returns the ISTR register value.
|
|
||||||
* Input : None.
|
|
||||||
* Output : None.
|
|
||||||
* Return : ISTR register Value
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetISTR(void)
|
|
||||||
{
|
|
||||||
return(_GetISTR());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetFNR
|
|
||||||
* Description : Returns the FNR register value.
|
|
||||||
* Input : None.
|
|
||||||
* Output : None.
|
|
||||||
* Return : FNR register Value
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetFNR(void)
|
|
||||||
{
|
|
||||||
return(_GetFNR());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetDADDR
|
|
||||||
* Description : Set the DADDR register value.
|
|
||||||
* Input : wRegValue: new register value.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetDADDR(uint16_t wRegValue)
|
|
||||||
{
|
|
||||||
_SetDADDR(wRegValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetDADDR
|
|
||||||
* Description : Returns the DADDR register value.
|
|
||||||
* Input : None.
|
|
||||||
* Output : None.
|
|
||||||
* Return : DADDR register Value
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetDADDR(void)
|
|
||||||
{
|
|
||||||
return(_GetDADDR());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetBTABLE
|
|
||||||
* Description : Set the BTABLE.
|
|
||||||
* Input : wRegValue: New register value.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetBTABLE(uint16_t wRegValue)
|
|
||||||
{
|
|
||||||
_SetBTABLE(wRegValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetBTABLE.
|
|
||||||
* Description : Returns the BTABLE register value.
|
|
||||||
* Input : None.
|
|
||||||
* Output : None.
|
|
||||||
* Return : BTABLE address.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetBTABLE(void)
|
|
||||||
{
|
|
||||||
return(_GetBTABLE());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetENDPOINT
|
|
||||||
* Description : Set the Endpoint register value.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wRegValue.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetENDPOINT(uint8_t bEpNum, uint16_t wRegValue)
|
|
||||||
{
|
|
||||||
_SetENDPOINT(bEpNum, wRegValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetENDPOINT
|
|
||||||
* Description : Return the Endpoint register value.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Endpoint register value.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetENDPOINT(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetENDPOINT(bEpNum));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPType
|
|
||||||
* Description : sets the type in the endpoint register.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wType: type definition.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPType(uint8_t bEpNum, uint16_t wType)
|
|
||||||
{
|
|
||||||
_SetEPType(bEpNum, wType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPType
|
|
||||||
* Description : Returns the endpoint type.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Endpoint Type
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetEPType(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPType(bEpNum));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPTxStatus
|
|
||||||
* Description : Set the status of Tx endpoint.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wState: new state.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPTxStatus(uint8_t bEpNum, uint16_t wState)
|
|
||||||
{
|
|
||||||
_SetEPTxStatus(bEpNum, wState);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPRxStatus
|
|
||||||
* Description : Set the status of Rx endpoint.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wState: new state.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPRxStatus(uint8_t bEpNum, uint16_t wState)
|
|
||||||
{
|
|
||||||
_SetEPRxStatus(bEpNum, wState);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetDouBleBuffEPStall
|
|
||||||
* Description : sets the status for Double Buffer Endpoint to STALL
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* bDir: Endpoint direction.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetDouBleBuffEPStall(uint8_t bEpNum, uint8_t bDir)
|
|
||||||
{
|
|
||||||
uint16_t Endpoint_DTOG_Status;
|
|
||||||
Endpoint_DTOG_Status = GetENDPOINT(bEpNum);
|
|
||||||
if (bDir == EP_DBUF_OUT)
|
|
||||||
{ /* OUT double buffered endpoint */
|
|
||||||
_SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPRX_DTOG1);
|
|
||||||
}
|
|
||||||
else if (bDir == EP_DBUF_IN)
|
|
||||||
{ /* IN double buffered endpoint */
|
|
||||||
_SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPTX_DTOG1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPTxStatus
|
|
||||||
* Description : Returns the endpoint Tx status.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Endpoint TX Status
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetEPTxStatus(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPTxStatus(bEpNum));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPRxStatus
|
|
||||||
* Description : Returns the endpoint Rx status.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Endpoint RX Status
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetEPRxStatus(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPRxStatus(bEpNum));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPTxValid
|
|
||||||
* Description : Valid the endpoint Tx Status.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPTxValid(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_SetEPTxStatus(bEpNum, EP_TX_VALID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPRxValid
|
|
||||||
* Description : Valid the endpoint Rx Status.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPRxValid(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_SetEPRxStatus(bEpNum, EP_RX_VALID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEP_KIND
|
|
||||||
* Description : Clear the EP_KIND bit.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEP_KIND(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_SetEP_KIND(bEpNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : ClearEP_KIND
|
|
||||||
* Description : set the EP_KIND bit.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void ClearEP_KIND(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_ClearEP_KIND(bEpNum);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : Clear_Status_Out
|
|
||||||
* Description : Clear the Status Out of the related Endpoint
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Clear_Status_Out(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_ClearEP_KIND(bEpNum);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : Set_Status_Out
|
|
||||||
* Description : Set the Status Out of the related Endpoint
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Set_Status_Out(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_SetEP_KIND(bEpNum);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPDoubleBuff
|
|
||||||
* Description : Enable the double buffer feature for the endpoint.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPDoubleBuff(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_SetEP_KIND(bEpNum);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : ClearEPDoubleBuff
|
|
||||||
* Description : Disable the double buffer feature for the endpoint.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void ClearEPDoubleBuff(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_ClearEP_KIND(bEpNum);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetTxStallStatus
|
|
||||||
* Description : Returns the Stall status of the Tx endpoint.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Tx Stall status.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetTxStallStatus(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetTxStallStatus(bEpNum));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetRxStallStatus
|
|
||||||
* Description : Returns the Stall status of the Rx endpoint.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Rx Stall status.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetRxStallStatus(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetRxStallStatus(bEpNum));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : ClearEP_CTR_RX
|
|
||||||
* Description : Clear the CTR_RX bit.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void ClearEP_CTR_RX(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_ClearEP_CTR_RX(bEpNum);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : ClearEP_CTR_TX
|
|
||||||
* Description : Clear the CTR_TX bit.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void ClearEP_CTR_TX(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_ClearEP_CTR_TX(bEpNum);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : ToggleDTOG_RX
|
|
||||||
* Description : Toggle the DTOG_RX bit.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void ToggleDTOG_RX(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_ToggleDTOG_RX(bEpNum);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : ToggleDTOG_TX
|
|
||||||
* Description : Toggle the DTOG_TX bit.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void ToggleDTOG_TX(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_ToggleDTOG_TX(bEpNum);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : ClearDTOG_RX.
|
|
||||||
* Description : Clear the DTOG_RX bit.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void ClearDTOG_RX(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_ClearDTOG_RX(bEpNum);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : ClearDTOG_TX.
|
|
||||||
* Description : Clear the DTOG_TX bit.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void ClearDTOG_TX(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
_ClearDTOG_TX(bEpNum);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPAddress
|
|
||||||
* Description : Set the endpoint address.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* bAddr: New endpoint address.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPAddress(uint8_t bEpNum, uint8_t bAddr)
|
|
||||||
{
|
|
||||||
_SetEPAddress(bEpNum, bAddr);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPAddress
|
|
||||||
* Description : Get the endpoint address.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Endpoint address.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint8_t GetEPAddress(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPAddress(bEpNum));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPTxAddr
|
|
||||||
* Description : Set the endpoint Tx buffer address.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wAddr: new address.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPTxAddr(uint8_t bEpNum, uint16_t wAddr)
|
|
||||||
{
|
|
||||||
_SetEPTxAddr(bEpNum, wAddr);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPRxAddr
|
|
||||||
* Description : Set the endpoint Rx buffer address.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wAddr: new address.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPRxAddr(uint8_t bEpNum, uint16_t wAddr)
|
|
||||||
{
|
|
||||||
_SetEPRxAddr(bEpNum, wAddr);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPTxAddr
|
|
||||||
* Description : Returns the endpoint Tx buffer address.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Rx buffer address.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetEPTxAddr(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPTxAddr(bEpNum));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPRxAddr.
|
|
||||||
* Description : Returns the endpoint Rx buffer address.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Rx buffer address.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetEPRxAddr(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPRxAddr(bEpNum));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPTxCount.
|
|
||||||
* Description : Set the Tx count.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wCount: new count value.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPTxCount(uint8_t bEpNum, uint16_t wCount)
|
|
||||||
{
|
|
||||||
_SetEPTxCount(bEpNum, wCount);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPCountRxReg.
|
|
||||||
* Description : Set the Count Rx Register value.
|
|
||||||
* Input : *pdwReg: point to the register.
|
|
||||||
* wCount: the new register value.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPCountRxReg(uint32_t *pdwReg, uint16_t wCount)
|
|
||||||
{
|
|
||||||
_SetEPCountRxReg(dwReg, wCount);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPRxCount
|
|
||||||
* Description : Set the Rx count.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wCount: the new count value.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPRxCount(uint8_t bEpNum, uint16_t wCount)
|
|
||||||
{
|
|
||||||
_SetEPRxCount(bEpNum, wCount);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPTxCount
|
|
||||||
* Description : Get the Tx count.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None
|
|
||||||
* Return : Tx count value.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetEPTxCount(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPTxCount(bEpNum));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPRxCount
|
|
||||||
* Description : Get the Rx count.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Rx count value.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetEPRxCount(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPRxCount(bEpNum));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPDblBuffAddr
|
|
||||||
* Description : Set the addresses of the buffer 0 and 1.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* wBuf0Addr: new address of buffer 0.
|
|
||||||
* wBuf1Addr: new address of buffer 1.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPDblBuffAddr(uint8_t bEpNum, uint16_t wBuf0Addr, uint16_t wBuf1Addr)
|
|
||||||
{
|
|
||||||
_SetEPDblBuffAddr(bEpNum, wBuf0Addr, wBuf1Addr);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPDblBuf0Addr
|
|
||||||
* Description : Set the Buffer 1 address.
|
|
||||||
* Input : bEpNum: Endpoint Number
|
|
||||||
* wBuf0Addr: new address.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPDblBuf0Addr(uint8_t bEpNum, uint16_t wBuf0Addr)
|
|
||||||
{
|
|
||||||
_SetEPDblBuf0Addr(bEpNum, wBuf0Addr);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPDblBuf1Addr
|
|
||||||
* Description : Set the Buffer 1 address.
|
|
||||||
* Input : bEpNum: Endpoint Number
|
|
||||||
* wBuf1Addr: new address.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPDblBuf1Addr(uint8_t bEpNum, uint16_t wBuf1Addr)
|
|
||||||
{
|
|
||||||
_SetEPDblBuf1Addr(bEpNum, wBuf1Addr);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPDblBuf0Addr
|
|
||||||
* Description : Returns the address of the Buffer 0.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetEPDblBuf0Addr(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPDblBuf0Addr(bEpNum));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPDblBuf1Addr
|
|
||||||
* Description : Returns the address of the Buffer 1.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Address of the Buffer 1.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetEPDblBuf1Addr(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPDblBuf1Addr(bEpNum));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPDblBuffCount
|
|
||||||
* Description : Set the number of bytes for a double Buffer
|
|
||||||
* endpoint.
|
|
||||||
* Input : bEpNum,bDir, wCount
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPDblBuffCount(uint8_t bEpNum, uint8_t bDir, uint16_t wCount)
|
|
||||||
{
|
|
||||||
_SetEPDblBuffCount(bEpNum, bDir, wCount);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPDblBuf0Count
|
|
||||||
* Description : Set the number of bytes in the buffer 0 of a double Buffer
|
|
||||||
* endpoint.
|
|
||||||
* Input : bEpNum, bDir, wCount
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPDblBuf0Count(uint8_t bEpNum, uint8_t bDir, uint16_t wCount)
|
|
||||||
{
|
|
||||||
_SetEPDblBuf0Count(bEpNum, bDir, wCount);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : SetEPDblBuf1Count
|
|
||||||
* Description : Set the number of bytes in the buffer 0 of a double Buffer
|
|
||||||
* endpoint.
|
|
||||||
* Input : bEpNum, bDir, wCount
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SetEPDblBuf1Count(uint8_t bEpNum, uint8_t bDir, uint16_t wCount)
|
|
||||||
{
|
|
||||||
_SetEPDblBuf1Count(bEpNum, bDir, wCount);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPDblBuf0Count
|
|
||||||
* Description : Returns the number of byte received in the buffer 0 of a double
|
|
||||||
* Buffer endpoint.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Endpoint Buffer 0 count
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetEPDblBuf0Count(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPDblBuf0Count(bEpNum));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPDblBuf1Count
|
|
||||||
* Description : Returns the number of data received in the buffer 1 of a double
|
|
||||||
* Buffer endpoint.
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Endpoint Buffer 1 count.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t GetEPDblBuf1Count(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
return(_GetEPDblBuf1Count(bEpNum));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : GetEPDblBufDir
|
|
||||||
* Description : gets direction of the double buffered endpoint
|
|
||||||
* Input : bEpNum: Endpoint Number.
|
|
||||||
* Output : None.
|
|
||||||
* Return : EP_DBUF_OUT, EP_DBUF_IN,
|
|
||||||
* EP_DBUF_ERR if the endpoint counter not yet programmed.
|
|
||||||
*******************************************************************************/
|
|
||||||
EP_DBUF_DIR GetEPDblBufDir(uint8_t bEpNum)
|
|
||||||
{
|
|
||||||
if ((uint16_t)(*_pEPRxCount(bEpNum) & 0xFC00) != 0)
|
|
||||||
return(EP_DBUF_OUT);
|
|
||||||
else if (((uint16_t)(*_pEPTxCount(bEpNum)) & 0x03FF) != 0)
|
|
||||||
return(EP_DBUF_IN);
|
|
||||||
else
|
|
||||||
return(EP_DBUF_ERR);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : FreeUserBuffer
|
|
||||||
* Description : free buffer used from the application realizing it to the line
|
|
||||||
toggles bit SW_BUF in the double buffered endpoint register
|
|
||||||
* Input : bEpNum, bDir
|
|
||||||
* Output : None.
|
|
||||||
* Return : None.
|
|
||||||
*******************************************************************************/
|
|
||||||
void FreeUserBuffer(uint8_t bEpNum, uint8_t bDir)
|
|
||||||
{
|
|
||||||
if (bDir == EP_DBUF_OUT)
|
|
||||||
{ /* OUT double buffered endpoint */
|
|
||||||
_ToggleDTOG_TX(bEpNum);
|
|
||||||
}
|
|
||||||
else if (bDir == EP_DBUF_IN)
|
|
||||||
{ /* IN double buffered endpoint */
|
|
||||||
_ToggleDTOG_RX(bEpNum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : ToWord
|
|
||||||
* Description : merge two byte in a word.
|
|
||||||
* Input : bh: byte high, bl: bytes low.
|
|
||||||
* Output : None.
|
|
||||||
* Return : resulted word.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t ToWord(uint8_t bh, uint8_t bl)
|
|
||||||
{
|
|
||||||
uint16_t wRet;
|
|
||||||
wRet = (uint16_t)bl | ((uint16_t)bh << 8);
|
|
||||||
return(wRet);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : ByteSwap
|
|
||||||
* Description : Swap two byte in a word.
|
|
||||||
* Input : wSwW: word to Swap.
|
|
||||||
* Output : None.
|
|
||||||
* Return : resulted word.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint16_t ByteSwap(uint16_t wSwW)
|
|
||||||
{
|
|
||||||
uint8_t bTemp;
|
|
||||||
uint16_t wRet;
|
|
||||||
bTemp = (uint8_t)(wSwW & 0xff);
|
|
||||||
wRet = (wSwW >> 8) | ((uint16_t)bTemp << 8);
|
|
||||||
return(wRet);
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file usb_sil.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 28-August-2012
|
|
||||||
* @brief Simplified Interface Layer for Global Initialization and Endpoint
|
|
||||||
* Rea/Write operations.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "usb_lib.h"
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Extern variables ----------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : USB_SIL_Init
|
|
||||||
* Description : Initialize the USB Device IP and the Endpoint 0.
|
|
||||||
* Input : None.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Status.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint32_t USB_SIL_Init(void)
|
|
||||||
{
|
|
||||||
/* USB interrupts initialization */
|
|
||||||
/* clear pending interrupts */
|
|
||||||
_SetISTR(0);
|
|
||||||
wInterrupt_Mask = IMR_MSK;
|
|
||||||
/* set interrupts mask */
|
|
||||||
_SetCNTR(wInterrupt_Mask);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : USB_SIL_Write
|
|
||||||
* Description : Write a buffer of data to a selected endpoint.
|
|
||||||
* Input : - bEpAddr: The address of the non control endpoint.
|
|
||||||
* - pBufferPointer: The pointer to the buffer of data to be written
|
|
||||||
* to the endpoint.
|
|
||||||
* - wBufferSize: Number of data to be written (in bytes).
|
|
||||||
* Output : None.
|
|
||||||
* Return : Status.
|
|
||||||
*******************************************************************************/
|
|
||||||
uint32_t USB_SIL_Write(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize)
|
|
||||||
{
|
|
||||||
/* Use the memory interface function to write to the selected endpoint */
|
|
||||||
UserToPMABufferCopy(pBufferPointer, GetEPTxAddr(bEpAddr & 0x7F), wBufferSize);
|
|
||||||
|
|
||||||
/* Update the data length in the control register */
|
|
||||||
SetEPTxCount((bEpAddr & 0x7F), wBufferSize);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Function Name : USB_SIL_Read
|
|
||||||
* Description : Write a buffer of data to a selected endpoint.
|
|
||||||
* Input : - bEpAddr: The address of the non control endpoint.
|
|
||||||
* - pBufferPointer: The pointer to which will be saved the
|
|
||||||
* received data buffer.
|
|
||||||
* Output : None.
|
|
||||||
* Return : Number of received data (in Bytes).
|
|
||||||
*******************************************************************************/
|
|
||||||
uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer)
|
|
||||||
{
|
|
||||||
uint32_t DataLength = 0;
|
|
||||||
|
|
||||||
/* Get the number of received data on the selected Endpoint */
|
|
||||||
DataLength = GetEPRxCount(bEpAddr & 0x7F);
|
|
||||||
|
|
||||||
/* Use the memory interface function to write to the selected endpoint */
|
|
||||||
PMAToUserBufferCopy(pBufferPointer, GetEPRxAddr(bEpAddr & 0x7F), DataLength);
|
|
||||||
|
|
||||||
/* Return the number of received data */
|
|
||||||
return DataLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
|
||||||
File Name : APP_Version.h
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : bure & Celery
|
|
||||||
Data: 2015/08/03
|
|
||||||
History:
|
|
||||||
2015/08/03 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __VERSION_H
|
|
||||||
#define __VERSION_H
|
|
||||||
|
|
||||||
#define M_VER 'V','0'
|
|
||||||
#define S_VER '0','1'
|
|
||||||
#define OEM_TYPE "0"
|
|
||||||
#define APP_BASE 0x0800C000/*Start address of the virtual disk*/
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
#ifdef TYPE_DS201
|
|
||||||
#define PRODUCT_INFO "DS201"
|
|
||||||
#define SCH_VER "1.7B"
|
|
||||||
#else
|
|
||||||
#ifdef TYPE_DS202
|
|
||||||
#include "DS202V1_6.h"
|
|
||||||
#define FLASH_PAGE 0x0800
|
|
||||||
#else
|
|
||||||
#ifdef TYPE_DS203
|
|
||||||
#define PRODUCT_INFO "DS203"
|
|
||||||
#define SCH_VER "2.70"
|
|
||||||
#else
|
|
||||||
#ifdef TYPE_S100
|
|
||||||
#define PRODUCT_INFO "TS100"
|
|
||||||
#include "S100V0_1.h"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
#define DFU_VER {M_VER,'.',S_VER,LCD_M, 0}
|
|
||||||
#endif /* VERSION_H */
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
20
workspace/ts100/inc/Analog.h
Normal file
20
workspace/ts100/inc/Analog.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Analog.h
|
||||||
|
*
|
||||||
|
* Created on: 20 Sep 2016
|
||||||
|
* Author: ralim
|
||||||
|
*
|
||||||
|
* Interface to the ADC's basically
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ANALOG_H_
|
||||||
|
#define ANALOG_H_
|
||||||
|
#include "stm32f10x.h"
|
||||||
|
#include "Bios.h"
|
||||||
|
#include "Interrupt.h"
|
||||||
|
extern volatile uint16_t ADC1ConvertedValue[2];
|
||||||
|
|
||||||
|
uint16_t Get_ADC1Value(uint8_t i);
|
||||||
|
uint16_t readIronTemp(uint16_t calibration_temp, uint8_t read,uint16_t setPointTemp); //read the iron temp in C X10
|
||||||
|
uint16_t readDCVoltage();/*Get the system voltage X10*/
|
||||||
|
#endif /* ANALOG_H_ */
|
||||||
@@ -1,59 +1,44 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
/*
|
||||||
File Name : Bios.h
|
* Setup functions for the basic hardware present in the system
|
||||||
Version : S100 APP Ver 2.11
|
*/
|
||||||
Description:
|
|
||||||
Author : bure & Celery
|
|
||||||
Data: 2015/08/03
|
|
||||||
History:
|
|
||||||
2015/08/03 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __BIOS_H
|
#ifndef __BIOS_H
|
||||||
#define __BIOS_H
|
#define __BIOS_H
|
||||||
|
|
||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
#include "S100V0_1.h"
|
#include "S100V0_1.h"/*For pin definitions*/
|
||||||
extern volatile u32 gTime[];
|
#include "Analog.h"/*So that we can attach the DMA to the output array*/
|
||||||
|
#include "stm32f10x_flash.h"
|
||||||
#define USB_DN_OUT() GPIOA->CRH = (GPIOA->CRH & 0xFFFF3FFF) | 0x00003000
|
#include "stm32f10x_rcc.h"
|
||||||
#define USB_DP_OUT() GPIOA->CRH = (GPIOA->CRH & 0xFFF3FFFF) | 0x00030000
|
#include "stm32f10x_dma.h"
|
||||||
|
#include "stm32f10x_adc.h"
|
||||||
#define USB_DN_EN() GPIOA->CRH = (GPIOA->CRH & 0xFFFFBFFF) | 0x0000B000
|
#include "stm32f10x_tim.h"
|
||||||
#define USB_DP_EN() GPIOA->CRH = (GPIOA->CRH & 0xFFFBFFFF) | 0x000B0000
|
#include "stm32f10x_exti.h"
|
||||||
|
#include "stm32f10x_iwdg.h"
|
||||||
#define USB_DP_PD() GPIOA->CRH = (GPIOA->CRH & 0xFFF3FFFF) | 0x00030000
|
#include "misc.h"
|
||||||
|
extern volatile uint32_t gHeat_cnt;
|
||||||
#define USB_DN_HIGH() GPIOA->BSRR = GPIO_Pin_11
|
|
||||||
#define USB_DP_HIGH() GPIOA->BSRR = GPIO_Pin_12
|
|
||||||
|
|
||||||
#define USB_DN_LOW() GPIOA->BRR = GPIO_Pin_11
|
|
||||||
#define USB_DP_LOW() GPIOA->BRR = GPIO_Pin_12
|
|
||||||
|
|
||||||
#define LOW 0
|
|
||||||
#define HIGH 1
|
|
||||||
|
|
||||||
#define BLINK 1 // Bit0 : 0/1 <20><>ʾ/<2F><>˸״̬<D7B4><CCAC>־
|
|
||||||
#define WAIT_TIMES 100000
|
|
||||||
|
|
||||||
|
|
||||||
#define SECTOR_SIZE 512
|
|
||||||
#define SECTOR_CNT 4096
|
|
||||||
#define HEAT_T 200
|
|
||||||
|
|
||||||
|
inline void setIronTimer(uint32_t time) {
|
||||||
|
gHeat_cnt = time;
|
||||||
|
}
|
||||||
|
inline uint32_t getIronTimer() {
|
||||||
|
return gHeat_cnt;
|
||||||
|
}
|
||||||
|
/*Get set the remaining toggles of the heater output*/
|
||||||
u32 Get_HeatingTime(void);
|
u32 Get_HeatingTime(void);
|
||||||
void Set_HeatingTime(u32 heating_time);
|
void Set_HeatingTime(u32 heating_time);
|
||||||
u16 Get_AdcValue(u8 i);
|
|
||||||
void Init_Gtime(void);
|
void Init_Gtime(void);
|
||||||
void Delay_Ms(u32 ms);
|
|
||||||
void Delay_HalfMs(u32 ms);
|
|
||||||
void USB_Port(u8 state);
|
void USB_Port(u8 state);
|
||||||
void NVIC_Config(u16 tab_offset);
|
void NVIC_Config(u16 tab_offset);
|
||||||
void RCC_Config(void);
|
void RCC_Config(void);
|
||||||
void GPIO_Config(void);
|
void GPIO_Config(void);
|
||||||
void Adc_Init(void);
|
void Adc_Init(void);
|
||||||
void Init_Timer2(void);
|
|
||||||
void Init_Timer3(void);
|
void Init_Timer3(void);
|
||||||
void TIM2_ISR(void);
|
/*Interrupts*/
|
||||||
void TIM3_ISR(void);
|
void TIM3_ISR(void);
|
||||||
|
void Init_EXTI(void);
|
||||||
|
/*Watchdog*/
|
||||||
|
void Start_Watchdog(uint32_t ms);
|
||||||
|
void Clear_Watchdog(void);
|
||||||
#endif
|
#endif
|
||||||
/********************************* END OF FILE ********************************/
|
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
|
||||||
File Name : CTRL.h
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : Celery
|
|
||||||
Data: 2015/07/07
|
|
||||||
History:
|
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef _CTRL_H
|
|
||||||
#define _CTRL_H
|
|
||||||
|
|
||||||
#include "stm32f10x.h"
|
|
||||||
#include "Bios.h"
|
|
||||||
|
|
||||||
#define TEMPSHOW_TIMER gTime[0]/*TEMPSHOW_TIMER*/
|
|
||||||
#define HEATING_TIMER gTime[1]/*HEATING_TIMER*/
|
|
||||||
#define ENTER_WAIT_TIMER gTime[2]/*ENTER_WAIT_TIMER*/
|
|
||||||
#define EFFECTIVE_KEY_TIMER gTime[3]/*EFFECTIVE_KEY_TIMER*/
|
|
||||||
#define LEAVE_WAIT_TIMER gTime[4]/*LEAVE_WAIT_TIMER*/
|
|
||||||
#define G6_TIMER gTime[5]/*SWITCH_SHOW_TIMER*/
|
|
||||||
#define UI_TIMER gTime[6]/*UI_TIMER ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>*/
|
|
||||||
#define KD_TIMER gTime[7]/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ*/
|
|
||||||
|
|
||||||
///^^-- All the times in gTime are decremented by 1 if >0 by timer2 tick <bottom of bios.c>
|
|
||||||
//------------------------------ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>------------------------------------//
|
|
||||||
#define KEY_ST(KEY_PIN) GPIO_ReadInputDataBit(GPIOA, KEY_PIN)
|
|
||||||
#define NO_KEY 0x0 /*NO Keys pressed*/
|
|
||||||
#define KEY_V1 0x0100/*V1 key pressed*/
|
|
||||||
#define KEY_V2 0x0040/*V2 Key pressed*/
|
|
||||||
#define KEY_CN 0X8000/*(Long key press i think)*/
|
|
||||||
#define KEY_V3 (KEY_V1|KEY_V2)/*Both Keys pressed*/
|
|
||||||
|
|
||||||
typedef enum WORK_STATUS {
|
|
||||||
IDLE = 1, //System is idle
|
|
||||||
THERMOMETER, //Thermometer mode, basically reads sensor and shows temp
|
|
||||||
TEMP_CTR, //Soldering Mode (Temp Controlled)
|
|
||||||
WAIT, //System in wait state
|
|
||||||
TEMP_SET, //Setting the soldering temp
|
|
||||||
CONFIG, //system config mode
|
|
||||||
MODE_CNG, //DFU mode i think??
|
|
||||||
ALARM, //An alarm has been fired
|
|
||||||
} WORK_STATUS;
|
|
||||||
|
|
||||||
typedef enum WARNING_STATUS {
|
|
||||||
NORMAL_TEMP = 1, HIGH_TEMP, SEN_ERR, HIGH_VOLTAGE, LOW_VOLTAGE,
|
|
||||||
} WARNING_STATUS;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
u8 ver[16];
|
|
||||||
s16 t_standby; // 200<30><30>C=1800 2520,<2C><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
|
||||||
s16 t_work; // 350<35><30>C=3362, <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
|
||||||
s16 t_step; //<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
|
|
||||||
u32 wait_time; //3*60*100 3 mintute
|
|
||||||
u32 idle_time; //6*60*100 6 minute
|
|
||||||
} DEVICE_INFO_SYS;
|
|
||||||
|
|
||||||
extern DEVICE_INFO_SYS device_info;
|
|
||||||
void Set_PrevTemp(s16 Temp);
|
|
||||||
u8 Get_CtrlStatus(void);
|
|
||||||
void Set_CtrlStatus(u8 status);
|
|
||||||
s16 Get_TempVal(void);
|
|
||||||
u16 Get_HtFlag(void);
|
|
||||||
void System_Init(void);
|
|
||||||
void Pid_Init(void);
|
|
||||||
u16 Pid_Realize(s16 temp);
|
|
||||||
u32 Heating_Time(s16 temp, s16 wk_temp);
|
|
||||||
void Status_Tran(void);
|
|
||||||
#endif
|
|
||||||
/******************************** END OF FILE *********************************/
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
|
||||||
File Name : Disk.h
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : Celery
|
|
||||||
Data: 2015/08/03
|
|
||||||
History:
|
|
||||||
2016/09/13 : Ben V. Brown - english comments
|
|
||||||
2015/08/03 :
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __DISK_H
|
|
||||||
#define __DISK_H
|
|
||||||
|
|
||||||
#include "stm32f10x_flash.h"
|
|
||||||
#include "usb_scsi.h"
|
|
||||||
#include "usb_regs.h"
|
|
||||||
#include "usb_conf.h"
|
|
||||||
#include "usb_bot.h"
|
|
||||||
#include "usb_mem.h"
|
|
||||||
#include "usb_lib.h"
|
|
||||||
#include "usb_pwr.h"
|
|
||||||
|
|
||||||
#define SECTOR_SIZE 512
|
|
||||||
#define SECTOR_CNT 4096
|
|
||||||
|
|
||||||
#define FAT1_SECTOR &gDisk_buff[0x000]
|
|
||||||
#define FAT2_SECTOR &gDisk_buff[0x200]
|
|
||||||
#define ROOT_SECTOR &gDisk_buff[0x400]
|
|
||||||
#define VOLUME_BASE &gDisk_buff[0x416]
|
|
||||||
#define OTHER_FILES &gDisk_buff[0x420]
|
|
||||||
#define FILE_SECTOR &gDisk_buff[0x600]
|
|
||||||
#define Root (u8*)ROOT_SECTOR
|
|
||||||
|
|
||||||
//#define APP_BASE 0x0800C000
|
|
||||||
|
|
||||||
#define HEX 0
|
|
||||||
#define BIN 2
|
|
||||||
#define SET 1
|
|
||||||
|
|
||||||
#define RDY 0
|
|
||||||
#define NOT 2
|
|
||||||
#define END 3
|
|
||||||
#define ERR 4
|
|
||||||
|
|
||||||
#define DATA_SEG 0x00
|
|
||||||
#define DATA_END 0x01
|
|
||||||
#define EXT_ADDR 0x04
|
|
||||||
|
|
||||||
#define TXFR_IDLE 0
|
|
||||||
#define TXFR_ONGOING 1
|
|
||||||
|
|
||||||
//#define FAT_DATA 0x00FFFFF8
|
|
||||||
#define VOLUME 0x40DD8D18 //0x3E645C29
|
|
||||||
|
|
||||||
#define BUFF 0 //
|
|
||||||
|
|
||||||
#define V32_BASE SECTOR_SIZE // V32 8*4=32
|
|
||||||
#define W_ADDR 0
|
|
||||||
#define ADDR 1
|
|
||||||
#define H_ADDR 2
|
|
||||||
#define OFFSET 3
|
|
||||||
#define SEC_CNT 4
|
|
||||||
#define COUNT 5
|
|
||||||
#define RD_CNT 6
|
|
||||||
#define WR_CNT 7
|
|
||||||
|
|
||||||
#define VAR_BASE V32_BASE + 32 // VAR 9+17=26
|
|
||||||
#define USB_ST 0
|
|
||||||
#define SEG_KIND 1
|
|
||||||
#define SEG_LEN 2
|
|
||||||
#define SEG_SUM 3
|
|
||||||
#define SEG_TMP 4
|
|
||||||
#define SEG_ST 5
|
|
||||||
#define DATA_CNT 6
|
|
||||||
#define F_TYPE 7
|
|
||||||
#define F_FLAG 8
|
|
||||||
#define SEG_DATA 9 //9~26
|
|
||||||
|
|
||||||
u8 Cal_Val(u8 str[], u8 k, u8 flag);
|
|
||||||
void Disk_BuffInit(void);
|
|
||||||
u8 ReWrite_All(void);
|
|
||||||
u8 Config_Analysis(void);
|
|
||||||
void Disk_BuffInit(void);
|
|
||||||
void Disk_SecWrite(u8* pbuffer, u32 disk_addr);
|
|
||||||
void Close_File(void);
|
|
||||||
void Write_Memory(u32 w_offset, u32 w_length);
|
|
||||||
void Read_Memory(u32 r_offset, u32 r_length);
|
|
||||||
void Set_Ver(u8 str[], u8 i);
|
|
||||||
void Erase(void);
|
|
||||||
char * Get_Line(char *dst, char *src, int n, int m);
|
|
||||||
void Upper(u8* str, u16 len);
|
|
||||||
u8* SearchFile(u8* pfilename, u16* pfilelen, u16* root_addr);
|
|
||||||
u8 ReWriteFlsash(void);
|
|
||||||
#endif
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
|
||||||
File Name : EXT_Flash.h
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : bure
|
|
||||||
Data:
|
|
||||||
History:
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __EXT_FLASH_H
|
|
||||||
#define __EXT_FLASH_H
|
|
||||||
//#include "stm32f10x_lib.h"
|
|
||||||
#include "stm32f10x.h"
|
|
||||||
|
|
||||||
extern u8 flash_mode;
|
|
||||||
#define FLASH_2M 1
|
|
||||||
#define FLASH_8M 2
|
|
||||||
//#define W25Q64BV
|
|
||||||
|
|
||||||
#define WREN 0x06 // Write enable instruction
|
|
||||||
#define READ 0x03 // Read from Memory instruction
|
|
||||||
#define RDSR 0x05 // Read Status Register instruction
|
|
||||||
#define PP 0x02 // Write to Memory instruction
|
|
||||||
#define PE 0xDB // Page Erase instruction
|
|
||||||
#define PW 0x0A // Page write instruction
|
|
||||||
#define DP 0xB9 // Deep power-down instruction
|
|
||||||
#define RDP 0xAB // Release from deep power-down instruction
|
|
||||||
//----W25Q64BV----------------------------------------------------------------//
|
|
||||||
#define CHIPE 0xC7 // Chip All Erase instruction
|
|
||||||
#define BE64 0xD8 // Block 32k Erase instruction
|
|
||||||
#define BE32 0x52 // Block 64k Erase instruction
|
|
||||||
#define SE 0x20 // Sector 4K Erase instruction
|
|
||||||
#define Dummy_Byte 0xA5
|
|
||||||
#define EXT_FLASH_PageSize 256
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
|
||||||
#define WIP_Flag 0x01 // Write In Progress (WIP) flag
|
|
||||||
|
|
||||||
|
|
||||||
#define ExtFlash_CS_LOW() GPIO_ResetBits(GPIOB, GPIO_Pin_7)
|
|
||||||
#define ExtFlash_CS_HIGH() GPIO_SetBits(GPIOB, GPIO_Pin_7)
|
|
||||||
|
|
||||||
void ExtFlash_PageWR(u8* pBuffer, u32 WriteAddr);
|
|
||||||
void ExtFlash_PageRD(u8* pBuffer, u32 ReadAddr, u16 Lenght);
|
|
||||||
void MAL_GetStatus (void);
|
|
||||||
u8 ExtFlash_ReadByte(void);
|
|
||||||
u8 ExtFlash_SendByte(u8 byte);
|
|
||||||
void ExtFlash_WriteEnable(void);
|
|
||||||
void ExtFlash_WaitForWriteEnd(void);
|
|
||||||
void ExtFlash_PageProg(u8* pBuffer, u32 WriteAddr,u8 CMD);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
|
||||||
File Name : FAT12.h
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : bure
|
|
||||||
Data:
|
|
||||||
History:
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __FAT12_H
|
|
||||||
#define __FAT12_H
|
|
||||||
|
|
||||||
#include "stm32f10x.h"
|
|
||||||
|
|
||||||
|
|
||||||
u8 ReadFileSec(u8* Buffer, u16* Cluster);
|
|
||||||
u8 ReadDiskData(u8* pBuffer, u32 ReadAddr, u16 Lenght);
|
|
||||||
u8 NextCluster(u16* Cluster);
|
|
||||||
u8 ProgFileSec(u8* Buffer, u16* Cluster);
|
|
||||||
u8 ProgDiskPage(u8* Buffer, u32 ProgAddr);
|
|
||||||
u8 SeekBlank(u8* Buffer, u16* Cluster);
|
|
||||||
u8 SetCluster(u8* Buffer, u16* Cluster);
|
|
||||||
u8 OpenFileRd(u8* Buffer, u8* FileName, u16* Cluster, u32* pDirAddr);
|
|
||||||
u8 OpenFileWr(u8* Buffer, u8* FileName, u16* Cluster, u32* pDirAddr);
|
|
||||||
u8 CloseFile(u8* Buffer, u32 Lenght, u16* Cluster, u32* pDirAddr);
|
|
||||||
u8 FAT_SearchFile(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr,u32* flag);
|
|
||||||
void ExtFlash_PageWrite(u8* pBuffer, u32 WriteAddr, u8 Mode);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/********************************* END OF FILE ********************************/
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
|
||||||
File Name : Flash.h
|
|
||||||
Version : Author : bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __EXT_FLASH_H
|
|
||||||
#define __EXT_FLASH_H
|
|
||||||
#include "stm32f10x.h"
|
|
||||||
#define PAGESIZE 256
|
|
||||||
|
|
||||||
#define WREN 0x06 // Write enable instruction
|
|
||||||
#define READ 0x03 // Read from Memory instruction
|
|
||||||
#define RDSR 0x05 // Read Status Register instruction
|
|
||||||
#define PP 0x02 // Write to Memory instruction
|
|
||||||
#define PW 0x0A // Page write instruction
|
|
||||||
|
|
||||||
#define OK 0 //
|
|
||||||
#define SEC_ERR 1 //
|
|
||||||
#define TMAX 100000 //
|
|
||||||
|
|
||||||
#define WIP_Flag 0x01 // Write In Progress (WIP) flag
|
|
||||||
#define Dummy_Byte 0xA5
|
|
||||||
|
|
||||||
u8 FLASH_Prog(u32 Address, u16 Data);
|
|
||||||
void FLASH_Erase(u32 Address);
|
|
||||||
void ExtFlashPageWR(u8* pBuffer, u32 WriteAddr);
|
|
||||||
void ExtFlashDataRD(u8* pBuffer, u32 ReadAddr, u16 Lenght);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
166
workspace/ts100/inc/Font.h
Normal file
166
workspace/ts100/inc/Font.h
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
/*
|
||||||
|
* Font.h
|
||||||
|
*
|
||||||
|
* Created on: 17 Sep 2016
|
||||||
|
* Author: Ralim
|
||||||
|
*
|
||||||
|
* ... This file contains the font...
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FONT_H_
|
||||||
|
#define FONT_H_
|
||||||
|
|
||||||
|
#define FONT_WIDTH 12 /*How many pixels wide the font is*/
|
||||||
|
const uint8_t FONT[]={
|
||||||
|
0x00,0xF0,0xFC,0x0E,0x82,0xC2,0x62,0x1E,0xFC,0xF0,0x00,0x00,
|
||||||
|
0x00,0x03,0x0F,0x1F,0x11,0x10,0x10,0x1C,0x0F,0x03,0x00,0x00,/*0*/
|
||||||
|
0x00,0x08,0x04,0x02,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x10,0x10,0x10,0x1F,0x1F,0x10,0x10,0x10,0x00,0x00,0x00,/*1*/
|
||||||
|
0x00,0x04,0x02,0x02,0x02,0xC6,0xFC,0x78,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x18,0x1C,0x16,0x13,0x11,0x10,0x10,0x10,0x00,0x00,0x00,/*2*/
|
||||||
|
0x00,0x02,0x02,0x42,0x42,0x66,0xFE,0x9C,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x10,0x10,0x10,0x10,0x10,0x08,0x0F,0x07,0x00,0x00,0x00,/*3*/
|
||||||
|
0x00,0x00,0x80,0xE0,0x30,0x1C,0x06,0xFE,0xFE,0x00,0x00,0x00,
|
||||||
|
0x00,0x03,0x03,0x02,0x02,0x02,0x02,0x1F,0x1F,0x02,0x02,0x00,/*4*/
|
||||||
|
0x00,0x7E,0x7E,0x42,0x42,0x42,0xC2,0x82,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x10,0x10,0x10,0x10,0x10,0x08,0x0F,0x07,0x00,0x00,0x00,/*5*/
|
||||||
|
0x00,0xE0,0xF8,0x8C,0x44,0x42,0x42,0xC2,0x82,0x80,0x00,0x00,
|
||||||
|
0x00,0x07,0x0F,0x18,0x10,0x10,0x10,0x18,0x0F,0x07,0x00,0x00,/*6*/
|
||||||
|
0x00,0x02,0x02,0x02,0x02,0xC2,0xF2,0x1E,0x06,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x10,0x1C,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,/*7*/
|
||||||
|
0x00,0x38,0x7C,0x66,0xC2,0x82,0xC2,0x66,0x7C,0x3C,0x00,0x00,
|
||||||
|
0x00,0x0E,0x0F,0x19,0x10,0x10,0x10,0x19,0x0F,0x0E,0x00,0x00,/*8*/
|
||||||
|
0x00,0x78,0x7C,0xC6,0x82,0x82,0x82,0x46,0xFC,0xF8,0x00,0x00,
|
||||||
|
0x00,0x00,0x10,0x10,0x10,0x10,0x08,0x0C,0x07,0x03,0x00,0x00,/*9*/
|
||||||
|
|
||||||
|
0x00,0x00,0x80,0xF0,0x1E,0x02,0x1E,0xF0,0x80,0x00,0x00,0x00,
|
||||||
|
0x00,0x1C,0x0F,0x03,0x02,0x02,0x02,0x03,0x0F,0x1C,0x00,0x00,/*A*/
|
||||||
|
0x00,0xFE,0xFE,0x42,0x42,0x42,0xE6,0xBE,0x9C,0x00,0x00,0x00,
|
||||||
|
0x00,0x1F,0x1F,0x10,0x10,0x10,0x18,0x0F,0x07,0x00,0x00,0x00,/*B*/
|
||||||
|
0x00,0xF0,0xF8,0x0C,0x06,0x02,0x02,0x02,0x04,0x00,0x00,0x00,
|
||||||
|
0x00,0x03,0x0F,0x0C,0x18,0x10,0x10,0x10,0x08,0x00,0x00,0x00,/*C*/
|
||||||
|
0x00,0xFE,0xFE,0x02,0x02,0x02,0x06,0x0C,0xFC,0xF0,0x00,0x00,
|
||||||
|
0x00,0x1F,0x1F,0x10,0x10,0x10,0x18,0x0C,0x07,0x03,0x00,0x00,/*D*/
|
||||||
|
0x00,0xFE,0xFE,0x42,0x42,0x42,0x42,0x42,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x1F,0x1F,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,/*E*/
|
||||||
|
0x00,0xFE,0xFE,0x82,0x82,0x82,0x82,0x82,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*F*/
|
||||||
|
0x00,0xF0,0xF8,0x0C,0x06,0x02,0x82,0x82,0x82,0x84,0x00,0x00,
|
||||||
|
0x00,0x03,0x0F,0x0C,0x18,0x10,0x10,0x10,0x1F,0x1F,0x00,0x00,/*G*/
|
||||||
|
0x00,0xFE,0xFE,0x40,0x40,0x40,0x40,0xFE,0xFE,0x00,0x00,0x00,
|
||||||
|
0x00,0x1F,0x1F,0x00,0x00,0x00,0x00,0x1F,0x1F,0x00,0x00,0x00,/*H*/
|
||||||
|
0x00,0x02,0x02,0x02,0xFE,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,
|
||||||
|
0x00,0x10,0x10,0x10,0x1F,0x1F,0x10,0x10,0x10,0x00,0x00,0x00,/*I*/
|
||||||
|
0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0xFE,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x08,0x10,0x10,0x10,0x18,0x0F,0x07,0x00,0x00,0x00,0x00,/*J*/
|
||||||
|
0x00,0xFE,0xFE,0xC0,0xE0,0x30,0x18,0x0C,0x06,0x02,0x00,0x00,
|
||||||
|
0x00,0x1F,0x1F,0x00,0x01,0x03,0x06,0x0C,0x18,0x10,0x00,0x00,/*K*/
|
||||||
|
0x00,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x1F,0x1F,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,/*L*/
|
||||||
|
0x00,0x00,0xFE,0x06,0x3C,0xC0,0xC0,0x3C,0x06,0xFE,0x00,0x00,
|
||||||
|
0x00,0x10,0x1F,0x00,0x00,0x01,0x01,0x00,0x00,0x1F,0x18,0x00,/*M*/
|
||||||
|
0x00,0xFE,0xFE,0x1E,0x70,0x80,0x00,0xFE,0xFE,0x00,0x00,0x00,
|
||||||
|
0x00,0x1F,0x1F,0x00,0x00,0x03,0x1C,0x1F,0x1F,0x00,0x00,0x00,/*N*/
|
||||||
|
0x00,0xF0,0xFC,0x0C,0x02,0x02,0x02,0x0E,0xFC,0xF0,0x00,0x00,
|
||||||
|
0x00,0x03,0x0F,0x1C,0x10,0x10,0x10,0x0C,0x0F,0x03,0x00,0x00,/*O*/
|
||||||
|
0x00,0xFE,0xFE,0x02,0x02,0x02,0x86,0xFC,0x78,0x00,0x00,0x00,
|
||||||
|
0x00,0x1F,0x1F,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,/*P*/
|
||||||
|
0x00,0xF0,0xF8,0x0C,0x02,0x02,0x02,0x02,0x0C,0xFC,0xF0,0x00,
|
||||||
|
0x00,0x03,0x0F,0x1C,0x10,0x30,0x70,0xD8,0x8C,0x8F,0x83,0x40,/*Q*/
|
||||||
|
0x00,0xFE,0xFE,0x42,0x42,0xC2,0xE6,0x3C,0x1C,0x00,0x00,0x00,
|
||||||
|
0x00,0x1F,0x1F,0x00,0x00,0x00,0x01,0x0F,0x1C,0x10,0x00,0x00,/*R*/
|
||||||
|
0x00,0x38,0x7C,0x66,0xC2,0xC2,0x82,0x84,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x08,0x10,0x10,0x10,0x10,0x19,0x0F,0x07,0x00,0x00,0x00,/*S*/
|
||||||
|
0x00,0x02,0x02,0x02,0x02,0xFE,0xFE,0x02,0x02,0x02,0x02,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,/*T*/
|
||||||
|
0x00,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00,0xFE,0xFE,0x00,0x00,
|
||||||
|
0x00,0x07,0x0F,0x18,0x10,0x10,0x10,0x18,0x0F,0x07,0x00,0x00,/*U*/
|
||||||
|
0x00,0x0E,0x7E,0xE0,0x00,0x00,0x00,0xE0,0x7C,0x0E,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x03,0x1F,0x18,0x1F,0x03,0x00,0x00,0x00,0x00,/*V*/
|
||||||
|
0x00,0x7E,0xFE,0x00,0x00,0xE0,0xE0,0x00,0x00,0xFE,0x7E,0x00,
|
||||||
|
0x00,0x00,0x1F,0x18,0x0F,0x01,0x01,0x0F,0x18,0x1F,0x00,0x00,/*W*/
|
||||||
|
0x00,0x02,0x06,0x1C,0x38,0xE0,0xE0,0x38,0x1C,0x06,0x02,0x00,
|
||||||
|
0x00,0x10,0x18,0x0E,0x07,0x01,0x01,0x07,0x0E,0x18,0x10,0x00,/*X*/
|
||||||
|
0x00,0x02,0x0E,0x3C,0xF0,0xC0,0xC0,0xF0,0x3C,0x0E,0x02,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,/*Y*/
|
||||||
|
0x00,0x02,0x02,0x02,0xC2,0xE2,0x3A,0x0E,0x02,0x00,0x00,0x00,
|
||||||
|
0x00,0x10,0x1C,0x17,0x11,0x10,0x10,0x10,0x10,0x00,0x00,0x00,/*Z*/
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/* */
|
||||||
|
|
||||||
|
0x00,0x60,0xF0,0x98,0x0C,0x06,0x02,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x01,0x03,0x06,0x04,0x00,0x00,0x00,0x00,0x00,/*<*/
|
||||||
|
0x00,0x02,0x06,0x0C,0x98,0xF0,0x60,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x04,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*>*/
|
||||||
|
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x0F,0x0F,0x0F,0x0F,0x00,0x00,0x00,0x00,/*.*/
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t Iron_Base[] ={
|
||||||
|
0x00,0x20,0x60,0x60,0x60,0x60,0x60,0x60,0x90,0x90,0x90,0x90,
|
||||||
|
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
|
||||||
|
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x60,0x60,
|
||||||
|
0x60,0x60,0x60,0x60,0x60,0x70,0xF8,0x88,0x84,0x82,0x82,0x83,
|
||||||
|
0x83,0x83,0x83,0x83,0x83,0x82,0x82,0x82,0x82,0x83,0x83,0x83,
|
||||||
|
0x83,0x83,0x83,0x82,0x82,0x82,0x82,0x82,0x86,0x84,0x84,0x84,
|
||||||
|
0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,
|
||||||
|
0x84,0x84,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,
|
||||||
|
|
||||||
|
};
|
||||||
|
//The top pixel row for left arrow / on hint
|
||||||
|
const uint8_t Iron_LeftArrow_UP[] = {
|
||||||
|
0x00,0x7C,0x82,0x82,0x82,0x7C,0x00,0xFE,0x08,0x10,0x20,0xFE,//ON
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,
|
||||||
|
0x98,0xBF,0xBF,0x98,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t Iron_LeftArrow_DOWN[] = {
|
||||||
|
0x00,0x7C,0x82,0x82,0x82,0x7C,0x00,0xFE,0x08,0x10,0x20,0xFE,//ON
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
|
||||||
|
0x30,0x7E,0x7E,0x30,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
};
|
||||||
|
//The top pixel row for both arrows /
|
||||||
|
const uint8_t Iron_BothArrows[] = {
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,
|
||||||
|
0x98,0xBF,0xBF,0x98,0x88,0x00,0x00,0x00,0x00,0x88,0x98,0xBF,
|
||||||
|
0xBF,0x98,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
};
|
||||||
|
//The top pixel row for right arrow / settings hint
|
||||||
|
const uint8_t Iron_RightArrow_UP[] = {
|
||||||
|
0x00,0x8C,0x92,0x92,0x92,0x62,0x00,0xFE,0x92,0x92,0x92,0x82,//SE
|
||||||
|
0x00,0x02,0x02,0xFE,0x02,0x02,0x00,0x02,0x02,0xFE,0x02,0x02,//TT
|
||||||
|
0x00,0x00,0x82,0xFE,0x82,0x00,0x00,0xFE,0x08,0x10,0x20,0xFE,//IN
|
||||||
|
0x00,0x7C,0x82,0x82,0xA2,0x62,0x00,0x8C,0x92,0x92,0x92,0x62,//GS
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x98,0xBF,
|
||||||
|
0xBF,0x98,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
};
|
||||||
|
const uint8_t Iron_RightArrow_DOWN[] = {
|
||||||
|
0x00,0x8C,0x92,0x92,0x92,0x62,0x00,0xFE,0x92,0x92,0x92,0x82,//SE
|
||||||
|
0x00,0x02,0x02,0xFE,0x02,0x02,0x00,0x02,0x02,0xFE,0x02,0x02,//TT
|
||||||
|
0x00,0x00,0x82,0xFE,0x82,0x00,0x00,0xFE,0x08,0x10,0x20,0xFE,//IN
|
||||||
|
0x00,0x7C,0x82,0x82,0xA2,0x62,0x00,0x8C,0x92,0x92,0x92,0x62,//GS
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x30,0x7E,
|
||||||
|
0x7E,0x30,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FONT_H_ */
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
|
||||||
File Name : CTRL.h
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : Celery
|
|
||||||
Data: 2015/07/07
|
|
||||||
History:
|
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef _HARDWARE_H
|
|
||||||
#define _HARDWARE_H
|
|
||||||
|
|
||||||
#include "stm32f10x.h"
|
|
||||||
|
|
||||||
#define SI_COE 8//56
|
|
||||||
#define SI_THRESHOLD 60
|
|
||||||
|
|
||||||
typedef enum VOL_CLASS {
|
|
||||||
H_ALARM = 0,
|
|
||||||
VOL_24,
|
|
||||||
VOL_19,
|
|
||||||
VOL_12,
|
|
||||||
VOL_5,
|
|
||||||
L_ALARM,
|
|
||||||
} VOL_CLASS;
|
|
||||||
|
|
||||||
extern s32 gZerop_ad;
|
|
||||||
extern u8 gCalib_flag;
|
|
||||||
extern u32 gTurn_offv;
|
|
||||||
|
|
||||||
u32 Get_gKey(void);
|
|
||||||
void Set_gKey(u32 key);
|
|
||||||
void Set_LongKeyFlag(u32 flag);
|
|
||||||
void Zero_Calibration(void);
|
|
||||||
int Read_Vb(u8 flag);
|
|
||||||
void Scan_Key(void);
|
|
||||||
u32 Get_SlAvg(u32 avg_data);
|
|
||||||
int Get_TempSlAvg(int avg_data);
|
|
||||||
u32 Get_AvgAd(void);
|
|
||||||
int Get_SensorTmp(void);
|
|
||||||
u16 Get_ThermometerTemp(void);
|
|
||||||
s16 Get_Temp(s16 wk_temp);
|
|
||||||
void Clear_Watchdog(void);
|
|
||||||
u32 Start_Watchdog(u32 ms);
|
|
||||||
u8 Get_AlarmType(void);
|
|
||||||
void Set_AlarmType(u8 type);
|
|
||||||
u32 Get_CalFlag(void);
|
|
||||||
#endif
|
|
||||||
/******************************** END OF FILE *********************************/
|
|
||||||
@@ -1,21 +1,16 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
/*
|
||||||
File Name : I2C.h
|
* I2C.h
|
||||||
Version : S100 APP Ver 2.11
|
* I2C wrapper for the stm32 hardware I2C port
|
||||||
Description:
|
*/
|
||||||
Author : Celery
|
|
||||||
Data: 2015/08/03
|
|
||||||
History:
|
|
||||||
2015/08/03 :
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __I2C_H
|
#ifndef __I2C_H
|
||||||
#define __I2C_H
|
#define __I2C_H
|
||||||
|
|
||||||
#define I2C_TX 1
|
#include "stm32f10x_i2c.h"
|
||||||
#define I2C_RX 2
|
#include "stm32f10x.h"
|
||||||
|
#include "stm32f10x_gpio.h"
|
||||||
|
|
||||||
void I2C_Configuration(void);
|
void I2C_Configuration(void);
|
||||||
void Delay_uS(u32 us);
|
void I2C_PageWrite(u8* pbuf, u8 numbyte, u8 deviceaddr);
|
||||||
void I2C_PageWrite(u8* pbuf, u8 numbyte,u8 deviceaddr );
|
void I2C_PageRead(u8* pbuf, u8 numbyte, u8 deviceaddr, u8 readaddr);
|
||||||
void I2C_PageRead(u8* pbuf, u8 numbyte,u8 deviceaddr, u8 readaddr);
|
|
||||||
#endif
|
#endif
|
||||||
/******************************** END OF FILE *********************************/
|
/******************************** END OF FILE *********************************/
|
||||||
|
|||||||
@@ -1,70 +1,41 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. *******************/
|
/*
|
||||||
/* Brief : Interrupt Service Routines Author : bure */
|
* Interrupt Service Routines
|
||||||
/******************************************************************************/
|
* This file manages all the IRQ events that can be generated
|
||||||
|
*/
|
||||||
#ifndef __INTERRUPT_H
|
#ifndef __INTERRUPT_H
|
||||||
#define __INTERRUPT_H
|
#define __INTERRUPT_H
|
||||||
//See here for refernce to this block http://embedded.kleier.selfhost.me/vector.php
|
#include <stdint.h>
|
||||||
static void forever (void);
|
/* Functions for access to data */
|
||||||
void __attribute__ ((weak, alias ("forever"))) WWDG_IRQHandler (void);
|
extern volatile uint32_t system_Ticks;
|
||||||
void __attribute__ ((weak, alias ("forever"))) PVD_IRQHandler (void);
|
void delayMs(uint32_t ticks);
|
||||||
void __attribute__ ((weak, alias ("forever"))) TAMPER_IRQHandler (void);
|
volatile extern uint32_t lastKeyPress;
|
||||||
void __attribute__ ((weak, alias ("forever"))) RTC_IRQHandler (void);
|
volatile extern uint32_t lastMovement;
|
||||||
void __attribute__ ((weak, alias ("forever"))) FLASH_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) RCC_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) EXTI0_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) EXTI1_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) EXTI2_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) EXTI3_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) EXTI4_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) DMA1_Channel1_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) DMA1_Channel2_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) DMA1_Channel3_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) DMA1_Channel4_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) DMA1_Channel5_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) DMA1_Channel6_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) DMA1_Channel7_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) ADC1_2_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) USB_HP_CAN1_TX_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) CAN1_RX1_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) CAN1_SCE_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) EXTI9_5_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM1_BRK_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM1_UP_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM1_TRG_COM_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM1_CC_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM4_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) I2C1_EV_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) I2C1_ER_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) I2C2_EV_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) I2C2_ER_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) SPI1_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) SPI2_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) USART1_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) USART2_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) USART3_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) EXTI15_10_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) RTCAlarm_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) USBWakeUp_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM8_BRK_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM8_UP_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM8_TRG_COM_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM8_CC_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) ADC3_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) FSMC_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) SDIO_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM5_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) SPI3_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) UART4_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) UART5_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM6_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) TIM7_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) DMA2_Channel1_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) DMA2_Channel2_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) DMA2_Channel3_IRQHandler (void);
|
|
||||||
void __attribute__ ((weak, alias ("forever"))) DMA2_Channel4_5_IRQHandler (void);
|
|
||||||
|
|
||||||
|
volatile extern uint16_t keyState;
|
||||||
|
inline uint32_t millis() {
|
||||||
|
return system_Ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint32_t getLastButtonPress() {
|
||||||
|
return lastKeyPress;
|
||||||
|
}
|
||||||
|
inline void resetLastButtonPress() {
|
||||||
|
lastKeyPress = millis();
|
||||||
|
|
||||||
|
}
|
||||||
|
inline void resetButtons() {
|
||||||
|
lastKeyPress = millis();
|
||||||
|
keyState = 0;
|
||||||
|
}
|
||||||
|
inline uint32_t getLastMovement() {
|
||||||
|
return lastMovement;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint16_t getButtons() {
|
||||||
|
return keyState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*IRQ prototypes*/
|
||||||
void NMI_Handler(void);
|
void NMI_Handler(void);
|
||||||
void HardFault_Handler(void);
|
void HardFault_Handler(void);
|
||||||
void MemManage_Handler(void);
|
void MemManage_Handler(void);
|
||||||
@@ -87,7 +58,64 @@ void I2C1_ER_IRQHandler(void);
|
|||||||
void TIM2_IRQHandler(void);
|
void TIM2_IRQHandler(void);
|
||||||
void TIM3_IRQHandler(void);
|
void TIM3_IRQHandler(void);
|
||||||
|
|
||||||
|
void WWDG_IRQHandler(void);
|
||||||
|
void PVD_IRQHandler(void);
|
||||||
|
|
||||||
|
void TAMPER_IRQHandler(void);
|
||||||
|
void RTC_IRQHandler(void);
|
||||||
|
void FLASH_IRQHandler(void);
|
||||||
|
void RCC_IRQHandler(void);
|
||||||
|
void EXTI0_IRQHandler(void);
|
||||||
|
void EXTI1_IRQHandler(void);
|
||||||
|
void EXTI2_IRQHandler(void);
|
||||||
|
void EXTI3_IRQHandler(void);
|
||||||
|
void EXTI4_IRQHandler(void);
|
||||||
|
void DMA1_Channel1_IRQHandler(void);
|
||||||
|
void DMA1_Channel2_IRQHandler(void);
|
||||||
|
void DMA1_Channel3_IRQHandler(void);
|
||||||
|
void DMA1_Channel4_IRQHandler(void);
|
||||||
|
void DMA1_Channel5_IRQHandler(void);
|
||||||
|
void DMA1_Channel6_IRQHandler(void);
|
||||||
|
void DMA1_Channel7_IRQHandler(void);
|
||||||
|
void ADC1_2_IRQHandler(void);
|
||||||
|
void USB_HP_CAN1_TX_IRQHandler(void);
|
||||||
|
void CAN1_RX1_IRQHandler(void);
|
||||||
|
void CAN1_SCE_IRQHandler(void);
|
||||||
|
void EXTI9_5_IRQHandler(void);
|
||||||
|
void TIM1_BRK_IRQHandler(void);
|
||||||
|
void TIM1_UP_IRQHandler(void);
|
||||||
|
void TIM1_TRG_COM_IRQHandler(void);
|
||||||
|
void TIM1_CC_IRQHandler(void);
|
||||||
|
void TIM4_IRQHandler(void);
|
||||||
|
void I2C1_EV_IRQHandler(void);
|
||||||
|
void I2C1_ER_IRQHandler(void);
|
||||||
|
void I2C2_EV_IRQHandler(void);
|
||||||
|
void I2C2_ER_IRQHandler(void);
|
||||||
|
void SPI1_IRQHandler(void);
|
||||||
|
void SPI2_IRQHandler(void);
|
||||||
|
void USART1_IRQHandler(void);
|
||||||
|
void USART2_IRQHandler(void);
|
||||||
|
void USART3_IRQHandler(void);
|
||||||
|
void EXTI15_10_IRQHandler(void);
|
||||||
|
void RTCAlarm_IRQHandler(void);
|
||||||
|
void USBWakeUp_IRQHandler(void);
|
||||||
|
void TIM8_BRK_IRQHandler(void);
|
||||||
|
void TIM8_UP_IRQHandler(void);
|
||||||
|
void TIM8_TRG_COM_IRQHandler(void);
|
||||||
|
void TIM8_CC_IRQHandler(void);
|
||||||
|
void ADC3_IRQHandler(void);
|
||||||
|
void FSMC_IRQHandler(void);
|
||||||
|
void SDIO_IRQHandler(void);
|
||||||
|
void TIM5_IRQHandler(void);
|
||||||
|
void SPI3_IRQHandler(void);
|
||||||
|
void UART4_IRQHandler(void);
|
||||||
|
void UART5_IRQHandler(void);
|
||||||
|
void TIM6_IRQHandler(void);
|
||||||
|
void TIM7_IRQHandler(void);
|
||||||
|
void DMA2_Channel1_IRQHandler(void);
|
||||||
|
void DMA2_Channel2_IRQHandler(void);
|
||||||
|
void DMA2_Channel3_IRQHandler(void);
|
||||||
|
void DMA2_Channel4_5_IRQHandler(void);
|
||||||
|
|
||||||
#endif /* __INTERRUPT_H */
|
#endif /* __INTERRUPT_H */
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,91 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
/*
|
||||||
File Name : MMA8652FC.h
|
* MMA8652FC.*
|
||||||
Version : S100 APP Ver 2.11
|
* Files for the built in accelerometer from NXP.
|
||||||
Description:
|
* This sets the unit up in motion detection mode with an interrupt on movement
|
||||||
Author : Celery
|
* This interrupt is fed to PB5 which catches it via EXTI5
|
||||||
Data: 2015/07/07
|
*
|
||||||
History:
|
* http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8652FC.pdf
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
*
|
||||||
*******************************************************************************/
|
* EXTI Motion config setup values lifted from AN4070 from NXP
|
||||||
|
* #defines also taken from ^
|
||||||
|
*
|
||||||
|
* Ben V. Brown - <ralim@ralimtek.com>
|
||||||
|
*/
|
||||||
#ifndef __MMA8652FC__H
|
#ifndef __MMA8652FC__H
|
||||||
#define __MMA8652FC__H
|
#define __MMA8652FC__H
|
||||||
|
|
||||||
|
|
||||||
|
void StartUp_Accelerometer(uint8_t sensitivity);//This is the only function we expose
|
||||||
|
|
||||||
//--------------MMA8652 Device ID----------------------------------------------//
|
//--------------MMA8652 Device ID----------------------------------------------//
|
||||||
|
|
||||||
#define DEVICE_ADDR 0X1D
|
#define DEVICE_ADDR 0X1D
|
||||||
//--------------MMA8652 Registers-------------------------------------------//
|
//--------------MMA8652 Registers-------------------------------------------//
|
||||||
|
|
||||||
|
#define STATUS_REG 0x00 // STATUS Register
|
||||||
|
|
||||||
|
#define OUT_X_MSB_REG 0x01 // [7:0] are 8 MSBs of the 14-bit X-axis sample
|
||||||
|
#define OUT_X_LSB_REG 0x02 // [7:2] are the 6 LSB of 14-bit X-axis sample
|
||||||
|
#define OUT_Y_MSB_REG 0x03 // [7:0] are 8 MSBs of the 14-bit Y-axis sample
|
||||||
|
#define OUT_Y_LSB_REG 0x04 // [7:2] are the 6 LSB of 14-bit Y-axis sample
|
||||||
|
#define OUT_Z_MSB_REG 0x05 // [7:0] are 8 MSBs of the 14-bit Z-axis sample
|
||||||
|
#define OUT_Z_LSB_REG 0x06 // [7:2] are the 6 LSB of 14-bit Z-axis sample
|
||||||
|
|
||||||
|
#define F_SETUP_REG 0x09 // F_SETUP FIFO Setup Register
|
||||||
|
#define TRIG_CFG_REG 0x0A // TRIG_CFG Map of FIFO data capture events
|
||||||
|
#define SYSMOD_REG 0x0B // SYSMOD System Mode Register
|
||||||
|
#define INT_SOURCE_REG 0x0C // INT_SOURCE System Interrupt Status Register
|
||||||
|
#define WHO_AM_I_REG 0x0D // WHO_AM_I Device ID Register
|
||||||
|
#define XYZ_DATA_CFG_REG 0x0E // XYZ_DATA_CFG Sensor Data Configuration Register
|
||||||
|
#define HP_FILTER_CUTOFF_REG 0x0F // HP_FILTER_CUTOFF High Pass Filter Register
|
||||||
|
|
||||||
|
#define PL_STATUS_REG 0x10 // PL_STATUS Portrait/Landscape Status Register
|
||||||
|
#define PL_CFG_REG 0x11 // PL_CFG Portrait/Landscape Configuration Register
|
||||||
|
#define PL_COUNT_REG 0x12 // PL_COUNT Portrait/Landscape Debounce Register
|
||||||
|
#define PL_BF_ZCOMP_REG 0x13 // PL_BF_ZCOMP Back/Front and Z Compensation Register
|
||||||
|
#define P_L_THS_REG 0x14 // P_L_THS Portrait to Landscape Threshold Register
|
||||||
|
|
||||||
|
#define FF_MT_CFG_REG 0x15 // FF_MT_CFG Freefall and Motion Configuration Register
|
||||||
|
#define FF_MT_SRC_REG 0x16 // FF_MT_SRC Freefall and Motion Source Register
|
||||||
|
#define FF_MT_THS_REG 0x17 // FF_MT_THS Freefall and Motion Threshold Register
|
||||||
|
#define FF_MT_COUNT_REG 0x18 // FF_MT_COUNT Freefall Motion Count Register
|
||||||
|
|
||||||
|
#define TRANSIENT_CFG_REG 0x1D // TRANSIENT_CFG Transient Configuration Register
|
||||||
|
#define TRANSIENT_SRC_REG 0x1E // TRANSIENT_SRC Transient Source Register
|
||||||
|
#define TRANSIENT_THS_REG 0x1F // TRANSIENT_THS Transient Threshold Register
|
||||||
|
#define TRANSIENT_COUNT_REG 0x20 // TRANSIENT_COUNT Transient Debounce Counter Register
|
||||||
|
|
||||||
|
#define PULSE_CFG_REG 0x21 // PULSE_CFG Pulse Configuration Register
|
||||||
|
#define PULSE_SRC_REG 0x22 // PULSE_SRC Pulse Source Register
|
||||||
|
#define PULSE_THSX_REG 0x23 // PULSE_THS XYZ Pulse Threshold Registers
|
||||||
|
#define PULSE_THSY_REG 0x24
|
||||||
|
#define PULSE_THSZ_REG 0x25
|
||||||
|
#define PULSE_TMLT_REG 0x26 // PULSE_TMLT Pulse Time Window Register
|
||||||
|
#define PULSE_LTCY_REG 0x27 // PULSE_LTCY Pulse Latency Timer Register
|
||||||
|
#define PULSE_WIND_REG 0x28 // PULSE_WIND Second Pulse Time Window Register
|
||||||
|
|
||||||
|
#define ASLP_COUNT_REG 0x29 // ASLP_COUNT Auto Sleep Inactivity Timer Register
|
||||||
|
|
||||||
|
#define CTRL_REG1 0x2A // CTRL_REG1 System Control 1 Register
|
||||||
|
#define CTRL_REG2 0x2B // CTRL_REG2 System Control 2 Register
|
||||||
|
#define CTRL_REG3 0x2C // CTRL_REG3 Interrupt Control Register
|
||||||
|
#define CTRL_REG4 0x2D // CTRL_REG4 Interrupt Enable Register
|
||||||
|
#define CTRL_REG5 0x2E // CTRL_REG5 Interrupt Configuration Register
|
||||||
|
|
||||||
|
#define OFF_X_REG 0x2F // XYZ Offset Correction Registers
|
||||||
|
#define OFF_Y_REG 0x30
|
||||||
|
#define OFF_Z_REG 0x31
|
||||||
|
|
||||||
|
//MMA8652FC 7-bit I2C address
|
||||||
|
|
||||||
|
#define MMA8652FC_I2C_ADDRESS 0x1D // MMA865xFC 7-bit I2C address is fixed
|
||||||
|
|
||||||
|
//MMA8652FC Sensitivity
|
||||||
|
|
||||||
|
#define SENSITIVITY_2G 1024
|
||||||
|
#define SENSITIVITY_4G 512
|
||||||
|
#define SENSITIVITY_8G 256
|
||||||
|
|
||||||
#define STATUS_REG 0x00
|
#define STATUS_REG 0x00
|
||||||
#define X_MSB_REG 0X01
|
#define X_MSB_REG 0X01
|
||||||
#define X_LSB_REG 0X02
|
#define X_LSB_REG 0X02
|
||||||
@@ -27,15 +99,8 @@ History:
|
|||||||
#define INT_SOURCE 0X0C
|
#define INT_SOURCE 0X0C
|
||||||
#define DEVICE_ID 0X0D
|
#define DEVICE_ID 0X0D
|
||||||
|
|
||||||
#define XYZ_DATA_CFG_REG 0X0E
|
|
||||||
|
|
||||||
|
|
||||||
#define CTRL_REG1 0X2A //
|
|
||||||
#define CTRL_REG2 0X2B //System Control 2 register
|
|
||||||
#define CTRL_REG3 0X2C //
|
|
||||||
#define CTRL_REG4 0X2D //Interrupt Enable register
|
|
||||||
#define CTRL_REG5 0X2E //
|
|
||||||
|
|
||||||
//-----STATUS_REG(0X00)-----Bit Define----------------------------------------//
|
//-----STATUS_REG(0X00)-----Bit Define----------------------------------------//
|
||||||
#define ZYXDR_BIT 0X08
|
#define ZYXDR_BIT 0X08
|
||||||
//----XYZ_DATA_CFG_REG(0xE)-Bit Define----------------------------------------//
|
//----XYZ_DATA_CFG_REG(0xE)-Bit Define----------------------------------------//
|
||||||
@@ -54,7 +119,7 @@ History:
|
|||||||
#define FHZ2 0x5 //12.5hz
|
#define FHZ2 0x5 //12.5hz
|
||||||
#define FHZ1 0x6 //6.25hz
|
#define FHZ1 0x6 //6.25hz
|
||||||
#define FHZ0 0x7 //1.563hz
|
#define FHZ0 0x7 //1.563hz
|
||||||
#define DataRateValue FHZ100
|
|
||||||
//---------CTRL_REG2(0X2B)Bit Define------------------------------------------//
|
//---------CTRL_REG2(0X2B)Bit Define------------------------------------------//
|
||||||
#define MODS_MASK 0x03 //Oversampling Mode 4
|
#define MODS_MASK 0x03 //Oversampling Mode 4
|
||||||
#define Normal_Mode 0x0 //Normal=0,Low Noise Low Power MODS=1,
|
#define Normal_Mode 0x0 //Normal=0,Low Noise Low Power MODS=1,
|
||||||
@@ -70,16 +135,5 @@ History:
|
|||||||
#define INT_EN_FF_MT 1<<2 //Freefall/Motion Interrupt Enable
|
#define INT_EN_FF_MT 1<<2 //Freefall/Motion Interrupt Enable
|
||||||
#define INT_EN_DRDY 1<<0 //Data Ready Interrupt Enable
|
#define INT_EN_DRDY 1<<0 //Data Ready Interrupt Enable
|
||||||
|
|
||||||
u16 Get_MmaShift(void);
|
|
||||||
void Set_MmaShift(u16 shift);
|
|
||||||
u16 Get_MmaActive(void);
|
|
||||||
void MMA865x_Standby(void);
|
|
||||||
void MMA865x_Active(void);
|
|
||||||
u16 Cheak_XYData(u16 x0,u16 y0,u16 x1,u16 y1);
|
|
||||||
u16 Update_X(void);
|
|
||||||
u16 Update_Y(void);
|
|
||||||
u16 Update_Z(void);
|
|
||||||
void Check_Accelerated(void);
|
|
||||||
void StartUp_Accelerated(void);
|
|
||||||
#endif
|
#endif
|
||||||
/******************************** END OF FILE *********************************/
|
/******************************** END OF FILE *********************************/
|
||||||
|
|||||||
44
workspace/ts100/inc/Modes.h
Normal file
44
workspace/ts100/inc/Modes.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Modes.h
|
||||||
|
*
|
||||||
|
* Created on: 17 Sep 2016
|
||||||
|
* Author: Ralim
|
||||||
|
*
|
||||||
|
* Modes.h -> Main function for driving the application
|
||||||
|
* This processes the buttons then does the gui
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MODES_H_
|
||||||
|
#define MODES_H_
|
||||||
|
#include "Interrupt.h"
|
||||||
|
#include "S100V0_1.h"
|
||||||
|
#include "Oled.h"
|
||||||
|
#include "PID.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
#include "Analog.h"
|
||||||
|
enum {
|
||||||
|
STARTUP, //we are sitting on the prompt to push a button
|
||||||
|
SOLDERING,
|
||||||
|
TEMP_ADJ,
|
||||||
|
SETTINGS,
|
||||||
|
SLEEP,
|
||||||
|
COOLING,
|
||||||
|
UVLOWARN,
|
||||||
|
THERMOMETER,
|
||||||
|
DCINDISP,
|
||||||
|
TEMPCAL,
|
||||||
|
} operatingMode;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
UVCO = 0,
|
||||||
|
SLEEP_TEMP,
|
||||||
|
SLEEP_TIME,
|
||||||
|
MOTIONDETECT,
|
||||||
|
MOTIONSENSITIVITY,
|
||||||
|
TEMPDISPLAY,
|
||||||
|
LEFTY,
|
||||||
|
} settingsPage;
|
||||||
|
|
||||||
|
void ProcessUI();
|
||||||
|
void DrawUI();
|
||||||
|
#endif /* MODES_H_ */
|
||||||
@@ -1,33 +1,31 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
/*
|
||||||
File Name : Oled.h
|
* Oled.h
|
||||||
Version : S100 APP Ver 2.11
|
* Functions for writing to the OLED screen
|
||||||
Description:
|
* Basically wraps drawing text and numbers to the OLED
|
||||||
Author : Celery
|
* Uses font.h -> 14 pixel wide fixed width
|
||||||
Data: 2015/07/07
|
*/
|
||||||
History:
|
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef _OLED_SSD1306_H
|
#ifndef _OLED_SSD1306_H
|
||||||
#define _OLED_SSD1306_H
|
#define _OLED_SSD1306_H
|
||||||
|
|
||||||
#define DEVICEADDR_OLED 0x3c
|
#define DEVICEADDR_OLED 0x3c
|
||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
void Sc_Pt(u8 Co);
|
#include "Interrupt.h"
|
||||||
|
|
||||||
void Oled_DisplayOn(void);
|
void Oled_DisplayOn(void);
|
||||||
void Oled_DisplayOff(void);
|
void Oled_DisplayOff(void);
|
||||||
u8* Oled_DrawArea(u8 x0,u8 y0,u8 wide, u8 high,u8* ptr);
|
|
||||||
void Set_ShowPos(u8 x,u8 y);
|
|
||||||
|
|
||||||
u8* Show_posi(u8 posi,u8* ptr,u8 word_width);
|
u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high, u8* ptr);
|
||||||
void Clean_Char(int k,u8 wide);
|
void Set_ShowPos(u8 x, u8 y);
|
||||||
void Write_Command(u8 Data);
|
void Oled_DisplayFlip();
|
||||||
void Write_Data(u8 Data);
|
|
||||||
void GPIO_Init_OLED(void);
|
void GPIO_Init_OLED(void);
|
||||||
void Init_Oled(void);
|
void Init_Oled(uint8_t leftHanded);
|
||||||
u8* Data_Command(u8 len,u8* ptr);
|
u8* Data_Command(u8 len, u8* ptr);
|
||||||
void Reg_Command(u8 posi,u8 flag);
|
void Clear_Screen(void);//Clear the screen
|
||||||
void Clear_Screen(void);
|
/*Functions for writing to the screen*/
|
||||||
void Write_InitCommand_data(u32 Com_len,u8* data);
|
void OLED_DrawString(char* string, uint8_t length);
|
||||||
void Display_BG(void);
|
void OLED_DrawChar(char c, uint8_t x);
|
||||||
|
void OLED_DrawTwoNumber(uint8_t in, uint8_t x);
|
||||||
|
void OLED_DrawThreeNumber(uint16_t in, uint8_t x);
|
||||||
|
void OLED_DrawIDLELogo();
|
||||||
#endif
|
#endif
|
||||||
/******************************** END OF FILE *********************************/
|
/******************************** END OF FILE *********************************/
|
||||||
|
|||||||
21
workspace/ts100/inc/PID.h
Normal file
21
workspace/ts100/inc/PID.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* PID.h
|
||||||
|
*
|
||||||
|
* Created on: 20 Sep 2016
|
||||||
|
* Author: ralim
|
||||||
|
*
|
||||||
|
* Functions for computing the PID for the iron temp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PID_H_
|
||||||
|
#define PID_H_
|
||||||
|
#include "Analog.h"
|
||||||
|
#include "Interrupt.h"
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint32_t kp, ki, kd; //PID values
|
||||||
|
} pidSettings;
|
||||||
|
|
||||||
|
int32_t computePID(uint16_t setpoint);
|
||||||
|
void setupPID(void);
|
||||||
|
#endif /* PID_H_ */
|
||||||
@@ -1,68 +1,37 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
/*
|
||||||
Brief : <20>ײ<EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Author : bure
|
* Defines for the device
|
||||||
Modified by Ben V. Brown into English
|
* These houses the settings for the device hardware
|
||||||
*******************************************************************************/
|
*/
|
||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
|
#include "stm32f10x_gpio.h"
|
||||||
#define PRODUCT_INFO "TS100"
|
|
||||||
#define MCU_TYPE "STM32F103T8"
|
|
||||||
#define ADC_TYPE "MCU's ADC"
|
|
||||||
#define FPGA_TYPE "None"
|
|
||||||
#define SCH_VER "2.46"
|
|
||||||
// #define SSD1316 1
|
|
||||||
// #define MFTSEEED "Manufacturer"
|
|
||||||
// #define MFTMINI "Manufacturer"
|
|
||||||
|
|
||||||
#define SPIx SPI1
|
|
||||||
#define FLASH_PAGE 0x0400
|
|
||||||
//--------------------------- key Definitions ------------------------------//
|
//--------------------------- key Definitions ------------------------------//
|
||||||
#define KEY1_PIN GPIO_Pin_9 //PA8
|
#define KEY1_PIN GPIO_Pin_9 //PA8
|
||||||
#define KEY2_PIN GPIO_Pin_6 //PA6
|
#define KEY2_PIN GPIO_Pin_6 //PA6
|
||||||
#define KEY_1 !(GPIOA->IDR & KEY1_PIN)
|
|
||||||
#define KEY_2 !(GPIOA->IDR & KEY2_PIN)
|
|
||||||
#define KEY_DFU KEY_1
|
|
||||||
#define KEY_ON 0
|
|
||||||
|
|
||||||
#define I2C1_DMA_CHANNEL_TX DMA1_Channel6
|
#define KEY_A KEY1_PIN
|
||||||
#define I2C1_DMA_CHANNEL_RX DMA1_Channel7
|
#define KEY_B KEY2_PIN
|
||||||
|
#define BUT_A 0x01
|
||||||
|
#define BUT_B 0x02
|
||||||
|
|
||||||
#define I2C2_DMA_CHANNEL_TX DMA1_Channel4
|
|
||||||
#define I2C2_DMA_CHANNEL_RX DMA1_Channel5
|
|
||||||
|
|
||||||
#define I2C1_DR_Address 0x40005410
|
//--------------------------- OLED ------------------------------//
|
||||||
#define I2C2_DR_Address 0x40005810
|
|
||||||
|
|
||||||
#define SERIAL_NO1 (*(u32*)0x1FFFF7E8)
|
|
||||||
#define SERIAL_NO2 (*(u32*)0x1FFFF7EC)
|
|
||||||
#define SERIAL_NO3 (*(u32*)0x1FFFF7F0)
|
|
||||||
|
|
||||||
//--------------------------- OLED <20><>ؿ<EFBFBD><D8BF><EFBFBD><EFBFBD>ź<EFBFBD> ------------------------------//
|
|
||||||
#define OLED_RST_PIN GPIO_Pin_8 //PA9
|
#define OLED_RST_PIN GPIO_Pin_8 //PA9
|
||||||
#define OLED_RST() GPIO_ResetBits(GPIOA, OLED_RST_PIN)
|
#define OLED_RST() GPIO_ResetBits(GPIOA, OLED_RST_PIN)
|
||||||
#define OLED_ACT() GPIO_SetBits (GPIOA, OLED_RST_PIN)
|
#define OLED_ACT() GPIO_SetBits (GPIOA, OLED_RST_PIN)
|
||||||
|
|
||||||
//------------------------------ <EFBFBD><EFBFBD><EFBFBD>ȿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD> --------------------------------//
|
//------------------------------ Iron Heater --------------------------------//
|
||||||
#define HEAT_PIN GPIO_Pin_4 //PA15(JTDI)
|
#define HEAT_PIN GPIO_Pin_4
|
||||||
|
#define HEAT_OFF() GPIOB->BRR = HEAT_PIN
|
||||||
|
#define HEAT_ON() GPIOB->BSRR = HEAT_PIN
|
||||||
|
|
||||||
#define HEAT_OFF() GPIOB->BRR = HEAT_PIN//GPIO_ResetBits(GPIOB, HEAT_PIN)
|
//-----------------------Battery voltage measurement---------------------------------------//
|
||||||
#define HEAT_ON() GPIOB->BSRR = HEAT_PIN//GPIO_SetBits (GPIOB, HEAT_PIN)
|
|
||||||
|
|
||||||
//---------------------<2D><><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD>--VB---------------------------------------//
|
|
||||||
#define VB_PIN GPIO_Pin_1 //PB1(Ai9)
|
#define VB_PIN GPIO_Pin_1 //PB1(Ai9)
|
||||||
//----------------------------ADX345 INT1,INT2--------------------------------//
|
|
||||||
|
//----------------------------Accelerometer INT1,INT2--------------------------------//
|
||||||
#define INT1_PIN GPIO_Pin_5 //PB5
|
#define INT1_PIN GPIO_Pin_5 //PB5
|
||||||
#define INT2_PIN GPIO_Pin_3 //PB3
|
#define INT2_PIN GPIO_Pin_3 //PB3
|
||||||
//------------------------------ GPIO <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD> -------------------------------//
|
|
||||||
|
|
||||||
#define GPIOA_OUTPUT() GPIOA->ODR = 0xFFFF;
|
//--------------------------------- RCC Clock Config ---------------------------------//
|
||||||
#define GPIOA_L_DEF() GPIOA->CRL = 0x08888888; /* Ai7 K2 xxx xxx xxx xxx xxx xxx */
|
|
||||||
#define GPIOA_H_DEF() GPIOA->CRH = 0x8BBBB883; /* xxx SWC SWD D+ D- xxx K1 nCR */
|
|
||||||
|
|
||||||
#define GPIOB_OUTPUT() GPIOB->ODR = 0xFFFF;
|
|
||||||
#define GPIOB_L_DEF() GPIOB->CRL = 0x44838800; /* SDA SCL It1 Po It2 xxx Ai9 Ai8 */
|
|
||||||
#define GPIOB_H_DEF() GPIOB->CRH = 0x88888888; /* xxx xxx xxx xxx xxx xxx xxx xxx */
|
|
||||||
|
|
||||||
//--------------------------------- RCC <20><><EFBFBD><EFBFBD> ---------------------------------//
|
|
||||||
|
|
||||||
#define RCC_PLL_EN() RCC->CR |= 0x01000000;// PLL En
|
#define RCC_PLL_EN() RCC->CR |= 0x01000000;// PLL En
|
||||||
|
|
||||||
@@ -77,4 +46,3 @@
|
|||||||
||+-------Bit22 = 1 USB prescaler is PLL clock
|
||+-------Bit22 = 1 USB prescaler is PLL clock
|
||||||
++--------Bits31~27 Reserved*/
|
++--------Bits31~27 Reserved*/
|
||||||
|
|
||||||
/******************************** END OF FILE *********************************/
|
|
||||||
|
|||||||
38
workspace/ts100/inc/Settings.h
Normal file
38
workspace/ts100/inc/Settings.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Settings.h
|
||||||
|
*
|
||||||
|
* Created on: 29 Sep 2016
|
||||||
|
* Author: Ralim
|
||||||
|
*
|
||||||
|
* Houses the system settings and allows saving / restoring from flash
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SETTINGS_H_
|
||||||
|
#define SETTINGS_H_
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "stm32f10x_flash.h"
|
||||||
|
#define SETTINGSVERSION 0x03 /*Change this if you change the struct below to prevent people getting out of sync*/
|
||||||
|
#define SETTINGSOPTIONSCOUNT 6 /*Number of settings in the settings menu*/
|
||||||
|
#define MOTION_HIGH (0x00)
|
||||||
|
#define MOTION_MED (0x10)
|
||||||
|
#define MOTION_LOW (0x20)
|
||||||
|
/*
|
||||||
|
* This struct must be a multiple of 2 bytes as it is saved / restored from flash in uint16_t chunks
|
||||||
|
*/
|
||||||
|
struct {
|
||||||
|
uint32_t SolderingTemp; //current setpoint for the iron
|
||||||
|
uint32_t SleepTemp; //temp to drop to in sleep
|
||||||
|
uint8_t version; //Used to track if a reset is needed on firmware upgrade
|
||||||
|
uint8_t SleepTime; //minutes timeout to sleep
|
||||||
|
uint8_t cutoutVoltage:5; //The voltage we cutout at for undervoltage
|
||||||
|
uint8_t movementEnabled:1; //If movement is enabled
|
||||||
|
uint8_t displayTempInF:1; //If we need to convert the C reading to F
|
||||||
|
uint8_t flipDisplay:1; //If true we want to invert the display for lefties
|
||||||
|
uint8_t sensitivity:7; //Sensitivity of accelerometer
|
||||||
|
uint16_t tempCalibration; //Temperature calibration value
|
||||||
|
} systemSettings;
|
||||||
|
|
||||||
|
void saveSettings();
|
||||||
|
void restoreSettings();
|
||||||
|
void resetSettings();
|
||||||
|
#endif /* SETTINGS_H_ */
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
|
||||||
File Name : UI.h
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : Celery
|
|
||||||
Data: 2015/07/07
|
|
||||||
History:
|
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef _UI_H
|
|
||||||
#define _UI_H
|
|
||||||
|
|
||||||
#include "stm32f10x.h"
|
|
||||||
|
|
||||||
u32 Get_UpdataFlag(void);
|
|
||||||
void Set_UpdataFlag(u32 Cont);
|
|
||||||
void APP_Init(void);
|
|
||||||
u32 Calculation_TWork(u8 Flag);
|
|
||||||
void Temp_SetProc(void);
|
|
||||||
void Display_Temp(u8 x, s16 Temp);
|
|
||||||
void Show_Notice(void);
|
|
||||||
void Show_Warning(void);
|
|
||||||
void Show_MiniTS(void);
|
|
||||||
void Show_TempDown(s16 Temp, s16 Dst_Temp);
|
|
||||||
void Set_TemperatureShowFlag(u8 flag);
|
|
||||||
s16 TemperatureShow_Change(u8 flag, s16 Tmp);
|
|
||||||
u8 Get_TemperatureShowFlag(void);
|
|
||||||
|
|
||||||
void Show_Triangle(u8 empty, u8 fill);
|
|
||||||
void Shift_Char(u8* ptr, u8 pos);
|
|
||||||
void Show_Set(void);
|
|
||||||
void Show_OrderChar(u8* ptr, u8 num, u8 width);
|
|
||||||
u8 Reverse_Bin8(u8 data);
|
|
||||||
void Show_ReverseChar(u8* ptr, u8 num, u8 width, u8 direction);
|
|
||||||
u8 Show_TempReverse(u8 num, u8 width, u8 direction);
|
|
||||||
void Show_HeatingIcon(u32 ht_flag, u16 active);
|
|
||||||
void Display_Str(u8 x, char* str);
|
|
||||||
void Display_Str10(u8 x, char* str);
|
|
||||||
void Clear_Pervious(u16 data);
|
|
||||||
void Print_Integer(s32 data, u8 posi);
|
|
||||||
u8 Roll_Num(u16 Step, u8 Flag);
|
|
||||||
void OLed_Display(void);
|
|
||||||
void Show_Cal(u8 flag);
|
|
||||||
void Show_Config(void);
|
|
||||||
#endif
|
|
||||||
/******************************** END OF FILE *********************************/
|
|
||||||
@@ -1,404 +0,0 @@
|
|||||||
#ifndef _WORDLIB_H
|
|
||||||
#define _WORDLIB_H
|
|
||||||
|
|
||||||
const u8 wordlib[] = { //16*16 <20><><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD>
|
|
||||||
0x00,0x00,0x00,0xF8,0xFE,0x03,0x01,0x01,0x01,0x03,0xFE,0xFC,0xF0,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x3F,0x7F,0xE0,0x80,0x80,0x80,0xC0,0x7F,0x3F,0x07,0x00,0x00,0x00,/*"0",0*/
|
|
||||||
0x00,0x00,0x00,0x08,0x04,0x04,0x06,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x00,0x00,0x00,0x00,/*"1",1*/
|
|
||||||
0x00,0x00,0x00,0x06,0x07,0x01,0x01,0x01,0x81,0xC3,0x7F,0x3E,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0xE0,0xF0,0xD8,0xCC,0xC6,0xC3,0xC0,0xC0,0xE0,0x00,0x00,0x00,0x00,/*"2",2*/
|
|
||||||
0x00,0x00,0x00,0x06,0x07,0x81,0x81,0x81,0xC1,0x63,0x3F,0x1E,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0xE0,0xC0,0x80,0x80,0x81,0x81,0xC3,0x7F,0x3E,0x00,0x00,0x00,0x00,/*"3",3*/
|
|
||||||
0x00,0x00,0x00,0x00,0xC0,0x60,0x38,0x0C,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x06,0x07,0x05,0x04,0x04,0x84,0xFF,0xFF,0xC4,0x84,0x06,0x00,0x00,0x00,/*"4",4*/
|
|
||||||
0x00,0x00,0x00,0xFF,0xFF,0x83,0x83,0x83,0x83,0x83,0x83,0x03,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0xE0,0xC0,0x80,0x80,0x80,0x80,0xC1,0x7F,0x3F,0x08,0x00,0x00,0x00,/*"5",5*/
|
|
||||||
0x00,0x00,0x00,0xE0,0xF8,0x9C,0x8E,0xC2,0xC3,0xC1,0x81,0x81,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x3F,0x7F,0xC0,0x80,0x80,0x80,0x80,0xC1,0x7F,0x3F,0x00,0x00,0x00,/*"6",6*/
|
|
||||||
0x00,0x00,0x00,0x0F,0x03,0x03,0x03,0x03,0x83,0xE3,0x3B,0x0F,0x03,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x80,0xE0,0x78,0x1E,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,/*"7",7*/
|
|
||||||
0x00,0x00,0x18,0x7E,0x7E,0xC3,0x81,0x81,0x81,0x81,0x67,0x7E,0x3C,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x1C,0x7E,0xFF,0xC1,0x80,0x80,0x80,0x81,0xE3,0x7F,0x3C,0x00,0x00,0x00,/*"8",8*/
|
|
||||||
0x00,0x00,0x78,0xFE,0xC6,0x03,0x01,0x01,0x01,0x03,0x9E,0xFC,0xF0,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x01,0x01,0x83,0x83,0xC3,0x61,0x71,0x3F,0x0F,0x01,0x00,0x00,0x00,/*"9",9*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",10*/
|
|
||||||
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x01,0x01,0x01,0x00,//"+",11
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,//"-",12
|
|
||||||
|
|
||||||
0x0E,0x11,0x11,0x0E,0xE0,0xF8,0x0C,0x06,0x03,0x01,0x01,0x01,0x01,0x02,0x1E,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x0F,0x3F,0x70,0xC0,0x80,0x80,0x80,0x80,0x80,0x40,0x20,0x00,/*"<22><>",13*/
|
|
||||||
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,//":",14
|
|
||||||
|
|
||||||
0x08,0x14,0x22,0x14,0x08,0x02,0x02,0xFE,0x06,0x02,0x02,0x02,0xC2,0x02,0x06,0x1E,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xFF,0x81,0x81,0x01,0x01,0x03,0x00,0x00,0x00,/*"<22>H",15*/
|
|
||||||
|
|
||||||
0xC0,0x30,0x08,0x04,0x04,0x02,0xFA,0xAA,0xFA,0x02,0x04,0x04,0x08,0x30,0xC0,0x00,
|
|
||||||
0x07,0x18,0x20,0x40,0x58,0xA4,0xDB,0xDE,0xDB,0xA4,0x58,0x40,0x20,0x18,0x07,0x00,/*"<22>¶ȼ<C2B6>",16*/
|
|
||||||
};
|
|
||||||
|
|
||||||
const u8 Maplib[] = {
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,
|
|
||||||
0x98,0xBF,0xBF,0x98,0x88,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x20,0x60,0x60,0x60,0x60,0x60,0x60,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
|
|
||||||
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
|
|
||||||
0x90,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x70,0xF8,0x88,0x84,0x82,0x82,0x83,
|
|
||||||
0x83,0x83,0x83,0x83,0x83,0x82,0x82,0x82,0x82,0x83,0x83,0x83,0x83,0x83,0x83,0x82,
|
|
||||||
0x82,0x82,0x82,0x82,0x86,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,
|
|
||||||
0x84,0x84,0x84,0x84,0x84,0x84,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,/*"C:\Users\888\Desktop\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.BMP",0*/
|
|
||||||
|
|
||||||
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,
|
|
||||||
0xB0,0xFE,0xFE,0xB0,0x90,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x20,0x60,0x60,0x60,0x60,0x60,0x60,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
|
|
||||||
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
|
|
||||||
0x90,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x70,0xF8,0x88,0x84,0x82,0x82,0x83,
|
|
||||||
0x83,0x83,0x83,0x83,0x83,0x82,0x82,0x82,0x82,0x83,0x83,0x83,0x83,0x83,0x83,0x82,
|
|
||||||
0x82,0x82,0x82,0x82,0x86,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,
|
|
||||||
0x84,0x84,0x84,0x84,0x84,0x84,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,/*"C:\Users\888\Desktop\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.BMP",0*/
|
|
||||||
|
|
||||||
// 0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0x00,0x00,0xF0,0xF0,0xF0,0x00,0x00,0xF0,0xF0,0x00,//"<22><>ͷ"2//
|
|
||||||
// 0x01,0x03,0x07,0x0F,0x1F,0x3F,0x00,0x00,0x0F,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,
|
|
||||||
0x00,0xF0,0xF0,0x00,0x00,0xF0,0xF0,0xF0,0x00,0x00,0xFC,0xF8,0xF0,0xE0,0xC0,0x80, ///"<22><>ͷ"7///
|
|
||||||
0x00,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x0F,0x00,0x00,0x3F,0x1F,0x0F,0x07,0x03,0x01,
|
|
||||||
// 0x00,0xF8,0xF8,0x00,0x00,0xF8,0xF8,0xF8,0xF8,0x00,0x00,0xFE,0xFE,0xF8,0xE0,0x80,
|
|
||||||
// 0x00,0x1F,0x1F,0x00,0x00,0x1F,0x1F,0x1F,0x1F,0x00,0x00,0x7F,0x7F,0x1F,0x07,0x01 //"<22><>ͷ8"//
|
|
||||||
};
|
|
||||||
|
|
||||||
const u8 Maplib1[] = {/* 14 * 16*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",15*/
|
|
||||||
0x00,0x01,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x81,0xC6,0x7E,0x38,
|
|
||||||
0x00,0x80,0xFF,0xFF,0x81,0x81,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,/*"P",0*/
|
|
||||||
0x00,0x20,0x20,0x20,0xE0,0xE0,0x00,0x80,0x40,0x40,0x20,0x60,0xC0,0x40,
|
|
||||||
0x00,0x80,0x80,0x80,0xFF,0xFF,0x81,0x80,0x80,0x80,0x00,0x00,0x00,0x00,/*"r",1*/
|
|
||||||
0x00,0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x20,0x40,0x40,0x80,0x00,0x00,
|
|
||||||
0x00,0x00,0x3F,0x7F,0x44,0x84,0x84,0x84,0x84,0x84,0x84,0x47,0x27,0x00,/*"e",2*/
|
|
||||||
0x00,0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x20,0x40,0x40,0xC0,0x00,0x00,
|
|
||||||
0x00,0x00,0x20,0xC3,0x82,0x86,0x84,0x84,0x8C,0x8C,0x88,0x78,0x30,0x00,/*"s",3*/
|
|
||||||
0x00,0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x20,0x40,0x40,0xC0,0x00,0x00,
|
|
||||||
0x00,0x00,0x20,0xC3,0x82,0x86,0x84,0x84,0x8C,0x8C,0x88,0x78,0x30,0x00,/*"s",4*/
|
|
||||||
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0x60,0x20,0x10,0x18,0x0C,0x86,
|
|
||||||
0xE0,0xE0,0xE0,0xEC,0xFC,0xF2,0xF3,0xF1,0xF0,0xF8,0xEC,0xE4,0xE4,0xE2,0xE3,0x01,/*"C:\Users\888\Desktop\sssss.BMP",0*/
|
|
||||||
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x40,0x20,0x30,0x18,0x0C,
|
|
||||||
0xC0,0xC0,0xC0,0xD8,0xF8,0xE4,0xE6,0xE3,0xE1,0xF1,0xD8,0xC8,0xC8,0xC4,0xC6,0x03,/*"C:\Users\888\Desktop\sssss.BMP",0*/
|
|
||||||
|
|
||||||
0xFC,0xFC,0xFC,0x00,0x00,0x00,0x00,0xC0,0x38,0x26,0x25,0x01,0x01,0x01,0x01,0x01,
|
|
||||||
0x01,0x01,0x01,0x02,0x7F,0x7F,0x7F,0x06,0x09,0x09,0x09,0x09,0x09,0x09,0x39,0x48,
|
|
||||||
0x48,0x48,0x48,0x30,0x10,0x08,0x08,0x04,/*"C:\Users\888\Desktop\<5C><><EFBFBD><EFBFBD>.BMP",0*/
|
|
||||||
|
|
||||||
0xFC,0xFC,0x00,0x00,0x00,0x00,0xC0,0x38,0x26,0x25,0x01,0x01,0x01,0x01,0x01,0x01,
|
|
||||||
0x01,0x01,0x02,0x02,0x7F,0x7F,0x06,0x09,0x09,0x09,0x09,0x09,0x09,0x39,0x48,0x48,
|
|
||||||
0x48,0x48,0x30,0x10,0x08,0x08,0x04,0x04,/*"C:\Users\888\Desktop\<5C><><EFBFBD><EFBFBD>.BMP",0*/
|
|
||||||
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0x60,0x30,0x18,0x0C,0x86,
|
|
||||||
0x00,0xE0,0xE0,0xEC,0xF4,0xF6,0xF6,0xFB,0xF5,0xE8,0xE8,0xE4,0xE2,0xE2,0xE1,0x00,/*"δ<><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>",0*/
|
|
||||||
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x60,0x30,0x18,0x0C,
|
|
||||||
0x00,0xC0,0xC0,0xD8,0xE8,0xEC,0xEC,0xF6,0xEB,0xD1,0xD1,0xC8,0xC4,0xC4,0xC2,0x01,/*"δ<><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>",0*/
|
|
||||||
|
|
||||||
0xFE,0xFE,0xFE,0x80,0x40,0x40,0x60,0x58,0x54,0x02,0x02,0x02,0x02,0x02,0x02,0x84,
|
|
||||||
0x3F,0x3F,0x3F,0x00,0x01,0x01,0x01,0x01,0x01,0x07,0x05,0x05,0x06,0x02,0x01,0x00,/*"δ<><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>",0*/
|
|
||||||
|
|
||||||
0xFE,0xFE,0x80,0x40,0x40,0x60,0x58,0x54,0x02,0x02,0x02,0x02,0x02,0x02,0x84,0x84,
|
|
||||||
0x3F,0x3F,0x00,0x01,0x01,0x01,0x01,0x01,0x07,0x05,0x05,0x06,0x02,0x01,0x00,0x00,/*"δ<><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>",0*/
|
|
||||||
};
|
|
||||||
|
|
||||||
const u8 MiniTS[] = {/*16*16*/
|
|
||||||
0x01,0xF9,0xFF,0x3F,0xFF,0xF0,0x80,0x00,0x80,0xF0,0x7E,0xFF,0xFF,0xFF,0x01,0x01,
|
|
||||||
0x80,0xFF,0xFF,0x80,0x83,0x1F,0xFF,0xF8,0x3F,0x87,0x80,0xFF,0xFF,0xFF,0x80,0x80,/*"M",0*/
|
|
||||||
0x00,0x00,0x00,0x20,0x20,0x20,0x63,0xE3,0xE3,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x80,0x00,0x00,0x00,/*"i",1*/
|
|
||||||
0x00,0x20,0xE0,0xE0,0xE0,0xC0,0x40,0x60,0x20,0x20,0x60,0xC0,0xC0,0x00,0x00,0x00,
|
|
||||||
0x00,0x80,0xFF,0xFF,0xFF,0x80,0x80,0x00,0x00,0x80,0x80,0xFF,0xFF,0x80,0x80,0x00,/*"n",2*/
|
|
||||||
0x00,0x00,0x00,0x20,0x20,0x20,0x63,0xE3,0xE3,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x80,0x00,0x00,0x00,/*"i",3*/
|
|
||||||
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"-",4*/
|
|
||||||
0x00,0x06,0x07,0x03,0x01,0x01,0xFF,0xFF,0xFF,0x01,0x01,0x01,0x03,0x0F,0x0C,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x80,0x80,0xFF,0xFF,0xFF,0x80,0x80,0x00,0x00,0x00,0x00,0x00,/*"T",5*/
|
|
||||||
0x00,0x00,0x00,0x80,0xC0,0x40,0x60,0x20,0x20,0x60,0x40,0xC0,0x80,0x00,0x00,0x00,
|
|
||||||
0x00,0x0E,0x3F,0x7F,0xE1,0x80,0x80,0x80,0x80,0x80,0xC0,0x71,0x7F,0x3F,0x00,0x00,/*"o",6*/
|
|
||||||
0x00,0x00,0x00,0x80,0xC0,0x40,0x60,0x20,0x20,0x60,0x40,0xC0,0x80,0x00,0x00,0x00,
|
|
||||||
0x00,0x0E,0x3F,0x7F,0xE1,0x80,0x80,0x80,0x80,0x80,0xC0,0x71,0x7F,0x3F,0x00,0x00,/*"o",7*/
|
|
||||||
0x00,0x00,0x00,0x01,0x01,0x01,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x80,0x00,0x00,0x00,/*"l",8*/
|
|
||||||
0x00,0x00,0x00,0x80,0xC0,0x40,0x60,0x20,0x20,0x60,0x40,0xC0,0xC0,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x20,0xE3,0xC3,0x86,0x86,0x84,0x8C,0x8C,0x8C,0xF8,0x78,0x30,0x00,0x00,/*"s",9*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",10*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",11*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",12*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",13*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",14*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",15*/
|
|
||||||
};
|
|
||||||
//const u8 Arrow[] = {/*16*16*/
|
|
||||||
// 0x00,0x03,0x0E,0x18,0x60,0xC3,0x06,0x18,0x70,0xC0,0x00,0x00,0x00,0x80,0x60,0x38,
|
|
||||||
// 0x0C,0x83,0xC1,0x30,0x0C,0x07,0x01,0x00,/*"<22><>",0*/
|
|
||||||
|
|
||||||
// 0x00,0x00,0xC0,0x60,0x18,0x0C,0xC3,0x71,0x18,0x06,0x03,0x00,0x00,0x01,0x03,0x0C,
|
|
||||||
// 0x30,0x61,0x87,0x0C,0x30,0xE0,0x80,0x00,/*"<22><>",0*/
|
|
||||||
|
|
||||||
// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",0*/
|
|
||||||
//};
|
|
||||||
const u8 Triangle[] = {/*16*16*/
|
|
||||||
0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0xFE,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x01,0x01,0x02,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x3F,0x00,0x00,0x00,/*"<22><><EFBFBD><EFBFBD>",0*/
|
|
||||||
|
|
||||||
0x00,0x00,0xFE,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x80,0x80,0x00,
|
|
||||||
0x00,0x00,0x3F,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x01,0x01,0x00,0x00,0x00,/*"<22>ҡ<EFBFBD>",0*/
|
|
||||||
|
|
||||||
0x00,0x80,0x80,0xC0,0xC0,0x60,0x60,0x30,0x30,0x18,0x18,0x0C,0x0C,0xFE,0x00,0x00,
|
|
||||||
0x00,0x01,0x01,0x03,0x03,0x06,0x06,0x0C,0x0C,0x18,0x18,0x30,0x30,0x7F,0x00,0x00,/*"<22>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD>",0*/
|
|
||||||
|
|
||||||
0x00,0x00,0xFE,0x0C,0x0C,0x18,0x18,0x30,0x30,0x60,0x60,0xC0,0xC0,0x80,0x80,0x00,
|
|
||||||
0x00,0x00,0x7F,0x30,0x30,0x18,0x18,0x0C,0x0C,0x06,0x06,0x03,0x03,0x01,0x01,0x00,/*"<22>Ӵ<EFBFBD><D3B4>ҡ<EFBFBD>",0*/
|
|
||||||
|
|
||||||
0x80,0x80,0xC0,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFE,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x01,0x01,0x03,0x03,0x07,0x07,0x0F,0x0F,0x1F,0x1F,0x3F,0x00,0x00,0x00,/*"<22><><EFBFBD><EFBFBD>",1*/
|
|
||||||
|
|
||||||
0x00,0x00,0xFE,0xFC,0xFC,0xF8,0xF8,0xF0,0xF0,0xE0,0xE0,0xC0,0xC0,0x80,0x80,0x00,
|
|
||||||
0x00,0x00,0x3F,0x1F,0x1F,0x0F,0x0F,0x07,0x07,0x03,0x03,0x01,0x01,0x00,0x00,0x00,/*"<22>ҡ<EFBFBD>",1*/
|
|
||||||
};
|
|
||||||
|
|
||||||
const u8 IhIcon[] = {
|
|
||||||
0x00,0xF0,0xFE,0xFF,0xF0,0x00,
|
|
||||||
0x00,0x7F,0x7F,0x7F,0x7F,0x00,/*"<22><><EFBFBD><EFBFBD>",0*/
|
|
||||||
|
|
||||||
0xFF,0x0F,0xE1,0xE0,0x0F,0xFF,
|
|
||||||
0xFF,0x80,0xBF,0xBF,0x80,0xFF,/*"<22><><EFBFBD><EFBFBD>",0*/
|
|
||||||
};
|
|
||||||
const u8 TempIcon[] = {/*16*16*/
|
|
||||||
0x10,0x18,0x8C,0xC6,0x63,0x63,0xC6,0x8C,0x18,0x10,
|
|
||||||
0x42,0x63,0x31,0x18,0x0C,0x0C,0x18,0x31,0x63,0x42,/*"10*16",0*/
|
|
||||||
|
|
||||||
0x00,0xF0,0x1E,0x1F,0xF0,0x00,
|
|
||||||
0x00,0xFF,0x80,0x80,0xFF,0x00,/*"6*16",0*/
|
|
||||||
|
|
||||||
0x42,0xC6,0x8C,0x18,0x30,0x30,0x18,0x8C,0xC6,0x42,
|
|
||||||
0x08,0x18,0x31,0x63,0xC6,0xC6,0x63,0x31,0x18,0x08,/*"10*16",1*/
|
|
||||||
|
|
||||||
0x8C,0x8C,0xC6,0xC6,0x8C,0x8C,0xC6,0xC6,0x8C,0x8C,
|
|
||||||
0x31,0x31,0x18,0x18,0x31,0x31,0x18,0x18,0x31,0x31,/*"10*16",2*/
|
|
||||||
|
|
||||||
|
|
||||||
0x00,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x8C,0x00,
|
|
||||||
0x00,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x00,/*"<22>¶<EFBFBD>ƽ<EFBFBD><C6BD>",0*/
|
|
||||||
|
|
||||||
0x80,0xC0,0x60,0x30,0x98,0xCC,0x66,0x33,0x33,0x66,0xCC,0x98,0x30,0x60,0xC0,0x80,
|
|
||||||
0x88,0xCC,0x66,0x33,0x19,0x0C,0x06,0x03,0x03,0x06,0x0C,0x19,0x33,0x66,0xCC,0x88,/*"<22><><EFBFBD><EFBFBD>",0*/
|
|
||||||
|
|
||||||
0x11,0x33,0x66,0xCC,0x98,0x30,0x60,0xC0,0xC0,0x60,0x30,0x98,0xCC,0x66,0x33,0x11,
|
|
||||||
0x01,0x03,0x06,0x0C,0x19,0x33,0x66,0xCC,0xCC,0x66,0x33,0x19,0x0C,0x06,0x03,0x01,/*"<22><><EFBFBD><EFBFBD>",0*/
|
|
||||||
};
|
|
||||||
|
|
||||||
const u8 Warning[] = {/*10*16*/
|
|
||||||
0x01,0xFF,0x00,0xE1,0x1F,0xE0,0x00,0xFF,0x01,0x00,0x00,0x01,0x1E,0x01,0x00,0x01,
|
|
||||||
0x1E,0x01,0x00,0x00,/*"W",0*/
|
|
||||||
0x00,0x60,0x10,0x10,0x90,0x90,0xE0,0x00,0x00,0x00,0x00,0x0E,0x11,0x11,0x10,0x08,
|
|
||||||
0x1F,0x18,0x00,0x00,/*"a",1*/
|
|
||||||
0x10,0x10,0xF0,0x40,0x20,0x10,0x10,0x30,0x00,0x00,0x10,0x10,0x1F,0x10,0x10,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,/*"r",2*/
|
|
||||||
0x10,0xF0,0x20,0x10,0x10,0x10,0x10,0xE0,0x00,0x00,0x10,0x1F,0x10,0x00,0x00,0x00,
|
|
||||||
0x10,0x1F,0x10,0x00,/*"n",3*/
|
|
||||||
0x00,0x00,0x10,0x13,0xF3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x1F,0x10,
|
|
||||||
0x10,0x00,0x00,0x00,/*"i",4*/
|
|
||||||
0x10,0xF0,0x20,0x10,0x10,0x10,0x10,0xE0,0x00,0x00,0x10,0x1F,0x10,0x00,0x00,0x00,
|
|
||||||
0x10,0x1F,0x10,0x00,/*"n",5*/
|
|
||||||
0x00,0xE0,0x10,0x10,0x10,0x10,0xF0,0x10,0x00,0x00,0x00,0x7D,0x8A,0x8A,0x8A,0x8A,
|
|
||||||
0x91,0x70,0x00,0x00,/*"g",6*/
|
|
||||||
|
|
||||||
0x00,0x00,0x00,0x80,0xE0,0xF8,0xFE,0x07,0x07,0xFE,0xF8,0xE0,0x80,0x00,0x00,0x00,
|
|
||||||
0x10,0x1C,0x1F,0x1F,0x1F,0x1F,0x1F,0x12,0x12,0x1F,0x1F,0x1F,0x1F,0x1F,0x1C,0x10,/*"C:\Users\888\Desktop\attention.bmp",0*/
|
|
||||||
};
|
|
||||||
const u8 SenErr[] = {/*10*16*/
|
|
||||||
0x00,0x1C,0x22,0x21,0x41,0x41,0x41,0x82,0x07,0x00,0x00,0x1E,0x08,0x10,0x10,0x10,
|
|
||||||
0x10,0x08,0x07,0x00,/*"S",0*/
|
|
||||||
0x00,0xC0,0xA0,0x90,0x90,0x90,0x90,0xA0,0xC0,0x00,0x00,0x07,0x08,0x10,0x10,0x10,
|
|
||||||
0x10,0x08,0x04,0x00,/*"e",1*/
|
|
||||||
0x10,0xF0,0x20,0x10,0x10,0x10,0x10,0xE0,0x00,0x00,0x10,0x1F,0x10,0x00,0x00,0x00,
|
|
||||||
0x10,0x1F,0x10,0x00,/*"n",2*/
|
|
||||||
0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,/*"-",3*/
|
|
||||||
0x01,0xFF,0x21,0x21,0x21,0x21,0xF9,0x03,0x04,0x00,0x10,0x1F,0x10,0x10,0x10,0x10,
|
|
||||||
0x10,0x18,0x04,0x00,/*"E",4*/
|
|
||||||
0x00,0x10,0x10,0xF0,0x40,0x20,0x10,0x10,0x30,0x00,0x00,0x10,0x10,0x1F,0x10,0x10,
|
|
||||||
0x00,0x00,0x00,0x00,/*"r",5*/
|
|
||||||
0x00,0x10,0x10,0xF0,0x40,0x20,0x10,0x10,0x30,0x00,0x00,0x10,0x10,0x1F,0x10,0x10,
|
|
||||||
0x00,0x00,0x00,0x00,/*"r",6*/
|
|
||||||
|
|
||||||
};
|
|
||||||
const u8 HighVt[] = {/*10*16*/
|
|
||||||
0x01,0xFF,0x41,0x40,0x40,0x40,0x41,0xFF,0x01,0x00,0x10,0x1F,0x10,0x00,0x00,0x00,
|
|
||||||
0x10,0x1F,0x10,0x00,/*"H",0*/
|
|
||||||
0x00,0x00,0x10,0x13,0xF3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x1F,0x10,
|
|
||||||
0x10,0x00,0x00,0x00,/*"i",1*/
|
|
||||||
0x00,0x00,0xE0,0x10,0x10,0x10,0x10,0xF0,0x10,0x00,0x00,0x60,0x9D,0x8A,0x8A,0x8A,
|
|
||||||
0x8A,0x91,0x70,0x00,/*"g",2*/
|
|
||||||
0x01,0xFF,0x20,0x10,0x10,0x10,0x10,0xE0,0x00,0x00,0x10,0x1F,0x10,0x00,0x00,0x00,
|
|
||||||
0x10,0x1F,0x10,0x00,/*"h",3*/
|
|
||||||
0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,/*"-",3*/
|
|
||||||
0x01,0x07,0x79,0x80,0x00,0x80,0x79,0x07,0x01,0x00,0x00,0x00,0x00,0x07,0x1C,0x07,
|
|
||||||
0x00,0x00,0x00,0x00,/*"V",5*/
|
|
||||||
0x00,0x00,0x10,0x10,0xFE,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x10,
|
|
||||||
0x10,0x08,0x00,0x00,/*"t",6*/
|
|
||||||
};
|
|
||||||
const u8 LowVot[] = {/*10*16*/
|
|
||||||
0x01,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x1F,0x10,0x10,0x10,0x10,
|
|
||||||
0x10,0x18,0x04,0x00,/*"L",0*/
|
|
||||||
0x00,0xC0,0x20,0x10,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0x07,0x08,0x10,0x10,0x10,
|
|
||||||
0x10,0x08,0x07,0x00,/*"o",1*/
|
|
||||||
0x10,0xF0,0x00,0x10,0xF0,0x10,0x00,0xF0,0x10,0x00,0x00,0x03,0x1C,0x03,0x00,0x03,
|
|
||||||
0x1C,0x03,0x00,0x00,/*"w",2*/
|
|
||||||
0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,/*"-",3*/
|
|
||||||
0x01,0x07,0x79,0x80,0x00,0x80,0x79,0x07,0x01,0x00,0x00,0x00,0x00,0x07,0x1C,0x07,
|
|
||||||
0x00,0x00,0x00,0x00,/*"V",4*/
|
|
||||||
0x00,0xC0,0x20,0x10,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0x07,0x08,0x10,0x10,0x10,
|
|
||||||
0x10,0x08,0x07,0x00,/*"o",5*/
|
|
||||||
0x00,0x00,0x10,0x10,0xFE,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x10,
|
|
||||||
0x10,0x08,0x00,0x00,/*"t",6*/
|
|
||||||
};
|
|
||||||
|
|
||||||
const u8 Cal_UnDone[] = { /*16*16 Cal_Ud*/
|
|
||||||
0xE0,0x18,0x04,0x02,0x12,0x21,0x41,0x81,0x81,0x41,0x22,0x12,0x04,0x18,0xE0,0x00,
|
|
||||||
0x03,0x0C,0x10,0x20,0x28,0x44,0x42,0x41,0x41,0x42,0x24,0x28,0x10,0x0C,0x03,0x00,/*"Уʧ<D7BC><CAA7>.BMP",0*/
|
|
||||||
|
|
||||||
0xF0,0x0C,0x02,0x01,0x01,0x01,0x01,0x02,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x03,0x0C,0x08,0x10,0x10,0x10,0x10,0x08,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"C",0*/
|
|
||||||
0x00,0x60,0x10,0x10,0x90,0x90,0x90,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x0E,0x11,0x11,0x10,0x10,0x08,0x1F,0x10,0x18,0x00,0x00,0x00,0x00,0x00,0x00,/*"a",1*/
|
|
||||||
0x00,0x01,0x01,0x01,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x10,0x10,0x10,0x1F,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"l",2*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,/*"_",3*/
|
|
||||||
0x00,0x01,0x07,0x19,0xE0,0xB0,0x0D,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x10,0x18,0x17,0x00,0x01,0x16,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"X",4*/
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
const u8 Cal_Done[] = {/*16*16 Cal_Dn*/
|
|
||||||
0xE0,0x18,0x64,0xE2,0x82,0x01,0x01,0x01,0x01,0x01,0x82,0xE2,0x64,0x18,0xE0,0x00,
|
|
||||||
0x03,0x0C,0x10,0x21,0x27,0x4E,0x58,0x50,0x58,0x4E,0x27,0x21,0x10,0x0C,0x03,0x00,/*"У<D0A3>ɹ<EFBFBD>.BMP",0*/
|
|
||||||
|
|
||||||
0xF0,0x0C,0x02,0x01,0x01,0x01,0x01,0x02,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x03,0x0C,0x08,0x10,0x10,0x10,0x10,0x08,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"C",0*/
|
|
||||||
0x00,0x60,0x10,0x10,0x90,0x90,0x90,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x0E,0x11,0x11,0x10,0x10,0x08,0x1F,0x10,0x18,0x00,0x00,0x00,0x00,0x00,0x00,/*"a",1*/
|
|
||||||
0x00,0x01,0x01,0x01,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x10,0x10,0x10,0x1F,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"l",2*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,/*"_",3*/
|
|
||||||
0x01,0x07,0x79,0x80,0x00,0x80,0x79,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x07,0x1C,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"V",4*/
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
const u8 Number12[] = {/*12*16*/
|
|
||||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x10,0x20,
|
|
||||||
0x20,0x10,0x0F,0x00,0x00,0x00,0x00,0x00,/*"0",0*/
|
|
||||||
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,
|
|
||||||
0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,/*"1",1*/
|
|
||||||
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x28,0x24,
|
|
||||||
0x22,0x21,0x30,0x00,0x00,0x00,0x00,0x00,/*"2",2*/
|
|
||||||
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x20,0x20,
|
|
||||||
0x20,0x11,0x0E,0x00,0x00,0x00,0x00,0x00,/*"3",3*/
|
|
||||||
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x04,0x24,
|
|
||||||
0x24,0x3F,0x24,0x00,0x00,0x00,0x00,0x00,/*"4",4*/
|
|
||||||
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x21,0x20,
|
|
||||||
0x20,0x11,0x0E,0x00,0x00,0x00,0x00,0x00,/*"5",5*/
|
|
||||||
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x11,0x20,
|
|
||||||
0x20,0x11,0x0E,0x00,0x00,0x00,0x00,0x00,/*"6",6*/
|
|
||||||
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"7",7*/
|
|
||||||
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x21,
|
|
||||||
0x21,0x22,0x1C,0x00,0x00,0x00,0x00,0x00,/*"8",8*/
|
|
||||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x22,
|
|
||||||
0x22,0x11,0x0F,0x00,0x00,0x00,0x00,0x00,/*"9",9*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*".",10*/
|
|
||||||
};
|
|
||||||
|
|
||||||
const u8 Number10[] = { /*10*16*/
|
|
||||||
0x00,0xE0,0x18,0x04,0x04,0x04,0x04,0x18,0xE0,0x00,0x00,0x0F,0x30,0x40,0x40,0x40,
|
|
||||||
0x40,0x30,0x0F,0x00,/*"0",0*/
|
|
||||||
0x00,0x00,0x08,0x08,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x7F,0x40,
|
|
||||||
0x40,0x00,0x00,0x00,/*"1",1*/
|
|
||||||
0x00,0x78,0x04,0x04,0x04,0x04,0x04,0x88,0x70,0x00,0x00,0x60,0x50,0x48,0x44,0x42,
|
|
||||||
0x41,0x40,0x70,0x00,/*"2",2*/
|
|
||||||
0x00,0x38,0x04,0x04,0x84,0x84,0xC8,0x30,0x00,0x00,0x00,0x38,0x40,0x40,0x40,0x40,
|
|
||||||
0x40,0x21,0x1E,0x00,/*"3",3*/
|
|
||||||
0x00,0x00,0x80,0x60,0x10,0x08,0xFE,0x00,0x00,0x00,0x00,0x07,0x04,0x04,0x44,0x44,
|
|
||||||
0x7F,0x44,0x44,0x00,/*"4",4*/
|
|
||||||
0x00,0x00,0xFC,0x04,0x84,0x84,0x84,0x04,0x04,0x00,0x00,0x38,0x41,0x41,0x40,0x40,
|
|
||||||
0x40,0x21,0x1E,0x00,/*"5",5*/
|
|
||||||
0x00,0xC0,0x30,0x88,0x84,0x84,0x84,0x04,0x18,0x00,0x00,0x0F,0x31,0x40,0x40,0x40,
|
|
||||||
0x40,0x21,0x1E,0x00,/*"6",6*/
|
|
||||||
0x00,0x1C,0x04,0x04,0x84,0x44,0x34,0x0C,0x04,0x00,0x00,0x00,0x00,0x7E,0x01,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,/*"7",7*/
|
|
||||||
0x00,0x70,0x88,0x04,0x04,0x04,0x04,0x88,0x70,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,
|
|
||||||
0x41,0x22,0x1C,0x00,/*"8",8*/
|
|
||||||
0x00,0xF0,0x08,0x04,0x04,0x04,0x04,0x18,0xE0,0x00,0x00,0x30,0x41,0x42,0x42,0x42,
|
|
||||||
0x22,0x19,0x07,0x00,/*"9",9*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,/*" ",10*/
|
|
||||||
0x1C,0x1C,0xC0,0x30,0x08,0x04,0x04,0x04,0x08,0x30,0x00,0x00,0x07,0x18,0x20,0x40,
|
|
||||||
0x40,0x40,0x20,0x10,/*"<22><>",11*/
|
|
||||||
0x1C,0x12,0x0C,0x02,0x02,0xFE,0x82,0x82,0xE2,0x02,0x00,0x00,0x00,0x00,0x40,0x7F,
|
|
||||||
0x40,0x00,0x03,0x00,/*"<22>H",12*/
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
const u8 Guide[] = { /*16*16*/
|
|
||||||
0x00,0x00,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x18,0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<5C><><EFBFBD><EFBFBD>.BMP",0*/
|
|
||||||
0x00,0x00,0x30,0x60,0xC0,0x80,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x18,0x0C,0x06,0x03,0x19,0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,/*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<5C><><EFBFBD><EFBFBD>.BMP",0*/
|
|
||||||
0x00,0x00,0x30,0x60,0xC0,0x80,0x30,0x60,0xC0,0x80,0x30,0x60,0xC0,0x80,0x00,0x00,
|
|
||||||
0x00,0x00,0x18,0x0C,0x06,0x03,0x19,0x0C,0x06,0x03,0x19,0x0C,0x06,0x03,0x01,0x00,/*"D:\yinyongqin\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<5C><><EFBFBD><EFBFBD>.BMP",0*/
|
|
||||||
0x00,0x00,0x18,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*">",0*/
|
|
||||||
0x00,0x00,0x18,0x30,0x60,0xC0,0x98,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x0C,0x06,0x03,0x01,0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,/*">>",0*/
|
|
||||||
0x00,0x00,0x18,0x30,0x60,0xC0,0x98,0x30,0x60,0xC0,0x98,0x30,0x60,0xC0,0x80,0x00,
|
|
||||||
0x00,0x00,0x0C,0x06,0x03,0x01,0x0C,0x06,0x03,0x01,0x0C,0x06,0x03,0x01,0x00,0x00,/*">>>",0*/
|
|
||||||
};
|
|
||||||
const u8 Config[] = { /*16*16*/
|
|
||||||
0x00,0x00,0x00,0xC0,0xF0,0x38,0x08,0x04,0x04,0x04,0x04,0x08,0x08,0x1C,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x0F,0x1F,0x30,0x60,0x40,0x40,0x40,0x40,0x20,0x30,0x08,0x00,0x00,/*"C",0*/
|
|
||||||
0x00,0x00,0x00,0xC0,0xF0,0x18,0x0C,0x04,0x04,0x04,0x0C,0x18,0xF0,0xC0,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x07,0x1F,0x30,0x60,0x40,0x40,0x40,0x60,0x30,0x1F,0x07,0x00,0x00,/*"O",1*/
|
|
||||||
0x00,0x00,0x00,0x04,0xFC,0x1C,0x38,0xE0,0xC0,0x00,0x00,0x04,0xFC,0x04,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x40,0x7F,0x40,0x00,0x00,0x01,0x07,0x1E,0x38,0x7F,0x00,0x00,0x00,/*"N",2*/
|
|
||||||
0x00,0x00,0x00,0x04,0xFC,0xFC,0x84,0x84,0x84,0x84,0xE4,0x04,0x0C,0x10,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x40,0x7F,0x7F,0x40,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,/*"F",3*/
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0xFC,0xFC,0x04,0x04,0x04,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x7F,0x40,0x40,0x40,0x00,0x00,0x00,/*"I",4*/
|
|
||||||
0x00,0x00,0x00,0xC0,0xF0,0x38,0x08,0x04,0x04,0x04,0x04,0x0C,0x1C,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x07,0x1F,0x38,0x60,0x40,0x40,0x42,0x42,0x3E,0x3E,0x02,0x02,0x00,/*"G",5*/
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32f10x_conf.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @version V4.0.0
|
|
||||||
* @date 21-January-2013
|
|
||||||
* @brief Library configuration file.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
|
|
||||||
*
|
|
||||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
|
||||||
* You may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.st.com/software_license_agreement_liberty_v2
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __STM32F10x_CONF_H
|
|
||||||
#define __STM32F10x_CONF_H
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
/* Uncomment the line below to enable peripheral header file inclusion */
|
|
||||||
#include "stm32f10x_adc.h"
|
|
||||||
#include "stm32f10x_bkp.h"
|
|
||||||
#include "stm32f10x_can.h"
|
|
||||||
#include "stm32f10x_crc.h"
|
|
||||||
#include "stm32f10x_dac.h"
|
|
||||||
#include "stm32f10x_dbgmcu.h"
|
|
||||||
#include "stm32f10x_dma.h"
|
|
||||||
#include "stm32f10x_exti.h"
|
|
||||||
#include "stm32f10x_flash.h"
|
|
||||||
#include "stm32f10x_fsmc.h"
|
|
||||||
#include "stm32f10x_gpio.h"
|
|
||||||
#include "stm32f10x_i2c.h"
|
|
||||||
#include "stm32f10x_iwdg.h"
|
|
||||||
#include "stm32f10x_pwr.h"
|
|
||||||
#include "stm32f10x_rcc.h"
|
|
||||||
#include "stm32f10x_rtc.h"
|
|
||||||
#include "stm32f10x_sdio.h"
|
|
||||||
#include "stm32f10x_spi.h"
|
|
||||||
#include "stm32f10x_tim.h"
|
|
||||||
#include "stm32f10x_usart.h"
|
|
||||||
#include "stm32f10x_wwdg.h"
|
|
||||||
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/* Uncomment the line below to expanse the "assert_param" macro in the
|
|
||||||
Standard Peripheral Library drivers code */
|
|
||||||
/* #define USE_FULL_ASSERT 1 */
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
#ifdef USE_FULL_ASSERT
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Macro Name : assert_param
|
|
||||||
* Description : The assert_param macro is used for function's parameters check.
|
|
||||||
* Input : - expr: If expr is false, it calls assert_failed function
|
|
||||||
* which reports the name of the source file and the source
|
|
||||||
* line number of the call that failed.
|
|
||||||
* If expr is true, it returns no value.
|
|
||||||
* Return : None
|
|
||||||
*******************************************************************************/
|
|
||||||
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
|
|
||||||
/* Exported functions ------------------------------------------------------- */
|
|
||||||
void assert_failed(uint8_t* file, uint32_t line);
|
|
||||||
#else
|
|
||||||
#define assert_param(expr) ((void)0)
|
|
||||||
#endif /* USE_FULL_ASSERT */
|
|
||||||
|
|
||||||
#endif /* __STM32F10x_CONF_H */
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2013 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_bot.h
|
|
||||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __USB_BOT_H
|
|
||||||
#define __USB_BOT_H
|
|
||||||
|
|
||||||
typedef struct _Bulk_Only_CBW
|
|
||||||
{
|
|
||||||
u32 dSignature;
|
|
||||||
u32 dTag;
|
|
||||||
u32 dDataLength;
|
|
||||||
u8 bmFlags;
|
|
||||||
u8 bLUN;
|
|
||||||
u8 bCBLength;
|
|
||||||
u8 CB[16];
|
|
||||||
}
|
|
||||||
Bulk_Only_CBW;
|
|
||||||
|
|
||||||
/* Bulk-only Command Status Wrapper */
|
|
||||||
typedef struct _Bulk_Only_CSW
|
|
||||||
{
|
|
||||||
u32 dSignature;
|
|
||||||
u32 dTag;
|
|
||||||
u32 dDataResidue;
|
|
||||||
u8 bStatus;
|
|
||||||
}
|
|
||||||
Bulk_Only_CSW;
|
|
||||||
|
|
||||||
#define BOT_IDLE 0 /* Idle state */
|
|
||||||
#define BOT_DATA_OUT 1 /* Data Out state */
|
|
||||||
#define BOT_DATA_IN 2 /* Data In state */
|
|
||||||
#define BOT_DATA_IN_LAST 3 /* Last Data In Last */
|
|
||||||
#define BOT_CSW_Send 4 /* Command Status Wrapper */
|
|
||||||
#define BOT_ERROR 5 /* error state */
|
|
||||||
|
|
||||||
#define BOT_CBW_SIGNATURE 0x43425355
|
|
||||||
#define BOT_CSW_SIGNATURE 0x53425355
|
|
||||||
#define BOT_CBW_PACKET_LENGTH 31
|
|
||||||
|
|
||||||
#define CSW_DATA_LENGTH 0x000D
|
|
||||||
|
|
||||||
/* CSW Status Definitions */
|
|
||||||
#define CSW_CMD_PASSED 0x00
|
|
||||||
#define CSW_CMD_FAILED 0x01
|
|
||||||
#define CSW_PHASE_ERROR 0x02
|
|
||||||
|
|
||||||
#define SEND_CSW_DISABLE 0
|
|
||||||
#define SEND_CSW_ENABLE 1
|
|
||||||
|
|
||||||
#define DIR_IN 0
|
|
||||||
#define DIR_OUT 1
|
|
||||||
#define BOTH_DIR 2
|
|
||||||
|
|
||||||
#define BULK_MAX_PACKET_SIZE 0x00000040
|
|
||||||
|
|
||||||
extern u8 Bot_State;
|
|
||||||
extern u16 Data_Len;
|
|
||||||
extern u8 Bot_State;
|
|
||||||
extern Bulk_Only_CBW CBW;
|
|
||||||
extern Bulk_Only_CSW CSW;
|
|
||||||
extern u8 Bulk_Buff[];
|
|
||||||
|
|
||||||
void Mass_Storage_In (void);
|
|
||||||
void Mass_Storage_Out (void);
|
|
||||||
void CBW_Decode(void);
|
|
||||||
void Transfer_Data_Request(u8* Data_Pointer, u16 Data_Len);
|
|
||||||
void Set_CSW (u8 CSW_Status, u8 Send_Permission);
|
|
||||||
void Bot_Abort(u8 Direction);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
|
|
||||||
* File Name : usb_conf.h
|
|
||||||
* Author : MCD Application Team
|
|
||||||
* Version : V2.2.1
|
|
||||||
* Date : 09/22/2008
|
|
||||||
* Description : Mass Storage Demo configuration header
|
|
||||||
********************************************************************************
|
|
||||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
|
||||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
|
||||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
|
||||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
|
||||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
|
||||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
|
||||||
*******************************************************************************/
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef __USB_CONF_H
|
|
||||||
#define __USB_CONF_H
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* EP_NUM */
|
|
||||||
/* defines how many endpoints are used by the device */
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
#define EP_NUM (3)
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* -------------- Buffer Description Table -----------------*/
|
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
/* buffer table base address */
|
|
||||||
|
|
||||||
#define BTABLE_ADDRESS (0x00)
|
|
||||||
|
|
||||||
/* EP0 */
|
|
||||||
/* rx/tx buffer base address */
|
|
||||||
#define ENDP0_RXADDR (0x18)
|
|
||||||
#define ENDP0_TXADDR (0x58)
|
|
||||||
|
|
||||||
/* EP1 */
|
|
||||||
/* tx buffer base address */
|
|
||||||
#define ENDP1_TXADDR (0x98)
|
|
||||||
|
|
||||||
/* EP2 */
|
|
||||||
/* Rx buffer base address */
|
|
||||||
#define ENDP2_RXADDR (0xD8)
|
|
||||||
|
|
||||||
|
|
||||||
/* ISTR events */
|
|
||||||
/* IMR_MSK */
|
|
||||||
/* mask defining which events has to be handled */
|
|
||||||
/* by the device application software */
|
|
||||||
#define IMR_MSK (CNTR_CTRM | CNTR_RESETM)
|
|
||||||
|
|
||||||
/* CTR service routines */
|
|
||||||
/* associated to defined endpoints */
|
|
||||||
//#define EP1_IN_Callback NOP_Process
|
|
||||||
#define EP2_IN_Callback NOP_Process
|
|
||||||
#define EP3_IN_Callback NOP_Process
|
|
||||||
#define EP4_IN_Callback NOP_Process
|
|
||||||
#define EP5_IN_Callback NOP_Process
|
|
||||||
#define EP6_IN_Callback NOP_Process
|
|
||||||
#define EP7_IN_Callback NOP_Process
|
|
||||||
|
|
||||||
|
|
||||||
#define EP1_OUT_Callback NOP_Process
|
|
||||||
//#define EP2_OUT_Callback NOP_Process
|
|
||||||
#define EP3_OUT_Callback NOP_Process
|
|
||||||
#define EP4_OUT_Callback NOP_Process
|
|
||||||
#define EP5_OUT_Callback NOP_Process
|
|
||||||
#define EP6_OUT_Callback NOP_Process
|
|
||||||
#define EP7_OUT_Callback NOP_Process
|
|
||||||
|
|
||||||
#endif /* __USB_CONF_H */
|
|
||||||
|
|
||||||
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_desc.h
|
|
||||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __USB_DESC_H
|
|
||||||
#define __USB_DESC_H
|
|
||||||
|
|
||||||
#ifdef STM32F30X
|
|
||||||
#include "stm32f30x.h"
|
|
||||||
#else
|
|
||||||
#include "stm32f10x.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MASS_SIZ_DEVICE_DESC 18
|
|
||||||
#define MASS_SIZ_CONFIG_DESC 32
|
|
||||||
|
|
||||||
#define MASS_SIZ_STRING_LANGID 4
|
|
||||||
#define MASS_SIZ_STRING_VENDOR 38
|
|
||||||
#define MASS_SIZ_STRING_PRODUCT 38
|
|
||||||
#define MASS_SIZ_STRING_SERIAL 26
|
|
||||||
#define MASS_SIZ_STRING_INTERFACE 16
|
|
||||||
|
|
||||||
extern const u8 MASS_DeviceDescriptor[MASS_SIZ_DEVICE_DESC];
|
|
||||||
extern const u8 MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC];
|
|
||||||
|
|
||||||
extern const u8 MASS_StringLangID[MASS_SIZ_STRING_LANGID];
|
|
||||||
extern const u8 MASS_StringVendor[MASS_SIZ_STRING_VENDOR];
|
|
||||||
extern const u8 MASS_StringProduct[MASS_SIZ_STRING_PRODUCT];
|
|
||||||
extern u8 MASS_StringSerial[MASS_SIZ_STRING_SERIAL];
|
|
||||||
extern const u8 MASS_StringInterface[MASS_SIZ_STRING_INTERFACE];
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_istr.h
|
|
||||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __USB_ISTR_H
|
|
||||||
#define __USB_ISTR_H
|
|
||||||
|
|
||||||
#include "usb_conf.h"
|
|
||||||
|
|
||||||
void CTR_HP(void);
|
|
||||||
void USB_Istr(void);
|
|
||||||
|
|
||||||
/* function prototypes Automatically built defining related macros */
|
|
||||||
|
|
||||||
#ifdef CTR_CALLBACK
|
|
||||||
void CTR_Callback(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DOVR_CALLBACK
|
|
||||||
void DOVR_Callback(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ERR_CALLBACK
|
|
||||||
void ERR_Callback(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WKUP_CALLBACK
|
|
||||||
void WKUP_Callback(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SUSP_CALLBACK
|
|
||||||
void SUSP_Callback(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RESET_CALLBACK
|
|
||||||
void RESET_Callback(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SOF_CALLBACK
|
|
||||||
void SOF_Callback(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ESOF_CALLBACK
|
|
||||||
void ESOF_Callback(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void EP1_IN_Callback(void);
|
|
||||||
void EP2_IN_Callback(void);
|
|
||||||
void EP3_IN_Callback(void);
|
|
||||||
void EP4_IN_Callback(void);
|
|
||||||
void EP5_IN_Callback(void);
|
|
||||||
void EP6_IN_Callback(void);
|
|
||||||
void EP7_IN_Callback(void);
|
|
||||||
|
|
||||||
void EP1_OUT_Callback(void);
|
|
||||||
void EP2_OUT_Callback(void);
|
|
||||||
void EP3_OUT_Callback(void);
|
|
||||||
void EP4_OUT_Callback(void);
|
|
||||||
void EP5_OUT_Callback(void);
|
|
||||||
void EP6_OUT_Callback(void);
|
|
||||||
void EP7_OUT_Callback(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_prop.h
|
|
||||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __usb_prop_H
|
|
||||||
#define __usb_prop_H
|
|
||||||
|
|
||||||
#include "usb_core.h"
|
|
||||||
|
|
||||||
#ifdef STM32F30X
|
|
||||||
#include "stm32f30x.h"
|
|
||||||
#elif STM32F10X_HD
|
|
||||||
#include "stm32f10x.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define Mass_Storage_GetConfiguration NOP_Process
|
|
||||||
/* #define Mass_Storage_SetConfiguration NOP_Process*/
|
|
||||||
#define Mass_Storage_GetInterface NOP_Process
|
|
||||||
#define Mass_Storage_SetInterface NOP_Process
|
|
||||||
#define Mass_Storage_GetStatus NOP_Process
|
|
||||||
/* #define Mass_Storage_ClearFeature NOP_Process*/
|
|
||||||
#define Mass_Storage_SetEndPointFeature NOP_Process
|
|
||||||
#define Mass_Storage_SetDeviceFeature NOP_Process
|
|
||||||
/*#define Mass_Storage_SetDeviceAddress NOP_Process*/
|
|
||||||
|
|
||||||
/* MASS Storage Requests*/
|
|
||||||
#define GET_MAX_LUN 0xFE
|
|
||||||
#define MASS_STORAGE_RESET 0xFF
|
|
||||||
#define LUN_DATA_LENGTH 1
|
|
||||||
|
|
||||||
extern u32 Max_Lun;
|
|
||||||
|
|
||||||
void MASS_init(void);
|
|
||||||
void MASS_Reset(void);
|
|
||||||
void Mass_Storage_SetConfiguration(void);
|
|
||||||
void Mass_Storage_ClearFeature(void);
|
|
||||||
void Mass_Storage_SetDeviceAddress (void);
|
|
||||||
void MASS_Status_In (void);
|
|
||||||
void MASS_Status_Out (void);
|
|
||||||
RESULT MASS_Data_Setup(u8);
|
|
||||||
RESULT MASS_NoData_Setup(u8);
|
|
||||||
RESULT MASS_Get_Interface_Setting(u8 Interface, u8 AlternateSetting);
|
|
||||||
u8 *MASS_GetDeviceDescriptor(u16 );
|
|
||||||
u8 *MASS_GetConfigDescriptor(u16);
|
|
||||||
u8 *MASS_GetStringDescriptor(u16);
|
|
||||||
u8 *Get_Max_Lun(u16 Length);
|
|
||||||
void Get_SerialNum(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_pwr.h
|
|
||||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __USB_PWR_H
|
|
||||||
#define __USB_PWR_H
|
|
||||||
|
|
||||||
#include "usb_core.h"
|
|
||||||
|
|
||||||
typedef enum _RESUME_STATE
|
|
||||||
{
|
|
||||||
RESUME_EXTERNAL,
|
|
||||||
RESUME_INTERNAL,
|
|
||||||
RESUME_LATER,
|
|
||||||
RESUME_WAIT,
|
|
||||||
RESUME_START,
|
|
||||||
RESUME_ON,
|
|
||||||
RESUME_OFF,
|
|
||||||
RESUME_ESOF
|
|
||||||
} RESUME_STATE;
|
|
||||||
|
|
||||||
typedef enum _DEVICE_STATE
|
|
||||||
{
|
|
||||||
UNCONNECTED,
|
|
||||||
ATTACHED,
|
|
||||||
POWERED,
|
|
||||||
SUSPENDED,
|
|
||||||
ADDRESSED,
|
|
||||||
CONFIGURED
|
|
||||||
} DEVICE_STATE;
|
|
||||||
|
|
||||||
void Suspend(void);
|
|
||||||
void Resume_Init(void);
|
|
||||||
void Resume(RESUME_STATE eResumeSetVal);
|
|
||||||
RESULT PowerOn(void);
|
|
||||||
RESULT PowerOff(void);
|
|
||||||
|
|
||||||
extern vu32 bDeviceState; /* USB device status */
|
|
||||||
extern vu8 fSuspendEnabled; /* true when suspend is possible */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_scsi.h
|
|
||||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __USB_SCSI_H
|
|
||||||
#define __USB_SCSI_H
|
|
||||||
|
|
||||||
#ifdef STM32F30X
|
|
||||||
#include "stm32f30x.h"
|
|
||||||
#else
|
|
||||||
#include "stm32f10x.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* SCSI Commands */
|
|
||||||
#define SCSI_FORMAT_UNIT 0x04
|
|
||||||
#define SCSI_INQUIRY 0x12
|
|
||||||
#define SCSI_MODE_SELECT6 0x15
|
|
||||||
#define SCSI_MODE_SELECT10 0x55
|
|
||||||
#define SCSI_MODE_SENSE6 0x1A
|
|
||||||
#define SCSI_MODE_SENSE10 0x5A
|
|
||||||
#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1E
|
|
||||||
#define SCSI_READ6 0x08
|
|
||||||
#define SCSI_READ10 0x28
|
|
||||||
#define SCSI_READ12 0xA8
|
|
||||||
#define SCSI_READ16 0x88
|
|
||||||
|
|
||||||
#define SCSI_READ_CAPACITY10 0x25
|
|
||||||
#define SCSI_READ_CAPACITY16 0x9E
|
|
||||||
|
|
||||||
#define SCSI_REQUEST_SENSE 0x03
|
|
||||||
#define SCSI_START_STOP_UNIT 0x1B
|
|
||||||
#define SCSI_TEST_UNIT_READY 0x00
|
|
||||||
#define SCSI_WRITE6 0x0A
|
|
||||||
#define SCSI_WRITE10 0x2A
|
|
||||||
#define SCSI_WRITE12 0xAA
|
|
||||||
#define SCSI_WRITE16 0x8A
|
|
||||||
|
|
||||||
#define SCSI_VERIFY10 0x2F
|
|
||||||
#define SCSI_VERIFY12 0xAF
|
|
||||||
#define SCSI_VERIFY16 0x8F
|
|
||||||
|
|
||||||
#define SCSI_SEND_DIAGNOSTIC 0x1D
|
|
||||||
#define SCSI_READ_FORMAT_CAPACITIES 0x23
|
|
||||||
|
|
||||||
#define NO_SENSE 0
|
|
||||||
#define RECOVERED_ERROR 1
|
|
||||||
#define NOT_READY 2
|
|
||||||
#define MEDIUM_ERROR 3
|
|
||||||
#define HARDWARE_ERROR 4
|
|
||||||
#define ILLEGAL_REQUEST 5
|
|
||||||
#define UNIT_ATTENTION 6
|
|
||||||
#define DATA_PROTECT 7
|
|
||||||
#define BLANK_CHECK 8
|
|
||||||
#define VENDOR_SPECIFIC 9
|
|
||||||
#define COPY_ABORTED 10
|
|
||||||
#define ABORTED_COMMAND 11
|
|
||||||
#define VOLUME_OVERFLOW 13
|
|
||||||
#define MISCOMPARE 14
|
|
||||||
|
|
||||||
|
|
||||||
#define INVALID_COMMAND 0x20
|
|
||||||
#define INVALID_FIELED_IN_COMMAND 0x24
|
|
||||||
#define PARAMETER_LIST_LENGTH_ERROR 0x1A
|
|
||||||
#define INVALID_FIELD_IN_PARAMETER_LIST 0x26
|
|
||||||
#define ADDRESS_OUT_OF_RANGE 0x21
|
|
||||||
#define MEDIUM_NOT_PRESENT 0x3A
|
|
||||||
#define MEDIUM_HAVE_CHANGED 0x28
|
|
||||||
|
|
||||||
#define READ_FORMAT_CAPACITY_DATA_LEN 0x0C
|
|
||||||
#define READ_CAPACITY10_DATA_LEN 0x08
|
|
||||||
#define MODE_SENSE10_DATA_LEN 0x08
|
|
||||||
#define MODE_SENSE6_DATA_LEN 0x04
|
|
||||||
#define REQUEST_SENSE_DATA_LEN 0x12
|
|
||||||
#define STANDARD_INQUIRY_DATA_LEN 0x24 // 0x24
|
|
||||||
#define BLKVFY 0x04
|
|
||||||
|
|
||||||
extern u8 Page00_Inquiry_Data[];
|
|
||||||
extern u8 Standard_Inquiry_Data[];
|
|
||||||
extern u8 Mode_Sense6_data[];
|
|
||||||
extern u8 Mode_Sense10_data[];
|
|
||||||
extern u8 Scsi_Sense_Data[];
|
|
||||||
extern u8 ReadCapacity10_Data[];
|
|
||||||
|
|
||||||
extern u8 Bot_State;
|
|
||||||
|
|
||||||
void SCSI_Inquiry_Cmd(void);
|
|
||||||
void SCSI_ReadFormatCapacity_Cmd(void);
|
|
||||||
void SCSI_ReadCapacity10_Cmd(void);
|
|
||||||
void SCSI_RequestSense_Cmd (void);
|
|
||||||
void SCSI_Start_Stop_Unit_Cmd(void);
|
|
||||||
void SCSI_ModeSense6_Cmd (void);
|
|
||||||
void SCSI_ModeSense10_Cmd (void);
|
|
||||||
void SCSI_Write10_Cmd(u32 LBA , u32 BlockNbr);
|
|
||||||
void SCSI_Read10_Cmd(u32 LBA , u32 BlockNbr);
|
|
||||||
void SCSI_Verify10_Cmd(void);
|
|
||||||
|
|
||||||
void SCSI_Invalid_Cmd(void);
|
|
||||||
void SCSI_Valid_Cmd(void);
|
|
||||||
u8 SCSI_Address_Management(u8 Cmd , u32 LBA , u32 BlockNbr);
|
|
||||||
|
|
||||||
void Set_Scsi_Sense_Data(u8 Sens_Key, u8 Asc);
|
|
||||||
void SCSI_TestUnitReady_Cmd (void);
|
|
||||||
void SCSI_Format_Cmd (void);
|
|
||||||
|
|
||||||
#define SCSI_Prevent_Removal_Cmd SCSI_Valid_Cmd
|
|
||||||
|
|
||||||
// Invalid (Unsupported) commands
|
|
||||||
#define SCSI_READ_CAPACITY16_Cmd SCSI_Invalid_Cmd
|
|
||||||
|
|
||||||
//#define SCSI_FormatUnit_Cmd SCSI_Invalid_Cmd
|
|
||||||
#define SCSI_Write6_Cmd SCSI_Invalid_Cmd
|
|
||||||
#define SCSI_Write16_Cmd SCSI_Invalid_Cmd
|
|
||||||
#define SCSI_Write12_Cmd SCSI_Invalid_Cmd
|
|
||||||
#define SCSI_Read6_Cmd SCSI_Invalid_Cmd
|
|
||||||
#define SCSI_Read12_Cmd SCSI_Invalid_Cmd
|
|
||||||
#define SCSI_Read16_Cmd SCSI_Invalid_Cmd
|
|
||||||
#define SCSI_Send_Diagnostic_Cmd SCSI_Invalid_Cmd
|
|
||||||
#define SCSI_Mode_Select6_Cmd SCSI_Invalid_Cmd
|
|
||||||
#define SCSI_Mode_Select10_Cmd SCSI_Invalid_Cmd
|
|
||||||
#define SCSI_Verify12_Cmd SCSI_Invalid_Cmd
|
|
||||||
#define SCSI_Verify16_Cmd SCSI_Invalid_Cmd
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
|
|
||||||
@@ -1,284 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
|
||||||
File Name : 2FAT12.c
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : bure & Celery
|
|
||||||
Data: 2015/08/03
|
|
||||||
History:
|
|
||||||
2016/09/13 Ben V. Brown -> English comments and cleaning up
|
|
||||||
2015/08/03
|
|
||||||
*******************************************************************************/
|
|
||||||
#include <string.h>
|
|
||||||
#include "FAT12.h"
|
|
||||||
#include "Bios.h"
|
|
||||||
|
|
||||||
#define FAT_LEN 0x1800
|
|
||||||
#define FAT1_BASE 0x00001000 // FAT1
|
|
||||||
#define FAT2_BASE 0x00002800 // FAT2
|
|
||||||
#define ROOT_BASE 0x00004000 //
|
|
||||||
#define FILE_BASE 0x00008000 //
|
|
||||||
#define SEC_LEN 512 //length of a sector -> 512 Bytes
|
|
||||||
#define FAT1_SEC 0x0C // FAT1 Sector
|
|
||||||
#define FAT2_SEC 0x0C // FAT2 Sector
|
|
||||||
|
|
||||||
#define OK 0 //Error codes
|
|
||||||
#define SEC_ERR 1 //
|
|
||||||
#define FAT_ERR 2 //
|
|
||||||
#define OVER 3 //
|
|
||||||
#define NEW 4 //
|
|
||||||
#define END 0xFFF //
|
|
||||||
|
|
||||||
#define OW 0 //
|
|
||||||
#define RW 1 //
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: NextCluster
|
|
||||||
Description:
|
|
||||||
Input:
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 NextCluster(u16* pCluster) {
|
|
||||||
u16 FatNum;
|
|
||||||
u32 Addr = FAT1_BASE + (*pCluster + *pCluster / 2);
|
|
||||||
|
|
||||||
*(pCluster + 1) = *pCluster; // <20><><EFBFBD><EFBFBD>ǰһ<C7B0><D2BB><EFBFBD>غ<EFBFBD>
|
|
||||||
// *(pCluster+1)= 0;
|
|
||||||
if ((*pCluster >= END) || (*pCluster < 2))
|
|
||||||
return OK;
|
|
||||||
if (ReadDiskData((u8*) &FatNum, Addr, 2) != OK)
|
|
||||||
return SEC_ERR;
|
|
||||||
*pCluster = (*pCluster & 1) ? (FatNum >> 4) : (FatNum & 0x0FFF); // ָ<><D6B8><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: ReadFileSec
|
|
||||||
Description:
|
|
||||||
Input:
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 ReadFileSec(u8* pBuffer, u16* pCluster) {
|
|
||||||
u32 ReadAddr = FILE_BASE + SEC_LEN * (*pCluster - 2);
|
|
||||||
//This code appears to read the data in two chunks of 256 bytes...
|
|
||||||
if (ReadDiskData(pBuffer, ReadAddr, 256) != OK)
|
|
||||||
return SEC_ERR; //
|
|
||||||
pBuffer += 256;
|
|
||||||
ReadAddr += 256;
|
|
||||||
if (ReadDiskData(pBuffer, ReadAddr, 256) != OK)
|
|
||||||
return SEC_ERR; // Failed to read the sector
|
|
||||||
if (NextCluster(pCluster) != 0)
|
|
||||||
return FAT_ERR; //
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: ProgFileSec
|
|
||||||
Description:
|
|
||||||
Input:
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 ProgFileSec(u8* pBuffer, u16* pCluster) {
|
|
||||||
u16 Tmp;
|
|
||||||
u32 ProgAddr = FILE_BASE + SEC_LEN * (*pCluster - 2);
|
|
||||||
|
|
||||||
if (ProgDiskPage(pBuffer, ProgAddr) != OK)
|
|
||||||
return SEC_ERR; //
|
|
||||||
pBuffer += 256;
|
|
||||||
ProgAddr += 256;
|
|
||||||
if (ProgDiskPage(pBuffer, ProgAddr) != OK)
|
|
||||||
return SEC_ERR; //
|
|
||||||
Tmp = *pCluster;
|
|
||||||
switch (Tmp) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
if (SeekBlank(pBuffer, pCluster) != OK)
|
|
||||||
return OVER;
|
|
||||||
if (SetCluster(pBuffer, pCluster) != OK)
|
|
||||||
return SEC_ERR;
|
|
||||||
*(pCluster + 1) = Tmp;
|
|
||||||
return OK;
|
|
||||||
case END:
|
|
||||||
default:
|
|
||||||
if (NextCluster(pCluster) != OK)
|
|
||||||
return FAT_ERR;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: SeekBlank
|
|
||||||
Description:
|
|
||||||
Input:
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 SeekBlank(u8* pBuffer, u16* pCluster) {
|
|
||||||
u16 Offset, Tmp, i, n = 0;
|
|
||||||
u32 SecAddr;
|
|
||||||
|
|
||||||
for (i = 0; i < 4096; i++) {
|
|
||||||
Offset = i + i / 2;
|
|
||||||
if ((Offset % 256) == 0) {
|
|
||||||
SecAddr = FAT1_BASE + (Offset & (~0xFF));
|
|
||||||
if (ReadDiskData(pBuffer, SecAddr, 258) != 0)
|
|
||||||
return SEC_ERR;
|
|
||||||
}
|
|
||||||
Offset %= 256;
|
|
||||||
Tmp = pBuffer[Offset] + (pBuffer[Offset + 1] << 8);
|
|
||||||
Tmp = (i & 1) ? (Tmp >> 4) : (Tmp & 0xFFF);
|
|
||||||
if (Tmp == 0) {
|
|
||||||
*pCluster++ = i;
|
|
||||||
n++;
|
|
||||||
if (n > 1)
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*(pCluster + 1) = 0xFFF;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:
|
|
||||||
Description:
|
|
||||||
Input:
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 SetCluster(u8* pBuffer, u16* pCluster) {
|
|
||||||
u16 Offset, Tmp, i, k;
|
|
||||||
u32 SecAddr;
|
|
||||||
|
|
||||||
i = *pCluster; // <20><>ȡԭ<C8A1><D4AD>ǰ<EFBFBD>غ<EFBFBD>
|
|
||||||
k = *(pCluster + 1); // <20><>ȡ<EFBFBD><C8A1>һ<EFBFBD>غ<EFBFBD>
|
|
||||||
*pCluster = k;
|
|
||||||
Offset = i + i / 2;
|
|
||||||
SecAddr = FAT1_BASE + (Offset & (~0xFF));
|
|
||||||
Tmp = Offset & 0xFF;
|
|
||||||
if (ReadDiskData(pBuffer, SecAddr, 256) != 0)
|
|
||||||
return SEC_ERR;
|
|
||||||
if (i & 1)
|
|
||||||
pBuffer[Tmp] = ((k << 4) & 0xF0) + (pBuffer[Tmp] & 0x0F);
|
|
||||||
else
|
|
||||||
pBuffer[Tmp] = k;
|
|
||||||
if (Tmp++ < 256) {
|
|
||||||
if (i & 1)
|
|
||||||
pBuffer[Tmp] = k >> 4;
|
|
||||||
else
|
|
||||||
pBuffer[Tmp] = ((k >> 8) & 0x0F) + (pBuffer[Tmp] & 0xF0);
|
|
||||||
if (ProgDiskPage(pBuffer, SecAddr) != 0)
|
|
||||||
return SEC_ERR;
|
|
||||||
} else {
|
|
||||||
if (ProgDiskPage(pBuffer, SecAddr) != 0)
|
|
||||||
return SEC_ERR;
|
|
||||||
SecAddr += 256;
|
|
||||||
if (ReadDiskData(pBuffer, SecAddr, 256) != 0)
|
|
||||||
return SEC_ERR;
|
|
||||||
if (i & 1)
|
|
||||||
pBuffer[0] = k >> 4;
|
|
||||||
else
|
|
||||||
pBuffer[0] = ((k >> 8) & 0x0F) + (pBuffer[0] & 0xF0);
|
|
||||||
if (ProgDiskPage(pBuffer, SecAddr) != 0)
|
|
||||||
return SEC_ERR;
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:
|
|
||||||
Description:
|
|
||||||
Input:
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 FAT_SearchFile(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr,
|
|
||||||
u32* flag) {
|
|
||||||
u16 i, n;
|
|
||||||
|
|
||||||
*pCluster = 0;
|
|
||||||
for (*pDirAddr = ROOT_BASE; *pDirAddr < FILE_BASE;) {
|
|
||||||
if (ReadDiskData(pBuffer, *pDirAddr, 256) != OK)
|
|
||||||
return SEC_ERR;
|
|
||||||
for (n = 0; n < 256; n += 32) {
|
|
||||||
for (i = 0; i < 4; i++) {
|
|
||||||
if (pBuffer[n + i] != 0) {
|
|
||||||
if (pBuffer[n + i] != pFileName[i])
|
|
||||||
break;
|
|
||||||
if (i == 3) { // <20>ҵ<EFBFBD><D2B5>ļ<EFBFBD><C4BC><EFBFBD>
|
|
||||||
*pCluster = *(u16*) (pBuffer + n + 0x1A); // <20>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
return NEW; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD>
|
|
||||||
}
|
|
||||||
*pDirAddr += 32;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:OpenFileRd
|
|
||||||
Description: Opens a file for reading from
|
|
||||||
Input:
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 OpenFileRd(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr) {
|
|
||||||
u16 i, n;
|
|
||||||
|
|
||||||
*pCluster = 0;
|
|
||||||
for (*pDirAddr = ROOT_BASE; *pDirAddr < FILE_BASE;) {
|
|
||||||
if (ReadDiskData(pBuffer, *pDirAddr, 256) != OK)
|
|
||||||
return SEC_ERR;
|
|
||||||
for (n = 0; n < 256; n += 32) {
|
|
||||||
for (i = 0; i < 11; i++) {
|
|
||||||
if (pBuffer[n + i] != 0) {
|
|
||||||
if (pBuffer[n + i] != pFileName[i])
|
|
||||||
break;
|
|
||||||
if (i == 10) { // <20>ҵ<EFBFBD><D2B5>ļ<EFBFBD><C4BC><EFBFBD>
|
|
||||||
*pCluster = *(u16*) (pBuffer + n + 0x1A); // <20>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>غ<EFBFBD>
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
return NEW; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD>
|
|
||||||
}
|
|
||||||
*pDirAddr += 32;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return OVER;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: OpenFileWr
|
|
||||||
Description: Opens a file for writing to
|
|
||||||
Input:
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 OpenFileWr(u8* pBuffer, u8* pFileName, u16* pCluster, u32* pDirAddr) {
|
|
||||||
u16 i, n;
|
|
||||||
|
|
||||||
i = OpenFileRd(pBuffer, pFileName, pCluster, pDirAddr);
|
|
||||||
if (i != NEW)
|
|
||||||
return i;
|
|
||||||
else { // <20><>ǰ<EFBFBD><C7B0>Ϊ<EFBFBD>հ<EFBFBD>Ŀ¼<C4BF><C2BC>
|
|
||||||
if (SeekBlank(pBuffer, pCluster) != OK)
|
|
||||||
return OVER; // <20><>FAT<41><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
n = *pDirAddr & 0xFF; // nΪ<6E><CEAA>ǰҳĿ¼<C4BF><C2BC>
|
|
||||||
if (ReadDiskData(pBuffer, (*pDirAddr) - n, 256) != OK)
|
|
||||||
return SEC_ERR;
|
|
||||||
for (i = 0; i < 11; i++)
|
|
||||||
pBuffer[n + i] = pFileName[i]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC>
|
|
||||||
*(u16*) (pBuffer + n + 0x1A) = *pCluster;
|
|
||||||
if (ProgDiskPage(pBuffer, (*pDirAddr) - n) != OK)
|
|
||||||
return SEC_ERR;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: CloseFile
|
|
||||||
Description: Closes a file that was previously opened
|
|
||||||
Input:
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 CloseFile(u8* pBuffer, u32 Lenght, u16* pCluster, u32* pDirAddr) {
|
|
||||||
u16 n;
|
|
||||||
|
|
||||||
// *pCluster = *(pCluster+1); // <20><>ȡǰһ<C7B0><D2BB><EFBFBD>غ<EFBFBD>
|
|
||||||
*(pCluster + 1) = 0xFFF;
|
|
||||||
SetCluster(pBuffer, pCluster);
|
|
||||||
if (ReadDiskData(pBuffer, (*pDirAddr & (~0xFF)), 256) != OK)
|
|
||||||
return SEC_ERR;
|
|
||||||
*(u8*) (pBuffer + (*pDirAddr & 0xFF) + 0x0B) = 0x20;
|
|
||||||
*(u32*) (pBuffer + (*pDirAddr & 0xFF) + 0x1C) = Lenght;
|
|
||||||
if (ProgDiskPage(pBuffer, (*pDirAddr & (~0xFF))) != OK)
|
|
||||||
return SEC_ERR;
|
|
||||||
for (n = 0; n < FAT1_SEC; n++) {
|
|
||||||
if (ReadDiskData(pBuffer, FAT1_BASE + n * 256, 256) != OK)
|
|
||||||
return SEC_ERR;
|
|
||||||
if (ProgDiskPage(pBuffer, FAT2_BASE + n * 256) != OK)
|
|
||||||
return SEC_ERR;
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
/******************************** END OF FILE *********************************/
|
|
||||||
137
workspace/ts100/src/Analog.c
Normal file
137
workspace/ts100/src/Analog.c
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
/*
|
||||||
|
* Analog.c
|
||||||
|
*
|
||||||
|
* Created on: 20 Sep 2016
|
||||||
|
* Author: ralim
|
||||||
|
* Contains the functions related to reading and scaling the adc pins
|
||||||
|
* This is used for temperature and battery voltage sense
|
||||||
|
*/
|
||||||
|
#include "Analog.h"
|
||||||
|
|
||||||
|
//Reads the dc input and returns it as X10 voltage (ie 236 = 23.6V)
|
||||||
|
//Seems unstable below 9.5V input
|
||||||
|
uint16_t readDCVoltage() {
|
||||||
|
uint16_t reading = 0;
|
||||||
|
for (u8 i = 0; i < 10; i++) {
|
||||||
|
reading += ADC_GetConversionValue(ADC2);
|
||||||
|
}
|
||||||
|
reading /= 144; //take the average and convert to X10 voltage
|
||||||
|
return reading; //return the read voltage
|
||||||
|
}
|
||||||
|
|
||||||
|
//This reads the thermocouple in the tip
|
||||||
|
//This allows us to read it in X10 mode
|
||||||
|
//Returns temperature in C X10 mode
|
||||||
|
int16_t readTipTemp() {
|
||||||
|
static uint32_t rollingAverage[4];
|
||||||
|
static uint8_t rIndex = 0;
|
||||||
|
|
||||||
|
/*The head has a thermocouple inline with the heater
|
||||||
|
This is read by turning off the heater
|
||||||
|
Then read the output of the op-amp that is connected across the connections
|
||||||
|
*/
|
||||||
|
uint32_t ad_sum = 0;
|
||||||
|
uint32_t max = 0, min;
|
||||||
|
uint32_t ad_value, avg_data;
|
||||||
|
uint32_t timer = getIronTimer();
|
||||||
|
setIronTimer(0); //set the remaining time to zero
|
||||||
|
HEAT_OFF(); //heater must be off
|
||||||
|
delayMs(5); //wait for the heater to time out
|
||||||
|
uint8_t gMeas_cnt = 9; //how many measurements to make
|
||||||
|
max = ad_sum = min = Get_ADC1Value(0);
|
||||||
|
|
||||||
|
while (gMeas_cnt > 0) {
|
||||||
|
ad_value = Get_ADC1Value(0);
|
||||||
|
ad_sum += ad_value;
|
||||||
|
if (ad_value > max)
|
||||||
|
max = ad_value;
|
||||||
|
if (ad_value < min)
|
||||||
|
min = ad_value;
|
||||||
|
|
||||||
|
gMeas_cnt--;
|
||||||
|
}
|
||||||
|
setIronTimer(timer);
|
||||||
|
ad_sum = ad_sum - max - min; //remove the two outliers
|
||||||
|
avg_data = ad_sum / 8; //take the average
|
||||||
|
rollingAverage[rIndex] = avg_data;
|
||||||
|
rIndex = (rIndex + 1) % 4;
|
||||||
|
return (rollingAverage[0] + rollingAverage[1] + rollingAverage[2]
|
||||||
|
+ rollingAverage[3]) / 4; //get the average
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
Function:
|
||||||
|
Description:Reads the temperature of the on board temp sensor for calibration
|
||||||
|
http://www.analog.com/media/en/technical-documentation/data-sheets/TMP35_36_37.pdf
|
||||||
|
Output: The onboardTemp in C X 10
|
||||||
|
*******************************************************************************/
|
||||||
|
int readSensorTemp(void) {
|
||||||
|
static uint32_t rollingAverage[4];
|
||||||
|
static uint8_t rIndex = 0;
|
||||||
|
u32 ad_sum = 0;
|
||||||
|
u32 max, min;
|
||||||
|
u32 ad_value, avg_data, slide_data;
|
||||||
|
|
||||||
|
u8 gMeas_cnt = 9;
|
||||||
|
ad_sum = min = max = Get_ADC1Value(1);
|
||||||
|
while (gMeas_cnt > 0) {
|
||||||
|
ad_value = Get_ADC1Value(1);
|
||||||
|
ad_sum += ad_value;
|
||||||
|
if (ad_value > max)
|
||||||
|
max = ad_value;
|
||||||
|
if (ad_value < min)
|
||||||
|
min = ad_value;
|
||||||
|
gMeas_cnt--;
|
||||||
|
}
|
||||||
|
ad_sum = ad_sum - max - min;
|
||||||
|
avg_data = ad_sum / 8;
|
||||||
|
//^ Removes the two outliers from the data spread
|
||||||
|
|
||||||
|
rollingAverage[rIndex] = avg_data; //store this result
|
||||||
|
rIndex = (rIndex + 1) % 4; //move the index
|
||||||
|
slide_data = (rollingAverage[0] + rollingAverage[1] + rollingAverage[2]
|
||||||
|
+ rollingAverage[3]) / 4; //get the average
|
||||||
|
return (250 + (3300 * slide_data / 4096) - 750);
|
||||||
|
//(25 + ((10*(33*gSlide_data)/4096)-75));
|
||||||
|
//^ Convert the reading to C
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
volatile uint16_t ADC1ConvertedValue[2];
|
||||||
|
//returns the latest reading from ADC1 that was buffered using DMA
|
||||||
|
uint16_t Get_ADC1Value(uint8_t i) {
|
||||||
|
return ADC1ConvertedValue[i];
|
||||||
|
}
|
||||||
|
//This returns the calibrated temperature reading of the iron temp
|
||||||
|
//inputs : calibration value / wether to take a new reading or not
|
||||||
|
uint16_t readIronTemp(uint16_t calibration_temp, uint8_t read,
|
||||||
|
uint16_t setPointTemp) {
|
||||||
|
static uint16_t calTemp = 0;
|
||||||
|
static uint16_t lastVal = 0;
|
||||||
|
static uint16_t lastSetTemp;
|
||||||
|
if(setPointTemp!=0xFFFF)
|
||||||
|
lastSetTemp = setPointTemp;
|
||||||
|
if (calibration_temp != 0)
|
||||||
|
calTemp = calibration_temp;
|
||||||
|
|
||||||
|
if (read) {
|
||||||
|
int16_t compensation = 80 + 150 * (lastSetTemp - 1000) / 3000;
|
||||||
|
int16_t tipTemp = readTipTemp();
|
||||||
|
int16_t ColdJTemp = readSensorTemp();
|
||||||
|
if (lastSetTemp == 1000)
|
||||||
|
compensation -= 10;
|
||||||
|
|
||||||
|
if (lastSetTemp != 0) {
|
||||||
|
if (tipTemp > (compensation + calTemp))
|
||||||
|
tipTemp -= compensation;
|
||||||
|
}
|
||||||
|
if (ColdJTemp > 400)
|
||||||
|
ColdJTemp = 400;
|
||||||
|
lastVal = (tipTemp * 1000 + 807 * ColdJTemp - calTemp * 1000) / 807;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return lastVal;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,110 +1,17 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
/*
|
||||||
File Name : Bios.c
|
* Setup all the basic hardware in the system and handle timer3 tick
|
||||||
Version : S100 APP Ver 2.11
|
*/
|
||||||
Description:
|
|
||||||
Author : Celery
|
|
||||||
Data: 2015/07/07
|
|
||||||
History:
|
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include <Hardware.h>
|
|
||||||
#include <usb_lib.h>
|
|
||||||
#include "APP_Version.h"
|
|
||||||
#include "Bios.h"
|
#include "Bios.h"
|
||||||
#include "I2C.h"
|
#include "I2C.h"
|
||||||
#include "CTRL.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
#define ADC1_DR_Address ((u32)0x4001244C)
|
#define ADC1_DR_Address ((u32)0x4001244C)
|
||||||
|
volatile uint32_t gHeat_cnt = 0;
|
||||||
|
|
||||||
vu32 gTimeOut, gMs_timeout;
|
/*
|
||||||
volatile u32 gTime[8]; //times for timer storage
|
* Setup system clocks to run off internal oscillator at 48Mhz
|
||||||
//^-- gTime is automatically decremented on each firing of timer 2 if >0
|
*/
|
||||||
vu16 ADC1ConvertedValue[2];
|
|
||||||
vu32 gHeat_cnt = 0;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_AdcValue
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡADC ת<><D7AA><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:ת<><D7AA><EFBFBD><EFBFBD><EFBFBD>AD
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
u16 Get_AdcValue(u8 i) {
|
|
||||||
return ADC1ConvertedValue[i];
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_HeatingTime
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:heating_time <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void Set_HeatingTime(u32 heating_time) {
|
|
||||||
gHeat_cnt = heating_time;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_HeatingTime
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:<3A><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
||||||
*******************************************************************************/
|
|
||||||
u32 Get_HeatingTime(void) {
|
|
||||||
return gHeat_cnt;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:
|
|
||||||
Description: Init the global count down timers
|
|
||||||
*******************************************************************************/
|
|
||||||
void Init_Gtime(void) {
|
|
||||||
u8 i;
|
|
||||||
|
|
||||||
for (i = 0; i < 8; i++)
|
|
||||||
gTime[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Delay_Ms
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʱ<EFBFBD>ȴ<EFBFBD><C8B4>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void Delay_Ms(u32 ms) {
|
|
||||||
gMs_timeout = ms * 20;
|
|
||||||
while (gMs_timeout)
|
|
||||||
; // {if(Scan_key()!=0)break;}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Delay_HalfMs
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:ÿ<><C3BF>λΪ0.5<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʱ<EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>0.5<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void Delay_HalfMs(u32 ms) {
|
|
||||||
gMs_timeout = ms * 10;
|
|
||||||
while (gMs_timeout)
|
|
||||||
; // {if(Scan_key()!=0)break;}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: USB_Port
|
|
||||||
Description: Enables or disables the usb pins
|
|
||||||
Input: state == ENABLE or DISABLE
|
|
||||||
*******************************************************************************/
|
|
||||||
void USB_Port(u8 state) {
|
|
||||||
USB_DN_LOW();
|
|
||||||
USB_DP_LOW();
|
|
||||||
if (state == DISABLE) {
|
|
||||||
USB_DN_OUT();
|
|
||||||
USB_DP_OUT();
|
|
||||||
} else {
|
|
||||||
USB_DN_EN();
|
|
||||||
USB_DP_EN();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:RCC_Config
|
|
||||||
Description:Setup the system clocks to use internal HSE to run the system at 48Mhz
|
|
||||||
*******************************************************************************/
|
|
||||||
void RCC_Config(void) {
|
void RCC_Config(void) {
|
||||||
RCC_DeInit();
|
RCC_DeInit();
|
||||||
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
|
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
|
||||||
@@ -123,90 +30,77 @@ void RCC_Config(void) {
|
|||||||
|
|
||||||
RCC_AHBPeriphClockCmd(
|
RCC_AHBPeriphClockCmd(
|
||||||
RCC_AHBPeriph_SRAM | RCC_AHBPeriph_DMA1 | RCC_AHBPeriph_DMA2 |
|
RCC_AHBPeriph_SRAM | RCC_AHBPeriph_DMA1 | RCC_AHBPeriph_DMA2 |
|
||||||
RCC_AHBPeriph_FLITF, // Enable DMA1 clock ???
|
RCC_AHBPeriph_FLITF, ENABLE);
|
||||||
ENABLE);
|
|
||||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
|
||||||
RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2, //| RCC_APB2Periph_ADC3, //RCC_APB2Periph_TIM1,
|
RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2, ENABLE);
|
||||||
ENABLE);
|
|
||||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3, ENABLE);
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3, ENABLE);
|
||||||
|
|
||||||
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_Div1); // USBCLK = 48MHz
|
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_Div1); // USBCLK = 48MHz
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: NVIC_Config
|
|
||||||
Description: Configures the NVIC table in the hardware
|
|
||||||
Input: (tab_offset) the table offset for the NVIC
|
|
||||||
*******************************************************************************/
|
|
||||||
void NVIC_Config(u16 tab_offset) {
|
|
||||||
NVIC_InitTypeDef NVIC_InitStructure;
|
|
||||||
|
|
||||||
|
RCC_ClocksTypeDef RCC_Clocks;
|
||||||
|
RCC_GetClocksFreq(&RCC_Clocks);
|
||||||
|
SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000); //Enable the systick timer at 1ms
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Shift the NVIC (Interrupt table) location relative to flash start
|
||||||
|
*/
|
||||||
|
void NVIC_Config(u16 tab_offset) {
|
||||||
NVIC_SetVectorTable(NVIC_VectTab_FLASH, tab_offset);
|
NVIC_SetVectorTable(NVIC_VectTab_FLASH, tab_offset);
|
||||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
||||||
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
|
||||||
NVIC_Init(&NVIC_InitStructure);
|
|
||||||
}
|
}
|
||||||
/*******************************************************************************
|
/*
|
||||||
Function:GPIO_Config
|
* Setup the GPIO
|
||||||
Description: Configures all the GPIO into required states
|
*/
|
||||||
*******************************************************************************/
|
|
||||||
void GPIO_Config(void) {
|
void GPIO_Config(void) {
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE); // GPIOB & AFIO
|
||||||
|
|
||||||
GPIOA_OUTPUT()
|
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE);
|
||||||
;
|
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
|
||||||
GPIOA_L_DEF()
|
|
||||||
;
|
|
||||||
GPIOA_H_DEF()
|
|
||||||
;
|
|
||||||
|
|
||||||
GPIOB_OUTPUT()
|
//------ PA7 TMP36 Analog input ----------------------------------------//
|
||||||
;
|
|
||||||
GPIOB_L_DEF()
|
|
||||||
;
|
|
||||||
GPIOB_H_DEF()
|
|
||||||
;
|
|
||||||
|
|
||||||
//------ PA7 TMP36 Analog input ----------------------------------------//
|
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
|
||||||
//------ OLED_RST_PIN(PB9) ------------------------------------------------------------//
|
//------ OLED_RST_PIN(PB9) ---------------------------------------------//
|
||||||
GPIO_InitStructure.GPIO_Pin = OLED_RST_PIN;
|
GPIO_InitStructure.GPIO_Pin = OLED_RST_PIN;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
|
||||||
//------- Heat_Pin - Iron enable output PB4--------------------------------------------------------//
|
//------- Heat_Pin - Iron enable output PB4-----------------------------//
|
||||||
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE); //Disable PB4=JNTRST
|
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = HEAT_PIN;
|
GPIO_InitStructure.GPIO_Pin = HEAT_PIN;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
||||||
//------ PB0 Iron temp input---------------------------------------//
|
//----------- PB0 Iron temp input---------------------------------------//
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
||||||
//---------- INPUT Voltage Detection Pin VB PB1(Ai9) ---------------------------------------//
|
//---------- INPUT Voltage Detection Pin VB PB1(Ai9) -------------------//
|
||||||
GPIO_InitStructure.GPIO_Pin = VB_PIN;
|
GPIO_InitStructure.GPIO_Pin = VB_PIN;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
||||||
//-------- K1 = PA9, K2 = PA6 ----------------------------------------------------------//
|
//-------- K1 = PA9, K2 = PA6 ------------------------------------------//
|
||||||
GPIO_InitStructure.GPIO_Pin = KEY1_PIN | KEY2_PIN;
|
GPIO_InitStructure.GPIO_Pin = KEY1_PIN | KEY2_PIN;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
//--------INT 1 == PB5 -------------------------------------------------//
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;//pullup just in case something resets the accel
|
||||||
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
||||||
}
|
}
|
||||||
/*******************************************************************************
|
/*
|
||||||
Function: Adc_Init
|
* Init the ADC's
|
||||||
Description:Enable the ADC's and setup the DMA as well to automatically read them to system ram.
|
* Setup ADC1 to read via DMA to device ram automatically
|
||||||
*******************************************************************************/
|
*/
|
||||||
void Adc_Init(void) {
|
void Adc_Init(void) {
|
||||||
u32 timeout = 10 * 0x1000;
|
u32 timeout = 10 * 0x1000;
|
||||||
ADC_InitTypeDef ADC_InitStructure;
|
ADC_InitTypeDef ADC_InitStructure;
|
||||||
@@ -220,7 +114,8 @@ void Adc_Init(void) {
|
|||||||
DMA_InitStructure.DMA_BufferSize = 2;
|
DMA_InitStructure.DMA_BufferSize = 2;
|
||||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||||
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
|
DMA_InitStructure.DMA_PeripheralDataSize =
|
||||||
|
DMA_PeripheralDataSize_HalfWord;
|
||||||
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
|
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
|
||||||
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
|
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
|
||||||
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
|
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
|
||||||
@@ -250,9 +145,12 @@ void Adc_Init(void) {
|
|||||||
ADC_Init(ADC2, &ADC_InitStructure);
|
ADC_Init(ADC2, &ADC_InitStructure);
|
||||||
|
|
||||||
// ADC1,2 regular channel7 channel9 and channel8 configuration ----------//
|
// ADC1,2 regular channel7 channel9 and channel8 configuration ----------//
|
||||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 2, ADC_SampleTime_239Cycles5); //28 or 55
|
ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 2,
|
||||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 1, ADC_SampleTime_239Cycles5); //28 or 55
|
ADC_SampleTime_239Cycles5); //28 or 55
|
||||||
ADC_RegularChannelConfig(ADC2, ADC_Channel_9, 1, ADC_SampleTime_55Cycles5); //28 or 55
|
ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 1,
|
||||||
|
ADC_SampleTime_239Cycles5); //28 or 55
|
||||||
|
ADC_RegularChannelConfig(ADC2, ADC_Channel_9, 1,
|
||||||
|
ADC_SampleTime_55Cycles5); //28 or 55
|
||||||
|
|
||||||
/* Enable ADC1 DMA */
|
/* Enable ADC1 DMA */
|
||||||
ADC_DMACmd(ADC1, ENABLE);
|
ADC_DMACmd(ADC1, ENABLE);
|
||||||
@@ -275,43 +173,19 @@ void Adc_Init(void) {
|
|||||||
ADC_SoftwareStartConvCmd(ADC2, ENABLE);
|
ADC_SoftwareStartConvCmd(ADC2, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*
|
||||||
Function:
|
* Init Timer3 to fire every 50us to be used to control the irons software PWM
|
||||||
Description: Setup Timer2 to fire every 10ms
|
* This needs to be really fast as there is a cap used between this and the driver circuitry
|
||||||
*******************************************************************************/
|
* That prevents a stuck mcu heating the tip
|
||||||
void Init_Timer2(void) {
|
*/
|
||||||
NVIC_InitTypeDef NVIC_InitStructure;
|
|
||||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
|
||||||
|
|
||||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
|
|
||||||
|
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = 48 - 1; // (48MHz)/48 = 1MHz
|
|
||||||
TIM_TimeBaseStructure.TIM_Period = 10000 - 1; // Interrupt per 10mS
|
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
|
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
|
||||||
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
|
|
||||||
TIM_ARRPreloadConfig(TIM2, ENABLE);
|
|
||||||
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
|
|
||||||
TIM_Cmd(TIM2, ENABLE);
|
|
||||||
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
|
|
||||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
|
||||||
NVIC_Init(&NVIC_InitStructure);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:
|
|
||||||
Description: Init Timer3 to fire every 50us to be used to control the irons software PWM
|
|
||||||
*******************************************************************************/
|
|
||||||
void Init_Timer3(void) {
|
void Init_Timer3(void) {
|
||||||
NVIC_InitTypeDef NVIC_InitStructure;
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||||
|
|
||||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
|
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
|
||||||
|
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = 48 - 1; //(48MHz)/48 = 1MHz
|
TIM_TimeBaseStructure.TIM_Prescaler = 48 - 1; //(48MHz)/48 = 1MHz
|
||||||
TIM_TimeBaseStructure.TIM_Period = 50 - 1; // Interrupt per 50us
|
TIM_TimeBaseStructure.TIM_Period = 50 - 1; // Interrupt per 50us
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV2;
|
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV2;
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
|
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
|
||||||
@@ -325,50 +199,74 @@ void Init_Timer3(void) {
|
|||||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
}
|
}
|
||||||
/*******************************************************************************
|
//We want to enable the EXTI IRQ for the two buttons on PA6 and PA9
|
||||||
Function:TIM2_ISR
|
void Init_EXTI(void) {
|
||||||
Description:Handles Timer 2 tick. (10mS)
|
EXTI_InitTypeDef EXTI_InitStructure;
|
||||||
Automatically decrements all >0 values in gTime.
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
Also reads the buttons every 4 ticks
|
|
||||||
*******************************************************************************/
|
|
||||||
void TIM2_ISR(void) {
|
|
||||||
static u8 buttonReadDivider;
|
|
||||||
|
|
||||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update); // Clear interrupt flag
|
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,
|
||||||
for (u8 i = 0; i < 8; i++)
|
GPIO_PinSource6 | GPIO_PinSource9);
|
||||||
if (gTime[i] > 0)
|
|
||||||
gTime[i]--;
|
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,
|
||||||
|
GPIO_PinSource5); //PB5 == accelerometer
|
||||||
|
|
||||||
|
/* Configure EXTI5/6/9 line */
|
||||||
|
EXTI_InitStructure.EXTI_Line = EXTI_Line5 | EXTI_Line6 | EXTI_Line9;
|
||||||
|
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||||
|
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; //trigger on up and down
|
||||||
|
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
|
||||||
|
EXTI_Init(&EXTI_InitStructure);
|
||||||
|
|
||||||
|
/* Enable and set EXTI9_5 Interrupt to the lowest priority */
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||||
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
|
|
||||||
if (++buttonReadDivider % 4 == 0)
|
|
||||||
Scan_Key();
|
|
||||||
}
|
}
|
||||||
/*******************************************************************************
|
//Start the system watchdog with a timeout specified
|
||||||
Function: TIM3_ISR
|
//Note you cannot turn this off once you turn it on
|
||||||
Description:Sets the output pin as appropriate
|
void Start_Watchdog(uint32_t ms) {
|
||||||
If the Heat_cnt >0 then heater on, otherwise off.
|
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
|
||||||
*******************************************************************************/
|
|
||||||
|
/* IWDG counter clock: 40KHz(LSI) / 32 = 1.25 KHz (min:0.8ms -- max:3276.8ms */
|
||||||
|
IWDG_SetPrescaler(IWDG_Prescaler_32);
|
||||||
|
|
||||||
|
/* Set counter reload value to XXms */
|
||||||
|
IWDG_SetReload(ms * 10 / 8);
|
||||||
|
|
||||||
|
/* Reload IWDG counter */
|
||||||
|
IWDG_ReloadCounter();
|
||||||
|
|
||||||
|
/* Enable IWDG (the LSI oscillator will be enabled by hardware) */
|
||||||
|
IWDG_Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Reset the system watchdog
|
||||||
|
void Clear_Watchdog(void) {
|
||||||
|
IWDG_ReloadCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
//TIM3_ISR handles the tick of the timer 3 IRQ
|
||||||
void TIM3_ISR(void) {
|
void TIM3_ISR(void) {
|
||||||
volatile static u8 heat_flag = 0;
|
volatile static u8 heat_flag = 0;
|
||||||
|
//heat flag == used to make the pin toggle
|
||||||
|
//As the output is passed through a cap, the iron is on whilever we provide a square wave drive output
|
||||||
|
|
||||||
TIM_ClearITPendingBit(TIM3, TIM_IT_Update); // Clear interrupt flag
|
TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
|
||||||
|
// Clear interrupt flag
|
||||||
if (gTimeOut > 0)
|
|
||||||
gTimeOut--;
|
|
||||||
if (gMs_timeout > 0)
|
|
||||||
gMs_timeout--;
|
|
||||||
|
|
||||||
if (gHeat_cnt > 0) {
|
if (gHeat_cnt > 0) {
|
||||||
gHeat_cnt--;
|
--gHeat_cnt;
|
||||||
if (heat_flag)
|
if (heat_flag)
|
||||||
HEAT_OFF();
|
HEAT_OFF(); //write the pin off
|
||||||
else
|
else
|
||||||
HEAT_ON();
|
HEAT_ON(); //write the pin on
|
||||||
|
heat_flag = !heat_flag;
|
||||||
heat_flag = ~heat_flag;
|
} else {
|
||||||
}
|
HEAT_OFF(); //set the pin low for measurements
|
||||||
if (gHeat_cnt == 0) {
|
|
||||||
HEAT_OFF();
|
|
||||||
heat_flag = 0;
|
heat_flag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/******************************** END OF FILE *********************************/
|
|
||||||
|
|||||||
@@ -1,450 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
|
||||||
File Name : CTRL.c
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : Celery
|
|
||||||
Data: 2015/08/03
|
|
||||||
History:
|
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
2015/08/03 <20>Ż<EFBFBD><C5BB>ƶ<EFBFBD><C6B6>ж<EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "CTRL.h"
|
|
||||||
#include "Bios.h"
|
|
||||||
#include "UI.h"
|
|
||||||
#include "Hardware.h"
|
|
||||||
#include "S100V0_1.h"
|
|
||||||
#include "Disk.h"
|
|
||||||
#include "MMA8652FC.h"
|
|
||||||
|
|
||||||
#define HEATINGCYCLE 30
|
|
||||||
/******************************************************************************/
|
|
||||||
DEVICE_INFO_SYS device_info;
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
u8 gCtrl_status = 1;
|
|
||||||
//^ System current status / operating mode.
|
|
||||||
u16 gHt_flag = 0;
|
|
||||||
vs16 gTemp_data = 250; //
|
|
||||||
s16 gPrev_temp = 250; //
|
|
||||||
u8 gIs_restartkey = 0; //
|
|
||||||
u8 gPre_status = 1; //
|
|
||||||
|
|
||||||
const DEVICE_INFO_SYS info_def = { "2.13", //Ver
|
|
||||||
2000, //T_Standby; // 200C=1800 2520
|
|
||||||
3000, // T_Work; // 350C=3362,
|
|
||||||
100, //T_Step;
|
|
||||||
3 * 60 * 100, //Wait_Time; //3*60*100 3 minutes
|
|
||||||
6 * 60 * 100 // Idle_Time; //6*60*100 6 minutes
|
|
||||||
};
|
|
||||||
struct _pid {
|
|
||||||
s16 settemp; //Current ideal setpoint for the temp
|
|
||||||
s16 actualtemp; //Actual current temp of the tip
|
|
||||||
s16 err; //Error term
|
|
||||||
s16 err_last; //last error term
|
|
||||||
s32 ht_time; //
|
|
||||||
u16 kp, ki, kd; //Constants for the PID Controller
|
|
||||||
s32 integral; //
|
|
||||||
} pid;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Get_Ctrl_Status
|
|
||||||
Description: Returns the current operating Mode
|
|
||||||
Input:Void
|
|
||||||
Output:Current System Status
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 Get_CtrlStatus(void) {
|
|
||||||
return gCtrl_status;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Set_CtrlStatus
|
|
||||||
Description: Set the current operating Mode
|
|
||||||
Input:status uint8_t
|
|
||||||
Output:Void
|
|
||||||
*******************************************************************************/
|
|
||||||
void Set_CtrlStatus(u8 status) {
|
|
||||||
gCtrl_status = status;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Set_PrevTemp
|
|
||||||
Description:Set the previous temp record for the PID
|
|
||||||
Input:Previous Temp (int16_t)
|
|
||||||
Output:Void
|
|
||||||
*******************************************************************************/
|
|
||||||
void Set_PrevTemp(s16 temp) {
|
|
||||||
gPrev_temp = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Get_HtFlag
|
|
||||||
Description:
|
|
||||||
Input:Void
|
|
||||||
Output:Void
|
|
||||||
|
|
||||||
*******************************************************************************/
|
|
||||||
u16 Get_HtFlag(void) {
|
|
||||||
return gHt_flag;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:Get_TempVal
|
|
||||||
Description:
|
|
||||||
Input:Void
|
|
||||||
Output:Void
|
|
||||||
*******************************************************************************/
|
|
||||||
s16 Get_TempVal(void) {
|
|
||||||
return gTemp_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:System_Init
|
|
||||||
Description:Init the device info to be a known start value (as defined at top of CTRL.c)
|
|
||||||
Input:Void
|
|
||||||
Output:Void
|
|
||||||
*******************************************************************************/
|
|
||||||
void System_Init(void) {
|
|
||||||
memcpy((void*) &device_info, (void*) &info_def, sizeof(device_info));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:Pid_Init
|
|
||||||
Description:Inits the PID values to defaults (0 usually)
|
|
||||||
Input:Void
|
|
||||||
Output:Void
|
|
||||||
*******************************************************************************/
|
|
||||||
void Pid_Init(void) {
|
|
||||||
pid.settemp = 0;
|
|
||||||
pid.actualtemp = 0;
|
|
||||||
pid.err = 0;
|
|
||||||
pid.err_last = 0;
|
|
||||||
pid.integral = 0;
|
|
||||||
pid.ht_time = 0;
|
|
||||||
pid.kp = 15;
|
|
||||||
pid.ki = 2;
|
|
||||||
pid.kd = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:Pid_Realize
|
|
||||||
Description: Calculates the next heating value using the PID algorithum
|
|
||||||
Input:Current temp from the tip
|
|
||||||
Output:
|
|
||||||
*******************************************************************************/
|
|
||||||
u16 Pid_Realize(s16 temp) {
|
|
||||||
u8 index = 0, index1 = 1;
|
|
||||||
s16 d_err = 0;
|
|
||||||
|
|
||||||
pid.actualtemp = temp;
|
|
||||||
pid.err = pid.settemp - pid.actualtemp; //
|
|
||||||
|
|
||||||
if (pid.err >= 500)
|
|
||||||
index = 0;
|
|
||||||
else {
|
|
||||||
index = 1;
|
|
||||||
pid.integral += pid.err; //
|
|
||||||
}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
if (pid.settemp < pid.actualtemp) {
|
|
||||||
d_err = pid.actualtemp - pid.settemp;
|
|
||||||
if (d_err > 20) {
|
|
||||||
pid.integral = 0; //
|
|
||||||
index1 = 0;
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
if (pid.err <= 30)
|
|
||||||
index1 = 0;
|
|
||||||
else
|
|
||||||
index1 = 1;
|
|
||||||
pid.ht_time = pid.kp * pid.err + pid.ki * index * pid.integral
|
|
||||||
+ pid.kd * (pid.err - pid.err_last) * index1;
|
|
||||||
pid.err_last = pid.err;
|
|
||||||
|
|
||||||
if (pid.ht_time <= 0)
|
|
||||||
pid.ht_time = 0;
|
|
||||||
else if (pid.ht_time > 30 * 200)
|
|
||||||
pid.ht_time = 30 * 200;
|
|
||||||
|
|
||||||
return pid.ht_time;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:Heating_Time
|
|
||||||
Description:Calcuates the on time for the heating element
|
|
||||||
Input: (temp) current Tip Temp, (wk_temp) current ideal setpoint temp
|
|
||||||
Output: The ON time for the heater element
|
|
||||||
*******************************************************************************/
|
|
||||||
u32 Heating_Time(s16 temp, s16 wk_temp) {
|
|
||||||
u32 heat_timecnt;
|
|
||||||
|
|
||||||
pid.settemp = wk_temp;
|
|
||||||
if (wk_temp > temp) {
|
|
||||||
if (wk_temp - temp >= 18)
|
|
||||||
gHt_flag = 0; //<2F><><EFBFBD><EFBFBD>
|
|
||||||
else
|
|
||||||
gHt_flag = 2; //<2F><><EFBFBD><EFBFBD>
|
|
||||||
} else {
|
|
||||||
if (temp - wk_temp <= 18)
|
|
||||||
gHt_flag = 2; //<2F><><EFBFBD><EFBFBD>
|
|
||||||
else
|
|
||||||
gHt_flag = 1; //<2F><><EFBFBD><EFBFBD>
|
|
||||||
}
|
|
||||||
|
|
||||||
heat_timecnt = Pid_Realize(temp); //Sub_data * 1000;
|
|
||||||
|
|
||||||
return heat_timecnt;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:Status_Tran
|
|
||||||
Description: Handles the current status of the unit, and task selection
|
|
||||||
Basically this is called in main() repeatedly
|
|
||||||
Input:Void
|
|
||||||
Output:Void
|
|
||||||
*******************************************************************************/
|
|
||||||
void Status_Tran(void) //
|
|
||||||
{
|
|
||||||
static u16 init_waitingtime = 0; //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>־λ: 0=> δ<><CEB4>ʼ<EFBFBD><CABC>,1=><3E>ѳ<EFBFBD>ʼ<EFBFBD><CABC>
|
|
||||||
static u8 back_prestatus = 0;
|
|
||||||
s16 heat_timecnt = 0, wk_temp;
|
|
||||||
u16 mma_active;
|
|
||||||
|
|
||||||
switch (Get_CtrlStatus()) {
|
|
||||||
case IDLE:
|
|
||||||
switch (Get_gKey()) { //Read current switch positions
|
|
||||||
case KEY_V1: //If V1 key is pressed
|
|
||||||
if (gIs_restartkey != 1) { //check we are not in a soft restart situation
|
|
||||||
if (Read_Vb(1) < 4) { //Read that the input voltage is acceptable??
|
|
||||||
Set_CtrlStatus(TEMP_CTR); //Set to temperature controlled mode (Aka soldering mode)
|
|
||||||
init_waitingtime = 0; //Initialize the wait count to 0
|
|
||||||
TEMPSHOW_TIMER= 0; //Initialize the timer to 0
|
|
||||||
UI_TIMER= 0;
|
|
||||||
G6_TIMER= 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KEY_V2: //check if V2 key is pressed
|
|
||||||
if(gIs_restartkey != 1) { //check this is not a soft restart situation
|
|
||||||
Set_CtrlStatus(THERMOMETER);//Change system to Thermometer mode instead (ie reading temp only, no drive)
|
|
||||||
UI_TIMER = 0;
|
|
||||||
Set_LongKeyFlag(1);//Set the long key pressed flag??
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KEY_CN|KEY_V3: //If A&B pressed at the same time, no action
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(gIs_restartkey && (KD_TIMER == 0)) { //This is a soft restart situation instead
|
|
||||||
gIs_restartkey = 0;//reset the flag for soft restart
|
|
||||||
Set_gKey(NO_KEY);//reset keys pressed
|
|
||||||
}
|
|
||||||
if(Read_Vb(1) == 0) { //Invalid voltage, I think this means no input power detected
|
|
||||||
if(Get_UpdataFlag() == 1) Set_UpdataFlag(0);
|
|
||||||
Set_CtrlStatus(ALARM);
|
|
||||||
}
|
|
||||||
if(gPre_status != WAIT && gPre_status != IDLE) { //System has been left alone, turn off screen to stop burn in
|
|
||||||
G6_TIMER = device_info.idle_time;
|
|
||||||
Set_gKey(NO_KEY);
|
|
||||||
gPre_status = IDLE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TEMP_CTR: //We are in soldering mode
|
|
||||||
switch(Get_gKey()) { //switch on the pressed key
|
|
||||||
case KEY_CN|KEY_V1:
|
|
||||||
case KEY_CN|KEY_V2://if either key long pressed
|
|
||||||
Set_HeatingTime(0);//turn off heater
|
|
||||||
Set_CtrlStatus(TEMP_SET);//Goto temperature set mode
|
|
||||||
HEATING_TIMER = 0;//reset heating timer
|
|
||||||
EFFECTIVE_KEY_TIMER = 500;
|
|
||||||
break;
|
|
||||||
case KEY_CN|KEY_V3://Both keys pressed
|
|
||||||
Set_HeatingTime(0);//Stop the heater
|
|
||||||
Set_LongKeyFlag(0);//Reset the long key press flag
|
|
||||||
Set_CtrlStatus(IDLE);//Change the system back to IDLE state (stop soldering)
|
|
||||||
gPre_status = TEMP_CTR;//Set previous status
|
|
||||||
gIs_restartkey = 1;
|
|
||||||
KD_TIMER = 50;//
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Read_Vb(1) >= 4) { //Check input voltage is in the acceptable range
|
|
||||||
Set_HeatingTime(0);//Turn of heater as we are out of range
|
|
||||||
Set_LongKeyFlag(0);//reset key flag
|
|
||||||
Set_CtrlStatus(IDLE);//reset to IDLE state
|
|
||||||
gPre_status = TEMP_CTR;//set previous state
|
|
||||||
gIs_restartkey = 1;
|
|
||||||
KD_TIMER = 50;//
|
|
||||||
}
|
|
||||||
|
|
||||||
wk_temp = device_info.t_work; //update setpoint temp from the struct
|
|
||||||
if(HEATING_TIMER == 0) {
|
|
||||||
gTemp_data = Get_Temp(wk_temp);
|
|
||||||
heat_timecnt = Heating_Time(gTemp_data,wk_temp); //Calculate the on time for the heating cycle
|
|
||||||
Set_HeatingTime(heat_timecnt);//set the on time for the heating cycle
|
|
||||||
HEATING_TIMER = HEATINGCYCLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Get_HeatingTime() == 0) { //If calcuated heater time is 0 stop the timer ?
|
|
||||||
HEATING_TIMER = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The logic here is :
|
|
||||||
* If the device is moving then disarm the timer and mark it as needed a re-init
|
|
||||||
* else check if the timer needs init, if it does set it up and exit
|
|
||||||
* if the timer does not need init, then check if the timer has expired (its a count down)
|
|
||||||
* If the timer has expired goto wait state instead and shutdown iron
|
|
||||||
*/
|
|
||||||
mma_active = Get_MmaShift(); //check the accelerometer for movement
|
|
||||||
if(mma_active == 0) { //MMA_active = 0 ==> static ,MMA_active = 1 ==>move
|
|
||||||
if(init_waitingtime == 0) { //If the waiting countdown timer is not initialized
|
|
||||||
init_waitingtime = 1;//we initialize it and set this <- flag.
|
|
||||||
ENTER_WAIT_TIMER = device_info.wait_time;
|
|
||||||
}
|
|
||||||
if((init_waitingtime != 0) && (ENTER_WAIT_TIMER == 0)) { //if timeout has been initalized and enter_wait_timer has reached 0
|
|
||||||
gHt_flag = 0;//reset heating flags
|
|
||||||
UI_TIMER = 0;//reset ui timers
|
|
||||||
Set_HeatingTime(0);//turn off the soldering iron
|
|
||||||
Set_gKey(0);//clear keys
|
|
||||||
G6_TIMER = device_info.idle_time;//set the device to idle timer move
|
|
||||||
Set_CtrlStatus(WAIT);//Set system mode to waiting for movement
|
|
||||||
}
|
|
||||||
} else { //The iron is moving
|
|
||||||
init_waitingtime = 0;//mark the waiting timer for needing reset if movement stops again
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Get_AlarmType() > NORMAL_TEMP) { //
|
|
||||||
if(Get_UpdataFlag() == 1) Set_UpdataFlag(0);
|
|
||||||
Set_CtrlStatus(ALARM);//Change to alarm state
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WAIT:
|
|
||||||
//This mode (WAIT) occures when the iron has been idling on a desk for too long (ie someone forgot it was left on)
|
|
||||||
//In this state we drop to a lower, safer temp and wait for movement or button push to wake up to operating temp again
|
|
||||||
wk_temp = device_info.t_standby;
|
|
||||||
if(device_info.t_standby > device_info.t_work) {
|
|
||||||
//Check if the set temp was greater than the idle temp, if it was we set the idle temp to the set temp
|
|
||||||
//This is done to avoid standby going to a higher temp
|
|
||||||
wk_temp = device_info.t_work;
|
|
||||||
}
|
|
||||||
//if the heating timer has expired, update the readings
|
|
||||||
if(HEATING_TIMER == 0) {
|
|
||||||
gTemp_data = Get_Temp(wk_temp); //read the tip temp
|
|
||||||
heat_timecnt = Heating_Time(gTemp_data,wk_temp);//calculate the new heating timer value from temps
|
|
||||||
Set_HeatingTime(heat_timecnt);//apply the new heating timer
|
|
||||||
HEATING_TIMER = 30;//set update rate for heating_timer
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Read_Vb(1) >= 4) { //If the input voltage is not valid
|
|
||||||
Set_HeatingTime(0);//turn off heater
|
|
||||||
Set_LongKeyFlag(0);//reset key press flag
|
|
||||||
Set_CtrlStatus(IDLE);//goto IDLE state
|
|
||||||
G6_TIMER = device_info.idle_time;
|
|
||||||
gPre_status = WAIT;//set previous state
|
|
||||||
gIs_restartkey = 1;
|
|
||||||
KD_TIMER = 50;//
|
|
||||||
}
|
|
||||||
|
|
||||||
if(G6_TIMER == 0) { //
|
|
||||||
Set_HeatingTime(0);
|
|
||||||
Set_LongKeyFlag(0);
|
|
||||||
gIs_restartkey = 1;
|
|
||||||
KD_TIMER = 200;//
|
|
||||||
gPre_status = WAIT;
|
|
||||||
Set_CtrlStatus(IDLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
//If movement has occurred OR a key has been pressed -> Wakeup back to soldering
|
|
||||||
mma_active = Get_MmaShift();//read accelerometer
|
|
||||||
if(mma_active == 1 || Get_gKey() != 0) {
|
|
||||||
UI_TIMER = 0; //reset the un-needed timers
|
|
||||||
G6_TIMER = 0;
|
|
||||||
init_waitingtime = 0;
|
|
||||||
Set_CtrlStatus(TEMP_CTR);//Go back to soldering iron mode
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Get_AlarmType() > NORMAL_TEMP) { //If an alarm has occurred??
|
|
||||||
if(Get_UpdataFlag() == 1) Set_UpdataFlag(0);
|
|
||||||
Set_CtrlStatus(ALARM);//goto alarm error state
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TEMP_SET: //We are in the setting soldering iron temp mode
|
|
||||||
if(EFFECTIVE_KEY_TIMER == 0) {
|
|
||||||
gCalib_flag = 1;
|
|
||||||
Disk_BuffInit();
|
|
||||||
Config_Analysis(); //
|
|
||||||
gCalib_flag = 0;
|
|
||||||
Set_CtrlStatus(TEMP_CTR);//return to soldering mode
|
|
||||||
TEMPSHOW_TIMER = 0;//turn off the timer
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case THERMOMETER: //we are measuring the tip temp without applying any power
|
|
||||||
if(KD_TIMER > 0) {
|
|
||||||
Set_gKey(NO_KEY);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(Get_gKey()) {
|
|
||||||
case KEY_CN|KEY_V1:
|
|
||||||
case KEY_CN|KEY_V2:
|
|
||||||
back_prestatus = 1;
|
|
||||||
break;
|
|
||||||
case KEY_CN|KEY_V3:
|
|
||||||
Zero_Calibration(); //Calibrate the temperature (i think??)
|
|
||||||
if(Get_CalFlag() == 1) {
|
|
||||||
Disk_BuffInit();
|
|
||||||
Config_Analysis(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>U<EFBFBD><55>
|
|
||||||
}
|
|
||||||
KD_TIMER = 200; //20150717 <20><EFBFBD>
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(back_prestatus == 1) { //we are exiting
|
|
||||||
back_prestatus = 0;//clear flag
|
|
||||||
Set_HeatingTime(0);//turn off heater? (not sure why this is done again)
|
|
||||||
Set_CtrlStatus(IDLE);//Goto IDLE state
|
|
||||||
gPre_status = THERMOMETER;//set previous state
|
|
||||||
gIs_restartkey = 1;//signal soft restart required as we may have done a calibration
|
|
||||||
Set_LongKeyFlag(0);//reset long key hold flag
|
|
||||||
KD_TIMER = 50;//
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ALARM: //An error has occured so we are in alarm state
|
|
||||||
switch(Get_AlarmType()) {
|
|
||||||
case HIGH_TEMP: //over temp condition
|
|
||||||
case SEN_ERR://sensor reading error
|
|
||||||
wk_temp = device_info.t_work;
|
|
||||||
gTemp_data = Get_Temp(wk_temp);
|
|
||||||
if(Get_AlarmType() == NORMAL_TEMP) {
|
|
||||||
Set_CtrlStatus(TEMP_CTR);
|
|
||||||
Set_UpdataFlag(0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HIGH_VOLTAGE: //over voltage
|
|
||||||
case LOW_VOLTAGE://under voltage
|
|
||||||
if(Read_Vb(1) >= 1 && Read_Vb(1) <= 3) {
|
|
||||||
Set_HeatingTime(0); //turn off heater
|
|
||||||
Set_LongKeyFlag(0);//reset key flag
|
|
||||||
gIs_restartkey = 1;
|
|
||||||
UI_TIMER = 2;// 2<><32>
|
|
||||||
gPre_status = THERMOMETER;
|
|
||||||
Set_CtrlStatus(IDLE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//V-- No idea what this does yet.. At all.. since it will always be skipped..
|
|
||||||
if(Get_HeatingTime != 0) {
|
|
||||||
Set_HeatingTime(0); //<2F><><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|
||||||
HEAT_OFF();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************** END OF FILE *********************************/
|
|
||||||
@@ -1,773 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
|
||||||
File Name : Disk.c
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : Celery
|
|
||||||
Data: 2015/07/07
|
|
||||||
History:
|
|
||||||
2016/09/13 Ben V. Brown English notation/comments
|
|
||||||
2015/07/07
|
|
||||||
*******************************************************************************/
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "APP_Version.h"
|
|
||||||
#include "Disk.h"
|
|
||||||
#include "Bios.h"
|
|
||||||
#include "Flash.h"
|
|
||||||
#include "Oled.h"
|
|
||||||
#include "UI.h"
|
|
||||||
#include "CTRL.h"
|
|
||||||
#include "Hardware.h"
|
|
||||||
|
|
||||||
#define Delay_mS Delay_Ms
|
|
||||||
void Disk_SecWrite(u8* pBuffer, u32 DiskAddr);
|
|
||||||
void Disk_SecRead(u8* pBuffer, u32 DiskAddr);
|
|
||||||
void Soft_Delay(void);
|
|
||||||
//Hard coded boot sector for the virtual device
|
|
||||||
const uint8_t BOOT_SEC[512] = { 0xEB, 0x3C, 0x90, 0x4D, 0x53, 0x44, 0x4F, 0x53,
|
|
||||||
0x35, 0x2E, 0x30, 0x00, 0x02, 0x01, 0x08, 0x00, 0x02, 0x00, 0x02, 0x50,
|
|
||||||
0x00, 0xF8, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0xA2, 0x98, 0xE4, 0x6C, 0x4E,
|
|
||||||
0x4F, 0x20, 0x4E, 0x41, 0x4D, 0x45, 0x20, 0x20, 0x20, 0x20, 0x46, 0x41,
|
|
||||||
0x54, 0x31, 0x32, 0x20, 0x20, 0x20, 0x33, 0xC9, 0x8E, 0xD1, 0xBC, 0xF0,
|
|
||||||
0x7B, 0x8E, 0xD9, 0xB8, 0x00, 0x20, 0x8E, 0xC0, 0xFC, 0xBD, 0x00, 0x7C,
|
|
||||||
0x38, 0x4E, 0x24, 0x7D, 0x24, 0x8B, 0xC1, 0x99, 0xE8, 0x3C, 0x01, 0x72,
|
|
||||||
0x1C, 0x83, 0xEB, 0x3A, 0x66, 0xA1, 0x1C, 0x7C, 0x26, 0x66, 0x3B, 0x07,
|
|
||||||
0x26, 0x8A, 0x57, 0xFC, 0x75, 0x06, 0x80, 0xCA, 0x02, 0x88, 0x56, 0x02,
|
|
||||||
0x80, 0xC3, 0x10, 0x73, 0xEB, 0x33, 0xC9, 0x8A, 0x46, 0x10, 0x98, 0xF7,
|
|
||||||
0x66, 0x16, 0x03, 0x46, 0x1C, 0x13, 0x56, 0x1E, 0x03, 0x46, 0x0E, 0x13,
|
|
||||||
0xD1, 0x8B, 0x76, 0x11, 0x60, 0x89, 0x46, 0xFC, 0x89, 0x56, 0xFE, 0xB8,
|
|
||||||
0x20, 0x00, 0xF7, 0xE6, 0x8B, 0x5E, 0x0B, 0x03, 0xC3, 0x48, 0xF7, 0xF3,
|
|
||||||
0x01, 0x46, 0xFC, 0x11, 0x4E, 0xFE, 0x61, 0xBF, 0x00, 0x00, 0xE8, 0xE6,
|
|
||||||
0x00, 0x72, 0x39, 0x26, 0x38, 0x2D, 0x74, 0x17, 0x60, 0xB1, 0x0B, 0xBE,
|
|
||||||
0xA1, 0x7D, 0xF3, 0xA6, 0x61, 0x74, 0x32, 0x4E, 0x74, 0x09, 0x83, 0xC7,
|
|
||||||
0x20, 0x3B, 0xFB, 0x72, 0xE6, 0xEB, 0xDC, 0xA0, 0xFB, 0x7D, 0xB4, 0x7D,
|
|
||||||
0x8B, 0xF0, 0xAC, 0x98, 0x40, 0x74, 0x0C, 0x48, 0x74, 0x13, 0xB4, 0x0E,
|
|
||||||
0xBB, 0x07, 0x00, 0xCD, 0x10, 0xEB, 0xEF, 0xA0, 0xFD, 0x7D, 0xEB, 0xE6,
|
|
||||||
0xA0, 0xFC, 0x7D, 0xEB, 0xE1, 0xCD, 0x16, 0xCD, 0x19, 0x26, 0x8B, 0x55,
|
|
||||||
0x1A, 0x52, 0xB0, 0x01, 0xBB, 0x00, 0x00, 0xE8, 0x3B, 0x00, 0x72, 0xE8,
|
|
||||||
0x5B, 0x8A, 0x56, 0x24, 0xBE, 0x0B, 0x7C, 0x8B, 0xFC, 0xC7, 0x46, 0xF0,
|
|
||||||
0x3D, 0x7D, 0xC7, 0x46, 0xF4, 0x29, 0x7D, 0x8C, 0xD9, 0x89, 0x4E, 0xF2,
|
|
||||||
0x89, 0x4E, 0xF6, 0xC6, 0x06, 0x96, 0x7D, 0xCB, 0xEA, 0x03, 0x00, 0x00,
|
|
||||||
0x20, 0x0F, 0xB6, 0xC8, 0x66, 0x8B, 0x46, 0xF8, 0x66, 0x03, 0x46, 0x1C,
|
|
||||||
0x66, 0x8B, 0xD0, 0x66, 0xC1, 0xEA, 0x10, 0xEB, 0x5E, 0x0F, 0xB6, 0xC8,
|
|
||||||
0x4A, 0x4A, 0x8A, 0x46, 0x0D, 0x32, 0xE4, 0xF7, 0xE2, 0x03, 0x46, 0xFC,
|
|
||||||
0x13, 0x56, 0xFE, 0xEB, 0x4A, 0x52, 0x50, 0x06, 0x53, 0x6A, 0x01, 0x6A,
|
|
||||||
0x10, 0x91, 0x8B, 0x46, 0x18, 0x96, 0x92, 0x33, 0xD2, 0xF7, 0xF6, 0x91,
|
|
||||||
0xF7, 0xF6, 0x42, 0x87, 0xCA, 0xF7, 0x76, 0x1A, 0x8A, 0xF2, 0x8A, 0xE8,
|
|
||||||
0xC0, 0xCC, 0x02, 0x0A, 0xCC, 0xB8, 0x01, 0x02, 0x80, 0x7E, 0x02, 0x0E,
|
|
||||||
0x75, 0x04, 0xB4, 0x42, 0x8B, 0xF4, 0x8A, 0x56, 0x24, 0xCD, 0x13, 0x61,
|
|
||||||
0x61, 0x72, 0x0B, 0x40, 0x75, 0x01, 0x42, 0x03, 0x5E, 0x0B, 0x49, 0x75,
|
|
||||||
0x06, 0xF8, 0xC3, 0x41, 0xBB, 0x00, 0x00, 0x60, 0x66, 0x6A, 0x00, 0xEB,
|
|
||||||
0xB0, 0x4E, 0x54, 0x4C, 0x44, 0x52, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x0D, 0x0A, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x20, 0x64, 0x69, 0x73,
|
|
||||||
0x6B, 0x73, 0x20, 0x6F, 0x72, 0x20, 0x6F, 0x74, 0x68, 0x65, 0x72, 0x20,
|
|
||||||
0x6D, 0x65, 0x64, 0x69, 0x61, 0x2E, 0xFF, 0x0D, 0x0A, 0x44, 0x69, 0x73,
|
|
||||||
0x6B, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0xFF, 0x0D, 0x0A, 0x50, 0x72,
|
|
||||||
0x65, 0x73, 0x73, 0x20, 0x61, 0x6E, 0x79, 0x20, 0x6B, 0x65, 0x79, 0x20,
|
|
||||||
0x74, 0x6F, 0x20, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x0D, 0x0A,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAC, 0xCB, 0xD8, 0x55, 0xAA };
|
|
||||||
|
|
||||||
static u8 gDisk_buff[0x2600]; //RAM Buffer used to implement the virtual disk
|
|
||||||
static u32 gDisk_var[(512 + 32 + 28) / 4]; //
|
|
||||||
static u32 *gV32 = (u32*) &gDisk_var[512 / 4];
|
|
||||||
static u8 *gVar = (u8*) &gDisk_var[512 / 4 + 8];
|
|
||||||
|
|
||||||
static u8 *gBuff = (u8*) &gDisk_var[0];
|
|
||||||
const u8 gFat_data[] = { 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; //{0xF8,0XFF,0XFF,0xff,0X0f};//
|
|
||||||
//The options
|
|
||||||
const char *gKey_words[] = { "T_Standby", "T_Work", "Wait_Time", "Idle_Time",
|
|
||||||
"T_Step", "Turn_Off_v", "TempShowFlag", "ZeroP_Ad" };
|
|
||||||
//default settings
|
|
||||||
const char *gDef_set[] = { "T_Standby=200", "T_Work=300", "Wait_Time=180",
|
|
||||||
"Idle_Time=360", "T_Step=10", "Turn_Off_v=10", "TempShowFlag=0",
|
|
||||||
"ZeroP_Ad=239" };
|
|
||||||
//comments for accepted range
|
|
||||||
const char *gSet_range[] = { " #(100~400)\r\n", " #(100~400)\r\n",
|
|
||||||
" #(60~9999)\r\n", " #(300~9999)\r\n", " #(5~25)\r\n",
|
|
||||||
" #(9~12)\r\n", " #(0,1)\r\n", " #ReadOnly\r\n" };
|
|
||||||
|
|
||||||
static u8 gFile_con[512]; //file contents buffer
|
|
||||||
#define CONFIG_CONT 8 /*Number of variables in config.txt*/
|
|
||||||
u8 gRewriteflag[16]; //This flags if this sector has changed and needs to be written to flash
|
|
||||||
|
|
||||||
#define ROW_CONT 35
|
|
||||||
#define FILE_CONT 254
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Soft_Delay()
|
|
||||||
Description: Small software delay.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Soft_Delay() {
|
|
||||||
int i, j;
|
|
||||||
for (i = 0; i < 1000; i++)
|
|
||||||
for (j = 0; j < 100; j++)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Set_Ver
|
|
||||||
Description:
|
|
||||||
Input:
|
|
||||||
*******************************************************************************/
|
|
||||||
void Set_Ver(u8 str[], u8 k) {
|
|
||||||
s16 set_ver = 0;
|
|
||||||
|
|
||||||
switch (k) {
|
|
||||||
case 0:
|
|
||||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
|
||||||
device_info.t_standby = set_ver * 10;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
|
||||||
if (!gCalib_flag)
|
|
||||||
device_info.t_work = set_ver * 10;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (str[3] <= '9' && str[3] >= '0') { //4
|
|
||||||
set_ver = (str[0] - 48) * 1000 + (str[1] - 48) * 100
|
|
||||||
+ (str[2] - 48) * 10 + (str[3] - 48);
|
|
||||||
} else if (str[2] <= '9' && str[2] >= '0') { //3
|
|
||||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
|
||||||
} else if (str[1] <= '9' && str[1] >= '0') { //2
|
|
||||||
set_ver = (str[0] - 48) * 10 + (str[1] - 48);
|
|
||||||
}
|
|
||||||
device_info.wait_time = set_ver * 100;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (str[3] <= '9' && str[3] >= '0') { //4
|
|
||||||
set_ver = (str[0] - 48) * 1000 + (str[1] - 48) * 100
|
|
||||||
+ (str[2] - 48) * 10 + (str[3] - 48);
|
|
||||||
} else if (str[2] <= '9' && str[2] >= '0') { //3
|
|
||||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
|
||||||
}
|
|
||||||
device_info.idle_time = set_ver * 100;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
if (str[1] <= '9' && str[1] >= '0') { //2
|
|
||||||
set_ver = (str[0] - 48) * 10 + (str[1] - 48);
|
|
||||||
} else {
|
|
||||||
set_ver = str[0] - 48;
|
|
||||||
}
|
|
||||||
device_info.t_step = set_ver * 10;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if (str[3] <= '9' && str[3] >= '0') { //4
|
|
||||||
set_ver = (str[0] - 48) * 1000 + (str[1] - 48) * 100
|
|
||||||
+ (str[2] - 48) * 10 + (str[3] - 48);
|
|
||||||
} else if (str[2] <= '9' && str[2] >= '0') { //3
|
|
||||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
|
||||||
} else if (str[1] <= '9' && str[1] >= '0') { //2
|
|
||||||
set_ver = (str[0] - 48) * 10 + (str[1] - 48);
|
|
||||||
} else {
|
|
||||||
set_ver = str[0] - 48;
|
|
||||||
}
|
|
||||||
gTurn_offv = set_ver * 10;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
set_ver = str[0] - 48;
|
|
||||||
Set_TemperatureShowFlag(set_ver);
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
if (str[2] <= '9' && str[2] >= '0') { //3
|
|
||||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
|
||||||
} else if (str[1] <= '9' && str[1] >= '0') { //2
|
|
||||||
set_ver = (str[0] - 48) * 10 + (str[1] - 48);
|
|
||||||
} else {
|
|
||||||
set_ver = str[0] - 48;
|
|
||||||
}
|
|
||||||
if (!gCalib_flag)
|
|
||||||
gZerop_ad = set_ver;
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Cal_Val
|
|
||||||
Description:
|
|
||||||
Inputs:
|
|
||||||
Output:
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 Cal_Val(u8 str[], u8 k, u8 flag) {
|
|
||||||
u16 set_ver;
|
|
||||||
|
|
||||||
switch (k) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
if (str[2] > '9' || str[2] < '0' || //
|
|
||||||
str[1] > '9' || str[1] < '0' || //
|
|
||||||
str[0] > '4' || str[0] <= '0' || //
|
|
||||||
(str[0] == '4' && (str[1] != '0' || str[2] != '0')))
|
|
||||||
return 0;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (str[3] <= '9' && str[3] >= '0') { //
|
|
||||||
if ((str[2] > '9' && str[2] < '0')
|
|
||||||
|| (str[1] > '9' && str[1] < '0')) //
|
|
||||||
return 0;
|
|
||||||
} else if (str[2] <= '9' && str[2] >= '0') { //
|
|
||||||
if (str[1] > '9' && str[1] < '0') //
|
|
||||||
return 0;
|
|
||||||
} else if (str[1] <= '9' && str[1] >= '0') { //
|
|
||||||
if (str[0] > '9' || str[0] < '6') //
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (str[3] <= '9' && str[3] >= '0') { //4
|
|
||||||
if ((str[2] > '9' && str[2] < '0')
|
|
||||||
|| (str[1] > '9' && str[1] < '0')) //
|
|
||||||
return 0;
|
|
||||||
} else if (str[2] <= '9' && str[2] >= '0') { //3
|
|
||||||
if (str[0] > '9' || str[0] < '3') //
|
|
||||||
return 0;
|
|
||||||
} else { //
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4: //T_Step=10 #(5~25)
|
|
||||||
if (str[1] <= '5' && str[1] >= '0') { //
|
|
||||||
if (str[0] > '2' || str[0] < '0') //
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
if (str[0] < '5' && (str[0] != '1')) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 5: //Turn_Off_v=10 #(9~12)
|
|
||||||
if (str[1] <= '2' && str[1] >= '0') { //
|
|
||||||
if (str[0] > '9' || str[0] < '0') //
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
if (str[0] < '9') {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6: //TempShowFlag=0 #(0,1)
|
|
||||||
if (str[0] != '1' && str[0] != '0')
|
|
||||||
return 0;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
if (str[2] <= '9' && str[2] >= '0') { //3
|
|
||||||
set_ver = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);
|
|
||||||
} else if (str[1] <= '9' && str[1] >= '0') { //2
|
|
||||||
set_ver = (str[0] - 48) * 10 + (str[1] - 48);
|
|
||||||
} else {
|
|
||||||
set_ver = str[0] - 48;
|
|
||||||
}
|
|
||||||
if (flag == 1) {
|
|
||||||
if (set_ver != gZerop_ad)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:Disk_BuffInit
|
|
||||||
Description: Initializes the buffer for the virtual disk. By loading from the chips flash
|
|
||||||
*******************************************************************************/
|
|
||||||
void Disk_BuffInit(void) {
|
|
||||||
memcpy(gDisk_buff, (u8*) APP_BASE, 0x2600);
|
|
||||||
memset(gRewriteflag, 0, 16);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Upper
|
|
||||||
Description: Converts the string passed in to upper case
|
|
||||||
Inputs: (str) buffer to change, (len) length of the buffer
|
|
||||||
*******************************************************************************/
|
|
||||||
void Upper(u8* str, u16 len) {
|
|
||||||
u16 i;
|
|
||||||
for (i = 0; i < len; i++) //Loop through the string
|
|
||||||
if (str[i] >= 'a' && str[i] <= 'z') //if char is lower case
|
|
||||||
str[i] -= 32; //shift to upper case
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: SearchFile
|
|
||||||
Description:
|
|
||||||
Inputs: (pfilename) filename to look for, (pfilelen) length of the file,(root_addr) root folder to search from
|
|
||||||
Outputs: NULL (failed) or pointer to file start
|
|
||||||
*******************************************************************************/
|
|
||||||
u8* SearchFile(u8* pfilename, u16* pfilelen, u16* root_addr) {
|
|
||||||
u16 n, sector;
|
|
||||||
u8 str_name[11];
|
|
||||||
u8* pdiraddr;
|
|
||||||
|
|
||||||
pdiraddr = ROOT_SECTOR;
|
|
||||||
|
|
||||||
for (n = 0; n < 16; n++) {
|
|
||||||
memcpy(str_name, pdiraddr, 11);
|
|
||||||
Upper(str_name, 11); //ensure path is upper case
|
|
||||||
if (memcmp(str_name, pfilename, 11) == 0) {
|
|
||||||
memcpy((u8*) pfilelen, pdiraddr + 0x1C, 2);
|
|
||||||
memcpy((u8*) §or, pdiraddr + 0x1A, 2);
|
|
||||||
return (u8*) FILE_SECTOR + (sector - 2) * 512;
|
|
||||||
}
|
|
||||||
|
|
||||||
pdiraddr += 32;
|
|
||||||
root_addr++;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:Config_Analysis
|
|
||||||
Description:Reads the CONFIG.TXT if file is found and also the LOGIN.BMP file as well
|
|
||||||
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 Config_Analysis(void) {
|
|
||||||
u32 i, j, k, m, flag;
|
|
||||||
u16 file_len;
|
|
||||||
u8 t_p[CONFIG_CONT][ROW_CONT];
|
|
||||||
u8 str[FILE_CONT];
|
|
||||||
u8 is_illegality = 0;
|
|
||||||
u8* p_file;
|
|
||||||
u16 root_addr;
|
|
||||||
|
|
||||||
root_addr = 0;
|
|
||||||
m = 0;
|
|
||||||
j = 0;
|
|
||||||
//read in the config.txt if it exists
|
|
||||||
if ((p_file = SearchFile((u8*) ("CONFIG TXT"), &file_len, &root_addr))) {
|
|
||||||
memset(t_p, 0x00, CONFIG_CONT * ROW_CONT);
|
|
||||||
memcpy((u8*) gFile_con, p_file, 512);
|
|
||||||
for (k = 0; k < CONFIG_CONT; k++) {
|
|
||||||
j = 0;
|
|
||||||
for (i = m; i < strlen((char *) gFile_con); i++) {
|
|
||||||
if (gFile_con[i] == 0x0D && gFile_con[i + 1] == 0x0A)
|
|
||||||
break;
|
|
||||||
else {
|
|
||||||
if (j < ROW_CONT)
|
|
||||||
t_p[k][j++] = gFile_con[i];
|
|
||||||
m++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t_p[k][j] = '\0';
|
|
||||||
m = i + 2;
|
|
||||||
}
|
|
||||||
for (k = 0; k < CONFIG_CONT; k++) {
|
|
||||||
if (memcmp(t_p[k], gKey_words[k], strlen(gKey_words[k])) == 0) {
|
|
||||||
flag = 0;
|
|
||||||
for (i = strlen(gKey_words[k]); i < strlen((char *) t_p[k]);
|
|
||||||
i++) {
|
|
||||||
if (t_p[k][i] >= '0' && t_p[k][i] <= '9') {
|
|
||||||
if (t_p[k][i] == '0') {
|
|
||||||
if (k == 6) {
|
|
||||||
flag = 1;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
flag = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
flag = 1;
|
|
||||||
break;
|
|
||||||
} else if ((t_p[k][i] != 0x20) && (t_p[k][i] != 0x3d)) {
|
|
||||||
flag = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (flag && Cal_Val(t_p[k] + i, k, 0)) {
|
|
||||||
Set_Ver(t_p[k] + i, k);
|
|
||||||
if (k == 0)
|
|
||||||
sprintf((char *) t_p[k], "T_Standby=%d",
|
|
||||||
device_info.t_standby / 10);
|
|
||||||
else if (k == 1)
|
|
||||||
sprintf((char *) t_p[k], "T_Work=%d",
|
|
||||||
device_info.t_work / 10);
|
|
||||||
else if (k == 2)
|
|
||||||
sprintf((char *) t_p[k], "Wait_Time=%ld",
|
|
||||||
device_info.wait_time / 100);
|
|
||||||
else if (k == 3)
|
|
||||||
sprintf((char *) t_p[k], "Idle_Time=%ld",
|
|
||||||
device_info.idle_time / 100);
|
|
||||||
else if (k == 4)
|
|
||||||
sprintf((char *) t_p[k], "T_Step=%d",
|
|
||||||
device_info.t_step / 10);
|
|
||||||
else if (k == 5)
|
|
||||||
sprintf((char *) t_p[k], "Turn_Off_v=%ld",
|
|
||||||
gTurn_offv / 10);
|
|
||||||
else if (k == 6)
|
|
||||||
sprintf((char *) t_p[k], "TempShowFlag=%d",
|
|
||||||
Get_TemperatureShowFlag());
|
|
||||||
else if (k == 7)
|
|
||||||
sprintf((char *) t_p[k], "ZeroP_Ad=%ld", gZerop_ad);
|
|
||||||
} else {
|
|
||||||
memset(t_p[k], 0, strlen((char *) t_p[k]));
|
|
||||||
memcpy(t_p[k], gDef_set[k], strlen((char *) gDef_set[k]));
|
|
||||||
is_illegality = 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
memcpy(t_p[k], gDef_set[k], strlen((char *) gDef_set[k]));
|
|
||||||
is_illegality = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_illegality || gCalib_flag) {
|
|
||||||
memset(str, 0x00, FILE_CONT);
|
|
||||||
m = 0;
|
|
||||||
for (k = 0; k < CONFIG_CONT; k++) {
|
|
||||||
strcat((char *) str, (char *) t_p[k]);
|
|
||||||
strcat((char *) str, (char *) gSet_range[k]);
|
|
||||||
}
|
|
||||||
m = strlen((char *) str);
|
|
||||||
|
|
||||||
if (m < 256) {
|
|
||||||
gDisk_buff[0x400 + root_addr * 32 + 0x1C] = m; //strlen((char *)str);
|
|
||||||
gDisk_buff[0x400 + root_addr * 32 + 0x1D] = 0;
|
|
||||||
} else {
|
|
||||||
gDisk_buff[0x400 + root_addr * 32 + 0x1C] = m % 256;
|
|
||||||
gDisk_buff[0x400 + root_addr * 32 + 0x1D] = m / 256;
|
|
||||||
}
|
|
||||||
|
|
||||||
gRewriteflag[(p_file - ROOT_SECTOR + 0x200) / 0x400] = 1;
|
|
||||||
memcpy(p_file, str, strlen((char *) str));
|
|
||||||
ReWriteFlsash();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((p_file = SearchFile("LOGOIN BMP", &file_len, &root_addr))) {
|
|
||||||
memcpy(str, p_file, 254);
|
|
||||||
memset(gDisk_buff, 0x00, 0x2600);
|
|
||||||
memcpy(ROOT_SECTOR + 32, "LOGOIN BMP", 0xC);
|
|
||||||
memcpy(FILE_SECTOR + 512, str, 254);
|
|
||||||
gDisk_buff[0x40B + 32] = 0x0; //<2F><><EFBFBD><EFBFBD>
|
|
||||||
*(u32*) (VOLUME_BASE + 32) = VOLUME;
|
|
||||||
gDisk_buff[0x41A + 32] = 0x03; //<2F>غ<EFBFBD>
|
|
||||||
gDisk_buff[0x41C + 32] = 254; //<2F>ļ<EFBFBD><C4BC><EFBFBD>С
|
|
||||||
} else {
|
|
||||||
memset(gDisk_buff, 0x00, 0x2600);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(ROOT_SECTOR, "CONFIG TXT", 0xC);
|
|
||||||
memcpy(FAT1_SECTOR, gFat_data, 6);
|
|
||||||
memcpy(FAT2_SECTOR, gFat_data, 6);
|
|
||||||
|
|
||||||
m = 0;
|
|
||||||
for (k = 0; k < CONFIG_CONT; k++) {
|
|
||||||
memcpy(FILE_SECTOR + m, gDef_set[k], strlen((char *) gDef_set[k]));
|
|
||||||
m += strlen((char *) gDef_set[k]);
|
|
||||||
memcpy(FILE_SECTOR + m, gSet_range[k],
|
|
||||||
strlen((char *) gSet_range[k]));
|
|
||||||
m += strlen((char *) gSet_range[k]);
|
|
||||||
}
|
|
||||||
|
|
||||||
gDisk_buff[0x40B] = 0x0;
|
|
||||||
*(u32*) VOLUME_BASE = VOLUME;
|
|
||||||
gDisk_buff[0x41A] = 0x02;
|
|
||||||
gDisk_buff[0x41C] = m;
|
|
||||||
ReWrite_All();
|
|
||||||
}
|
|
||||||
|
|
||||||
gVar[F_TYPE] = HEX;
|
|
||||||
gVar[F_FLAG] = RDY;
|
|
||||||
gVar[SEG_ST] = 0;
|
|
||||||
gV32[OFFSET] = 0;
|
|
||||||
gV32[COUNT] = 0;
|
|
||||||
gV32[WR_CNT] = 0;
|
|
||||||
gV32[RD_CNT] = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Disk_SecWrite
|
|
||||||
Description:
|
|
||||||
Inputs:
|
|
||||||
*******************************************************************************/
|
|
||||||
void Disk_SecWrite(u8* pbuffer, u32 diskaddr) {
|
|
||||||
u32 i, j, k, m, flag;
|
|
||||||
u8 t_p[CONFIG_CONT][ROW_CONT];
|
|
||||||
u8 str[FILE_CONT];
|
|
||||||
u8 ver[20];
|
|
||||||
static u16 Config_flag = 0;
|
|
||||||
|
|
||||||
if (diskaddr == 0x1000) { // Write FAT1 sector
|
|
||||||
if (memcmp(pbuffer, (u8*) FAT1_SECTOR, 512)) { //check different
|
|
||||||
memcpy((u8*) FAT1_SECTOR, pbuffer, 512);
|
|
||||||
gRewriteflag[0] = 1;
|
|
||||||
}
|
|
||||||
} else if (diskaddr == 0x2800) { // Write FAT2 sector
|
|
||||||
if (memcmp(pbuffer, (u8*) FAT2_SECTOR, 512)) { //check different
|
|
||||||
memcpy((u8*) FAT2_SECTOR, pbuffer, 512);
|
|
||||||
gRewriteflag[0] = 1;
|
|
||||||
}
|
|
||||||
} else if (diskaddr == 0x4000) { // Write DIR sector
|
|
||||||
if (memcmp(pbuffer, (u8*) ROOT_SECTOR, 512)) { //check different
|
|
||||||
memcpy((u8*) ROOT_SECTOR, pbuffer, 512);
|
|
||||||
gRewriteflag[1] = 1;
|
|
||||||
for (i = 0; i < 16; i++) {
|
|
||||||
memcpy((u8*) ver, (u8*) (pbuffer), 12); //copy the filename out for comparison
|
|
||||||
if (memcmp(ver, "CONFIG TXT", 11) == 0) { //if file name matches
|
|
||||||
Config_flag = pbuffer[0x1A];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pbuffer += 32; //move to the next chunk of the pbuffer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (diskaddr >= 0x8000 && diskaddr <= 0xA000) { // Write FILE sector
|
|
||||||
if (memcmp(pbuffer, (u8*) (FILE_SECTOR + (diskaddr - 0x8000)), 512)) { //check if different
|
|
||||||
memcpy((u8*) (FILE_SECTOR + (diskaddr - 0x8000)), pbuffer, 512);
|
|
||||||
}
|
|
||||||
if ((((diskaddr - 0x8000) / 0x200) + 2) == Config_flag) {
|
|
||||||
m = 0;
|
|
||||||
memset(t_p, 0x00, CONFIG_CONT * ROW_CONT);
|
|
||||||
memcpy((u8*) (gFile_con), pbuffer, 512);
|
|
||||||
|
|
||||||
for (k = 0; k < CONFIG_CONT; k++) { //
|
|
||||||
j = 0;
|
|
||||||
for (i = m; i < strlen((char *) gFile_con); i++) { //
|
|
||||||
if (gFile_con[i] == 0x0D && gFile_con[i + 1] == 0x0A)
|
|
||||||
break;
|
|
||||||
else {
|
|
||||||
if (j < ROW_CONT)
|
|
||||||
t_p[k][j++] = gFile_con[i];
|
|
||||||
m++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t_p[k][j] = '\0';
|
|
||||||
m = i + 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (k = 0; k < CONFIG_CONT; k++) {
|
|
||||||
if (memcmp(t_p[k], gKey_words[k], strlen(gKey_words[k])) == 0) {
|
|
||||||
flag = 0;
|
|
||||||
for (i = strlen(gKey_words[k]); i < strlen((char *) t_p[k]);
|
|
||||||
i++) {
|
|
||||||
if (t_p[k][i] >= '0' && t_p[k][i] <= '9') {
|
|
||||||
if (t_p[k][i] == '0') {
|
|
||||||
if (k == 6) {
|
|
||||||
flag = 1;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
flag = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
flag = 1;
|
|
||||||
break;
|
|
||||||
} else if ((t_p[k][i] != 0x20) && (t_p[k][i] != 0x3d)) {
|
|
||||||
flag = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((!flag) || (!Cal_Val(t_p[k] + i, k, 1))) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
Set_Ver(t_p[k] + i, k);
|
|
||||||
|
|
||||||
memset(t_p[k], 0, strlen((char *) t_p[k]));
|
|
||||||
if (k == 0)
|
|
||||||
sprintf((char *) t_p[k], "T_Standby=%d",
|
|
||||||
device_info.t_standby / 10);
|
|
||||||
else if (k == 1)
|
|
||||||
sprintf((char *) t_p[k], "T_Work=%d",
|
|
||||||
device_info.t_work / 10);
|
|
||||||
else if (k == 2)
|
|
||||||
sprintf((char *) t_p[k], "Wait_Time=%ld",
|
|
||||||
device_info.wait_time / 100);
|
|
||||||
else if (k == 3)
|
|
||||||
sprintf((char *) t_p[k], "Idle_Time=%ld",
|
|
||||||
device_info.idle_time / 100);
|
|
||||||
else if (k == 4)
|
|
||||||
sprintf((char *) t_p[k], "T_Step=%d",
|
|
||||||
device_info.t_step / 10);
|
|
||||||
else if (k == 5)
|
|
||||||
sprintf((char *) t_p[k], "Turn_Off_v=%ld",
|
|
||||||
gTurn_offv / 10);
|
|
||||||
else if (k == 6)
|
|
||||||
sprintf((char *) t_p[k], "TempShowFlag=%d",
|
|
||||||
Get_TemperatureShowFlag());
|
|
||||||
else if (k == 7)
|
|
||||||
sprintf((char *) t_p[k], "ZeroP_Ad=%ld", gZerop_ad);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
memcpy(t_p[k], gDef_set[k], strlen((char *) gDef_set[k]));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(str, 0, FILE_CONT);
|
|
||||||
for (k = 0; k < CONFIG_CONT; k++) {
|
|
||||||
strcat((char *) str, (char *) t_p[k]);
|
|
||||||
strcat((char *) str, (char *) gSet_range[k]);
|
|
||||||
}
|
|
||||||
m = strlen((char *) str);
|
|
||||||
gDisk_buff[0x400 + (Config_flag - 2) * 32 + 0x1C] = m % 256;
|
|
||||||
gDisk_buff[0x400 + (Config_flag - 2) * 32 + 0x1D] = m / 256;
|
|
||||||
|
|
||||||
memcpy((u8*) (FILE_SECTOR), (u8*) str, 512);
|
|
||||||
gRewriteflag[1] = 1;
|
|
||||||
gRewriteflag[((diskaddr - 0x8000 + 0x200) / 0x400) + 1] = 1;
|
|
||||||
ReWriteFlsash();
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
gRewriteflag[1] = 1;
|
|
||||||
gRewriteflag[((diskaddr - 0x8000 + 0x200) / 0x400) + 1] = 1;
|
|
||||||
ReWriteFlsash();
|
|
||||||
}
|
|
||||||
ReWriteFlsash();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Disk_SecRead
|
|
||||||
Description: Reads a sector from the virtual disk
|
|
||||||
*******************************************************************************/
|
|
||||||
void Disk_SecRead(u8* pbuffer, u32 disk_addr) {
|
|
||||||
Soft_Delay();
|
|
||||||
if (disk_addr == 0x0000) { // Read BOOT sector
|
|
||||||
memcpy(pbuffer, BOOT_SEC, 512);
|
|
||||||
} else if (disk_addr == 0x1000) { // Read FAT1 sector
|
|
||||||
memcpy(pbuffer, FAT1_SECTOR, 512);
|
|
||||||
} else if (disk_addr == 0x2800) { // Read FAT2 sector
|
|
||||||
memcpy(pbuffer, FAT2_SECTOR, 512);
|
|
||||||
} else if (disk_addr == 0x4000) { // Read DIR sector
|
|
||||||
memcpy(pbuffer, (u8*) (ROOT_SECTOR), 512);
|
|
||||||
} else if (disk_addr >= 0x8000 && disk_addr <= 0xA000) { // Read FILE sector
|
|
||||||
memcpy(pbuffer, (u8*) (APP_BASE + 0x600 + (disk_addr - 0x8000)), 512);
|
|
||||||
} else {
|
|
||||||
memset(pbuffer, 0, 512); //unknown, return 0's
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:ReWriteFlsash
|
|
||||||
Description:
|
|
||||||
Output:RDY(all good) or ERR (error)
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 ReWriteFlsash(void) {
|
|
||||||
u32 i, j;
|
|
||||||
u8 result;
|
|
||||||
u16 *f_buff;
|
|
||||||
|
|
||||||
FLASH_Unlock();
|
|
||||||
for (i = 0; i < 16; i++) {
|
|
||||||
if (gRewriteflag[i]) {
|
|
||||||
gRewriteflag[i] = 0;
|
|
||||||
FLASH_Erase(APP_BASE + i * 0x400);
|
|
||||||
f_buff = (u16*) &gDisk_buff[i * 0x400];
|
|
||||||
for (j = 0; j < 0x400; j += 2) { //Loop through the 1k block
|
|
||||||
result = FLASH_Prog((u32) (APP_BASE + i * 0x400 + j), //program each 16 bit block
|
|
||||||
*f_buff++);
|
|
||||||
if (result != FLASH_COMPLETE) { //something went wrong
|
|
||||||
FLASH_Lock(); //make sure the flash is locked again
|
|
||||||
return ERR; //return ERR
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FLASH_Lock();
|
|
||||||
return RDY;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: ReWrite_All
|
|
||||||
Description:
|
|
||||||
Output:
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 ReWrite_All(void) {
|
|
||||||
u16 i;
|
|
||||||
u8 result;
|
|
||||||
u16 *f_buff = (u16*) gDisk_buff;
|
|
||||||
|
|
||||||
FLASH_Unlock();
|
|
||||||
for (i = 0; i < 9; i++)
|
|
||||||
FLASH_Erase(APP_BASE + i * 0x400);
|
|
||||||
for (i = 0; i < 0X2600; i += 2) {
|
|
||||||
result = FLASH_Prog((u32) (APP_BASE + i), *f_buff++);
|
|
||||||
if (result != FLASH_COMPLETE)
|
|
||||||
return ERR;
|
|
||||||
}
|
|
||||||
FLASH_Lock();
|
|
||||||
return RDY;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:Erase
|
|
||||||
Description: Erase the first 9k from APP_BASE
|
|
||||||
*******************************************************************************/
|
|
||||||
void Erase(void) {
|
|
||||||
u16 i;
|
|
||||||
FLASH_Unlock(); //unlock the mcu flash controller
|
|
||||||
for (i = 0; i < 9; i++)
|
|
||||||
FLASH_Erase(APP_BASE + i * 0x400); //erase the flash
|
|
||||||
|
|
||||||
FLASH_Lock();
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Read_Memory
|
|
||||||
Description:
|
|
||||||
*******************************************************************************/
|
|
||||||
void Read_Memory(u32 r_offset, u32 r_length) {
|
|
||||||
static u32 offset, length, block_offset;
|
|
||||||
|
|
||||||
if (gVar[USB_ST] == TXFR_IDLE) {
|
|
||||||
offset = r_offset * SECTOR_SIZE;
|
|
||||||
length = r_length * SECTOR_SIZE;
|
|
||||||
gVar[USB_ST] = TXFR_ONGOING;
|
|
||||||
}
|
|
||||||
if (gVar[USB_ST] == TXFR_ONGOING) {
|
|
||||||
if (!gV32[RD_CNT]) {
|
|
||||||
Disk_SecRead(gBuff, offset);
|
|
||||||
UserToPMABufferCopy(gBuff, ENDP1_TXADDR, BULK_MAX_PACKET_SIZE);
|
|
||||||
gV32[RD_CNT] = SECTOR_SIZE - BULK_MAX_PACKET_SIZE;
|
|
||||||
block_offset = BULK_MAX_PACKET_SIZE;
|
|
||||||
} else {
|
|
||||||
UserToPMABufferCopy(gBuff + block_offset, ENDP1_TXADDR,
|
|
||||||
BULK_MAX_PACKET_SIZE);
|
|
||||||
gV32[RD_CNT] -= BULK_MAX_PACKET_SIZE;
|
|
||||||
block_offset += BULK_MAX_PACKET_SIZE;
|
|
||||||
}
|
|
||||||
SetEPTxCount(ENDP1, BULK_MAX_PACKET_SIZE);
|
|
||||||
SetEPTxStatus(ENDP1, EP_TX_VALID);
|
|
||||||
offset += BULK_MAX_PACKET_SIZE;
|
|
||||||
length -= BULK_MAX_PACKET_SIZE;
|
|
||||||
|
|
||||||
CSW.dDataResidue -= BULK_MAX_PACKET_SIZE;
|
|
||||||
}
|
|
||||||
if (length == 0) {
|
|
||||||
gV32[RD_CNT] = 0;
|
|
||||||
block_offset = 0;
|
|
||||||
offset = 0;
|
|
||||||
Bot_State = BOT_DATA_IN_LAST;
|
|
||||||
gVar[USB_ST] = TXFR_IDLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Write_Memory
|
|
||||||
Description:
|
|
||||||
*******************************************************************************/
|
|
||||||
void Write_Memory(u32 w_offset, u32 w_length) {
|
|
||||||
static u32 offset, length;
|
|
||||||
u32 idx, temp = gV32[WR_CNT] + 64;
|
|
||||||
|
|
||||||
if (gVar[USB_ST] == TXFR_IDLE) {
|
|
||||||
offset = w_offset * SECTOR_SIZE;
|
|
||||||
length = w_length * SECTOR_SIZE;
|
|
||||||
gVar[USB_ST] = TXFR_ONGOING;
|
|
||||||
}
|
|
||||||
if (gVar[USB_ST] == TXFR_ONGOING) {
|
|
||||||
for (idx = 0; gV32[WR_CNT] < temp; gV32[WR_CNT]++)
|
|
||||||
*(u8 *) (gBuff + gV32[WR_CNT]) = Bulk_Buff[idx++];
|
|
||||||
|
|
||||||
offset += Data_Len;
|
|
||||||
length -= Data_Len;
|
|
||||||
|
|
||||||
if (!(length % SECTOR_SIZE)) {
|
|
||||||
gV32[WR_CNT] = 0;
|
|
||||||
Disk_SecWrite(gBuff, offset - SECTOR_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
CSW.dDataResidue -= Data_Len;
|
|
||||||
SetEPRxStatus(ENDP2, EP_RX_VALID); /* enable the next transaction*/
|
|
||||||
}
|
|
||||||
if ((length == 0) || (Bot_State == BOT_CSW_Send)) {
|
|
||||||
gV32[WR_CNT] = 0;
|
|
||||||
Set_CSW(CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
|
||||||
gVar[USB_ST] = TXFR_IDLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
|
||||||
File Name : EXT_Flash.c
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : bure
|
|
||||||
Data:
|
|
||||||
History:
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "Ext_Flash.h"
|
|
||||||
#include "Bios.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define OK 0 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
#define SEC_ERR 1 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
|
||||||
#define TMAX 100000 // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
u32 Mass_Memory_Size;
|
|
||||||
u32 Mass_Block_Size;
|
|
||||||
u32 Mass_Block_Count;
|
|
||||||
u32 Tout;
|
|
||||||
|
|
||||||
|
|
||||||
u8 flash_mode;
|
|
||||||
|
|
||||||
void ExtFLASH_SectorErase(u32 SectorAddr);
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
SPI_FLASH_SectorErase : Sector Erases the specified FLASH Page.(4k/sector)
|
|
||||||
*******************************************************************************/
|
|
||||||
void ExtFLASH_SectorErase(u32 SectorAddr)
|
|
||||||
{
|
|
||||||
ExtFlash_WriteEnable();
|
|
||||||
ExtFlash_CS_LOW();
|
|
||||||
ExtFlash_SendByte(SE);
|
|
||||||
ExtFlash_SendByte((SectorAddr & 0xFF0000) >> 16); //Send high address byte
|
|
||||||
ExtFlash_SendByte((SectorAddr & 0xFF00) >> 8); //Send medium address byte
|
|
||||||
ExtFlash_SendByte(SectorAddr & 0xFF); //Send low address byte
|
|
||||||
ExtFlash_CS_HIGH();
|
|
||||||
ExtFlash_WaitForWriteEnd(); // Wait the end of Flash writing
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ExtFlash_PageWR(u8* pBuffer, u32 WriteAddr)
|
|
||||||
{
|
|
||||||
u32 addr,i,j;
|
|
||||||
u8* ptr;
|
|
||||||
u8 page=0,flag=0,write_mode;
|
|
||||||
u8 buffer[256];
|
|
||||||
|
|
||||||
flag=0;
|
|
||||||
if(flash_mode==FLASH_8M) {
|
|
||||||
addr=WriteAddr & 0xFFF000;
|
|
||||||
page=16;
|
|
||||||
} else {
|
|
||||||
page=1;
|
|
||||||
addr=WriteAddr & 0xFFFF00;
|
|
||||||
}
|
|
||||||
while(page>0) {
|
|
||||||
ExtFlash_PageRD((u8*)&buffer,addr, 256);
|
|
||||||
for(j=0; j<255; j++) {
|
|
||||||
if(buffer[j++]!=0xff) {
|
|
||||||
flag=1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addr+=256;
|
|
||||||
page--;
|
|
||||||
}
|
|
||||||
if(flash_mode==FLASH_8M) {
|
|
||||||
page=16;
|
|
||||||
addr=WriteAddr & 0xFFF000;
|
|
||||||
if(flag==1)ExtFLASH_SectorErase(addr);
|
|
||||||
write_mode=PP;
|
|
||||||
} else {
|
|
||||||
page=1;
|
|
||||||
addr=WriteAddr & 0xFFFF00;
|
|
||||||
if(flag==1)write_mode=PW;
|
|
||||||
else write_mode=PP;
|
|
||||||
}
|
|
||||||
ptr=pBuffer;
|
|
||||||
for(i=0; i<page; i++) {
|
|
||||||
ExtFlash_PageProg(ptr, addr,write_mode);
|
|
||||||
addr+=256;
|
|
||||||
ptr+=256;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
дFLASHҳ(256 Bytes)<29><> Mode=0: <20><>0<EFBFBD><30>1<EFBFBD><31><EFBFBD>ݸ<EFBFBD>д Mode=1: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д
|
|
||||||
*******************************************************************************/
|
|
||||||
void ExtFlash_PageProg(u8* pBuffer, u32 WriteAddr,u8 CMD)
|
|
||||||
{
|
|
||||||
u16 Lenght = 256;
|
|
||||||
|
|
||||||
ExtFlash_CS_HIGH();
|
|
||||||
ExtFlash_WaitForWriteEnd();
|
|
||||||
ExtFlash_WriteEnable();
|
|
||||||
ExtFlash_CS_LOW();
|
|
||||||
ExtFlash_SendByte(CMD);
|
|
||||||
ExtFlash_SendByte((WriteAddr & 0xFF0000) >> 16);
|
|
||||||
ExtFlash_SendByte((WriteAddr & 0xFF00) >> 8);
|
|
||||||
ExtFlash_SendByte(WriteAddr & 0xFF);
|
|
||||||
while(Lenght--) { // while there is data to be written on the FLASH
|
|
||||||
ExtFlash_SendByte((*pBuffer));
|
|
||||||
pBuffer++;
|
|
||||||
}
|
|
||||||
ExtFlash_CS_HIGH();
|
|
||||||
ExtFlash_WaitForWriteEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
SPI_FLASH_BufferRead
|
|
||||||
*******************************************************************************/
|
|
||||||
void ExtFlash_PageRD(u8* pBuffer, u32 ReadAddr, u16 Lenght)
|
|
||||||
{
|
|
||||||
ExtFlash_CS_HIGH();
|
|
||||||
ExtFlash_WaitForWriteEnd();
|
|
||||||
ExtFlash_CS_LOW();
|
|
||||||
ExtFlash_SendByte(READ);
|
|
||||||
ExtFlash_SendByte((ReadAddr & 0xFF0000) >> 16);
|
|
||||||
ExtFlash_SendByte((ReadAddr& 0xFF00) >> 8);
|
|
||||||
ExtFlash_SendByte(ReadAddr & 0xFF);
|
|
||||||
|
|
||||||
while(Lenght--) { // while there is data to be read
|
|
||||||
*pBuffer = (ExtFlash_SendByte(Dummy_Byte));
|
|
||||||
pBuffer++;
|
|
||||||
}
|
|
||||||
ExtFlash_CS_HIGH();
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SPI_FLASH_ReadByte
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 ExtFlash_ReadByte(void)
|
|
||||||
{
|
|
||||||
return (ExtFlash_SendByte(Dummy_Byte));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
SPI_FLASH_SendByte
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 ExtFlash_SendByte(u8 byte)
|
|
||||||
{
|
|
||||||
Tout = 0;
|
|
||||||
while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_TXE) == RESET) {
|
|
||||||
if(Tout++ > TMAX) return 255;
|
|
||||||
}
|
|
||||||
SPI_I2S_SendData(SPI3, byte);
|
|
||||||
Tout = 0;
|
|
||||||
while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_RXNE) == RESET) {
|
|
||||||
if(Tout++ > TMAX) return 255;
|
|
||||||
}
|
|
||||||
return SPI_I2S_ReceiveData(SPI3);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SPI_FLASH_WriteEnable
|
|
||||||
*******************************************************************************/
|
|
||||||
void ExtFlash_WriteEnable(void)
|
|
||||||
{
|
|
||||||
ExtFlash_CS_LOW();
|
|
||||||
ExtFlash_SendByte(WREN);
|
|
||||||
ExtFlash_CS_HIGH();
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SPI_FLASH_WaitForWriteEnd
|
|
||||||
*******************************************************************************/
|
|
||||||
void ExtFlash_WaitForWriteEnd(void)
|
|
||||||
{
|
|
||||||
u8 FLASH_Status = 0;
|
|
||||||
|
|
||||||
ExtFlash_CS_LOW();
|
|
||||||
ExtFlash_SendByte(RDSR);
|
|
||||||
Tout = 0;
|
|
||||||
do {
|
|
||||||
FLASH_Status = ExtFlash_SendByte(Dummy_Byte);
|
|
||||||
if(Tout++ > TMAX) return;
|
|
||||||
} while((FLASH_Status & WIP_Flag) == SET); // Write in progress
|
|
||||||
ExtFlash_CS_HIGH();
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
MAL_GetStatus
|
|
||||||
*******************************************************************************/
|
|
||||||
void MAL_GetStatus (void)
|
|
||||||
{
|
|
||||||
if(flash_mode==FLASH_8M) {
|
|
||||||
Mass_Block_Count = 2048; //FLASH_SIZE/FLASH_PAGE_SIZE;
|
|
||||||
Mass_Block_Size = 512*8; //FLASH_PAGE_SIZE; 4096
|
|
||||||
Mass_Memory_Size = 512*4096*4 ; //FLASH_SIZE; 0x800000;
|
|
||||||
} else {
|
|
||||||
Mass_Block_Count = 4096; //FLASH_SIZE/FLASH_PAGE_SIZE; 4096
|
|
||||||
Mass_Block_Size = 512; //FLASH_PAGE_SIZE;
|
|
||||||
Mass_Memory_Size = 512*4096 ; //FLASH_SIZE; 0x200000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
|
|
||||||
File Name : Flash.c
|
|
||||||
Version : Author : bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#include "APP_Version.h"
|
|
||||||
#include "Flash.h"
|
|
||||||
#include "Bios.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: FLASH_Prog
|
|
||||||
Description: Programs the data into the system flash at the specified address
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 FLASH_Prog(u32 Address, u16 Data) {
|
|
||||||
if (FLASH_WaitForLastOperation(WAIT_TIMES) != FLASH_TIMEOUT)
|
|
||||||
FLASH_ClearFlag(
|
|
||||||
FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
|
|
||||||
return FLASH_ProgramHalfWord(Address, Data);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: FLASH_Erase
|
|
||||||
Description: Erases a page of flash
|
|
||||||
Inputs: Starting address for the page to erase
|
|
||||||
*******************************************************************************/
|
|
||||||
void FLASH_Erase(u32 Address) {
|
|
||||||
if (Address % FLASH_PAGE == 0) { // FLASH Page start (1K/Page)
|
|
||||||
if (FLASH_WaitForLastOperation(WAIT_TIMES) != FLASH_TIMEOUT) //wait for last op to finish
|
|
||||||
FLASH_ClearFlag(
|
|
||||||
FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
|
|
||||||
FLASH_ErasePage(Address); // FLASH Page erase
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -1,384 +0,0 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
|
||||||
File Name : CTRL.c
|
|
||||||
Version : S100 APP Ver 2.11
|
|
||||||
Description:
|
|
||||||
Author : Celery
|
|
||||||
Data: 2015/07/07
|
|
||||||
History:
|
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
2015/07/20 <20>Ӵ<EFBFBD><D3B4>¶ȱ<C2B6><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "APP_Version.h"
|
|
||||||
#include "Hardware.h"
|
|
||||||
#include "CTRL.h"
|
|
||||||
#include "Bios.h"
|
|
||||||
#include "UI.h"
|
|
||||||
/******************************************************************************/
|
|
||||||
#define CAL_AD 250
|
|
||||||
const u32 gVol[] = { 3900, 2760, 1720, 584 };
|
|
||||||
const u16 gRate[] = { 300, 150, 90, 40 };
|
|
||||||
s32 gZerop_ad = 239;
|
|
||||||
u32 gTurn_offv = 100;
|
|
||||||
u8 gCalib_flag = 0;
|
|
||||||
vu16 gMeas_cnt = 0;/* Measure*/
|
|
||||||
u32 gKey_in;
|
|
||||||
u8 gLongkey_flag = 0;
|
|
||||||
u8 gAlarm_type = 1;
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_CalFlag
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡУ״̬
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:У״̬<D7B4><CCAC>־
|
|
||||||
*******************************************************************************/
|
|
||||||
u32 Get_CalFlag(void) {
|
|
||||||
return gCalib_flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_gKey
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>״̬
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:<3A><><EFBFBD><EFBFBD>״̬
|
|
||||||
*******************************************************************************/
|
|
||||||
u32 Get_gKey(void) {
|
|
||||||
return gKey_in;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_gKey
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ð<EFBFBD><C3B0><EFBFBD>״̬
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:Ҫ<><D2AA><EFBFBD>õİ<C3B5><C4B0><EFBFBD>״̬
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void Set_gKey(u32 key) {
|
|
||||||
gKey_in = key;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_LongKeyFlag
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:0 :<3A><><EFBFBD><EFBFBD><EFBFBD>Գ<EFBFBD><D4B3><EFBFBD><EFBFBD><EFBFBD> 1: <20><><EFBFBD>Գ<EFBFBD><D4B3><EFBFBD>
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void Set_LongKeyFlag(u32 flag) {
|
|
||||||
gLongkey_flag = flag;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_AlarmType
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
0:<3A><><EFBFBD><EFBFBD>
|
|
||||||
1:sensor - err
|
|
||||||
2:<3A><><EFBFBD><EFBFBD>
|
|
||||||
3:<3A><>ѹ
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 Get_AlarmType(void) {
|
|
||||||
return gAlarm_type;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Set_AlarmType
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
0:<3A><><EFBFBD><EFBFBD>
|
|
||||||
1:sen - err
|
|
||||||
2:<3A><><EFBFBD><EFBFBD>
|
|
||||||
3:<3A><>ѹ
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void Set_AlarmType(u8 type) {
|
|
||||||
gAlarm_type = type;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Read_Vb
|
|
||||||
Description:Reads the input voltage and compares it to the thresholds??
|
|
||||||
Input:Selects which threshold we are comparing to
|
|
||||||
Output:Returns a key for if the voltage is in spec (I think)
|
|
||||||
*******************************************************************************/
|
|
||||||
int Read_Vb(u8 flag) {
|
|
||||||
u32 tmp, i, sum = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < 10; i++) {
|
|
||||||
tmp = ADC_GetConversionValue(ADC2);
|
|
||||||
sum += tmp;
|
|
||||||
}
|
|
||||||
tmp = sum / 10;
|
|
||||||
if (tmp >= (gVol[0] + gVol[0] / 100)) {
|
|
||||||
gAlarm_type = HIGH_VOLTAGE;
|
|
||||||
return H_ALARM; //<2F><><EFBFBD><EFBFBD>3500
|
|
||||||
}
|
|
||||||
tmp = (tmp * 10 / 144); //<2F><>ѹvb = 3.3 * 85 *ad / 40950
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
|
||||||
if (i == 2) {
|
|
||||||
if (flag == 0) {
|
|
||||||
if (tmp >= gRate[i])
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if (tmp >= gTurn_offv)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (tmp >= gRate[i])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (i + 1);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Scan_Key
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD>(50msÿ<73><C3BF>)
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void Scan_Key(void) {
|
|
||||||
static u32 p_cnt = 0, key_statuslast = 0;
|
|
||||||
u32 key_state = 0;
|
|
||||||
|
|
||||||
if ((~GPIOA->IDR) & 0x0200)
|
|
||||||
key_state |= KEY_V1; //KEY_V1
|
|
||||||
if ((~GPIOA->IDR) & 0x0040)
|
|
||||||
key_state |= KEY_V2; //KEY_V2
|
|
||||||
|
|
||||||
if (key_state == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (gLongkey_flag == 1) { //LongKey_flag :<3A><><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
|
||||||
if (key_statuslast == key_state) {
|
|
||||||
p_cnt++;
|
|
||||||
if (p_cnt > 21)
|
|
||||||
Set_gKey(KEY_CN | key_state); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
} else {
|
|
||||||
p_cnt = 0;
|
|
||||||
key_statuslast = key_state;
|
|
||||||
Set_gKey(key_state);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p_cnt = 0;
|
|
||||||
key_statuslast = key_state;
|
|
||||||
Set_gKey(key_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_SlAvg
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>ֵ
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:avg_data ƽ<><C6BD><EFBFBD><EFBFBD>ADֵ
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:<3A><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>ֵ
|
|
||||||
*******************************************************************************/
|
|
||||||
u32 Get_SlAvg(u32 avg_data) {
|
|
||||||
static u32 sum_avg = 0;
|
|
||||||
static u8 init_flag = 0;
|
|
||||||
u16 si_avg = sum_avg / SI_COE, abs;
|
|
||||||
|
|
||||||
if (init_flag == 0) { /*<2A><>һ<EFBFBD><D2BB><EFBFBD>ϵ<EFBFBD>*/
|
|
||||||
sum_avg = SI_COE * avg_data;
|
|
||||||
init_flag = 1;
|
|
||||||
return sum_avg / SI_COE;
|
|
||||||
}
|
|
||||||
if (avg_data > si_avg)
|
|
||||||
abs = avg_data - si_avg;
|
|
||||||
else
|
|
||||||
abs = si_avg - avg_data;
|
|
||||||
|
|
||||||
if (abs > SI_THRESHOLD)
|
|
||||||
sum_avg = SI_COE * avg_data;
|
|
||||||
else
|
|
||||||
sum_avg += avg_data - sum_avg / SI_COE;
|
|
||||||
|
|
||||||
return sum_avg / SI_COE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:
|
|
||||||
Description: Read the thermocouple in the soldering iron head
|
|
||||||
Output:Soldering Iron temperature
|
|
||||||
*******************************************************************************/
|
|
||||||
u32 Get_AvgAd(void) {
|
|
||||||
/*The head has a thermocouple inline with the heater
|
|
||||||
This is read by turning off the heater
|
|
||||||
Then read the output of the op-amp that is connected across the connections
|
|
||||||
*/
|
|
||||||
static u32 ad_sum = 0;
|
|
||||||
static u32 max = 0, min = 5000;
|
|
||||||
u32 ad_value, avg_data, slide_data = 0;
|
|
||||||
|
|
||||||
Set_HeatingTime(0); //set the remaining time to zero
|
|
||||||
HEAT_OFF(); //heater must be off
|
|
||||||
Delay_HalfMs(25); //wait for the heater to time out
|
|
||||||
gMeas_cnt = 10; //how many measurements to make
|
|
||||||
|
|
||||||
while (gMeas_cnt > 0) {
|
|
||||||
ad_value = Get_AdcValue(0); //Read_Tmp();
|
|
||||||
ad_sum += ad_value;
|
|
||||||
if (ad_value > max)
|
|
||||||
max = ad_value;
|
|
||||||
if (ad_value < min)
|
|
||||||
min = ad_value;
|
|
||||||
|
|
||||||
if (gMeas_cnt == 1) { //We have just taken the last reading
|
|
||||||
ad_sum = ad_sum - max - min; //remove the two outliers
|
|
||||||
avg_data = ad_sum / 8; //take the average
|
|
||||||
|
|
||||||
slide_data = Get_SlAvg(avg_data);
|
|
||||||
ad_sum = 0;
|
|
||||||
min = 5000;
|
|
||||||
max = 0;
|
|
||||||
}
|
|
||||||
gMeas_cnt--;
|
|
||||||
}
|
|
||||||
return slide_data; //gSlide_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:
|
|
||||||
Description:
|
|
||||||
*******************************************************************************/
|
|
||||||
int Get_TempSlAvg(int avg_data) {
|
|
||||||
static int sum_avg = 0;
|
|
||||||
static u8 init_flag = 0;
|
|
||||||
|
|
||||||
if (init_flag == 0) {
|
|
||||||
sum_avg = 8 * avg_data;
|
|
||||||
init_flag = 1;
|
|
||||||
return sum_avg / 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
sum_avg += avg_data - sum_avg / 8;
|
|
||||||
|
|
||||||
return sum_avg / 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:
|
|
||||||
Description:Reads the temperature of the on board temp sensor for calibration
|
|
||||||
http://www.analog.com/media/en/technical-documentation/data-sheets/TMP35_36_37.pdf
|
|
||||||
Output: The onboardTemp in C
|
|
||||||
*******************************************************************************/
|
|
||||||
int Get_SensorTmp(void) {
|
|
||||||
u32 ad_sum = 0;
|
|
||||||
u32 max = 0, min = 5000;
|
|
||||||
u32 ad_value, avg_data, slide_data;
|
|
||||||
int sensor_temp = 0;
|
|
||||||
|
|
||||||
gMeas_cnt = 10;
|
|
||||||
|
|
||||||
while (gMeas_cnt > 0) {
|
|
||||||
ad_value = Get_AdcValue(1);
|
|
||||||
ad_sum += ad_value;
|
|
||||||
if (ad_value > max)
|
|
||||||
max = ad_value;
|
|
||||||
if (ad_value < min)
|
|
||||||
min = ad_value;
|
|
||||||
|
|
||||||
if (gMeas_cnt == 1) {
|
|
||||||
ad_sum = ad_sum - max - min;
|
|
||||||
avg_data = ad_sum / 8;
|
|
||||||
//^ Removes the two outliers from the data spread
|
|
||||||
slide_data = Get_TempSlAvg(avg_data);
|
|
||||||
sensor_temp = (250 + (3300 * slide_data / 4096) - 750); //(25 + ((10*(33*gSlide_data)/4096)-75));
|
|
||||||
//^ Convert the reading to C
|
|
||||||
ad_sum = 0;
|
|
||||||
min = 5000;
|
|
||||||
max = 0;
|
|
||||||
}
|
|
||||||
gMeas_cnt--;
|
|
||||||
}
|
|
||||||
return sensor_temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:
|
|
||||||
Description: Reads the Zero Temp.. And does something..
|
|
||||||
*******************************************************************************/
|
|
||||||
void Zero_Calibration(void) {
|
|
||||||
u32 zerop;
|
|
||||||
int cool_tmp;
|
|
||||||
|
|
||||||
zerop = Get_AvgAd(); //get the current
|
|
||||||
cool_tmp = Get_SensorTmp(); //get the temp of the onboard sensor
|
|
||||||
|
|
||||||
if (zerop >= 400) { //If the tip is too hot abort
|
|
||||||
gCalib_flag = 2;
|
|
||||||
} else {
|
|
||||||
if (cool_tmp < 300) { //If cool temp is cool enough continue
|
|
||||||
gZerop_ad = zerop; //store the zero point
|
|
||||||
gCalib_flag = 1;
|
|
||||||
} else { //abort if too warm
|
|
||||||
gCalib_flag = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Get_Temp
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>ȶ<EFBFBD><C8B6>¶<EFBFBD>,<2C><><EFBFBD><EFBFBD>AD<41><44><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:wk_temp <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:ʵ<><CAB5><EFBFBD>¶<EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
s16 Get_Temp(s16 wk_temp) {
|
|
||||||
int ad_value, cool_tmp, compensation = 0;
|
|
||||||
static u16 cnt = 0, h_cnt = 0;
|
|
||||||
|
|
||||||
ad_value = Get_AvgAd();
|
|
||||||
cool_tmp = Get_SensorTmp();
|
|
||||||
|
|
||||||
if (ad_value == 4095)
|
|
||||||
h_cnt++;
|
|
||||||
else {
|
|
||||||
h_cnt = 0;
|
|
||||||
if (ad_value > 3800 && ad_value < 4095)
|
|
||||||
cnt++;
|
|
||||||
else
|
|
||||||
cnt = 0;
|
|
||||||
}
|
|
||||||
if (h_cnt >= 60 && cnt == 0)
|
|
||||||
gAlarm_type = SEN_ERR; //Sensor error -- too many invalid readings
|
|
||||||
if (h_cnt == 0 && cnt >= 10)
|
|
||||||
gAlarm_type = HIGH_TEMP; //Stuck at a really high temp -> Has mosfet failed
|
|
||||||
if (h_cnt < 60 && cnt < 10)
|
|
||||||
gAlarm_type = NORMAL_TEMP; //No errors so far
|
|
||||||
|
|
||||||
compensation = 80 + 150 * (wk_temp - 1000) / 3000;
|
|
||||||
if (wk_temp == 1000)
|
|
||||||
compensation -= 10;
|
|
||||||
|
|
||||||
if (wk_temp != 0) {
|
|
||||||
if (ad_value > (compensation + gZerop_ad))
|
|
||||||
ad_value -= compensation;
|
|
||||||
}
|
|
||||||
if (cool_tmp > 400)
|
|
||||||
cool_tmp = 400; //cap cool temp at 40C
|
|
||||||
|
|
||||||
return (ad_value * 1000 + 806 * cool_tmp - gZerop_ad * 1000) / 806;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:Start_Watchdog
|
|
||||||
Description: Starts the system watchdog timer
|
|
||||||
*******************************************************************************/
|
|
||||||
u32 Start_Watchdog(u32 ms) {
|
|
||||||
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
|
|
||||||
|
|
||||||
/* IWDG counter clock: 40KHz(LSI) / 32 = 1.25 KHz (min:0.8ms -- max:3276.8ms */
|
|
||||||
IWDG_SetPrescaler(IWDG_Prescaler_32);
|
|
||||||
|
|
||||||
/* Set counter reload value to XXms */
|
|
||||||
IWDG_SetReload(ms * 10 / 8);
|
|
||||||
|
|
||||||
/* Reload IWDG counter */
|
|
||||||
IWDG_ReloadCounter();
|
|
||||||
|
|
||||||
/* Enable IWDG (the LSI oscillator will be enabled by hardware) */
|
|
||||||
IWDG_Enable();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:Clear_Watchdog
|
|
||||||
Description:Resets the watchdog timer
|
|
||||||
*******************************************************************************/
|
|
||||||
void Clear_Watchdog(void) {
|
|
||||||
IWDG_ReloadCounter();
|
|
||||||
|
|
||||||
}
|
|
||||||
/******************************** END OF FILE *********************************/
|
|
||||||
@@ -1,229 +1,148 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
/*
|
||||||
File Name : I2C.c
|
* I2C.h hardware interface class
|
||||||
Version : S100 APP Ver 2.11
|
* Based on the STM32 app note AN2824
|
||||||
Description:
|
*/
|
||||||
Author : Celery
|
|
||||||
Data: 2015/07/20
|
|
||||||
History:
|
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
2015/07/21 I2C_DELAYTIME = 2;
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include "stm32f10x.h"
|
|
||||||
#include "I2C.h"
|
#include "I2C.h"
|
||||||
#include "Bios.h"
|
|
||||||
#include "Oled.h"
|
|
||||||
#include "S100V0_1.h"
|
|
||||||
|
|
||||||
// --------- <20><><EFBFBD><EFBFBD>I2C<32>ӿ<EFBFBD><D3BF><EFBFBD>ض<EFBFBD><D8B6><EFBFBD>-------- //
|
/*
|
||||||
#define SDA GPIO_Pin_7
|
* Configure the I2C port hardware
|
||||||
#define SCL GPIO_Pin_6
|
*/
|
||||||
|
void I2C_Configuration(void) {
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
I2C_InitTypeDef I2C_InitStructure;
|
||||||
|
|
||||||
#define HIGH 1
|
/* PB6,7 SCL and SDA */
|
||||||
#define LOW 0
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
|
||||||
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
||||||
#define SDA_VAL GPIO_ReadInputDataBit(GPIOB, SDA)
|
/* I2C1 configuration ------------------------------------------------------*/
|
||||||
#define SCL_VAL GPIO_ReadInputDataBit(GPIOB, SCL)
|
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
|
||||||
|
I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
|
||||||
#define I2C_MORE 1
|
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
|
||||||
#define I2C_LAST 0
|
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
|
||||||
#define I2C_TIMEOUT 255
|
I2C_InitStructure.I2C_ClockSpeed = 400000; //400k
|
||||||
|
I2C_Init(I2C1, &I2C_InitStructure);
|
||||||
#define FAILURE 0
|
I2C_Cmd(I2C1, ENABLE);
|
||||||
#define SUCCEED 1
|
|
||||||
#define I2C_DELAYTIME 2
|
|
||||||
|
|
||||||
static void Sim_I2C_Set(u8 pin, u8 status);
|
|
||||||
static void Sim_I2C_Stop(void);
|
|
||||||
static void Sim_I2C_Start(void);
|
|
||||||
static u8 Sim_I2C_RD_Byte(u8 more);
|
|
||||||
static u8 Sim_I2C_WR_Byte(u8 data);
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Delay_uS
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD>ʱ
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:us
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void Delay_uS(u32 us)
|
|
||||||
{
|
|
||||||
while(us) us--;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: I2C_Configuration
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD>I2C
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void I2C_Configuration(void)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
|
||||||
I2C_InitTypeDef I2C_InitStructure;
|
|
||||||
|
|
||||||
GPIO_Init_OLED();
|
|
||||||
/* PB6,7 SCL and SDA */
|
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
|
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
|
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
|
||||||
|
|
||||||
/* I2C1 configuration ------------------------------------------------------*/
|
|
||||||
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
|
|
||||||
I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
|
|
||||||
I2C_InitStructure.I2C_OwnAddress1 = DEVICEADDR_OLED;
|
|
||||||
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
|
|
||||||
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
|
|
||||||
I2C_InitStructure.I2C_ClockSpeed = 100000;//100k
|
|
||||||
I2C_Init(I2C1, &I2C_InitStructure);
|
|
||||||
I2C_Cmd(I2C1, ENABLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: I2C_Configuration
|
* Writes a page of data over I2C using the I2C1 peripheral in the stm32
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD>I2C
|
*
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
*/
|
||||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
void I2C_PageWrite(u8* buf, u8 nbyte, u8 deviceaddr) {
|
||||||
*******************************************************************************/
|
|
||||||
void Sim_I2C_Set(u8 pin, u8 status)
|
|
||||||
{
|
|
||||||
if(status == HIGH) GPIO_SetBits (GPIOB, pin);
|
|
||||||
if(status == LOW) GPIO_ResetBits(GPIOB, pin);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sim_I2C_Start
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>ʼ
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void Sim_I2C_Start(void)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
|
||||||
|
|
||||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); // I2C_PIN_EN();
|
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY)) {
|
||||||
GPIO_InitStructure.GPIO_Pin = SCL | SDA;
|
}
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
|
// Intiate Start Sequence
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
I2C_GenerateSTART(I2C1, ENABLE);
|
||||||
GPIO_Init (GPIOB, &GPIO_InitStructure);
|
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)) {
|
||||||
|
}
|
||||||
|
// Send Address
|
||||||
|
I2C_Send7bitAddress(I2C1, deviceaddr << 1, I2C_Direction_Transmitter);
|
||||||
|
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)) {
|
||||||
|
}
|
||||||
|
// Write first byte EV8_1
|
||||||
|
I2C_SendData(I2C1, *buf++);
|
||||||
|
|
||||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
while (--nbyte) {
|
||||||
Sim_I2C_Set(SDA, HIGH); // SDA float, set as output high
|
// wait on BTF
|
||||||
Sim_I2C_Set(SCL, HIGH); // SCL high
|
while (!I2C_GetFlagStatus(I2C1, I2C_FLAG_BTF)) {
|
||||||
Delay_uS(I2C_DELAYTIME);
|
}
|
||||||
Sim_I2C_Set(SDA, LOW); // SDA high->low while sclk high, S state occur...
|
I2C_SendData(I2C1, *buf++);
|
||||||
Delay_uS(I2C_DELAYTIME);
|
}
|
||||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sim_I2C_Stop
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ֹͣ
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void Sim_I2C_Stop(void)
|
|
||||||
{
|
|
||||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
|
||||||
Sim_I2C_Set(SDA, LOW); // SDA low
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
Sim_I2C_Set(SCL, HIGH); // SCL high
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
Sim_I2C_Set(SDA, HIGH); // SDA low->high while sclk high, P state occur
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sim_I2C_WR_Byte
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>I2Cд<43><D0B4>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:dataҪд<D2AA><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 Sim_I2C_WR_Byte(u8 data)
|
|
||||||
{
|
|
||||||
u8 i = 8;
|
|
||||||
|
|
||||||
while(i--) { //send out a bit by sda line.
|
while (!I2C_GetFlagStatus(I2C1, I2C_FLAG_BTF)) {
|
||||||
Sim_I2C_Set(SCL, LOW); // sclk low
|
}
|
||||||
if(data & 0x80) Sim_I2C_Set(SDA, HIGH); // send bit is 1
|
I2C_GenerateSTOP(I2C1, ENABLE);
|
||||||
else Sim_I2C_Set(SDA, LOW); // send bit is 0
|
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_STOPF)) {
|
||||||
Delay_uS(I2C_DELAYTIME);
|
}
|
||||||
Sim_I2C_Set(SCL, HIGH); // SCL high
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
data <<=1; // left shift 1 bit, MSB send first.
|
|
||||||
}
|
|
||||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
|
||||||
Sim_I2C_Set(SDA, HIGH); // SDA set as input
|
|
||||||
for(i=I2C_TIMEOUT; i!=0; i--) { // wait for sda low to receive ack
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
if (!SDA_VAL) {
|
|
||||||
Sim_I2C_Set(SCL, HIGH); // SCL high
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
Sim_I2C_Set(SCL, LOW); // SCL_LOW();
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
return SUCCEED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sim_I2C_RD_Byte
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>I2C<32><43><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:more
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 Sim_I2C_RD_Byte(u8 more)
|
|
||||||
{
|
|
||||||
u8 i = 8, byte = 0;
|
|
||||||
|
|
||||||
Sim_I2C_Set(SDA, HIGH); // SDA set as input
|
|
||||||
while(i--) {
|
|
||||||
Sim_I2C_Set(SCL, LOW); // SCL low
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
Sim_I2C_Set(SCL, HIGH); // SCL high
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
byte <<=1; //recv a bit
|
|
||||||
if (SDA_VAL) byte |= 0x01;
|
|
||||||
}
|
|
||||||
Sim_I2C_Set(SCL, LOW);
|
|
||||||
if(!more) Sim_I2C_Set(SDA, HIGH); //last byte, send nack.
|
|
||||||
else Sim_I2C_Set(SDA, LOW); //send ack
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
Sim_I2C_Set(SCL, HIGH); // SCL_HIGH();
|
|
||||||
Delay_uS(I2C_DELAYTIME);
|
|
||||||
Sim_I2C_Set(SCL, LOW);
|
|
||||||
return byte;
|
|
||||||
}
|
}
|
||||||
/*******************************************************************************
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: I2C_PageWrite
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><> <20><>ַ deviceaddr д<><D0B4>numbyte<74><65><EFBFBD>ֽڵ<D6BD><DAB5><EFBFBD><EFBFBD>ݣ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>pbuf
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:pbuf д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>numbyte Ϊд<CEAA><D0B4><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>deviceaddrΪд<CEAA><D0B4>ĵ<EFBFBD>ַ
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void I2C_PageWrite(u8* pbuf, u8 numbyte,u8 deviceaddr )
|
|
||||||
{
|
|
||||||
Sim_I2C_Start();
|
|
||||||
Sim_I2C_WR_Byte(deviceaddr<<1);
|
|
||||||
while(numbyte--) Sim_I2C_WR_Byte(*pbuf++);
|
|
||||||
Sim_I2C_Stop();
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: I2C_PageRead
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>I2C<32><43><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: pbuf <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>ŵ<EFBFBD>ַ numbyteΪ<65><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
|
|
||||||
deviceaddr<64>豸<EFBFBD><E8B1B8>ַ readaddr<64><72>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
void I2C_PageRead(u8* pbuf, u8 numbyte,u8 deviceaddr, u8 readaddr)
|
|
||||||
{
|
|
||||||
Sim_I2C_Start();
|
|
||||||
Sim_I2C_WR_Byte(deviceaddr<<1);
|
|
||||||
Sim_I2C_WR_Byte(readaddr);
|
|
||||||
Sim_I2C_Start();
|
|
||||||
Sim_I2C_WR_Byte((deviceaddr<<1)|1);
|
|
||||||
|
|
||||||
while(numbyte--) {
|
/*
|
||||||
if(numbyte) *pbuf++ = Sim_I2C_RD_Byte(I2C_MORE);
|
* Read Page of data using I2C1 peripheral
|
||||||
else *pbuf++ = Sim_I2C_RD_Byte(I2C_LAST);
|
*/
|
||||||
}
|
|
||||||
Sim_I2C_Stop();
|
void I2C_PageRead(u8* buf, u8 nbyte, u8 deviceaddr, u8 readaddr) {
|
||||||
|
I2C_GenerateSTART(I2C1, ENABLE);
|
||||||
|
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_SB) == RESET)
|
||||||
|
;
|
||||||
|
I2C_Send7bitAddress(I2C1, deviceaddr << 1, I2C_Direction_Transmitter);
|
||||||
|
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_ADDR) == RESET)
|
||||||
|
;
|
||||||
|
I2C_GetFlagStatus(I2C1, I2C_FLAG_MSL);
|
||||||
|
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_TXE) == RESET)
|
||||||
|
;
|
||||||
|
// Send an 8bit byte address
|
||||||
|
I2C_SendData(I2C1, readaddr);
|
||||||
|
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY)) {
|
||||||
|
}
|
||||||
|
I2C_AcknowledgeConfig(I2C1, DISABLE);
|
||||||
|
I2C_NACKPositionConfig(I2C1, I2C_NACKPosition_Current);
|
||||||
|
I2C_GenerateSTART(I2C1, ENABLE);
|
||||||
|
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)) {
|
||||||
|
}
|
||||||
|
I2C_Send7bitAddress(I2C1, deviceaddr << 1, I2C_Direction_Receiver);
|
||||||
|
while (!I2C_GetFlagStatus(I2C1, I2C_FLAG_ADDR)) {
|
||||||
|
}
|
||||||
|
if (nbyte == 1) {
|
||||||
|
// Clear Ack bit
|
||||||
|
I2C_AcknowledgeConfig(I2C1, DISABLE);
|
||||||
|
// EV6_1 -- must be atomic -- Clear ADDR, generate STOP
|
||||||
|
__disable_irq();
|
||||||
|
(void) I2C1->SR2;
|
||||||
|
I2C_GenerateSTOP(I2C1, ENABLE);
|
||||||
|
__enable_irq();
|
||||||
|
// Receive data EV7
|
||||||
|
while (!I2C_GetFlagStatus(I2C1, I2C_FLAG_RXNE)) {
|
||||||
|
}
|
||||||
|
*buf++ = I2C_ReceiveData(I2C1);
|
||||||
|
} else if (nbyte == 2) {
|
||||||
|
// Set POS flag
|
||||||
|
I2C_NACKPositionConfig(I2C1, I2C_NACKPosition_Next);
|
||||||
|
// EV6_1 -- must be atomic and in this order
|
||||||
|
__disable_irq();
|
||||||
|
(void) I2C1->SR2; // Clear ADDR flag
|
||||||
|
I2C_AcknowledgeConfig(I2C1, DISABLE); // Clear Ack bit
|
||||||
|
__enable_irq();
|
||||||
|
// EV7_3 -- Wait for BTF, program stop, read data twice
|
||||||
|
while (!I2C_GetFlagStatus(I2C1, I2C_FLAG_BTF)) {
|
||||||
|
}
|
||||||
|
__disable_irq();
|
||||||
|
I2C_GenerateSTOP(I2C1, ENABLE);
|
||||||
|
*buf++ = I2C1->DR;
|
||||||
|
__enable_irq();
|
||||||
|
*buf++ = I2C1->DR;
|
||||||
|
} else {
|
||||||
|
(void) I2C1->SR2; // Clear ADDR flag
|
||||||
|
while (nbyte-- != 3) {
|
||||||
|
// EV7 -- cannot guarantee 1 transfer completion time, wait for BTF
|
||||||
|
// instead of RXNE
|
||||||
|
while (!I2C_GetFlagStatus(I2C1, I2C_FLAG_BTF)) {
|
||||||
|
}
|
||||||
|
*buf++ = I2C_ReceiveData(I2C1);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!I2C_GetFlagStatus(I2C1, I2C_FLAG_BTF)) {
|
||||||
|
}
|
||||||
|
// EV7_2 -- Figure 1 has an error, doesn't read N-2 !
|
||||||
|
I2C_AcknowledgeConfig(I2C1, DISABLE); // clear ack bit
|
||||||
|
__disable_irq();
|
||||||
|
*buf++ = I2C_ReceiveData(I2C1); // receive byte N-2
|
||||||
|
I2C_GenerateSTOP(I2C1, ENABLE); // program stop
|
||||||
|
__enable_irq();
|
||||||
|
*buf++ = I2C_ReceiveData(I2C1); // receive byte N-1
|
||||||
|
// wait for byte N
|
||||||
|
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_RECEIVED)) {
|
||||||
|
}
|
||||||
|
*buf++ = I2C_ReceiveData(I2C1);
|
||||||
|
nbyte = 0;
|
||||||
|
}
|
||||||
|
// Wait for stop
|
||||||
|
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_STOPF)) {
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
/******************************** END OF FILE *********************************/
|
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. *******************/
|
|
||||||
/* Brief : Interrupt Service Routines Author : bure */
|
|
||||||
/******************************************************************************/
|
|
||||||
#include "Interrupt.h"
|
#include "Interrupt.h"
|
||||||
#include "usb_istr.h"
|
|
||||||
#include "Bios.h"
|
#include "Bios.h"
|
||||||
#include "I2C.h"
|
#include "I2C.h"
|
||||||
|
|
||||||
/******************************************************************************/
|
volatile uint32_t system_Ticks;
|
||||||
/* Processor Exceptions Handlers */
|
volatile uint32_t lastKeyPress; //millis() at the last button event
|
||||||
/******************************************************************************/
|
volatile uint16_t keyState; //tracks the button status
|
||||||
|
volatile uint32_t lastMovement; //millis() at last movement event
|
||||||
|
|
||||||
|
//Delay in milliseconds using systemTick
|
||||||
|
void delayMs(uint32_t ticks) {
|
||||||
|
uint32_t endtime = ticks + millis();
|
||||||
|
while (millis() < endtime)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
void NMI_Handler(void) {
|
void NMI_Handler(void) {
|
||||||
;
|
;
|
||||||
@@ -34,6 +38,160 @@ void UsageFault_Handler(void) {
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Handles the tick of the sysTick events
|
||||||
|
void SysTick_Handler(void) {
|
||||||
|
++system_Ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Peripheral Interrupts */
|
||||||
|
|
||||||
|
void TIM3_IRQHandler(void) {
|
||||||
|
TIM3_ISR();
|
||||||
|
}
|
||||||
|
|
||||||
|
//EXTI IRQ handler
|
||||||
|
//used for buttons and movement
|
||||||
|
void EXTI9_5_IRQHandler(void) {
|
||||||
|
//we are interested in line 9 and line 6 for buttons
|
||||||
|
//Line 5 == movement
|
||||||
|
if (EXTI_GetITStatus(EXTI_Line9) != RESET) {
|
||||||
|
if (GPIO_ReadInputDataBit(GPIOA, KEY_A) == SET)
|
||||||
|
keyState &= ~(BUT_A);
|
||||||
|
else
|
||||||
|
keyState |= BUT_A;
|
||||||
|
lastKeyPress = millis();
|
||||||
|
EXTI_ClearITPendingBit(EXTI_Line9);
|
||||||
|
} else if (EXTI_GetITStatus(EXTI_Line6) != RESET) {
|
||||||
|
if (GPIO_ReadInputDataBit(GPIOA, KEY_B) == SET)
|
||||||
|
keyState &= ~(BUT_B);
|
||||||
|
else
|
||||||
|
keyState |= BUT_B;
|
||||||
|
lastKeyPress = millis();
|
||||||
|
EXTI_ClearITPendingBit(EXTI_Line6);
|
||||||
|
} else if (EXTI_GetITStatus(EXTI_Line5) != RESET) { //Movement Event
|
||||||
|
lastMovement = millis();
|
||||||
|
EXTI_ClearITPendingBit(EXTI_Line5);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************** UNUSED IRQ *****************************************/
|
||||||
|
void WWDG_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void PVD_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TAMPER_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void RTC_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void FLASH_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void RCC_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void EXTI0_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void EXTI1_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void EXTI2_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void EXTI3_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void EXTI4_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void DMA1_Channel1_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void DMA1_Channel2_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void DMA1_Channel3_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void DMA1_Channel4_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void DMA1_Channel5_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void DMA1_Channel6_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void DMA1_Channel7_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void ADC1_2_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void USB_HP_CAN1_TX_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void CAN1_RX1_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void CAN1_SCE_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void TIM1_BRK_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM1_UP_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM1_TRG_COM_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM1_CC_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM4_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void I2C1_EV_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void I2C1_ER_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void I2C2_EV_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void I2C2_ER_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void SPI1_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void SPI2_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void USART1_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void USART2_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void USART3_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void EXTI15_10_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void RTCAlarm_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void USBWakeUp_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM8_BRK_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM8_UP_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM8_TRG_COM_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM8_CC_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void ADC3_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void FSMC_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void SDIO_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM5_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void SPI3_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void UART4_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void UART5_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM6_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM7_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void DMA2_Channel1_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void DMA2_Channel2_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void DMA2_Channel3_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void DMA2_Channel4_5_IRQHandler(void) {
|
||||||
|
}
|
||||||
|
void TIM2_IRQHandler(void) {
|
||||||
|
|
||||||
|
}
|
||||||
void SVC_Handler(void) {
|
void SVC_Handler(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,33 +201,8 @@ void DebugMon_Handler(void) {
|
|||||||
void PendSV_Handler(void) {
|
void PendSV_Handler(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysTick_Handler(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Peripherals Interrupt Handlers */
|
|
||||||
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
|
|
||||||
/* available peripheral interrupt handler's name please refer to the startup */
|
|
||||||
/* file (startup_stm32f30x.s). */
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
void USB_LP_CAN1_RX0_IRQHandler(void) {
|
void USB_LP_CAN1_RX0_IRQHandler(void) {
|
||||||
USB_Istr();
|
|
||||||
}
|
|
||||||
void TIM2_IRQHandler(void) {
|
|
||||||
TIM2_ISR();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIM3_IRQHandler(void) {
|
|
||||||
TIM3_ISR();
|
|
||||||
}
|
|
||||||
/*This loop is used for un assigned IRQ's so that the debugger can catch them*/
|
|
||||||
static void forever()
|
|
||||||
|
|
||||||
{
|
|
||||||
for (;;)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,252 +1,43 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
/*
|
||||||
File Name : MMA8652FC.c
|
* MMA8652FC.*
|
||||||
Version : S100 APP Ver 2.11
|
* Files for the built in accelerometer from NXP.
|
||||||
Description:
|
* This sets the unit up in motion detection mode with an interrupt on movement
|
||||||
Author : Celery
|
* This interrupt is fed to PB5 which catches it via EXTI5
|
||||||
Data: 2015/07/07
|
*
|
||||||
History:
|
* http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8652FC.pdf
|
||||||
2016/09/13 Ben V. Brown - English comments and fixing a few errors
|
*
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* EXTI Motion config setup values lifted from AN4070from NXP
|
||||||
*******************************************************************************/
|
*
|
||||||
|
* Ben V. Brown - <ralim@ralimtek.com>
|
||||||
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
|
||||||
#include "APP_Version.h"
|
|
||||||
#include "Bios.h"
|
#include "Bios.h"
|
||||||
#include "Oled.h"
|
|
||||||
#include "MMA8652FC.h"
|
#include "MMA8652FC.h"
|
||||||
#include "I2C.h"
|
#include "I2C.h"
|
||||||
#include "CTRL.h"
|
|
||||||
#include "UI.h"
|
|
||||||
//------------------------------------------------------------------//
|
|
||||||
|
|
||||||
static int IIC_RegWrite(u8 reg, u8 data);
|
|
||||||
static int IIC_RegRead(u8 reg);
|
|
||||||
static int Read_ZYXDr(void);
|
|
||||||
|
|
||||||
u16 gactive = 0, gShift = 0;
|
|
||||||
u8 gMmatxdata;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
u8 hi;
|
|
||||||
u8 lo;
|
|
||||||
|
|
||||||
} DR_Value;
|
|
||||||
|
|
||||||
DR_Value gX_value, gY_value, gZ_value;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:
|
|
||||||
Description:Returns if the unit is actively being moved
|
|
||||||
Output: if the unit is active or not.
|
|
||||||
*******************************************************************************/
|
|
||||||
u16 Get_MmaActive(void) {
|
|
||||||
return gactive;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Get_MmaActive
|
|
||||||
Description:Returns if movement has occured (0==still,1==movement)
|
|
||||||
*******************************************************************************/
|
|
||||||
u16 Get_MmaShift(void) {
|
|
||||||
return gShift;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Set_MmaShift
|
|
||||||
Description: Set the Shift Value
|
|
||||||
Input: shift value
|
|
||||||
*******************************************************************************/
|
|
||||||
void Set_MmaShift(u16 shift) {
|
|
||||||
gShift = shift;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:IIC_RegWrite
|
|
||||||
Description:Writes a value to a register
|
|
||||||
Input:the register, the data
|
|
||||||
Output: 1 if the write succeeded
|
|
||||||
*******************************************************************************/
|
|
||||||
int IIC_RegWrite(u8 reg, u8 data) {
|
|
||||||
u8 tx_data[20];
|
|
||||||
|
|
||||||
|
void I2C_RegisterWrite(uint8_t reg, uint8_t data) {
|
||||||
|
u8 tx_data[2];
|
||||||
tx_data[0] = reg;
|
tx_data[0] = reg;
|
||||||
tx_data[1] = data;
|
tx_data[1] = data;
|
||||||
I2C_PageWrite(tx_data, 2, DEVICE_ADDR);
|
I2C_PageWrite(tx_data, 2, DEVICE_ADDR);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
/*******************************************************************************
|
|
||||||
Function:IIC_RegRead
|
uint8_t I2C_RegisterRead(uint8_t reg) {
|
||||||
Description: Reads a register from I2C, using a single byte addressing scheme
|
u8 tx_data[3];
|
||||||
Inputs: uint8_t register to read
|
|
||||||
Output: 1 if the read worked.
|
|
||||||
*******************************************************************************/
|
|
||||||
int IIC_RegRead(u8 reg) {
|
|
||||||
u8 tx_data[20];
|
|
||||||
tx_data[0] = reg;
|
tx_data[0] = reg;
|
||||||
|
|
||||||
I2C_PageRead(tx_data, 1, DEVICE_ADDR, reg);
|
I2C_PageRead(tx_data, 1, DEVICE_ADDR, reg);
|
||||||
gMmatxdata = tx_data[0];
|
return tx_data[0];
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: MMA865x_Standby
|
|
||||||
Description: Put the MMA865 into standby mode
|
|
||||||
*******************************************************************************/
|
|
||||||
void MMA865x_Standby(void) {
|
|
||||||
//Put the sensor into Standby Mode by clearing
|
|
||||||
// the Active bit of the System Control 1 Register
|
|
||||||
IIC_RegWrite(CTRL_REG1, 0); //(IIC_RegRead(CTRL_REG1) & ~ ACTIVE_MASK)
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: MMA865x_Active
|
|
||||||
Description: Put the MMA865 into active mode
|
|
||||||
*******************************************************************************/
|
|
||||||
void MMA865x_Active(void) {
|
|
||||||
// Put the sensor into Active Mode by setting the
|
|
||||||
// Active bit of the System Control 1 Register
|
|
||||||
IIC_RegWrite(CTRL_REG1, ACTIVE_MASK); //(IIC_RegRead(CTRL_REG1) | ACTIVE_MASK)
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: IIC_RegRead
|
|
||||||
Description:Setup the MMA865x IC settings
|
|
||||||
*******************************************************************************/
|
|
||||||
void StartUp_Accelerated(void) {
|
|
||||||
//Put the unit into standby state so we can edit its configuration registers
|
|
||||||
MMA865x_Standby();
|
|
||||||
//Set the unit to full scale measurement
|
|
||||||
IIC_RegWrite(XYZ_DATA_CFG_REG, FULL_SCALE_8G); //(IIC_RegRead(XYZ_DATA_CFG_REG) & ~FS_MASK)
|
|
||||||
//Set the unit to the required update rate (eg 100Hz)
|
|
||||||
IIC_RegWrite(CTRL_REG1, DataRateValue); //IIC_RegRead(CTRL_REG1)|
|
|
||||||
|
|
||||||
IIC_RegWrite(CTRL_REG2, 0); //Normal mode
|
|
||||||
|
|
||||||
//Change the unit back to active mode to exit setup and start the readings
|
|
||||||
MMA865x_Active();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
void StartUp_Accelerometer(uint8_t sensitivity) {
|
||||||
Function: Read_ZYXDr
|
I2C_RegisterWrite(CTRL_REG2, 0); //Normal mode
|
||||||
Description:
|
I2C_RegisterWrite( CTRL_REG2, 0x40); // Reset all registers to POR values
|
||||||
Output: 1 if new data, 0 if not
|
delayMs(2); // ~1ms delay
|
||||||
*******************************************************************************/
|
I2C_RegisterWrite(FF_MT_CFG_REG, 0x78); // Enable motion detection for X and Y axis, latch enabled
|
||||||
int Read_ZYXDr(void) {
|
I2C_RegisterWrite(FF_MT_THS_REG, sensitivity|0x0F); // Set threshold
|
||||||
u8 reg_flag;
|
I2C_RegisterWrite(FF_MT_COUNT_REG, 0x01); // Set debounce to 100ms
|
||||||
u8 ptr, i;
|
|
||||||
u8 value[6] = { 0, 0, 0, 0, 0, 0 };
|
|
||||||
//Poll the ZYXDR status bit and wait for it to set
|
|
||||||
if (IIC_RegRead(STATUS_REG)) { //check we can read the status
|
|
||||||
reg_flag = gMmatxdata;
|
|
||||||
if ((reg_flag & ZYXDR_BIT) != 0) { //if new measurement
|
|
||||||
//Read 12/10-bit XYZ results using a 6 byte IIC access
|
|
||||||
ptr = X_MSB_REG;
|
|
||||||
for (i = 0; i < 6; i++) {
|
|
||||||
if (IIC_RegRead(ptr++) == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
value[i] = gMmatxdata;
|
I2C_RegisterWrite( CTRL_REG4, 0x04); // Enable motion interrupt
|
||||||
//Copy and save each result as a 16-bit left-justified value
|
I2C_RegisterWrite( CTRL_REG5, 0x04);// Route motion interrupts to INT1 ->PB5 ->EXTI5
|
||||||
gX_value.hi = value[0];
|
I2C_RegisterWrite( CTRL_REG1, 0x19); // ODR=100 Hz, Active mode
|
||||||
gX_value.lo = value[1];
|
|
||||||
gY_value.hi = value[2];
|
|
||||||
gY_value.lo = value[3];
|
|
||||||
gZ_value.hi = value[4];
|
|
||||||
gZ_value.lo = value[5];
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
/*******************************************************************************
|
|
||||||
Function: Cheak_XYData
|
|
||||||
Description: Check the input X,Y for a large enough acceleration to wake the unit
|
|
||||||
Inputs:x0,y0,x1,y1 to check
|
|
||||||
Output: if the unit is active
|
|
||||||
*******************************************************************************/
|
|
||||||
u16 Cheak_XYData(u16 x0, u16 y0, u16 x1, u16 y1) {
|
|
||||||
u16 active = 0;
|
|
||||||
gShift = 0;
|
|
||||||
|
|
||||||
if ((x1 > (x0 + 32)) || (x1 < (x0 - 32)))
|
|
||||||
gShift = 1;
|
|
||||||
if ((y1 > (y0 + 32)) || (y1 < (y0 - 32)))
|
|
||||||
gShift = 1;
|
|
||||||
|
|
||||||
if ((x1 > (x0 + 16)) || (x1 < (x0 - 16)))
|
|
||||||
active = 1;
|
|
||||||
if ((y1 > (y0 + 16)) || (y1 < (y0 - 16)))
|
|
||||||
active = 1;
|
|
||||||
|
|
||||||
return active;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Update_X
|
|
||||||
Description: Converts the read value for x into an actual properly located value
|
|
||||||
Output: X
|
|
||||||
*******************************************************************************/
|
|
||||||
u16 Update_X(void) {
|
|
||||||
u16 value, x;
|
|
||||||
|
|
||||||
value = ((gX_value.hi << 8) | (gX_value.lo & 0xf0)) >> 4;
|
|
||||||
if (gX_value.hi > 0x7f)
|
|
||||||
x = (~value + 1) & 0xfff;
|
|
||||||
else
|
|
||||||
x = value & 0xfff;
|
|
||||||
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Update_Y
|
|
||||||
Description: Converts the read value for y into an actual properly located value
|
|
||||||
Output: Y
|
|
||||||
*******************************************************************************/
|
|
||||||
u16 Update_Y(void) {
|
|
||||||
u16 value, y;
|
|
||||||
|
|
||||||
value = ((gY_value.hi << 8) | (gY_value.lo & 0xf0)) >> 4;
|
|
||||||
if (gY_value.hi > 0x7f)
|
|
||||||
y = (~value + 1) & 0xfff;
|
|
||||||
else
|
|
||||||
y = value & 0xfff;
|
|
||||||
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Update_Z
|
|
||||||
Description: Converts the read value for z into an actual properly located value
|
|
||||||
Output: Z
|
|
||||||
*******************************************************************************/
|
|
||||||
u16 Update_Z(void) {
|
|
||||||
u16 value, z;
|
|
||||||
|
|
||||||
value = ((gZ_value.hi << 8) | (gZ_value.lo & 0xf0)) >> 4;
|
|
||||||
if (gZ_value.hi > 0x7f)
|
|
||||||
z = (~value + 1) & 0xfff;
|
|
||||||
else
|
|
||||||
z = value & 0xfff;
|
|
||||||
|
|
||||||
return z;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Check_Accelerated
|
|
||||||
Description:Check if the unit has moved
|
|
||||||
*******************************************************************************/
|
|
||||||
void Check_Accelerated(void) {
|
|
||||||
static u16 x0 = 0, y0 = 0;
|
|
||||||
u16 x1, y1;
|
|
||||||
|
|
||||||
if (Read_ZYXDr()) { //Read the new values from the accelerometer
|
|
||||||
x1 = Update_X(); //convert the values into usable form
|
|
||||||
y1 = Update_Y();
|
|
||||||
} else {
|
|
||||||
x1 = x0;
|
|
||||||
y1 = y0; //use old values
|
|
||||||
gactive = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gactive = Cheak_XYData(x0, y0, x1, y1); //gactive == If the unit is moving or not
|
|
||||||
|
|
||||||
x0 = x1;
|
|
||||||
y0 = y1;
|
|
||||||
}
|
|
||||||
/******************************** END OF FILE *********************************/
|
|
||||||
|
|||||||
@@ -1,63 +1,43 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
/*
|
||||||
File Name : main.c
|
* Created by Ben V. Brown
|
||||||
Version : S100 APP Ver 2.11
|
*/
|
||||||
Description:
|
|
||||||
Author : Celery
|
#include "Modes.h"
|
||||||
Data: 2015/07/07
|
|
||||||
History:
|
|
||||||
2016/8/11 Updates by Ben V. Brown <ralim@ralimtek.com> - Cleanup and english comments
|
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "APP_Version.h"
|
|
||||||
#include "Disk.h"
|
|
||||||
#include "Bios.h"
|
#include "Bios.h"
|
||||||
#include "usb_lib.h"
|
|
||||||
#include "I2C.h"
|
|
||||||
#include "Flash.h"
|
|
||||||
#include "MMA8652FC.h"
|
#include "MMA8652FC.h"
|
||||||
#include "UI.h"
|
#include "PID.h"
|
||||||
#include "Oled.h"
|
#include "Oled.h"
|
||||||
#include "CTRL.h"
|
#include "Settings.h"
|
||||||
#include "Hardware.h"
|
#include "I2C.h"
|
||||||
|
void setup();
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
RCC_Config(); //setup system clock
|
setup();/*Setup the system*/
|
||||||
NVIC_Config(0x4000);
|
|
||||||
Init_Timer2(); //init the timers
|
|
||||||
Init_Timer3();
|
|
||||||
GPIO_Config();//setup all the GPIO pins
|
|
||||||
|
|
||||||
USB_Port(DISABLE);//disable the USB hardware
|
|
||||||
Delay_Ms(200);//pause to let hardware stabilize
|
|
||||||
USB_Port(ENABLE);//enable the USB hardware
|
|
||||||
USB_Init();
|
|
||||||
I2C_Configuration(); //init the i2c bus
|
|
||||||
|
|
||||||
Adc_Init(); //init adc and dma
|
|
||||||
if (Get_CtrlStatus() != CONFIG)
|
|
||||||
StartUp_Accelerated();//start the accelerometer if not in config mode
|
|
||||||
|
|
||||||
System_Init();//load known safe values
|
|
||||||
Init_Oled();//init the OLED display
|
|
||||||
Clear_Screen();//clear the display buffer to black
|
|
||||||
Init_Gtime();//init the count down timers
|
|
||||||
APP_Init();//pick operating mode via input voltage
|
|
||||||
|
|
||||||
Disk_BuffInit();//fill the buffer for the virtual disk
|
|
||||||
Config_Analysis(); //read in config from virtual disk
|
|
||||||
Pid_Init(); //init the pid to starting values
|
|
||||||
Set_gKey(NO_KEY); //reset keys to all off
|
|
||||||
Start_Watchdog(3000);//start the system watchdog as 3 seconds
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
Clear_Watchdog(); //reset the Watchdog
|
Clear_Watchdog(); //reset the Watch dog timer
|
||||||
if (Get_CtrlStatus() != CONFIG && LEAVE_WAIT_TIMER== 0) {
|
ProcessUI();
|
||||||
Check_Accelerated(); //update readings from the accelerometer
|
DrawUI();
|
||||||
LEAVE_WAIT_TIMER = 50;//reset timer so we dont poll accelerometer for another 500ms
|
delayMs(50); //Slow the system down a little bit
|
||||||
}
|
|
||||||
OLed_Display(); //Draw in the Oled display for this mode
|
|
||||||
Status_Tran(); //Handle user input and mode changing
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/******************************** END OF FILE *********************************/
|
void setup() {
|
||||||
|
RCC_Config(); //setup system clock
|
||||||
|
NVIC_Config(0x4000); //this shifts the NVIC table to be offset, for the usb bootloader's size
|
||||||
|
GPIO_Config(); //setup all the GPIO pins
|
||||||
|
Init_EXTI(); //Init the EXTI inputs
|
||||||
|
Init_Timer3(); //Used for the soldering iron tip
|
||||||
|
Adc_Init(); //Init adc and DMA
|
||||||
|
I2C_Configuration(); //Start the I2C hardware
|
||||||
|
GPIO_Init_OLED(); //Init the GPIO ports for the OLED
|
||||||
|
restoreSettings(); //Load settings
|
||||||
|
|
||||||
|
StartUp_Accelerometer(systemSettings.sensitivity); //start the accelerometer
|
||||||
|
|
||||||
|
setupPID(); //Init the PID values
|
||||||
|
readIronTemp(systemSettings.tempCalibration, 0,0); //load the default calibration value
|
||||||
|
Init_Oled(systemSettings.flipDisplay); //Init the OLED display
|
||||||
|
|
||||||
|
OLED_DrawString("VER 1.04", 8); //
|
||||||
|
delayMs(800); //Pause to show version number
|
||||||
|
Start_Watchdog(1000); //start the system watch dog as 1 second timeout
|
||||||
|
}
|
||||||
|
|||||||
401
workspace/ts100/src/Modes.c
Normal file
401
workspace/ts100/src/Modes.c
Normal file
@@ -0,0 +1,401 @@
|
|||||||
|
/*
|
||||||
|
* Modes.c
|
||||||
|
*
|
||||||
|
* Created on: 17 Sep 2016
|
||||||
|
* Author: Ralim <ralim@ralimtek.com>
|
||||||
|
*/
|
||||||
|
#include "Modes.h"
|
||||||
|
uint8_t tempCalStatus = 0;
|
||||||
|
//This does the required processing and state changes
|
||||||
|
void ProcessUI() {
|
||||||
|
uint8_t Buttons = getButtons(); //read the buttons status
|
||||||
|
static uint32_t lastModeChange = 0;
|
||||||
|
if (millis() - getLastButtonPress() < 30)
|
||||||
|
Buttons = 0;
|
||||||
|
else if (Buttons != 0) {
|
||||||
|
resetLastButtonPress();
|
||||||
|
resetButtons();
|
||||||
|
}
|
||||||
|
//rough prevention for de-bouncing and allocates settling time
|
||||||
|
|
||||||
|
switch (operatingMode) {
|
||||||
|
case STARTUP:
|
||||||
|
if (Buttons == (BUT_A | BUT_B)) {
|
||||||
|
operatingMode = THERMOMETER;
|
||||||
|
} else if (Buttons == BUT_A) {
|
||||||
|
//A key pressed so we are moving to soldering mode
|
||||||
|
operatingMode = SOLDERING;
|
||||||
|
} else if (Buttons == BUT_B) {
|
||||||
|
//B Button was pressed so we are moving to the Settings menu
|
||||||
|
operatingMode = SETTINGS;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SOLDERING:
|
||||||
|
//We need to check the buttons if we need to jump out
|
||||||
|
if (Buttons == BUT_A || Buttons == BUT_B) {
|
||||||
|
//A or B key pressed so we are moving to temp set
|
||||||
|
operatingMode = TEMP_ADJ;
|
||||||
|
} else if (Buttons == (BUT_A | BUT_B)) {
|
||||||
|
|
||||||
|
//Both buttons were pressed, exit back to the cooling screen
|
||||||
|
operatingMode = COOLING;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//We need to check the timer for movement in case we need to goto idle
|
||||||
|
if (systemSettings.movementEnabled)
|
||||||
|
if (millis() - getLastMovement()
|
||||||
|
> (systemSettings.SleepTime * 60000)) {
|
||||||
|
if (millis() - getLastButtonPress()
|
||||||
|
> (systemSettings.SleepTime * 60000)) {
|
||||||
|
operatingMode = SLEEP;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint16_t voltage = readDCVoltage(); //get X10 voltage
|
||||||
|
if ((voltage / 10) < systemSettings.cutoutVoltage) {
|
||||||
|
operatingMode = UVLOWARN;
|
||||||
|
lastModeChange = millis();
|
||||||
|
}
|
||||||
|
//Update the PID Loop
|
||||||
|
int32_t newOutput = computePID(systemSettings.SolderingTemp);
|
||||||
|
setIronTimer(newOutput);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TEMP_ADJ:
|
||||||
|
if (Buttons == BUT_A) {
|
||||||
|
//A key pressed so we are moving down in temp
|
||||||
|
|
||||||
|
if (systemSettings.SolderingTemp > 1000)
|
||||||
|
systemSettings.SolderingTemp -= 100;
|
||||||
|
} else if (Buttons == BUT_B) {
|
||||||
|
//B key pressed so we are moving up in temp
|
||||||
|
if (systemSettings.SolderingTemp < 4500)
|
||||||
|
systemSettings.SolderingTemp += 100;
|
||||||
|
} else {
|
||||||
|
//we check the timeout for how long the buttons have not been pushed
|
||||||
|
//if idle for > 3 seconds then we return to soldering
|
||||||
|
//Or if both buttons pressed
|
||||||
|
if ((millis() - getLastButtonPress() > 2000)
|
||||||
|
|| Buttons == (BUT_A | BUT_B)) {
|
||||||
|
operatingMode = SOLDERING;
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SETTINGS:
|
||||||
|
//Settings is the mode with the most logic
|
||||||
|
//Here we are in the menu so we need to increment through the sub menus / increase the value
|
||||||
|
|
||||||
|
if (Buttons & BUT_A) {
|
||||||
|
//A key iterates through the menu
|
||||||
|
if (settingsPage == SETTINGSOPTIONSCOUNT) {
|
||||||
|
//Roll off the end
|
||||||
|
settingsPage = 0; //reset
|
||||||
|
operatingMode = STARTUP; //reset back to the startup
|
||||||
|
saveSettings(); //Save the settings
|
||||||
|
} else
|
||||||
|
++settingsPage; //move to the next option
|
||||||
|
} else if (Buttons & BUT_B) {
|
||||||
|
resetLastButtonPress();
|
||||||
|
//B changes the value selected
|
||||||
|
switch (settingsPage) {
|
||||||
|
case UVCO:
|
||||||
|
//we are incrementing the cutout voltage
|
||||||
|
systemSettings.cutoutVoltage += 1; //Go up 1V at a jump
|
||||||
|
if (systemSettings.cutoutVoltage > 24)
|
||||||
|
systemSettings.cutoutVoltage = 10;
|
||||||
|
break;
|
||||||
|
case SLEEP_TEMP:
|
||||||
|
systemSettings.SleepTemp += 100; //Go up 10c at a time
|
||||||
|
if (systemSettings.SleepTemp > 3000)
|
||||||
|
systemSettings.SleepTemp = 1000;//cant sleep higher than 300
|
||||||
|
break;
|
||||||
|
case SLEEP_TIME:
|
||||||
|
++systemSettings.SleepTime; //Go up 1 minute at a time
|
||||||
|
if (systemSettings.SleepTime > 30)
|
||||||
|
systemSettings.SleepTime = 1; //cant set time over 30 mins
|
||||||
|
//Remember that ^ is the time of no movement
|
||||||
|
break;
|
||||||
|
case MOTIONDETECT:
|
||||||
|
systemSettings.movementEnabled =
|
||||||
|
!systemSettings.movementEnabled;
|
||||||
|
break;
|
||||||
|
case TEMPDISPLAY:
|
||||||
|
systemSettings.displayTempInF = !systemSettings.displayTempInF;
|
||||||
|
break;
|
||||||
|
case LEFTY:
|
||||||
|
systemSettings.flipDisplay = !systemSettings.flipDisplay;
|
||||||
|
break;
|
||||||
|
case MOTIONSENSITIVITY:
|
||||||
|
systemSettings.sensitivity += 0x10;
|
||||||
|
if (systemSettings.sensitivity > 0x20)
|
||||||
|
systemSettings.sensitivity = 0; //reset to high on wrap
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SLEEP:
|
||||||
|
//The iron is sleeping at a lower temperature due to lack of movement
|
||||||
|
if (Buttons & BUT_A) {
|
||||||
|
//A Button was pressed so we are moving back to soldering
|
||||||
|
operatingMode = SOLDERING;
|
||||||
|
return;
|
||||||
|
} else if (Buttons & BUT_B) {
|
||||||
|
//B Button was pressed so we are moving back to soldering
|
||||||
|
operatingMode = SOLDERING;
|
||||||
|
return;
|
||||||
|
} else if (systemSettings.movementEnabled)
|
||||||
|
if (millis() - getLastMovement() < 1000) {//moved in the last second
|
||||||
|
operatingMode = SOLDERING; //Goto active mode again
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//else if nothing has been pushed we need to compute the PID to keep the iron at the sleep temp
|
||||||
|
int32_t newOutput = computePID(systemSettings.SleepTemp);
|
||||||
|
setIronTimer(newOutput);
|
||||||
|
break;
|
||||||
|
case COOLING: {
|
||||||
|
setIronTimer(0); //turn off heating
|
||||||
|
//This mode warns the user the iron is still cooling down
|
||||||
|
uint16_t temp = readIronTemp(0, 1, 0xFFFF); //take a new reading as the heater code is not taking new readings
|
||||||
|
if (temp < 400) { //if the temp is < 40C then we can go back to IDLE
|
||||||
|
operatingMode = STARTUP;
|
||||||
|
} else if (Buttons & (BUT_A | BUT_B)) { //we check if the user has pushed a button to ack
|
||||||
|
//Either button was pushed
|
||||||
|
operatingMode = STARTUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case UVLOWARN:
|
||||||
|
//We are here if the DC voltage went too low
|
||||||
|
//We want to jump back to IDLE after a bit
|
||||||
|
if (millis() - lastModeChange > 3000) { //its been 3 seconds
|
||||||
|
operatingMode = STARTUP; //jump back to idle mode
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case THERMOMETER: {
|
||||||
|
//This lets the user check the tip temp without heating the iron.. And eventually calibration will be added here
|
||||||
|
|
||||||
|
if (Buttons == BUT_A) {
|
||||||
|
//Single button press, cycle over to the DC display
|
||||||
|
operatingMode = DCINDISP;
|
||||||
|
} else if (Buttons == BUT_B) {
|
||||||
|
tempCalStatus = 0;
|
||||||
|
operatingMode = TEMPCAL;
|
||||||
|
} else if (Buttons == (BUT_A | BUT_B)) {
|
||||||
|
//If the user is holding both button, exit the screen
|
||||||
|
operatingMode = STARTUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DCINDISP: {
|
||||||
|
//This lets the user check the input voltage
|
||||||
|
|
||||||
|
if (Buttons == BUT_A) {
|
||||||
|
//Single button press, cycle over to the temp display
|
||||||
|
operatingMode = THERMOMETER;
|
||||||
|
} else if (Buttons == (BUT_A | BUT_B)) {
|
||||||
|
//If the user is holding both button, exit the screen
|
||||||
|
operatingMode = STARTUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TEMPCAL: {
|
||||||
|
if (Buttons == BUT_B) {
|
||||||
|
//Single button press, cycle over to the DC IN
|
||||||
|
operatingMode = THERMOMETER;
|
||||||
|
} else if (Buttons == BUT_A) {
|
||||||
|
//Try and calibrate
|
||||||
|
if (tempCalStatus == 0) {
|
||||||
|
if ((readTipTemp() < 300) && (readSensorTemp() < 300)) {
|
||||||
|
tempCalStatus = 1;
|
||||||
|
systemSettings.tempCalibration = readTipTemp();
|
||||||
|
saveSettings();
|
||||||
|
} else {
|
||||||
|
tempCalStatus = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (Buttons == (BUT_A | BUT_B)) {
|
||||||
|
//If the user is holding both button, exit the screen
|
||||||
|
operatingMode = STARTUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Draws the temp with temp conversion if needed
|
||||||
|
*/
|
||||||
|
void drawTemp(uint16_t temp, uint8_t x) {
|
||||||
|
if (systemSettings.displayTempInF)
|
||||||
|
temp = (temp * 9 + 1600) / 5;/*Convert to F -> T*(9/5)+32*/
|
||||||
|
if (temp % 10 > 5)
|
||||||
|
temp += 10;//round up
|
||||||
|
OLED_DrawThreeNumber(temp / 10, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Performs all the OLED drawing for the current operating mode
|
||||||
|
*/
|
||||||
|
void DrawUI() {
|
||||||
|
uint16_t temp = readIronTemp(0, 0, 0xFFFF);
|
||||||
|
switch (operatingMode) {
|
||||||
|
case STARTUP:
|
||||||
|
//We are chilling in the idle mode
|
||||||
|
//Check if movement in the last 5 minutes , if not sleep OLED
|
||||||
|
if (millis() - getLastMovement() > (5 * 60 * 1000)
|
||||||
|
&& (millis() - getLastButtonPress() > (5 * 60 * 1000))) {
|
||||||
|
//OLED off
|
||||||
|
Oled_DisplayOff();
|
||||||
|
} else {
|
||||||
|
Oled_DisplayOn();
|
||||||
|
//OLED_DrawString(" IDLE ", 8); //write the word IDLE
|
||||||
|
OLED_DrawIDLELogo();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SOLDERING:
|
||||||
|
//The user is soldering
|
||||||
|
{
|
||||||
|
if (getIronTimer() == 0) {
|
||||||
|
OLED_DrawChar('C', 5);
|
||||||
|
} else {
|
||||||
|
if (getIronTimer() < 900) {
|
||||||
|
OLED_DrawChar(' ', 5);
|
||||||
|
} else { //we are heating
|
||||||
|
OLED_DrawChar('H', 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawTemp(temp, 0);
|
||||||
|
OLED_DrawChar(' ', 3);
|
||||||
|
OLED_DrawChar(' ', 4);
|
||||||
|
OLED_DrawChar(' ', 6);
|
||||||
|
OLED_DrawChar(' ', 7);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TEMP_ADJ:
|
||||||
|
//We are prompting the user to change the temp so we draw the current setpoint temp
|
||||||
|
//With the nifty arrows
|
||||||
|
|
||||||
|
OLED_DrawChar(' ', 0);
|
||||||
|
OLED_DrawChar('<', 1);
|
||||||
|
drawTemp(systemSettings.SolderingTemp, 2);
|
||||||
|
OLED_DrawChar(' ', 5);
|
||||||
|
OLED_DrawChar(' ', 6);
|
||||||
|
OLED_DrawChar('>', 7);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SETTINGS:
|
||||||
|
//We are prompting the user the setting name
|
||||||
|
|
||||||
|
switch (settingsPage) {
|
||||||
|
case UVCO:
|
||||||
|
OLED_DrawString("UVCO ", 5);
|
||||||
|
OLED_DrawTwoNumber(systemSettings.cutoutVoltage, 5);
|
||||||
|
OLED_DrawChar('V', 7);
|
||||||
|
break;
|
||||||
|
case SLEEP_TEMP:
|
||||||
|
OLED_DrawString("STMP ", 5);
|
||||||
|
OLED_DrawThreeNumber(systemSettings.SleepTemp / 10, 5);
|
||||||
|
break;
|
||||||
|
case SLEEP_TIME:
|
||||||
|
OLED_DrawString("STIME ", 6);
|
||||||
|
OLED_DrawTwoNumber(systemSettings.SleepTime, 6);
|
||||||
|
break;
|
||||||
|
case MOTIONDETECT:/*Toggle the mode*/
|
||||||
|
if (systemSettings.movementEnabled)
|
||||||
|
OLED_DrawString("MOTION T", 8);
|
||||||
|
else
|
||||||
|
OLED_DrawString("MOTION F", 8);
|
||||||
|
break;
|
||||||
|
case TEMPDISPLAY:/*Are we showing in C or F ?*/
|
||||||
|
if (systemSettings.displayTempInF)
|
||||||
|
OLED_DrawString("TMPUNT F", 8);
|
||||||
|
else
|
||||||
|
OLED_DrawString("TMPUNT C", 8);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LEFTY:
|
||||||
|
|
||||||
|
if (systemSettings.flipDisplay)
|
||||||
|
OLED_DrawString("FLPDSP T", 8);
|
||||||
|
else
|
||||||
|
OLED_DrawString("FLPDSP F", 8);
|
||||||
|
break;
|
||||||
|
case MOTIONSENSITIVITY:
|
||||||
|
switch (systemSettings.sensitivity) {
|
||||||
|
case MOTION_HIGH:
|
||||||
|
OLED_DrawString("SENSE H ", 8);
|
||||||
|
break;
|
||||||
|
case MOTION_MED:
|
||||||
|
OLED_DrawString("SENSE M ", 8);
|
||||||
|
break;
|
||||||
|
case MOTION_LOW:
|
||||||
|
OLED_DrawString("SENSE L ", 8);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
OLED_DrawString("SENSE ", 8);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SLEEP:
|
||||||
|
//The iron is in sleep temp mode
|
||||||
|
//Draw in temp and sleep
|
||||||
|
OLED_DrawString("SLP", 3);
|
||||||
|
drawTemp(temp, 4);
|
||||||
|
break;
|
||||||
|
case COOLING:
|
||||||
|
//We are warning the user the tip is cooling
|
||||||
|
OLED_DrawString("COOL", 4);
|
||||||
|
drawTemp(temp, 5);
|
||||||
|
break;
|
||||||
|
case UVLOWARN:
|
||||||
|
OLED_DrawString("LOW VOLT", 8);
|
||||||
|
break;
|
||||||
|
case THERMOMETER:
|
||||||
|
temp = readIronTemp(0, 1, 0xFFFF); //Force a reading as heater is off
|
||||||
|
OLED_DrawString("TEMP ", 5);//extra one to it clears the leftover 'L' from IDLE
|
||||||
|
drawTemp(temp, 5);
|
||||||
|
break;
|
||||||
|
case DCINDISP: {
|
||||||
|
uint16_t voltage = readDCVoltage(); //get X10 voltage
|
||||||
|
OLED_DrawString("IN", 2);
|
||||||
|
OLED_DrawChar((voltage / 100) % 10, 2);
|
||||||
|
voltage -= (voltage / 100) * 100;
|
||||||
|
OLED_DrawChar((voltage / 10) % 10, 3);
|
||||||
|
voltage -= (voltage / 10) * 10;
|
||||||
|
OLED_DrawChar('.', 4);
|
||||||
|
OLED_DrawChar(voltage % 10, 5);
|
||||||
|
OLED_DrawChar('V', 6);
|
||||||
|
OLED_DrawChar(' ', 7);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TEMPCAL: {
|
||||||
|
|
||||||
|
if (tempCalStatus == 0) {
|
||||||
|
OLED_DrawString("CAL TEMP", 8);
|
||||||
|
} else if (tempCalStatus == 1) {
|
||||||
|
OLED_DrawString("CAL OK ", 8);
|
||||||
|
} else if (tempCalStatus == 2) {
|
||||||
|
OLED_DrawString("CAL FAIL", 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,86 +1,92 @@
|
|||||||
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. **********************
|
/*
|
||||||
File Name : Oled.c
|
*
|
||||||
Version : S100 APP Ver 2.11
|
* OLED.c
|
||||||
Description:
|
* Functions for working with the oled screen.
|
||||||
Author : Celery
|
* Writes to the screen using I2C
|
||||||
Data: 2015/07/07
|
*/
|
||||||
History:
|
|
||||||
2015/07/07 ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "APP_Version.h"
|
|
||||||
#include "Oled.h"
|
#include "Oled.h"
|
||||||
#include "Bios.h"
|
#include "Bios.h"
|
||||||
#include "I2C.h"
|
#include "I2C.h"
|
||||||
#include "Hardware.h"
|
|
||||||
#include "Disk.h"
|
|
||||||
#include "UI.h"
|
|
||||||
|
|
||||||
|
#include "Font.h"
|
||||||
//Setup params depending on oled model
|
int8_t displayOffset = 32;
|
||||||
#ifdef SSD1316
|
/*Setup params for the OLED screen*/
|
||||||
u8 gOled_param[50] = {0x80,0xAE,0x80,0x00,0x80,0x10,0x80,0x40,0x80,0xB0,0x80,
|
/*http://www.displayfuture.com/Display/datasheet/controller/SSD1307.pdf*/
|
||||||
0x81,0x80,0xFF,0x80,0xA0,0x80,0xA6,0x80,0xA8,0x80,0x1F,
|
/*All commands are prefixed with 0x80*/
|
||||||
0x80,0xC8,0x80,0xD3,0x80,0x00,0x80,0xD5,0x80,0x80,0x80,
|
u8 OLED_Setup_Array[46] = { 0x80, 0xAE,/*Display off*/
|
||||||
0xD9,0x80,0x22,0x80,0xDA,0x80,0x12,0x80,0xDB,0x80,0x40,
|
0x80, 0xD5,/*Set display clock divide ratio / osc freq*/
|
||||||
0x80,0x8D,0x80,0x14,0x80,0xAF,
|
0x80, 0x52,/*Unknown*/
|
||||||
|
0x80, 0xA8,/*Set Multiplex Ratio*/
|
||||||
|
0x80, 0x0F, /*16 == max brightness,39==dimmest*/
|
||||||
|
0x80, 0xC0,/*Set COM Scan direction*/
|
||||||
|
0x80, 0xD3,/*Set Display offset*/
|
||||||
|
0x80, 0x00,/*0 Offset*/
|
||||||
|
0x80, 0x40,/*Set Display start line to 0*/
|
||||||
|
0x80, 0xA0,/*Set Segment remap to normal*/
|
||||||
|
0x80, 0x8D,/*Unknown*/
|
||||||
|
0x80, 0x14,/*Unknown*/
|
||||||
|
0x80, 0xDA,/*Set VCOM Pins hardware config*/
|
||||||
|
0x80, 0x02,/*Combination 2*/
|
||||||
|
0x80, 0x81,/*Contrast*/
|
||||||
|
0x80, 0x33,/*51*/
|
||||||
|
0x80, 0xD9,/*Set pre-charge period*/
|
||||||
|
0x80, 0xF1,/**/
|
||||||
|
0x80, 0xDB,/*Adjust VCOMH regulator ouput*/
|
||||||
|
0x80, 0x30,/*Unknown*/
|
||||||
|
0x80, 0xA4,/*Enable the display GDDR*/
|
||||||
|
0x80, 0XA6,/*Normal display*/
|
||||||
|
0x80, 0xAF /*Dispaly on*/
|
||||||
};
|
};
|
||||||
#else
|
|
||||||
u8 gOled_param[46] = { 0x80, 0xAE, 0x80, 0xD5, 0x80, 0x52, 0x80, 0xA8, 0x80,
|
|
||||||
0x0f, 0x80, 0xC0, 0x80, 0xD3, 0x80, 0x00, 0x80, 0x40, 0x80, 0xA0, 0x80,
|
|
||||||
0x8D, 0x80, 0x14, 0x80, 0xDA, 0x80, 0x02, 0x80, 0x81, 0x80, 0x33, 0x80,
|
|
||||||
0xD9, 0x80, 0xF1, 0x80, 0xDB, 0x80, 0x30, 0x80, 0xA4, 0x80, 0XA6, 0x80,
|
|
||||||
0xAF };
|
|
||||||
#endif
|
|
||||||
/*******************************************************************************
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Sc_Pt
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>Ļ<EFBFBD>Աȶ<D4B1>
|
|
||||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:Co<43><6F>Ļ<EFBFBD>ԱȶȲ<C8B6><C8B2><EFBFBD>
|
|
||||||
<20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>:NULL
|
|
||||||
*******************************************************************************/
|
|
||||||
void Sc_Pt(u8 Co) //<2F><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
u8 pt[4] = { 0x80, 0x81, 0x80, Co };
|
|
||||||
|
|
||||||
I2C_PageWrite(pt, 4, DEVICEADDR_OLED);
|
/*
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Function: Oled_DisplayOn
|
Function: Oled_DisplayOn
|
||||||
Description:Turn on the Oled display
|
Description:Turn on the Oled display
|
||||||
*******************************************************************************/
|
*/
|
||||||
void Oled_DisplayOn(void) {
|
void Oled_DisplayOn(void) {
|
||||||
u8 data[6] = { 0x80, 0X8D, 0x80, 0X14, 0x80, 0XAF };
|
u8 data[6] = { 0x80, 0X8D, 0x80, 0X14, 0x80, 0XAF };
|
||||||
|
|
||||||
I2C_PageWrite(data, 6, DEVICEADDR_OLED);
|
I2C_PageWrite(data, 6, DEVICEADDR_OLED);
|
||||||
}
|
}
|
||||||
/*******************************************************************************
|
/*
|
||||||
Function: Oled_DisplayOff
|
Function: Oled_DisplayOff
|
||||||
Description:Turn off the Oled display
|
Description:Turn off the Oled display
|
||||||
*******************************************************************************/
|
*/
|
||||||
void Oled_DisplayOff(void) {
|
void Oled_DisplayOff(void) {
|
||||||
u8 data[6] = { 0x80, 0X8D, 0x80, 0X10, 0x80, 0XAE };
|
u8 data[6] = { 0x80, 0X8D, 0x80, 0X10, 0x80, 0XAE };
|
||||||
|
|
||||||
I2C_PageWrite(data, 6, DEVICEADDR_OLED);
|
I2C_PageWrite(data, 6, DEVICEADDR_OLED);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* This sets the OLED screen to invert the screen (flip it vertically)
|
||||||
|
* This is used if the unit is set to left hand mode
|
||||||
|
*/
|
||||||
|
void Oled_DisplayFlip() {
|
||||||
|
u8 data[2] = { 0x80, 0XC8 };
|
||||||
|
I2C_PageWrite(data, 2, DEVICEADDR_OLED);
|
||||||
|
data[1] = 0xA1;
|
||||||
|
I2C_PageWrite(data, 2, DEVICEADDR_OLED);
|
||||||
|
displayOffset = 0;
|
||||||
|
|
||||||
/*******************************************************************************
|
}
|
||||||
Function: Data_Command
|
/*
|
||||||
Description: write a command to the Oled display
|
Description: write a command to the Oled display
|
||||||
Input: number of bytes to write, array to write
|
Input: number of bytes to write, array to write
|
||||||
Output:
|
Output:
|
||||||
*******************************************************************************/
|
*/
|
||||||
u8* Data_Command(u8 wide, u8* ptr) {
|
u8* Data_Command(u8 length, u8* data) {
|
||||||
int i;
|
int i;
|
||||||
u8 tx_data[128];
|
u8 tx_data[129];
|
||||||
//here are are inserting the data write command at the beginning
|
//here are are inserting the data write command at the beginning
|
||||||
tx_data[0] = 0x40;
|
tx_data[0] = 0x40;
|
||||||
wide += 1;
|
length++;
|
||||||
for (i = 1; i < wide; i++) //Loop through the array of data
|
for (i = 1; i < length; i++) //Loop through the array of data
|
||||||
tx_data[i] = *ptr++;
|
tx_data[i] = *data++;
|
||||||
I2C_PageWrite(tx_data, wide, DEVICEADDR_OLED); //write out the buffer
|
I2C_PageWrite(tx_data, length, DEVICEADDR_OLED); //write out the buffer
|
||||||
return ptr;
|
return data;
|
||||||
}
|
}
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Function:Set_ShowPos
|
Function:Set_ShowPos
|
||||||
@@ -88,11 +94,10 @@ u8* Data_Command(u8 wide, u8* ptr) {
|
|||||||
Input:x,y co-ordinates
|
Input:x,y co-ordinates
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void Set_ShowPos(u8 x, u8 y) {
|
void Set_ShowPos(u8 x, u8 y) {
|
||||||
u8 pos_param[8] = { 0x80, 0xB0, 0x80, 0x21, 0x80, 0x20, 0x80, 0x7F };
|
u8 pos_param[8] = { 0x80, 0xB0, 0x80, 0x21, 0x80, 0x00, 0x80, 0x7F };
|
||||||
|
//page 0, start add = x(below) through to 0x7F (aka 127)
|
||||||
pos_param[5] = x + 32;
|
pos_param[5] = x + displayOffset;/*Display offset ==0 for Lefty, == 32 for righty*/
|
||||||
pos_param[1] += y;
|
pos_param[1] += y;
|
||||||
|
|
||||||
I2C_PageWrite(pos_param, 8, DEVICEADDR_OLED);
|
I2C_PageWrite(pos_param, 8, DEVICEADDR_OLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +105,7 @@ void Set_ShowPos(u8 x, u8 y) {
|
|||||||
Function:Oled_DrawArea
|
Function:Oled_DrawArea
|
||||||
Description:
|
Description:
|
||||||
Inputs:(x,y) start point, (width,height) of enclosing rect, pointer to data
|
Inputs:(x,y) start point, (width,height) of enclosing rect, pointer to data
|
||||||
Output: last byte written out
|
Output: pointer to the last byte written out
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high, u8* ptr) {
|
u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high, u8* ptr) {
|
||||||
u8 m, n, y;
|
u8 m, n, y;
|
||||||
@@ -123,20 +128,6 @@ u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high, u8* ptr) {
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Function:Clean_Char
|
|
||||||
Description:Overwries a square to off, used to overwrite a char
|
|
||||||
Inputs:(k) input X position char starts at, (wide) how many pixels wide the char is
|
|
||||||
*******************************************************************************/
|
|
||||||
void Clean_Char(int k, u8 wide) {
|
|
||||||
int i;
|
|
||||||
u8 tx_data[128];
|
|
||||||
|
|
||||||
memset(&tx_data[0], 0, wide);
|
|
||||||
for (i = 0; i < 2; i++) {
|
|
||||||
Oled_DrawArea(k, i * 8, wide, 8, tx_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Function:GPIO_Init_OLED
|
Function:GPIO_Init_OLED
|
||||||
Description:Init the outputs as needed for the OLED (in this case the RST line)
|
Description:Init the outputs as needed for the OLED (in this case the RST line)
|
||||||
@@ -151,23 +142,22 @@ void GPIO_Init_OLED(void) {
|
|||||||
}
|
}
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Function: Init_Oled
|
Function: Init_Oled
|
||||||
Description: Initalizes the Oled screen
|
Description: Initializes the Oled screen
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void Init_Oled(void) {
|
void Init_Oled(uint8_t leftHanded) {
|
||||||
u8 param_len;
|
u8 param_len;
|
||||||
|
|
||||||
OLED_RST();
|
OLED_RST();
|
||||||
Delay_Ms(2);
|
delayMs(5);
|
||||||
OLED_ACT();
|
OLED_ACT(); //Toggling reset to reset the oled
|
||||||
Delay_Ms(2);
|
delayMs(5);
|
||||||
|
|
||||||
#ifdef SSD1316
|
|
||||||
param_len = 50;
|
|
||||||
#else
|
|
||||||
param_len = 46;
|
param_len = 46;
|
||||||
#endif
|
if (leftHanded) {
|
||||||
|
OLED_Setup_Array[11] = 0xC8;
|
||||||
I2C_PageWrite((u8 *) gOled_param, param_len, DEVICEADDR_OLED);
|
OLED_Setup_Array[19] = 0xA1;
|
||||||
|
displayOffset = 0;
|
||||||
|
}
|
||||||
|
I2C_PageWrite((u8 *) OLED_Setup_Array, param_len, DEVICEADDR_OLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@@ -176,20 +166,91 @@ void Init_Oled(void) {
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void Clear_Screen(void) {
|
void Clear_Screen(void) {
|
||||||
u8 tx_data[128];
|
u8 tx_data[128];
|
||||||
u8 i, wd;
|
memset(tx_data, 0, 128);
|
||||||
|
for (u8 i = 0; i < 2; i++) {
|
||||||
#ifdef SSD1316
|
|
||||||
wd = 32;
|
|
||||||
#else
|
|
||||||
wd = 16;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
memset(&tx_data[0], 0, 128);
|
|
||||||
for (i = 0; i < wd / 8; i++) {
|
|
||||||
Oled_DrawArea(0, i * 8, 128, 8, tx_data);
|
Oled_DrawArea(0, i * 8, 128, 8, tx_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Draws a string onto the screen starting at the left
|
||||||
|
*/
|
||||||
|
void OLED_DrawString(char* string, uint8_t length) {
|
||||||
|
for (uint8_t i = 0; i < length; i++) {
|
||||||
|
OLED_DrawChar(string[i], i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Draw a char onscreen at letter index x
|
||||||
|
*/
|
||||||
|
void OLED_DrawChar(char c, uint8_t x) {
|
||||||
|
if (x > 7)
|
||||||
|
return; //clipping
|
||||||
|
x *= FONT_WIDTH; //convert to a x coordinate
|
||||||
|
|
||||||
|
u8* ptr = (u8*) FONT;
|
||||||
|
if (c >= 'A' && c <= 'Z') {
|
||||||
|
ptr += (c - 'A' + 10) * (FONT_WIDTH * 2); //alpha is ofset 10 chars into the array
|
||||||
|
} else if (c >= '0' && c <= '9')
|
||||||
|
ptr += (c - '0') * (FONT_WIDTH * 2);
|
||||||
|
else if (c < 10)
|
||||||
|
ptr += (c) * (FONT_WIDTH * 2);
|
||||||
|
else if (c == ' ') {
|
||||||
|
//blank on space bar
|
||||||
|
ptr += (36) * (FONT_WIDTH * 2);
|
||||||
|
} else if (c == '<') {
|
||||||
|
ptr += (37) * (FONT_WIDTH * 2);
|
||||||
|
} else if (c == '>') {
|
||||||
|
ptr += (38) * (FONT_WIDTH * 2);
|
||||||
|
} else if (c == '.') {
|
||||||
|
ptr += (39) * (FONT_WIDTH * 2);
|
||||||
|
}
|
||||||
|
|
||||||
/******************************** END OF FILE *********************************/
|
Oled_DrawArea(x, 0, FONT_WIDTH, 16, (u8*) ptr);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Draw a 2 digit number to the display at letter slot x
|
||||||
|
*/
|
||||||
|
void OLED_DrawTwoNumber(uint8_t in, uint8_t x) {
|
||||||
|
|
||||||
|
OLED_DrawChar((in / 10) % 10, x);
|
||||||
|
OLED_DrawChar(in % 10, x + 1);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Draw a 3 digit number to the display at letter slot x
|
||||||
|
*/
|
||||||
|
void OLED_DrawThreeNumber(uint16_t in, uint8_t x) {
|
||||||
|
|
||||||
|
OLED_DrawChar((in / 100) % 10, x);
|
||||||
|
OLED_DrawChar((in / 10) % 10, x + 1);
|
||||||
|
OLED_DrawChar(in % 10, x + 2);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Draw a 4 digit number to the display at letter slot x
|
||||||
|
*/
|
||||||
|
void OLED_DrawFourNumber(uint16_t in, uint8_t x) {
|
||||||
|
|
||||||
|
OLED_DrawChar((in / 1000) % 10, x);
|
||||||
|
OLED_DrawChar((in / 100) % 10, x + 1);
|
||||||
|
OLED_DrawChar((in / 10) % 10, x + 2);
|
||||||
|
OLED_DrawChar(in % 10, x + 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OLED_DrawIDLELogo() {
|
||||||
|
static uint8_t drawAttempt = 0;
|
||||||
|
drawAttempt++;
|
||||||
|
if (drawAttempt & 0x80) {
|
||||||
|
if (drawAttempt & 0x08)
|
||||||
|
Oled_DrawArea(0, 0, 96, 8, (u8*) Iron_RightArrow_UP);
|
||||||
|
else
|
||||||
|
Oled_DrawArea(0, 0, 96, 8, (u8*) Iron_RightArrow_DOWN);
|
||||||
|
|
||||||
|
Oled_DrawArea(0, 8, 96, 8, (u8*) Iron_Base);
|
||||||
|
} else {
|
||||||
|
if (drawAttempt & 0x08)
|
||||||
|
Oled_DrawArea(0, 0, 96, 8, (u8*) Iron_LeftArrow_UP);
|
||||||
|
else
|
||||||
|
Oled_DrawArea(0, 0, 96, 8, (u8*) Iron_LeftArrow_DOWN);
|
||||||
|
Oled_DrawArea(0, 8, 96, 8, (u8*) Iron_Base);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
41
workspace/ts100/src/PID.c
Normal file
41
workspace/ts100/src/PID.c
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* PID.c
|
||||||
|
*
|
||||||
|
* Created on: 20 Sep 2016
|
||||||
|
* Author: ralim
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "PID.h"
|
||||||
|
#define MAXPIDOUTPUT 50000
|
||||||
|
//This function computes the new value for the ON time of the system
|
||||||
|
//This is the return value from this function
|
||||||
|
int32_t computePID(uint16_t setpoint) {
|
||||||
|
int32_t ITerm = 0;
|
||||||
|
static int16_t lastReading = 0;
|
||||||
|
uint16_t currentReading = readIronTemp(0, 1,setpoint); //get the current temp of the iron
|
||||||
|
int16_t error = (int16_t) setpoint - (int16_t) currentReading; //calculate the error term
|
||||||
|
ITerm += (pidSettings.ki * error);
|
||||||
|
if (ITerm > MAXPIDOUTPUT)
|
||||||
|
ITerm = MAXPIDOUTPUT;
|
||||||
|
else if (ITerm < 0)
|
||||||
|
ITerm = 0; //cap at 0 since we cant force the iron to cool itself :)
|
||||||
|
|
||||||
|
int16_t DInput = (currentReading - lastReading); //compute the input to the D term
|
||||||
|
int32_t output = (pidSettings.kp * error) + (ITerm)
|
||||||
|
- (pidSettings.kd * DInput);
|
||||||
|
if (output > MAXPIDOUTPUT)
|
||||||
|
output = MAXPIDOUTPUT;
|
||||||
|
else if (output < 0)
|
||||||
|
output = 0;
|
||||||
|
|
||||||
|
lastReading = currentReading; //storing values for next iteration of the loop
|
||||||
|
return output;
|
||||||
|
|
||||||
|
}
|
||||||
|
/*Sets up the pid values*/
|
||||||
|
void setupPID(void) {
|
||||||
|
pidSettings.kp = 25;
|
||||||
|
pidSettings.ki = 7;
|
||||||
|
pidSettings.kd = 2;
|
||||||
|
|
||||||
|
}
|
||||||
56
workspace/ts100/src/Settings.c
Normal file
56
workspace/ts100/src/Settings.c
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Settings.c
|
||||||
|
*
|
||||||
|
* Created on: 29 Sep 2016
|
||||||
|
* Author: Ralim
|
||||||
|
*
|
||||||
|
* This file holds the users settings and saves / restores them to the devices flash
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Settings.h"
|
||||||
|
#define FLASH_ADDR (0x8000000|48896)/*Flash start OR'ed with the maximum amount of flash - 256 bytes*/
|
||||||
|
void saveSettings() {
|
||||||
|
//First we erase the flash
|
||||||
|
FLASH_Unlock(); //unlock flash writing
|
||||||
|
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
|
||||||
|
while (FLASH_ErasePage(FLASH_ADDR) != FLASH_COMPLETE)
|
||||||
|
; //wait for it
|
||||||
|
//erased the chunk
|
||||||
|
//now we program it
|
||||||
|
uint16_t *data = (uint16_t*) &systemSettings;
|
||||||
|
for (uint8_t i = 0; i < (sizeof(systemSettings) / 2); i++) {
|
||||||
|
FLASH_ProgramHalfWord(FLASH_ADDR + (i * 2), data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void restoreSettings() {
|
||||||
|
//We read the flash
|
||||||
|
uint16_t *data = (uint16_t*) &systemSettings;
|
||||||
|
for (uint8_t i = 0; i < (sizeof(systemSettings) / 2); i++) {
|
||||||
|
data[i] = *(uint16_t *) (FLASH_ADDR + (i * 2));
|
||||||
|
}
|
||||||
|
//if the version is correct were done
|
||||||
|
//if not we reset and save
|
||||||
|
if (systemSettings.version != SETTINGSVERSION) {
|
||||||
|
//probably not setup
|
||||||
|
resetSettings();
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetSettings() {
|
||||||
|
|
||||||
|
systemSettings.SleepTemp = 1500; //Temperature the iron sleeps at - default 150.0 C
|
||||||
|
systemSettings.SleepTime = 1; //How many minutes we wait until going to sleep - default 1 min
|
||||||
|
systemSettings.SolderingTemp = 3200; //Default soldering temp is 320.0 C
|
||||||
|
systemSettings.movementEnabled = 1; //we use movement detection by default
|
||||||
|
systemSettings.cutoutVoltage = 10; //10V is the minium cutout voltage as the unit V measurement is unstable below 9.5V
|
||||||
|
systemSettings.version = SETTINGSVERSION; //Store the version number to allow for easier upgrades
|
||||||
|
systemSettings.displayTempInF =0; //default to C
|
||||||
|
systemSettings.flipDisplay=0; //Default to right handed mode
|
||||||
|
systemSettings.sensitivity=0x00; //Default high sensitivity
|
||||||
|
systemSettings.tempCalibration=239; //Default to their calibration value
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,269 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_bot.c
|
|
||||||
Version : STM32_USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#include "usb_scsi.h"
|
|
||||||
#include "usb_regs.h"
|
|
||||||
#include "usb_mem.h"
|
|
||||||
#include "usb_conf.h"
|
|
||||||
#include "usb_bot.h"
|
|
||||||
#include "usb_prop.h"
|
|
||||||
|
|
||||||
u8 Bot_State;
|
|
||||||
u8 Bulk_Buff[BULK_MAX_PACKET_SIZE]; // Data_ data buffer
|
|
||||||
u16 Data_Len;
|
|
||||||
Bulk_Only_CBW CBW;
|
|
||||||
Bulk_Only_CSW CSW;
|
|
||||||
u32 SCSI_LBA , SCSI_BlkLen;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Mass_Storage_In: Mass Storage IN transfer.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Mass_Storage_In (void)
|
|
||||||
{
|
|
||||||
switch (Bot_State)
|
|
||||||
{
|
|
||||||
case BOT_CSW_Send:
|
|
||||||
case BOT_ERROR:
|
|
||||||
Bot_State = BOT_IDLE;
|
|
||||||
SetEPRxStatus(ENDP2, EP_RX_VALID);/* enable the Endpoint to receive the next cmd*/
|
|
||||||
break;
|
|
||||||
case BOT_DATA_IN:
|
|
||||||
switch (CBW.CB[0])
|
|
||||||
{
|
|
||||||
case SCSI_READ10:
|
|
||||||
SCSI_Read10_Cmd(SCSI_LBA , SCSI_BlkLen);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case BOT_DATA_IN_LAST:
|
|
||||||
Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
|
||||||
SetEPRxStatus(ENDP2, EP_RX_VALID);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Mass_Storage_Out: Mass Storage OUT transfer.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Mass_Storage_Out (void)
|
|
||||||
{
|
|
||||||
u8 CMD;
|
|
||||||
CMD = CBW.CB[0];
|
|
||||||
Data_Len = GetEPRxCount(ENDP2);
|
|
||||||
|
|
||||||
PMAToUserBufferCopy(Bulk_Buff, ENDP2_RXADDR, Data_Len);
|
|
||||||
|
|
||||||
switch (Bot_State)
|
|
||||||
{
|
|
||||||
case BOT_IDLE:
|
|
||||||
CBW_Decode();
|
|
||||||
break;
|
|
||||||
case BOT_DATA_OUT:
|
|
||||||
if (CMD == SCSI_WRITE10)
|
|
||||||
{
|
|
||||||
SCSI_Write10_Cmd(SCSI_LBA , SCSI_BlkLen);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Bot_Abort(DIR_OUT);
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
|
||||||
Set_CSW (CSW_PHASE_ERROR, SEND_CSW_DISABLE);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Bot_Abort(BOTH_DIR);
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
|
||||||
Set_CSW (CSW_PHASE_ERROR, SEND_CSW_DISABLE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
CBW_Decode: Decode the received CBW and call the related SCSI command
|
|
||||||
*******************************************************************************/
|
|
||||||
void CBW_Decode(void)
|
|
||||||
{
|
|
||||||
u32 Counter;
|
|
||||||
|
|
||||||
for (Counter = 0; Counter < Data_Len; Counter++)
|
|
||||||
{
|
|
||||||
*((u8 *)&CBW + Counter) = Bulk_Buff[Counter];
|
|
||||||
}
|
|
||||||
CSW.dTag = CBW.dTag;
|
|
||||||
CSW.dDataResidue = CBW.dDataLength;
|
|
||||||
if (Data_Len != BOT_CBW_PACKET_LENGTH)
|
|
||||||
{
|
|
||||||
Bot_Abort(BOTH_DIR);
|
|
||||||
// reset the CBW.dSignature to desible the clear feature until receiving a Mass storage reset
|
|
||||||
CBW.dSignature = 0;
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, PARAMETER_LIST_LENGTH_ERROR);
|
|
||||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((CBW.CB[0] == SCSI_READ10 ) || (CBW.CB[0] == SCSI_WRITE10 ))
|
|
||||||
{
|
|
||||||
// Calculate Logical Block Address
|
|
||||||
SCSI_LBA = (CBW.CB[2] << 24) | (CBW.CB[3] << 16) | (CBW.CB[4] << 8) | CBW.CB[5];
|
|
||||||
// Calculate the Number of Blocks to transfer
|
|
||||||
SCSI_BlkLen = (CBW.CB[7] << 8) | CBW.CB[8];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CBW.dSignature == BOT_CBW_SIGNATURE)
|
|
||||||
{
|
|
||||||
// Valid CBW
|
|
||||||
if ((CBW.bLUN > Max_Lun) || (CBW.bCBLength < 1) || (CBW.bCBLength > 16))
|
|
||||||
{
|
|
||||||
Bot_Abort(BOTH_DIR);
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
|
||||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (CBW.CB[0])
|
|
||||||
{
|
|
||||||
case SCSI_REQUEST_SENSE:
|
|
||||||
SCSI_RequestSense_Cmd ();
|
|
||||||
break;
|
|
||||||
case SCSI_INQUIRY:
|
|
||||||
SCSI_Inquiry_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_START_STOP_UNIT:
|
|
||||||
SCSI_Start_Stop_Unit_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_ALLOW_MEDIUM_REMOVAL:
|
|
||||||
SCSI_Start_Stop_Unit_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_MODE_SENSE6:
|
|
||||||
SCSI_ModeSense6_Cmd ();
|
|
||||||
break;
|
|
||||||
case SCSI_MODE_SENSE10:
|
|
||||||
SCSI_ModeSense10_Cmd ();
|
|
||||||
break;
|
|
||||||
case SCSI_READ_FORMAT_CAPACITIES:
|
|
||||||
SCSI_ReadFormatCapacity_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_READ_CAPACITY10:
|
|
||||||
SCSI_ReadCapacity10_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_TEST_UNIT_READY:
|
|
||||||
SCSI_TestUnitReady_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_READ10:
|
|
||||||
SCSI_Read10_Cmd(SCSI_LBA , SCSI_BlkLen);
|
|
||||||
break;
|
|
||||||
case SCSI_WRITE10:
|
|
||||||
SCSI_Write10_Cmd(SCSI_LBA , SCSI_BlkLen);
|
|
||||||
break;
|
|
||||||
case SCSI_VERIFY10:
|
|
||||||
SCSI_Verify10_Cmd();
|
|
||||||
break;
|
|
||||||
//Unsupported command
|
|
||||||
case SCSI_MODE_SELECT10:
|
|
||||||
SCSI_Mode_Select10_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_MODE_SELECT6:
|
|
||||||
SCSI_Mode_Select6_Cmd();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SCSI_SEND_DIAGNOSTIC:
|
|
||||||
SCSI_Send_Diagnostic_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_READ6:
|
|
||||||
SCSI_Read6_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_READ12:
|
|
||||||
SCSI_Read12_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_READ16:
|
|
||||||
SCSI_Read16_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_READ_CAPACITY16:
|
|
||||||
SCSI_READ_CAPACITY16_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_WRITE6:
|
|
||||||
SCSI_Write6_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_WRITE12:
|
|
||||||
SCSI_Write12_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_WRITE16:
|
|
||||||
SCSI_Write16_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_VERIFY12:
|
|
||||||
SCSI_Verify12_Cmd();
|
|
||||||
break;
|
|
||||||
case SCSI_VERIFY16:
|
|
||||||
SCSI_Verify16_Cmd();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
Bot_Abort(BOTH_DIR);
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_COMMAND);
|
|
||||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Invalid CBW
|
|
||||||
Bot_Abort(BOTH_DIR);
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_COMMAND);
|
|
||||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Transfer_Data_Request: Send the request response to the PC HOST.
|
|
||||||
Input : u8* Data_Address : point to the data to transfer.
|
|
||||||
u16 Data_Length : the nember of Bytes to transfer.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Transfer_Data_Request(u8* Data_Pointer, u16 Data_Len)
|
|
||||||
{
|
|
||||||
UserToPMABufferCopy(Data_Pointer, ENDP1_TXADDR, Data_Len);
|
|
||||||
SetEPTxCount(ENDP1, Data_Len);
|
|
||||||
SetEPTxStatus(ENDP1, EP_TX_VALID);
|
|
||||||
Bot_State = BOT_DATA_IN_LAST;
|
|
||||||
CSW.dDataResidue -= Data_Len;
|
|
||||||
CSW.bStatus = CSW_CMD_PASSED;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Set_CSW: Set the SCW with the needed fields.
|
|
||||||
Input : u8 CSW_Status this filed can be CSW_CMD_PASSED,CSW_CMD_FAILED,
|
|
||||||
or CSW_PHASE_ERROR.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Set_CSW (u8 CSW_Status, u8 Send_Permission)
|
|
||||||
{
|
|
||||||
CSW.dSignature = BOT_CSW_SIGNATURE;
|
|
||||||
CSW.bStatus = CSW_Status;
|
|
||||||
UserToPMABufferCopy(((u8 *)& CSW), ENDP1_TXADDR, CSW_DATA_LENGTH);
|
|
||||||
SetEPTxCount(ENDP1, CSW_DATA_LENGTH);
|
|
||||||
Bot_State = BOT_ERROR;
|
|
||||||
if (Send_Permission){
|
|
||||||
Bot_State = BOT_CSW_Send;
|
|
||||||
SetEPTxStatus(ENDP1, EP_TX_VALID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Bot_Abort: Stall the needed Endpoint according to the selected direction.
|
|
||||||
Input : Endpoint direction IN, OUT or both directions
|
|
||||||
*******************************************************************************/
|
|
||||||
void Bot_Abort(u8 Direction)
|
|
||||||
{
|
|
||||||
switch (Direction){
|
|
||||||
case DIR_IN :
|
|
||||||
SetEPTxStatus(ENDP1, EP_TX_STALL);
|
|
||||||
break;
|
|
||||||
case DIR_OUT :
|
|
||||||
SetEPRxStatus(ENDP2, EP_RX_STALL);
|
|
||||||
break;
|
|
||||||
case BOTH_DIR :
|
|
||||||
SetEPTxStatus(ENDP1, EP_TX_STALL);
|
|
||||||
SetEPRxStatus(ENDP2, EP_RX_STALL);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_desc.c
|
|
||||||
Version : STM32_USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#include "usb_desc.h"
|
|
||||||
|
|
||||||
const u8 MASS_DeviceDescriptor[MASS_SIZ_DEVICE_DESC] ={
|
|
||||||
0x12, /* bLength */
|
|
||||||
0x01, /* bDescriptorType */
|
|
||||||
0x00, /* bcdUSB, version 2.00 */
|
|
||||||
0x02,
|
|
||||||
0x00, /* bDeviceClass : each interface define the device class */
|
|
||||||
0x00, /* bDeviceSubClass */
|
|
||||||
0x00, /* bDeviceProtocol */
|
|
||||||
0x40, /* bMaxPacketSize0 0x40 = 64 */
|
|
||||||
0x83, /* idVendor (0483) */
|
|
||||||
0x04,
|
|
||||||
0x20, /* idProduct */
|
|
||||||
0x57,
|
|
||||||
0x00, /* bcdDevice 2.00*/
|
|
||||||
0x02,
|
|
||||||
1, /* index of string Manufacturer */
|
|
||||||
/**/
|
|
||||||
2, /* index of string descriptor of product*/
|
|
||||||
/* */
|
|
||||||
3, /* */
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
0x01 /*bNumConfigurations */
|
|
||||||
};
|
|
||||||
const u8 MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC] ={
|
|
||||||
0x09, /* bLength: Configuation Descriptor size */
|
|
||||||
0x02, /* bDescriptorType: Configuration */
|
|
||||||
MASS_SIZ_CONFIG_DESC,
|
|
||||||
0x00,
|
|
||||||
0x01, /* bNumInterfaces: 1 interface */
|
|
||||||
0x01, /* bConfigurationValue: */
|
|
||||||
/* Configuration value */
|
|
||||||
0x00, /* iConfiguration: */
|
|
||||||
/* Index of string descriptor */
|
|
||||||
/* describing the configuration */
|
|
||||||
0xC0, /* bmAttributes: */
|
|
||||||
/* bus powered */
|
|
||||||
0x32, /* MaxPower 100 mA */
|
|
||||||
|
|
||||||
/******************** Descriptor of Mass Storage interface ********************/
|
|
||||||
/* 09 */
|
|
||||||
0x09, /* bLength: Interface Descriptor size */
|
|
||||||
0x04, /* bDescriptorType: */
|
|
||||||
/* Interface descriptor type */
|
|
||||||
0x00, /* bInterfaceNumber: Number of Interface */
|
|
||||||
0x00, /* bAlternateSetting: Alternate setting */
|
|
||||||
0x02, /* bNumEndpoints*/
|
|
||||||
0x08, /* bInterfaceClass: MASS STORAGE Class */
|
|
||||||
0x06, /* bInterfaceSubClass : SCSI transparent*/
|
|
||||||
0x50, /* nInterfaceProtocol */
|
|
||||||
4, /* iInterface: */
|
|
||||||
/* 18 */
|
|
||||||
0x07, /*Endpoint descriptor length = 7*/
|
|
||||||
0x05, /*Endpoint descriptor type */
|
|
||||||
0x81, /*Endpoint address (IN, address 1) */
|
|
||||||
0x02, /*Bulk endpoint type */
|
|
||||||
0x40, /*Maximum packet size (64 bytes) */
|
|
||||||
0x00,
|
|
||||||
0x00, /*Polling interval in milliseconds */
|
|
||||||
/* 25 */
|
|
||||||
0x07, /*Endpoint descriptor length = 7 */
|
|
||||||
0x05, /*Endpoint descriptor type */
|
|
||||||
0x02, /*Endpoint address (OUT, address 2) */
|
|
||||||
0x02, /*Bulk endpoint type */
|
|
||||||
0x40, /*Maximum packet size (64 bytes) */
|
|
||||||
0x00,
|
|
||||||
0x00 /*Polling interval in milliseconds*/
|
|
||||||
/*32*/
|
|
||||||
};
|
|
||||||
const u8 MASS_StringLangID[MASS_SIZ_STRING_LANGID] ={
|
|
||||||
MASS_SIZ_STRING_LANGID,
|
|
||||||
0x03,
|
|
||||||
0x09,
|
|
||||||
0x04
|
|
||||||
}; // LangID = 0x0409: U.S. English //
|
|
||||||
const u8 MASS_StringVendor[MASS_SIZ_STRING_VENDOR] ={
|
|
||||||
MASS_SIZ_STRING_VENDOR, // Size of manufaturer string //
|
|
||||||
0x03, // bDescriptorType = String descriptor //
|
|
||||||
// Manufacturer: "STMicroelectronics" //
|
|
||||||
'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0,
|
|
||||||
'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0,
|
|
||||||
'c', 0, 's', 0
|
|
||||||
};
|
|
||||||
const u8 MASS_StringProduct[MASS_SIZ_STRING_PRODUCT] ={
|
|
||||||
MASS_SIZ_STRING_PRODUCT,
|
|
||||||
0x03,
|
|
||||||
// Product name: "STM32F10x:USB Mass Storage" //
|
|
||||||
'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'M', 0, 'a', 0, 's', 0,
|
|
||||||
's', 0, ' ', 0, 'S', 0, 't', 0, 'o', 0, 'r', 0, 'a', 0, 'g', 0, 'e', 0
|
|
||||||
};
|
|
||||||
u8 MASS_StringSerial[MASS_SIZ_STRING_SERIAL] ={
|
|
||||||
MASS_SIZ_STRING_SERIAL,
|
|
||||||
0x03,
|
|
||||||
// Serial number//
|
|
||||||
'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, '1', 0, '0', 0
|
|
||||||
};
|
|
||||||
const u8 MASS_StringInterface[MASS_SIZ_STRING_INTERFACE] ={
|
|
||||||
MASS_SIZ_STRING_INTERFACE,
|
|
||||||
0x03,
|
|
||||||
// Interface 0: "ST Mass" //
|
|
||||||
'S', 0, 'T', 0, ' ', 0, 'M', 0, 'a', 0, 's', 0, 's', 0
|
|
||||||
};
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_istr.c
|
|
||||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#include "usb_type.h"
|
|
||||||
#include "usb_regs.h"
|
|
||||||
#include "usb_pwr.h"
|
|
||||||
#include "usb_istr.h"
|
|
||||||
#include "usb_init.h"
|
|
||||||
#include "usb_int.h"
|
|
||||||
#include "usb_bot.h"
|
|
||||||
|
|
||||||
volatile u16 wIstr; /* ISTR register last read value */
|
|
||||||
volatile u8 bIntPackSOF = 0; /* SOFs received between 2 consecutive packets */
|
|
||||||
|
|
||||||
void (*pEpInt_IN[7])(void) ={
|
|
||||||
EP1_IN_Callback,
|
|
||||||
EP2_IN_Callback,
|
|
||||||
EP3_IN_Callback,
|
|
||||||
EP4_IN_Callback,
|
|
||||||
EP5_IN_Callback,
|
|
||||||
EP6_IN_Callback,
|
|
||||||
EP7_IN_Callback,
|
|
||||||
};
|
|
||||||
void (*pEpInt_OUT[7])(void) ={
|
|
||||||
EP1_OUT_Callback,
|
|
||||||
EP2_OUT_Callback,
|
|
||||||
EP3_OUT_Callback,
|
|
||||||
EP4_OUT_Callback,
|
|
||||||
EP5_OUT_Callback,
|
|
||||||
EP6_OUT_Callback,
|
|
||||||
EP7_OUT_Callback,
|
|
||||||
};
|
|
||||||
/*******************************************************************************
|
|
||||||
USB_Istr: ISTR events interrupt service routine
|
|
||||||
*******************************************************************************/
|
|
||||||
void USB_Istr(void)
|
|
||||||
{
|
|
||||||
wIstr = _GetISTR();
|
|
||||||
#if (IMR_MSK & ISTR_RESET)
|
|
||||||
if (wIstr & ISTR_RESET & wInterrupt_Mask){
|
|
||||||
// _SetISTR((u16)CLR_RESET);
|
|
||||||
Device_Property.Reset();
|
|
||||||
_SetISTR((u16)CLR_RESET);
|
|
||||||
//#ifdef RESET_CALLBACK
|
|
||||||
// RESET_Callback();
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#if (IMR_MSK & ISTR_DOVR)
|
|
||||||
if (wIstr & ISTR_DOVR & wInterrupt_Mask){
|
|
||||||
_SetISTR((u16)CLR_DOVR);
|
|
||||||
//#ifdef DOVR_CALLBACK
|
|
||||||
// DOVR_Callback();
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#if (IMR_MSK & ISTR_ERR)
|
|
||||||
if (wIstr & ISTR_ERR & wInterrupt_Mask){
|
|
||||||
_SetISTR((u16)CLR_ERR);
|
|
||||||
//#ifdef ERR_CALLBACK
|
|
||||||
// ERR_Callback();
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#if (IMR_MSK & ISTR_WKUP)
|
|
||||||
if (wIstr & ISTR_WKUP & wInterrupt_Mask){
|
|
||||||
// _SetISTR((u16)CLR_WKUP);
|
|
||||||
Resume(RESUME_EXTERNAL);
|
|
||||||
_SetISTR((u16)CLR_WKUP);
|
|
||||||
//#ifdef WKUP_CALLBACK
|
|
||||||
// WKUP_Callback();
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#if (IMR_MSK & ISTR_SUSP)
|
|
||||||
if (wIstr & ISTR_SUSP & wInterrupt_Mask){ // check if SUSPEND is possible
|
|
||||||
if (fSuspendEnabled) Suspend();
|
|
||||||
else Resume(RESUME_LATER); // if not possible then resume after xx ms
|
|
||||||
_SetISTR((u16)CLR_SUSP); // clear of the ISTR bit must be done after setting of CNTR_FSUSP
|
|
||||||
//#ifdef SUSP_CALLBACK
|
|
||||||
// SUSP_Callback();
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#if (IMR_MSK & ISTR_SOF)
|
|
||||||
if (wIstr & ISTR_SOF & wInterrupt_Mask){
|
|
||||||
_SetISTR((u16)CLR_SOF);
|
|
||||||
bIntPackSOF++;
|
|
||||||
//#ifdef SOF_CALLBACK
|
|
||||||
// SOF_Callback();
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#if (IMR_MSK & ISTR_ESOF)
|
|
||||||
if (wIstr & ISTR_ESOF & wInterrupt_Mask){
|
|
||||||
// _SetISTR((u16)CLR_ESOF); // resume handling timing is made with ESOFs
|
|
||||||
Resume(RESUME_ESOF); // request without change of the machine state
|
|
||||||
_SetISTR((u16)CLR_ESOF); // resume handling timing is made with ESOFs
|
|
||||||
//#ifdef ESOF_CALLBACK
|
|
||||||
// ESOF_Callback();
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#if (IMR_MSK & ISTR_CTR)
|
|
||||||
if (wIstr & ISTR_CTR & wInterrupt_Mask){
|
|
||||||
/* servicing of the endpoint correct transfer interrupt */
|
|
||||||
/* clear of the CTR flag into the sub */
|
|
||||||
CTR_LP();
|
|
||||||
//#ifdef CTR_CALLBACK
|
|
||||||
// CTR_Callback();
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} /* USB_Istr */
|
|
||||||
/*******************************************************************************
|
|
||||||
EP1_IN_Callback: EP1 IN Callback Routine
|
|
||||||
*******************************************************************************/
|
|
||||||
void EP1_IN_Callback(void)
|
|
||||||
{
|
|
||||||
Mass_Storage_In();
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
EP2_OUT_Callback: EP2 OUT Callback Routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void EP2_OUT_Callback(void)
|
|
||||||
{
|
|
||||||
Mass_Storage_Out();
|
|
||||||
}
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
|
|
||||||
@@ -1,262 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_prop.c
|
|
||||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#include "usb_desc.h"
|
|
||||||
#include "usb_pwr.h"
|
|
||||||
#include "usb_bot.h"
|
|
||||||
#include "usb_prop.h"
|
|
||||||
#include "usb_lib.h"
|
|
||||||
#include "Bios.h"
|
|
||||||
#include "APP_Version.h"
|
|
||||||
|
|
||||||
u32 Max_Lun = 0;
|
|
||||||
|
|
||||||
DEVICE Device_Table ={ EP_NUM, 1 };
|
|
||||||
DEVICE_PROP Device_Property ={
|
|
||||||
MASS_init,
|
|
||||||
MASS_Reset,
|
|
||||||
MASS_Status_In,
|
|
||||||
MASS_Status_Out,
|
|
||||||
MASS_Data_Setup,
|
|
||||||
MASS_NoData_Setup,
|
|
||||||
MASS_Get_Interface_Setting,
|
|
||||||
MASS_GetDeviceDescriptor,
|
|
||||||
MASS_GetConfigDescriptor,
|
|
||||||
MASS_GetStringDescriptor,
|
|
||||||
0,
|
|
||||||
0x40 // MAX PACKET SIZE
|
|
||||||
};
|
|
||||||
USER_STANDARD_REQUESTS User_Standard_Requests ={
|
|
||||||
Mass_Storage_GetConfiguration,
|
|
||||||
Mass_Storage_SetConfiguration,
|
|
||||||
Mass_Storage_GetInterface,
|
|
||||||
Mass_Storage_SetInterface,
|
|
||||||
Mass_Storage_GetStatus,
|
|
||||||
Mass_Storage_ClearFeature,
|
|
||||||
Mass_Storage_SetEndPointFeature,
|
|
||||||
Mass_Storage_SetDeviceFeature,
|
|
||||||
Mass_Storage_SetDeviceAddress
|
|
||||||
};
|
|
||||||
ONE_DESCRIPTOR Device_Descriptor ={
|
|
||||||
(u8*)MASS_DeviceDescriptor,
|
|
||||||
MASS_SIZ_DEVICE_DESC
|
|
||||||
};
|
|
||||||
ONE_DESCRIPTOR Config_Descriptor ={
|
|
||||||
(u8*)MASS_ConfigDescriptor,
|
|
||||||
MASS_SIZ_CONFIG_DESC
|
|
||||||
};
|
|
||||||
ONE_DESCRIPTOR String_Descriptor[5] ={
|
|
||||||
{(u8*)MASS_StringLangID, MASS_SIZ_STRING_LANGID},
|
|
||||||
{(u8*)MASS_StringVendor, MASS_SIZ_STRING_VENDOR},
|
|
||||||
{(u8*)MASS_StringProduct, MASS_SIZ_STRING_PRODUCT},
|
|
||||||
{(u8*)MASS_StringSerial, MASS_SIZ_STRING_SERIAL},
|
|
||||||
{(u8*)MASS_StringInterface, MASS_SIZ_STRING_INTERFACE},
|
|
||||||
};
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
MASS_init: Mass Storage init routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void MASS_init()
|
|
||||||
{
|
|
||||||
Get_SerialNum(); // Update the serial number string descriptor with the data from the unique ID
|
|
||||||
pInformation->Current_Configuration = 0;
|
|
||||||
PowerOn(); // Connect the device
|
|
||||||
_SetISTR(0); // USB interrupts initialization. clear pending interrupts
|
|
||||||
wInterrupt_Mask = IMR_MSK;
|
|
||||||
_SetCNTR(wInterrupt_Mask); // set interrupts mask
|
|
||||||
bDeviceState = UNCONNECTED;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
MASS_Reset: Mass Storage reset routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void MASS_Reset()
|
|
||||||
{
|
|
||||||
Device_Info.Current_Configuration = 0; // Set the device as not configured
|
|
||||||
pInformation->Current_Feature = MASS_ConfigDescriptor[7]; // Current Feature initialization
|
|
||||||
SetBTABLE(BTABLE_ADDRESS);
|
|
||||||
// Initialize Endpoint 0
|
|
||||||
SetEPType(ENDP0, EP_CONTROL);
|
|
||||||
SetEPTxStatus(ENDP0, EP_TX_NAK);
|
|
||||||
SetEPRxAddr(ENDP0, ENDP0_RXADDR);
|
|
||||||
SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
|
|
||||||
SetEPTxAddr(ENDP0, ENDP0_TXADDR);
|
|
||||||
Clear_Status_Out(ENDP0);
|
|
||||||
SetEPRxValid(ENDP0);
|
|
||||||
//Initialize Endpoint 1
|
|
||||||
SetEPType(ENDP1, EP_BULK);
|
|
||||||
SetEPTxAddr(ENDP1, ENDP1_TXADDR);
|
|
||||||
SetEPTxStatus(ENDP1, EP_TX_NAK);
|
|
||||||
SetEPRxStatus(ENDP1, EP_RX_DIS);
|
|
||||||
// Initialize Endpoint 2
|
|
||||||
SetEPType(ENDP2, EP_BULK);
|
|
||||||
SetEPRxAddr(ENDP2, ENDP2_RXADDR);
|
|
||||||
SetEPRxCount(ENDP2, Device_Property.MaxPacketSize);
|
|
||||||
SetEPRxStatus(ENDP2, EP_RX_VALID);
|
|
||||||
SetEPTxStatus(ENDP2, EP_TX_DIS);
|
|
||||||
|
|
||||||
SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
|
|
||||||
SetEPRxValid(ENDP0);
|
|
||||||
// Set the device to response on default address
|
|
||||||
SetDeviceAddress(0);
|
|
||||||
|
|
||||||
bDeviceState = ATTACHED;
|
|
||||||
|
|
||||||
CBW.dSignature = BOT_CBW_SIGNATURE;
|
|
||||||
Bot_State = BOT_IDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Mass_Storage_SetConfiguration: Handle the SetConfiguration request.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Mass_Storage_SetConfiguration(void)
|
|
||||||
{
|
|
||||||
if (pInformation->Current_Configuration != 0){
|
|
||||||
bDeviceState = CONFIGURED; // Device configured
|
|
||||||
ClearDTOG_TX(ENDP1);
|
|
||||||
ClearDTOG_RX(ENDP2);
|
|
||||||
Bot_State = BOT_IDLE; // set the Bot state machine to the IDLE state
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Mass_Storage_ClearFeature: Handle the ClearFeature request.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Mass_Storage_ClearFeature(void)
|
|
||||||
{
|
|
||||||
/* when the host send a CBW with invalid signature or invalid length the two
|
|
||||||
Endpoints (IN & OUT) shall stall until receiving a Mass Storage Reset */
|
|
||||||
if (CBW.dSignature != BOT_CBW_SIGNATURE)
|
|
||||||
Bot_Abort(BOTH_DIR);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Mass_Storage_SetConfiguration: Udpade the device state to addressed.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Mass_Storage_SetDeviceAddress (void)
|
|
||||||
{
|
|
||||||
bDeviceState = ADDRESSED;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
MASS_Status_In: Mass Storage Status IN routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void MASS_Status_In(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
MASS_Status_Out: Mass Storage Status OUT routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void MASS_Status_Out(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
MASS_Data_Setup: Handle the data class specific requests.
|
|
||||||
*******************************************************************************/
|
|
||||||
RESULT MASS_Data_Setup(u8 RequestNo)
|
|
||||||
{
|
|
||||||
u8* (*CopyRoutine)(u16);
|
|
||||||
|
|
||||||
CopyRoutine = NULL;
|
|
||||||
if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
|
|
||||||
&& (RequestNo == GET_MAX_LUN) && (pInformation->USBwValue == 0)
|
|
||||||
&& (pInformation->USBwIndex == 0) && (pInformation->USBwLength == 0x01))
|
|
||||||
{
|
|
||||||
CopyRoutine = Get_Max_Lun;
|
|
||||||
} else return USB_UNSUPPORT;
|
|
||||||
if (CopyRoutine == NULL) return USB_UNSUPPORT;
|
|
||||||
pInformation->Ctrl_Info.CopyData = CopyRoutine;
|
|
||||||
pInformation->Ctrl_Info.Usb_wOffset = 0;
|
|
||||||
(*CopyRoutine)(0);
|
|
||||||
return USB_SUCCESS;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
MASS_NoData_Setup: Handle the no data class specific requests.
|
|
||||||
*******************************************************************************/
|
|
||||||
RESULT MASS_NoData_Setup(u8 RequestNo)
|
|
||||||
{
|
|
||||||
if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
|
|
||||||
&& (RequestNo == MASS_STORAGE_RESET) && (pInformation->USBwValue == 0)
|
|
||||||
&& (pInformation->USBwIndex == 0) && (pInformation->USBwLength == 0x00))
|
|
||||||
{
|
|
||||||
ClearDTOG_TX(ENDP1); // Initialize Endpoint 1
|
|
||||||
ClearDTOG_RX(ENDP2); // Initialize Endpoint 2
|
|
||||||
CBW.dSignature = BOT_CBW_SIGNATURE; // intialise the CBW signature to enable the clear feature
|
|
||||||
Bot_State = BOT_IDLE;
|
|
||||||
return USB_SUCCESS;
|
|
||||||
}
|
|
||||||
return USB_UNSUPPORT;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
MASS_Get_Interface_Setting: Test the interface and the alternate setting
|
|
||||||
according to the supported one.
|
|
||||||
*******************************************************************************/
|
|
||||||
RESULT MASS_Get_Interface_Setting(u8 Interface, u8 AlternateSetting)
|
|
||||||
{
|
|
||||||
if (AlternateSetting > 0) return USB_UNSUPPORT;// in this application we don't have AlternateSetting
|
|
||||||
else if (Interface > 0) return USB_UNSUPPORT; // in this application we have only 1 interfaces
|
|
||||||
return USB_SUCCESS;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
MASS_GetDeviceDescriptor: Get the device descriptor.
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 *MASS_GetDeviceDescriptor(u16 Length)
|
|
||||||
{
|
|
||||||
return Standard_GetDescriptorData(Length, &Device_Descriptor );
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
MASS_GetConfigDescriptor: Get the configuration descriptor.
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 *MASS_GetConfigDescriptor(u16 Length)
|
|
||||||
{
|
|
||||||
return Standard_GetDescriptorData(Length, &Config_Descriptor );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
MASS_GetStringDescriptor: Get the string descriptors according to
|
|
||||||
the needed index.
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 *MASS_GetStringDescriptor(u16 Length)
|
|
||||||
{
|
|
||||||
u8 wValue0 = pInformation->USBwValue0;
|
|
||||||
if (wValue0 > 5) return NULL;
|
|
||||||
else return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Get_Max_Lun: Handle the Get Max Lun request.
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 *Get_Max_Lun(u16 Length)
|
|
||||||
{
|
|
||||||
if (Length == 0){
|
|
||||||
pInformation->Ctrl_Info.Usb_wLength = LUN_DATA_LENGTH;
|
|
||||||
return 0;
|
|
||||||
} else return((u8*)(&Max_Lun));
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Get_SerialNum : Create the serial number string descriptor.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Get_SerialNum(void)
|
|
||||||
{
|
|
||||||
u32 Device_Serial0, Device_Serial1, Device_Serial2;
|
|
||||||
|
|
||||||
Device_Serial0 = SERIAL_NO1;
|
|
||||||
Device_Serial1 = SERIAL_NO2;
|
|
||||||
Device_Serial2 = SERIAL_NO3;
|
|
||||||
|
|
||||||
if (Device_Serial0 != 0){
|
|
||||||
MASS_StringSerial[ 2] = (u8)( Device_Serial0 & 0x000000FF);
|
|
||||||
MASS_StringSerial[ 4] = (u8)((Device_Serial0 & 0x0000FF00) >> 8);
|
|
||||||
MASS_StringSerial[ 6] = (u8)((Device_Serial0 & 0x00FF0000) >> 16);
|
|
||||||
MASS_StringSerial[ 8] = (u8)((Device_Serial0 & 0xFF000000) >> 24);
|
|
||||||
|
|
||||||
MASS_StringSerial[10] = (u8)( Device_Serial1 & 0x000000FF);
|
|
||||||
MASS_StringSerial[12] = (u8)((Device_Serial1 & 0x0000FF00) >> 8);
|
|
||||||
MASS_StringSerial[14] = (u8)((Device_Serial1 & 0x00FF0000) >> 16);
|
|
||||||
MASS_StringSerial[16] = (u8)((Device_Serial1 & 0xFF000000) >> 24);
|
|
||||||
|
|
||||||
MASS_StringSerial[18] = (u8)( Device_Serial2 & 0x000000FF);
|
|
||||||
MASS_StringSerial[20] = (u8)((Device_Serial2 & 0x0000FF00) >> 8);
|
|
||||||
MASS_StringSerial[22] = (u8)((Device_Serial2 & 0x00FF0000) >> 16);
|
|
||||||
MASS_StringSerial[24] = (u8)((Device_Serial2 & 0xFF000000) >> 24);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_pwr.c
|
|
||||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#include "usb_lib.h"
|
|
||||||
#include "usb_conf.h"
|
|
||||||
#include "usb_pwr.h"
|
|
||||||
|
|
||||||
vu32 bDeviceState = UNCONNECTED; // USB device status
|
|
||||||
vu8 fSuspendEnabled = TRUE; // true when suspend is possible
|
|
||||||
|
|
||||||
struct{
|
|
||||||
volatile RESUME_STATE eState;
|
|
||||||
volatile u8 bESOFcnt;
|
|
||||||
} ResumeS;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
PowerOn Return : USB_SUCCESS
|
|
||||||
|
|
||||||
*******************************************************************************/
|
|
||||||
RESULT PowerOn(void)
|
|
||||||
{
|
|
||||||
u16 wRegVal;
|
|
||||||
|
|
||||||
/*** CNTR_PWDN = 0 ***/
|
|
||||||
wRegVal = CNTR_FRES;
|
|
||||||
_SetCNTR(wRegVal);
|
|
||||||
/*** CNTR_FRES = 0 ***/
|
|
||||||
wInterrupt_Mask = 0;
|
|
||||||
_SetCNTR(wInterrupt_Mask);
|
|
||||||
/*** Clear pending interrupts ***/
|
|
||||||
_SetISTR(0);
|
|
||||||
/*** Set interrupt mask ***/
|
|
||||||
wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM;
|
|
||||||
_SetCNTR(wInterrupt_Mask);
|
|
||||||
|
|
||||||
return USB_SUCCESS;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
PowerOff: handles switch-off conditions Return : USB_SUCCESS
|
|
||||||
*******************************************************************************/
|
|
||||||
RESULT PowerOff()
|
|
||||||
{
|
|
||||||
/* disable all ints and force USB reset */
|
|
||||||
_SetCNTR(CNTR_FRES);
|
|
||||||
/* clear interrupt status register */
|
|
||||||
_SetISTR(0);
|
|
||||||
/* Disable the Pull-Up*/
|
|
||||||
// USB_Cable_Config(DISABLE);
|
|
||||||
/* switch-off device */
|
|
||||||
_SetCNTR(CNTR_FRES + CNTR_PDWN);
|
|
||||||
/* sw variables reset */
|
|
||||||
/* ... */
|
|
||||||
|
|
||||||
return USB_SUCCESS;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Suspend: sets suspend mode operating conditions
|
|
||||||
Return : USB_SUCCESS.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Suspend(void)
|
|
||||||
{
|
|
||||||
u16 wCNTR;
|
|
||||||
/* suspend preparation */
|
|
||||||
/* macrocell enters suspend mode */
|
|
||||||
wCNTR = _GetCNTR();
|
|
||||||
wCNTR |= CNTR_FSUSP;
|
|
||||||
_SetCNTR(wCNTR);
|
|
||||||
/* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */
|
|
||||||
/* power reduction */
|
|
||||||
/* ... on connected devices */
|
|
||||||
/* force low-power mode in the macrocell */
|
|
||||||
wCNTR = _GetCNTR();
|
|
||||||
wCNTR |= CNTR_LPMODE;
|
|
||||||
_SetCNTR(wCNTR);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Resume_Init: Handles wake-up restoring normal operations
|
|
||||||
* Return : USB_SUCCESS.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Resume_Init(void)
|
|
||||||
{
|
|
||||||
u16 wCNTR;
|
|
||||||
/* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */
|
|
||||||
/* restart the clocks */
|
|
||||||
/* CNTR_LPMODE = 0 */
|
|
||||||
wCNTR = _GetCNTR();
|
|
||||||
wCNTR &= (~CNTR_LPMODE);
|
|
||||||
_SetCNTR(wCNTR);
|
|
||||||
/* restore full power */
|
|
||||||
/* ... on connected devices */
|
|
||||||
/* reset FSUSP bit */
|
|
||||||
_SetCNTR(IMR_MSK);
|
|
||||||
/* reverse suspend preparation */
|
|
||||||
/* ... */
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
Resume: This is the state machine handling resume operations and
|
|
||||||
timing sequence. The control is based on the Resume structure
|
|
||||||
variables and on the ESOF interrupt calling this subroutine
|
|
||||||
without changing machine state.
|
|
||||||
Input: a state machine value (RESUME_STATE)
|
|
||||||
RESUME_ESOF doesn't change ResumeS.eState allowing
|
|
||||||
decrementing of the ESOF counter in different states.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Resume(RESUME_STATE eResumeSetVal)
|
|
||||||
{
|
|
||||||
u16 wCNTR;
|
|
||||||
|
|
||||||
if (eResumeSetVal != RESUME_ESOF) ResumeS.eState = eResumeSetVal;
|
|
||||||
switch (ResumeS.eState){
|
|
||||||
case RESUME_EXTERNAL:
|
|
||||||
Resume_Init();
|
|
||||||
ResumeS.eState = RESUME_OFF;
|
|
||||||
break;
|
|
||||||
case RESUME_INTERNAL:
|
|
||||||
Resume_Init();
|
|
||||||
ResumeS.eState = RESUME_START;
|
|
||||||
break;
|
|
||||||
case RESUME_LATER:
|
|
||||||
ResumeS.bESOFcnt = 2;
|
|
||||||
ResumeS.eState = RESUME_WAIT;
|
|
||||||
break;
|
|
||||||
case RESUME_WAIT:
|
|
||||||
ResumeS.bESOFcnt--;
|
|
||||||
if (ResumeS.bESOFcnt == 0)
|
|
||||||
ResumeS.eState = RESUME_START;
|
|
||||||
break;
|
|
||||||
case RESUME_START:
|
|
||||||
wCNTR = _GetCNTR();
|
|
||||||
wCNTR |= CNTR_RESUME;
|
|
||||||
_SetCNTR(wCNTR);
|
|
||||||
ResumeS.eState = RESUME_ON;
|
|
||||||
ResumeS.bESOFcnt = 10;
|
|
||||||
break;
|
|
||||||
case RESUME_ON:
|
|
||||||
ResumeS.bESOFcnt--;
|
|
||||||
if (ResumeS.bESOFcnt == 0){
|
|
||||||
wCNTR = _GetCNTR();
|
|
||||||
wCNTR &= (~CNTR_RESUME);
|
|
||||||
_SetCNTR(wCNTR);
|
|
||||||
ResumeS.eState = RESUME_OFF;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RESUME_OFF:
|
|
||||||
case RESUME_ESOF:
|
|
||||||
default:
|
|
||||||
ResumeS.eState = RESUME_OFF;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -1,230 +0,0 @@
|
|||||||
/******************** (C) COPYRIGHT 2015 e-Design Co., Ltd. ********************
|
|
||||||
File Name : USB_scsi.c
|
|
||||||
Version : STM32 USB Disk Ver 3.4 Author : MCD Application Team & bure
|
|
||||||
*******************************************************************************/
|
|
||||||
#include "usb_scsi.h"
|
|
||||||
#include "usb_bot.h"
|
|
||||||
#include "usb_regs.h"
|
|
||||||
#include "usb_lib.h"
|
|
||||||
#include "Disk.h"
|
|
||||||
|
|
||||||
u8 Page00_Inquiry_Data[] ={ 0, 0, 0, 0, 0};
|
|
||||||
u8 Mode_Sense6_data[] ={0x03, 0x00, 0x00, 0x00};
|
|
||||||
u8 Mode_Sense10_data[] ={0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
||||||
u8 Scsi_Sense_Data[] ={0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
||||||
u8 ReadCapacity10_Data[] ={ 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
u8 ReadFormatCapacity[] ={ 0, 0, 0, 8, 0, 0, 0, 0, 2, 0, 0, 0};
|
|
||||||
|
|
||||||
#ifdef DFU_MODE
|
|
||||||
uc8 Disk_Inquiry_Str[] ={0x00, 0x80, 0x02, 0x02, 36-4, 0x00, 0x00, 0x00,
|
|
||||||
'V', 'i', 'r', 't', 'u', 'a', 'l', ' ',
|
|
||||||
'D', 'F', 'U', ' ', 'D', 'i', 's', 'k',
|
|
||||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
||||||
' ', ' ', ' ', ' ', };
|
|
||||||
#else
|
|
||||||
uc8 Disk_Inquiry_Str[] ={0x00, 0x80, 0x02, 0x02, 36-4, 0x00, 0x00, 0x00,
|
|
||||||
'M', 'i', 'n', 'i', ' ', 'D', 'S', 'O',
|
|
||||||
'D', 'i', 's', 'k', ' ', ' ', ' ', ' ',
|
|
||||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
|
||||||
' ', ' ', ' ', ' ', };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_Inquiry_Cmd: SCSI Inquiry Command routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_Inquiry_Cmd(void)
|
|
||||||
{
|
|
||||||
u8* Inquiry_Data;
|
|
||||||
u16 Inquiry_Data_Length;
|
|
||||||
|
|
||||||
if (CBW.CB[1] & 0x01){ // Evpd is set
|
|
||||||
Inquiry_Data = Page00_Inquiry_Data;
|
|
||||||
Inquiry_Data_Length = 5;
|
|
||||||
} else {
|
|
||||||
Inquiry_Data = (u8*)Disk_Inquiry_Str;
|
|
||||||
if (CBW.CB[4] <= STANDARD_INQUIRY_DATA_LEN) Inquiry_Data_Length = CBW.CB[4];
|
|
||||||
else Inquiry_Data_Length = STANDARD_INQUIRY_DATA_LEN;
|
|
||||||
}
|
|
||||||
Transfer_Data_Request(Inquiry_Data, Inquiry_Data_Length);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_ReadFormatCapacity_Cmd: SCSI ReadFormatCapacity Command routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_ReadFormatCapacity_Cmd(void)
|
|
||||||
{
|
|
||||||
ReadFormatCapacity[ 4] = (u8)(SECTOR_SIZE >> 24);
|
|
||||||
ReadFormatCapacity[ 5] = (u8)(SECTOR_SIZE >> 16);
|
|
||||||
ReadFormatCapacity[ 6] = (u8)(SECTOR_SIZE >> 8);
|
|
||||||
ReadFormatCapacity[ 7] = (u8)(SECTOR_SIZE);
|
|
||||||
|
|
||||||
ReadFormatCapacity[ 9] = (u8)(SECTOR_SIZE >> 16);
|
|
||||||
ReadFormatCapacity[10] = (u8)(SECTOR_SIZE >> 8);
|
|
||||||
ReadFormatCapacity[11] = (u8)(SECTOR_SIZE);
|
|
||||||
|
|
||||||
Transfer_Data_Request(ReadFormatCapacity, READ_FORMAT_CAPACITY_DATA_LEN);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_ReadCapacity10_Cmd: SCSI ReadCapacity10 Command routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_ReadCapacity10_Cmd(void)
|
|
||||||
{
|
|
||||||
ReadCapacity10_Data[0] = (u8)(SECTOR_CNT - 1 >> 24);
|
|
||||||
ReadCapacity10_Data[1] = (u8)(SECTOR_CNT - 1 >> 16);
|
|
||||||
ReadCapacity10_Data[2] = (u8)(SECTOR_CNT - 1 >> 8);
|
|
||||||
ReadCapacity10_Data[3] = (u8)(SECTOR_CNT - 1);
|
|
||||||
|
|
||||||
ReadCapacity10_Data[4] = (u8)(SECTOR_SIZE >> 24);
|
|
||||||
ReadCapacity10_Data[5] = (u8)(SECTOR_SIZE >> 16);
|
|
||||||
ReadCapacity10_Data[6] = (u8)(SECTOR_SIZE >> 8);
|
|
||||||
ReadCapacity10_Data[7] = (u8)(SECTOR_SIZE);
|
|
||||||
|
|
||||||
Transfer_Data_Request(ReadCapacity10_Data, READ_CAPACITY10_DATA_LEN);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_ModeSense6_Cmd: SCSI ModeSense6 Command routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_ModeSense6_Cmd (void)
|
|
||||||
{
|
|
||||||
Transfer_Data_Request(Mode_Sense6_data, MODE_SENSE6_DATA_LEN);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_ModeSense10_Cmd: SCSI ModeSense10 Command routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_ModeSense10_Cmd (void)
|
|
||||||
{
|
|
||||||
Transfer_Data_Request(Mode_Sense10_data, MODE_SENSE10_DATA_LEN);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_RequestSense_Cmd: SCSI RequestSense Command routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_RequestSense_Cmd (void)
|
|
||||||
{
|
|
||||||
u8 Request_Sense_data_Length;
|
|
||||||
|
|
||||||
if (CBW.CB[4] <= REQUEST_SENSE_DATA_LEN) Request_Sense_data_Length = CBW.CB[4];
|
|
||||||
else Request_Sense_data_Length = REQUEST_SENSE_DATA_LEN;
|
|
||||||
|
|
||||||
Transfer_Data_Request(Scsi_Sense_Data, Request_Sense_data_Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
Set_Scsi_Sense_Data: Set Scsi Sense Data routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void Set_Scsi_Sense_Data(u8 Sens_Key, u8 Asc)
|
|
||||||
{
|
|
||||||
Scsi_Sense_Data[2] = Sens_Key;
|
|
||||||
Scsi_Sense_Data[12] = Asc;
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_Start_Stop_Unit_Cmd: SCSI Start_Stop_Unit Command routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_Start_Stop_Unit_Cmd(void)
|
|
||||||
{
|
|
||||||
Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_Read10_Cmd: SCSI Read10 Command routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_Read10_Cmd(u32 LBA , u32 BlockNbr)
|
|
||||||
{
|
|
||||||
if (Bot_State == BOT_IDLE){
|
|
||||||
if (!(SCSI_Address_Management(SCSI_READ10, LBA, BlockNbr))) return;//address out of range
|
|
||||||
if ((CBW.bmFlags & 0x80) != 0){
|
|
||||||
Bot_State = BOT_DATA_IN;
|
|
||||||
Read_Memory(LBA , BlockNbr);
|
|
||||||
} else {
|
|
||||||
Bot_Abort(BOTH_DIR);
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
|
||||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_ENABLE);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if (Bot_State == BOT_DATA_IN) Read_Memory(LBA , BlockNbr);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_Write10_Cmd: SCSI Write10 Command routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_Write10_Cmd(u32 LBA , u32 BlockNbr)
|
|
||||||
{
|
|
||||||
if (Bot_State == BOT_IDLE){
|
|
||||||
if (!(SCSI_Address_Management(SCSI_WRITE10 , LBA, BlockNbr))) return;//address out of range
|
|
||||||
if ((CBW.bmFlags & 0x80) == 0){
|
|
||||||
Bot_State = BOT_DATA_OUT;
|
|
||||||
SetEPRxStatus(ENDP2, EP_RX_VALID);
|
|
||||||
} else {
|
|
||||||
Bot_Abort(DIR_IN);
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
|
||||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if (Bot_State == BOT_DATA_OUT) Write_Memory(LBA , BlockNbr);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_Verify10_Cmd: SCSI Verify10 Command routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_Verify10_Cmd(void)
|
|
||||||
{
|
|
||||||
if ((CBW.dDataLength == 0) && !(CBW.CB[1] & BLKVFY)){ // BLKVFY not set
|
|
||||||
Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
|
||||||
} else {
|
|
||||||
Bot_Abort(BOTH_DIR);
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
|
||||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_Valid_Cmd: Valid Commands routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_Valid_Cmd(void)
|
|
||||||
{
|
|
||||||
if (CBW.dDataLength != 0){
|
|
||||||
Bot_Abort(BOTH_DIR);
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_COMMAND);
|
|
||||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
|
||||||
} else Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_Valid_Cmd: Valid Commands routine.
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_TestUnitReady_Cmd(void)
|
|
||||||
{
|
|
||||||
Set_CSW (CSW_CMD_PASSED, SEND_CSW_ENABLE);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_Invalid_Cmd: Invalid Commands routine
|
|
||||||
*******************************************************************************/
|
|
||||||
void SCSI_Invalid_Cmd(void)
|
|
||||||
{
|
|
||||||
if (CBW.dDataLength == 0) Bot_Abort(DIR_IN);
|
|
||||||
else{
|
|
||||||
if ((CBW.bmFlags & 0x80) != 0) Bot_Abort(DIR_IN);
|
|
||||||
else Bot_Abort(BOTH_DIR);
|
|
||||||
}
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_COMMAND);
|
|
||||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
|
||||||
}
|
|
||||||
/*******************************************************************************
|
|
||||||
SCSI_Address_Management: Test the received address.
|
|
||||||
Input: Cmd the command can be SCSI_READ10 or SCSI_WRITE10.
|
|
||||||
Return: Read\Write status (bool).
|
|
||||||
*******************************************************************************/
|
|
||||||
u8 SCSI_Address_Management(u8 Cmd , u32 LBA , u32 BlockNbr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ((LBA + BlockNbr) > SECTOR_CNT){
|
|
||||||
if (Cmd == SCSI_WRITE10) Bot_Abort(BOTH_DIR);
|
|
||||||
Bot_Abort(DIR_IN);
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, ADDRESS_OUT_OF_RANGE);
|
|
||||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
if (CBW.dDataLength != BlockNbr * SECTOR_SIZE){
|
|
||||||
if (Cmd == SCSI_WRITE10) Bot_Abort(BOTH_DIR);
|
|
||||||
else Bot_Abort(DIR_IN);
|
|
||||||
Set_Scsi_Sense_Data(ILLEGAL_REQUEST, INVALID_FIELED_IN_COMMAND);
|
|
||||||
Set_CSW (CSW_CMD_FAILED, SEND_CSW_DISABLE);
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
/********************************* END OF FILE ******************************/
|
|
||||||
@@ -10,4 +10,6 @@ transport select "hla_swd"
|
|||||||
source [find target/stm32f1x_stlink.cfg]
|
source [find target/stm32f1x_stlink.cfg]
|
||||||
|
|
||||||
# use hardware reset, connect under reset
|
# use hardware reset, connect under reset
|
||||||
reset_config srst_only srst_nogate
|
#reset_config srst_only srst_nogate
|
||||||
|
#software
|
||||||
|
reset_config none separate
|
||||||
Reference in New Issue
Block a user