├── .gitattributes ├── .gitignore ├── ISSUE_TEMPLATE.md ├── LICENSE.txt ├── Makefile ├── README.md ├── README_de.md ├── README_it.md ├── README_pt_BR.docx ├── bin └── myevic.bin ├── constants.txt ├── driver ├── NuvotonCDC.inf └── readme.txt ├── git_doc_en ├── behaviourchanges_en.md ├── clock_en.md ├── coils_en.md ├── expert_en.md ├── howtobuild_en.md ├── interface_en.md ├── mainscr_en.md ├── menus_en.md ├── profiles_en.md ├── screen_en.md ├── usageandcompatibility_en.md └── vaping_en.md ├── git_doc_it ├── behaviourchanges_it.md ├── clock_it.md ├── coils_it.md ├── expert_it.md ├── howtobuild_it.md ├── interface_it.md ├── mainscr_it.md ├── menus_it.md ├── profiles_it.md ├── screen_it.md ├── usageandcompatibility_it.md └── vaping_it.md ├── inc ├── atomizer.h ├── battery.h ├── dataflash.h ├── display.h ├── dtmacros.h ├── events.h ├── flappy.h ├── meadc.h ├── megpio.h ├── menus.h ├── meusbd.h ├── miscs.h ├── myevic.h ├── myprintf.h ├── myrtc.h ├── screens.h ├── storage.h ├── timers.h └── vcom.h ├── linker.ld └── src ├── SSD1306.c ├── SSD1327.c ├── atomizer.c ├── battery.c ├── dataflash.c ├── display.c ├── eh.c ├── events.c ├── fbdata.c ├── flappy.c ├── fonts.c ├── main.c ├── mainview.c ├── meadc.c ├── megpio.c ├── menus.c ├── meusbd.c ├── miscs.c ├── myevic.s ├── myprintf.c ├── myrtc.c ├── screens.c ├── storage.c ├── strings.c ├── timers.c └── vcom.c /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | bin/ 49 | !bin/myevic.bin 50 | *.sh 51 | disasm/ 52 | obj/ 53 | projects/ 54 | *.o 55 | startfiles 56 | driver/*.sys 57 | *.map 58 | genuine/ 59 | wrkspc.txt 60 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | **Box Model:** 12 | 13 | **Coil setup:** 14 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TARGET := myevic 2 | 3 | # We make the following assumptions on Windows: 4 | # arm-none-eabi gcc and binutils are compiled for Windows, 5 | # so if you are using Cygwin, we will need path translations 6 | # NUVOSDK must be lazily evaluated, so that we can later 7 | # change EVICSDK when building include paths. 8 | 9 | # Small fix to bug where cygpath -w mistranslates paths with mixed slashes (/, \) 10 | EVICSDK := $(subst \,/,$(EVICSDK)) 11 | NUVOSDK = $(EVICSDK)/nuvoton-sdk/Library 12 | 13 | OBJS := $(NUVOSDK)/Device/Nuvoton/M451Series/Source/system_M451Series.o \ 14 | $(NUVOSDK)/StdDriver/src/clk.o \ 15 | $(NUVOSDK)/StdDriver/src/fmc.o \ 16 | $(NUVOSDK)/StdDriver/src/gpio.o \ 17 | $(NUVOSDK)/StdDriver/src/spi.o \ 18 | $(NUVOSDK)/StdDriver/src/sys.o \ 19 | $(NUVOSDK)/StdDriver/src/timer.o \ 20 | $(NUVOSDK)/StdDriver/src/rtc.o \ 21 | $(NUVOSDK)/StdDriver/src/usbd.o \ 22 | $(NUVOSDK)/StdDriver/src/eadc.o \ 23 | $(NUVOSDK)/StdDriver/src/pwm.o \ 24 | $(NUVOSDK)/StdDriver/src/wdt.o \ 25 | $(NUVOSDK)/StdDriver/src/uart.o \ 26 | $(NUVOSDK)/StdDriver/src/crc.o 27 | 28 | MYEVIC_OBJS := src/myevic.o \ 29 | src/main.o \ 30 | src/myprintf.o \ 31 | src/atomizer.o \ 32 | src/dataflash.o \ 33 | src/screens.o \ 34 | src/menus.o \ 35 | src/mainview.o \ 36 | src/battery.o \ 37 | src/events.o \ 38 | src/myrtc.o \ 39 | src/miscs.o \ 40 | src/eh.o \ 41 | src/timers.o \ 42 | src/meadc.o \ 43 | src/megpio.o \ 44 | src/strings.o \ 45 | src/meusbd.o \ 46 | src/vcom.o \ 47 | src/storage.o \ 48 | src/flappy.o \ 49 | src/fbdata.o \ 50 | src/fonts.o \ 51 | src/display.o \ 52 | src/SSD1306.o \ 53 | src/SSD1327.o 54 | 55 | AEABI_OBJS := src/aeabi/aeabi_memset-thumb2.o \ 56 | src/aeabi/aeabi_memclr.o 57 | 58 | OUTDIR := bin 59 | DOCDIR := doc 60 | 61 | CPU := cortex-m4 62 | FPU := fpv4-sp-d16 63 | 64 | # We need to find out if on cygwin or not 65 | ifeq ($(OS),Windows_NT) 66 | ifeq (, $(findstring cygwin, $(shell gcc -dumpmachine))) 67 | WIN_CYG := 0 68 | else 69 | WIN_CYG := 1 70 | endif 71 | endif 72 | 73 | ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) 74 | CC_IS_CLANG := 1 75 | endif 76 | 77 | ifeq ($(ARMGCC),) 78 | ARMGCC := $(shell cd $(shell arm-none-eabi-gcc --print-search-dir | grep 'libraries' | \ 79 | tr '=$(if $(filter Windows_NT,$(OS)),;,:)' '\n' | \ 80 | grep -E '/arm-none-eabi/lib/?$$' | head -1)/../.. && pwd) 81 | endif 82 | 83 | ifeq ($(OS),Windows_NT) 84 | # Always fix binutils path 85 | ifneq ($(ARMGCC),) 86 | # If using cygwin, use cygpath 87 | ifeq ($(WIN_CYG),1) 88 | ARMGCC := $(shell cygpath -w $(ARMGCC)) 89 | endif 90 | endif 91 | 92 | ifndef CC_IS_CLANG 93 | NEED_FIXPATH := 1 94 | endif 95 | endif 96 | 97 | ifneq ($(ARMGCC),) 98 | ifdef CC_IS_CLANG 99 | CFLAGS += -target armv7em-none-eabi -fshort-enums 100 | 101 | # AEABI_COUNT := $(shell arm-none-eabi-nm -g $(ARMGCC)/arm-none-eabi/lib/armv7e-m/libc.a | grep -Ec 'T __aeabi_mem(set|clr)[48]?$$') 102 | AEABI_COUNT := $(shell arm-none-eabi-nm -g $(ARMGCC)/arm-none-eabi/lib/thumb/v7e-m/libc.a | grep -Ec 'T __aeabi_mem(set|clr)[48]?$$') 103 | ifeq ($(AEABI_COUNT), 0) 104 | # __aeabi_memset* and __aeabi_memclr* are not exported by libc 105 | # We provide our own implementations 106 | OBJS += $(AEABI_OBJS) 107 | else ifneq ($(AEABI_COUNT), 6) 108 | # Only part of __aeabi_memset* and __aeabi_memclr* are exported by libc 109 | # This should never happen, bail out in env_check 110 | AEABI_ERROR := 1 111 | endif 112 | else 113 | CC := arm-none-eabi-gcc 114 | endif 115 | 116 | ifdef NEED_FIXPATH 117 | ifeq ($(WIN_CYG), 0) 118 | OBJS_FIXPATH := $(OBJS) 119 | else 120 | OBJS_FIXPATH := $(shell cygpath -w $(OBJS)) 121 | EVICSDK := $(shell cygpath -w $(EVICSDK)) 122 | endif 123 | else 124 | OBJS_FIXPATH := $(OBJS) 125 | endif 126 | endif 127 | 128 | ifeq ($(WIN_CYG),0) 129 | SDKTAG := $(shell git describe --abbrev --dirty --always --tags 2> NUL ) # Fix for Windows w/o cygwin (NUL instead of /dev/null) 130 | else 131 | SDKTAG := $(shell git describe --abbrev --dirty --always --tags 2> /dev/null ) 132 | endif 133 | ifeq ($(SDKTAG),) 134 | SDKTAG := unknown 135 | endif 136 | 137 | AS := arm-none-eabi-as 138 | LD := arm-none-eabi-ld 139 | AR := arm-none-eabi-ar 140 | OBJCOPY := arm-none-eabi-objcopy 141 | 142 | INCDIRS := $(foreach d,$(shell arm-none-eabi-gcc -x c -v -E /dev/null 2>&1 | sed -n -e '/<\.\.\.>/,/End/ p' | tail -n +2 | head -n -1 | sed 's/^\s*//'),-I$d) \ 143 | -I$(NUVOSDK)/CMSIS/Include \ 144 | -I$(NUVOSDK)/Device/Nuvoton/M451Series/Include \ 145 | -I$(NUVOSDK)/StdDriver/inc \ 146 | -Iinc \ 147 | -Isrc 148 | 149 | INCDIRS += -I$(ARMGCC)/arm-none-eabi/include 150 | 151 | GCC_VERSION := $(shell arm-none-eabi-gcc -dumpversion) 152 | 153 | LIBDIRS := -L$(ARMGCC)/arm-none-eabi/lib \ 154 | -L$(ARMGCC)/arm-none-eabi/newlib \ 155 | -L$(ARMGCC)/arm-none-eabi/newlib/thumb \ 156 | -L$(ARMGCC)/gcc/arm-none-eabi/$(GCC_VERSION) \ 157 | -L$(ARMGCC)/gcc/arm-none-eabi/$(GCC_VERSION)/thumb 158 | 159 | CFLAGS += -Wall -mcpu=$(CPU) -mfpu=$(FPU) -mthumb -Os -fdata-sections -ffunction-sections -std=c99 160 | CFLAGS += -fno-builtin-printf 161 | CFLAGS += $(INCDIRS) 162 | 163 | ASFLAGS := -mcpu=$(CPU) -mfpu=$(FPU) 164 | ASFLAGS += $(INCDIRS) 165 | 166 | LINKSCRIPT := linker.ld 167 | 168 | LDFLAGS += -u __aeabi_uldivmod 169 | LDFLAGS += $(LIBDIRS) 170 | LDFLAGS += -gc-sections -nostdlib -nostartfiles -T$(LINKSCRIPT) 171 | #LDFLAGS += --verbose --cref -Map=blah.map 172 | 173 | SRCDIR = src 174 | INCDIR = inc 175 | OBJDIR = src 176 | BINDIR = bin 177 | 178 | INCLUDEH := $(wildcard $(INCDIR)/*.h) 179 | INCLUDES := $(wildcard $(SRCDIR)/*.s) 180 | 181 | all: env_check $(TARGET).bin 182 | 183 | $(OBJS_FIXPATH): %.o: %.c 184 | $(CC) $(CFLAGS) -c $< -o $@ 185 | 186 | %.o: %.c $(INCLUDEH) 187 | $(CC) $(CFLAGS) -c $< -o $@ 188 | 189 | %.o: %.s $(INCLUDES) 190 | $(CC) $(CFLAGS) -c $< -o $@ 191 | 192 | $(TARGET)_dec.bin: $(OBJS_FIXPATH) $(MYEVIC_OBJS) 193 | test -d $(OUTDIR) || mkdir $(OUTDIR) 194 | $(LD) --start-group $(LIBS) $(OBJS_FIXPATH) $(MYEVIC_OBJS) --end-group $(LDFLAGS) -o $(OUTDIR)/$(TARGET).elf 195 | $(OBJCOPY) -O binary -j .text -j .data $(OUTDIR)/$(TARGET).elf $(OUTDIR)/$(TARGET)_dec.bin 196 | 197 | $(TARGET).bin: $(TARGET)_dec.bin 198 | evic convert $(OUTDIR)/$(TARGET)_dec.bin -o $(OUTDIR)/$(TARGET).bin 199 | 200 | docs: 201 | doxygen 202 | 203 | clean: 204 | rm -rf $(OBJS) $(MYEVIC_OBJS) $(AEABI_OBJS) $(OUTDIR)/$(TARGET).bin $(OUTDIR) $(DOCDIR) 205 | 206 | env_check: 207 | ifeq ($(ARMGCC),) 208 | $(error You must set the ARMGCC environment variable) 209 | endif 210 | ifneq ($(AEABI_ERROR),) 211 | $(error Your libc is exporting only part of __aeabi symbols) 212 | endif 213 | 214 | .PHONY: all clean docs env_check gen_tag 215 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## **myevic** 2 | This is myevic Custom Firmware. 3 | 4 | #### Based on: 5 | *Original VTC Mini 3.03 firmware* 6 | 7 | #### Main Features: 8 | The look-and-feel of the myevic firmware is more-or-less identical to the original firmware, so you shouldn't be lost. 9 | Many new features and options are made available through the menu system; I strongly encourage you to fully read the present documentation. 10 | 11 | 12 | ## Documentation Index 13 | __1.__ [Usage and compatibility](git_doc_en/usageandcompatibility_en.md) 14 | 15 | __2.__ [Behaviour Changes](git_doc_en/behaviourchanges_en.md) 16 | 17 | __3.__ [How to build](git_doc_en/howtobuild_en.md) 18 | 19 | __4.__ [Profiles](git_doc_en/profiles_en.md) 20 | 21 | __5.__ [Menus](git_doc_en/menus_en.md) 22 | 23 | 5a. [Main Screen](git_doc_en/mainscr_en.md) 24 | 25 | 5b. [Screen Menu](git_doc_en/screen_en.md) 26 | 27 | 5c. [Coil Menu](git_doc_en/coils_en.md) 28 | 29 | 5d. [Vaping Menu](git_doc_en/vaping_en.md) 30 | 31 | 5e. [Clock Menu](git_doc_en/clock_en.md) 32 | 33 | 5f. [Interface Menu](git_doc_en/interface_en.md) 34 | 35 | 5d. [Expert Menu](git_doc_en/expert_en.md) 36 | 37 | ----- 38 | ### Thanks to: 39 | 40 | * ReservedField 41 | * Bane 42 | * TBXin 43 | * maelstrom2001 44 | * Daveee10 45 | * Eugene San 46 | * MarkyAD 47 | * bluenazgul 48 | * Sharky1980 49 | * gdb 50 | 51 | And many others, supporting this project and taking the time to open or help solving issues. 52 | -------------------------------------------------------------------------------- /README_it.md: -------------------------------------------------------------------------------- 1 | ## **myevic** 2 | Questo è il Custom Firmware myevic. 3 | 4 | #### Basato su: 5 | *Original VTC Mini 3.03 firmware* 6 | 7 | #### Funzioni principali: 8 | L'interfaccia utente del firmware myevic non è molto diversa da quella del firmware ufficiale. 9 | Sono state aggiunte molte altre funzioni tramite i menù di sistema. 10 | Pertanto vi invitiamo a leggere la seguente documentazione. 11 | 12 | 13 | ## Indice 14 | __1.__ [Utilizzo e compatibiità](git_doc_it/usageandcompatibility_it.md) 15 | 16 | __2.__ [Comportamenti modificati](git_doc_it/behaviourchanges_it.md) 17 | 18 | __3.__ [Come compilare](git_doc_it/howtobuild_it.md) 19 | 20 | __4.__ [Profiles](git_doc_it/profiles_it.md) 21 | 22 | __5.__ [Menus](git_doc_it/menus_it.md) 23 | 24 | 5a. [Main Screen](git_doc_it/mainscr_it.md) 25 | 26 | 5b. [Screen Menu](git_doc_it/screen_it.md) 27 | 28 | 5c. [Coil Menu](git_doc_it/coils_it.md) 29 | 30 | 5d. [Vaping Menu](git_doc_it/vaping_it.md) 31 | 32 | 5e. [Clock Menu](git_doc_it/clock_it.md) 33 | 34 | 5f. [Interface Menu](git_doc_it/interface_it.md) 35 | 36 | 5d. [Expert Menu](git_doc_it/expert_it.md) 37 | 38 | ----- 39 | ### Thanks to: 40 | 41 | * ReservedField 42 | * Bane 43 | * TBXin 44 | * maelstrom2001 45 | * Daveee10 46 | * Eugene San 47 | * MarkyAD 48 | * bluenazgul 49 | * Sharky1980 50 | * gdb 51 | 52 | And many others, supporting this project and taking the time to open or help solving issues. 53 | -------------------------------------------------------------------------------- /README_pt_BR.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClockSelect/myevic/546394bcf1ac9ab63381fa2fb484a0dfa11d443f/README_pt_BR.docx -------------------------------------------------------------------------------- /bin/myevic.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClockSelect/myevic/546394bcf1ac9ab63381fa2fb484a0dfa11d443f/bin/myevic.bin -------------------------------------------------------------------------------- /constants.txt: -------------------------------------------------------------------------------- 1 | TMR0 HXT 100kHz (100k) 12000000 2 | TMR1 PCLK0 5000Hz (625) 12000000 3 | TMR2 HIRC 1000Hz (500) 22118400 4 | TMR3 HXT 10Hz (10) 12000000 5 | 6 | PA.0 : SSD RESET 7 | PA.1 : SSD VDD 8 | PB.0 : ADC CH0 (BATTERY VOLTS ON VTWO MINI/EVIC AIO) 9 | PB.1 : ADC CH1 (ATO VOLTS) 10 | PB.2 : ADC CH2 (ATO SHUNT) 11 | PB.6 : ADC CH14 (TEMP) 12 | PB.7 : ? (OUT, HIGH) 13 | PC.0 : PWM0 CH0 (BUCK DUTY) 14 | PC.1 : BUCK CONTROL LINE 15 | PC.2 : PWM0 CH2 (BOOST DUTY) 16 | PC.3 : BOOST CONTROL LINE 17 | PC.4 : SSD VCC 18 | PD.0 : BATTERY LOW INT (IN, INT FALL) 19 | PD.1 : UART0 TXD 20 | PD.2 : RIGHT BUTTON 21 | PD.3 : LEFT BUTTON 22 | PD.7 : BATTERY SENSE (IN, INT RISE) 23 | PE.0 : FIRE BUTTON 24 | PE.10: SPI0 D/C# 25 | PE.11: SPI0 MOSI 26 | PE.12: SPI0 SS 27 | PE.13: SPI0 CLK 28 | PF.3 : XT1_IN 29 | PF.4 : XT1_OUT 30 | 31 | dfStatus bits 32 | 0 0x00000001 Switched off 33 | 1 0x00000002 Key locked 34 | 2 0x00000004 Flipped display 35 | 3 0x00000008 LOGO Off 36 | 37 | Flags1 (20000064) 38 | 0 0x00000001 TMR1 5kHz 39 | 1 0x00000002 TMR2 1kHz 40 | 2 0x00000004 TMR2 1kHz 41 | 3 0x00000008 TMR2 100Hz 42 | 4 0x00000010 TMR3 10Hz 43 | 5 0x00000020 TMR3 5Hz 44 | 6 0x00000040 TMR3 2Hz 45 | 7 0x00000080 force new battery voltage 46 | 8 0x00000100 Powering Atomizer 47 | 9 0x00000200 Battery Low (hysteresis 3.1-3.3) 48 | 10 0x00000400 USB attached 49 | 11 0000000800 Refresh battery value 50 | 12 0x00001000 Battery+USB (charging) 51 | 13 0x00002000 probing atomizer 52 | 14 0x00004000 inactive user 53 | 15 0x00008000 Sampling VBat 54 | 16 0x00010000 Sampling BoardTemp 55 | 17 0x00020000 Display refresh needed 56 | 18 0x00040000 2Hz edited item blink 57 | 19 0x00080000 Batt < 10% 58 | 20 0x00100000 1Hz bat low blink 59 | 21 0x00200000 1Hz bat charging blink 60 | 22 0x00400000 Bat: decrease target volts 61 | 23 0x00800000 Check mode flag 62 | 24 0x01000000 ? (unused) 63 | 25 0x02000000 ? (unused) 64 | 26 0x04000000 Temp protec enabled 65 | 27 0x08000000 Unchecked rez TI 66 | 28 0x10000000 Unchecked rez NI 67 | 29 0x20000000 Bat: power downscale 68 | 30 0x40000000 Unbalanced batteries 69 | 31 0x80000000 Unchecked rez SS 70 | 71 | Flags2 (20000068) 72 | 0 0x00000001 Editing TCR value 73 | 1 0x00000002 Unchecked rez TCR 74 | 4 0x00000010 Editing TC pwr value 75 | 8 0x00000100 TMR3 1Hz 76 | 9 0x00000200 In Flappy Bird 77 | 78 | Events (20000043) 79 | 0 Idle 80 | 1 Fire button 81 | 2 Edit (+ button) 82 | 3 Edit (- button) 83 | 4 Key Lock/UnLock 84 | 5 (fire+ buttons) 85 | 6 Stealth ON/OFF 86 | 7 Menu button 87 | 8 Menu + 88 | 9 Menu - 89 | 10 USB cable attach 90 | 11 USB cable detach 91 | 12 Battery charging 92 | 13 Battery removed 93 | 15 Single fire click 94 | 16 Enter edit mode 95 | 17 Switch On/Off 96 | 18 Flip display 97 | 20 ? 98 | 21 ? 99 | 22 Reset Puff Counter 100 | 23 Reset Time Counter 101 | 24 10s Fire 102 | 25 Ato Short 103 | 26 Ato Open 104 | 27 Ato Low 105 | 28 Battery < 3.1V idle or < 2.8V firing 106 | 29 FW Version screen select 107 | 30 Key lock violation 108 | 31 Board temp screen select 109 | 32 New coil detected 110 | 33 (unused?) Ti ON/OFF select 111 | 34 Battery voltage screen select 112 | 38 (unused?) Change interface version 113 | 39 TCR Set menu select 114 | 40 LOGO menu select 115 | 41 Game menu select 116 | 100 Long Fire (2s) 117 | 118 | Screen (200000F6) 119 | 0 Black 120 | 1 Main view 121 | 2 Firing 122 | 3 Main view (relic) 123 | 4 (unused) 124 | 5 Black w/ Battery 125 | 20 No Atomizer Found 126 | 21 Atomizer Short 127 | 22 Atomizer Low 128 | 23 10s Protection 129 | 24 Battery Low 130 | 25 Battery Low Lock 131 | 28 Key Lock 132 | 29 Device too hot 133 | 31 Key UnLock 134 | 37 Board Temp 135 | 40 Stealth ON/OFF 136 | 41 Ti ON/OFF (unused) 137 | 50 FW Version 138 | 51 New Coil 139 | 54 Battery Voltage 140 | 59 TCR Set Menu 141 | 60 Big Clock 142 | 81 Screen Protec Menu 143 | 82 LOGO Menu 144 | 83 Game Menu 145 | 146 | Key state (20000041) 147 | 0 none 148 | 1 fire button 149 | 2 + button 150 | 3 - button 151 | 4 + and - buttons 152 | 5 fire and + buttons 153 | 6 fire and - buttons 154 | 14 ? 155 | 156 | 0x35 get info 157 | 0x3C update LDROM 158 | 0x53 set parameters 159 | 0x7C reset parameters 160 | 0xA5 set boot logo 161 | 0xB4 reset device 162 | 163 | RX200S 164 | ------ 165 | ADC18 BATT VOLTS 1 166 | ADC0 BATT VOLTS 1+2 167 | ADC4 BATT VOLTS 1+2+3 168 | -------------------------------------------------------------------------------- /driver/NuvotonCDC.inf: -------------------------------------------------------------------------------- 1 | ; 2 | ; Windows USB CDC Driver Setup File for Nuvoton-CDC (XP/2000) 3 | ; 4 | ; (c) Copyright 2008 Recursion Co., Ltd. 5 | ; 6 | 7 | [Version] 8 | Signature = "$Windows NT$" 9 | Provider = %COMPANY% 10 | DriverVer = 10/02/2014,1.0.0.1 11 | CatalogFile = NuvotonCDC.cat 12 | Class = Ports 13 | ClassGuid = {4D36E978-E325-11CE-BFC1-08002BE10318} 14 | 15 | [Manufacturer] 16 | %MFGNAME% = Devices,NT,NTamd64 17 | 18 | ;-------------------------------------------------------------------------- 19 | ; Files 20 | ;-------------------------------------------------------------------------- 21 | 22 | [DestinationDirs] 23 | DefaultDestDir = 12 24 | 25 | ;-------------------------------------------------------------------------- 26 | ; Device driver 27 | ;-------------------------------------------------------------------------- 28 | 29 | [NuvotonCDC_DEV.NT] 30 | Include = mdmcpq.inf 31 | CopyFiles = FakeModemCopyFileSection 32 | AddReg = NuvotonCDC_DEV.NT.AddReg 33 | 34 | [NuvotonCDC_DEV.NT.AddReg] 35 | HKR,,DevLoader,,*ntkern 36 | HKR,,NTMPDriver,,usbser.sys 37 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 38 | 39 | [NuvotonCDC_DEV.NT.Services] 40 | AddService=usbser, 0x00000002, DriverService 41 | 42 | ;-------------------------------------------------------------------------- 43 | ; Services 44 | ;-------------------------------------------------------------------------- 45 | 46 | [DriverService] 47 | DisplayName = %SERVICE% 48 | ServiceType = 1 49 | StartType = 3 50 | ErrorControl = 1 51 | ServiceBinary = %12%\usbser.sys 52 | 53 | ;-------------------------------------------------------------------------- 54 | ; Devices 55 | ;-------------------------------------------------------------------------- 56 | 57 | [Devices.NT] 58 | %DESCRIPTION% = NuvotonCDC_DEV, USB\VID_0416&PID_5020&MI_01 59 | 60 | [Devices.NTamd64] 61 | %DESCRIPTION% = NuvotonCDC_DEV, USB\VID_0416&PID_5020&MI_01 62 | 63 | ;-------------------------------------------------------------------------- 64 | ; Strings 65 | ;-------------------------------------------------------------------------- 66 | 67 | [Strings] 68 | COMPANY = "Nuvoton Co., Ltd." 69 | MFGNAME = "www.nuvoton.com" 70 | DESCRIPTION = "Nuvoton Virtual Com Port" 71 | SERVICE = "USB RS-232 Emulation Driver" 72 | -------------------------------------------------------------------------------- /driver/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | usbser.sys is required for USB Virtual COM device. 3 | It is included by windows operation system and could be found at \WINDOWS\system32\drivers 4 | or \i386\driver.cab 5 | 6 | To install the VCOM driver, user must find usbser.sys on their OS first and copy it to the same directory with Nuvoton CDC INF file. Finally install the driver manually when windows request to install the VCOM device driver. -------------------------------------------------------------------------------- /git_doc_en/behaviourchanges_en.md: -------------------------------------------------------------------------------- 1 | ### Changes in behavior ### 2 | Some changes has been made to the overall behavior of the firmware from the original. This paragraph may be read by any new user not to think something is a "bug". 3 | 4 | * Stealth mode: 5 | The stealth mode has been extended to some more screens. 6 | The battery charging screen does no longer show up in stealth mode; only for a few seconds when plugging in the USB cable, just to show it's been correctly plugged. 7 | The Key Lock/UnLock screen reverts to black screen if keys are locked. 8 | The Stealth On/Off screen goes to black when setting stealth On. 9 | 10 | * Right (+) and Left (-) buttons: 11 | While editing some values, the speed of change has been made more progressive before reaching the insane terminal velocity. 12 | Pressing those buttons does no longer wake up the box from screen saving, except if configured to do so in the Interface menu (see below). This makes the box more pocket-proof. 13 | 14 | * Temperature setting in TEMP mode: 15 | The temperature no longer wraps-around by switching between °C and °F; the temperature unit has to be chosen once and for all in the Interface menu. Default is °C. 16 | The temperature setting can vary by +/1 °C or +/-5 °F when edited if configured to do so in the Interface menu (see below). 17 | 18 | * Fire button Multi-Clicks: 19 | Clicking rapidly 2, 3 or 4 times on the fire button may now have some effect - see below in the Interface menu description to see those effects and how to set (or unset) them up. 20 | Clicking 10 times for board temperature, or 20 times for version screen does no longer require to switch off the box. 21 | 22 | * Coils memory: 23 | In POWER mode, the box now reminds of the power setting for any given resistance, up to 10 different (just like in SMART mode). Thus, when swapping between your tanks, the box will automatically set up the power setting you previously entered for that particular coil. 24 | Coils may vary by +/-10% in resistance to still be recognized, and two different coils within 10% won't be distinguished. 25 | The coils memory can be erased in the Coils >> Manage >> Zero All menu item (see below). 26 | 27 | * Bypass mode: 28 | Power is now displayed on top of screen instead of voltage, as it's a more relevant information regarding vaping quality. Real-time output voltage information is still available as a third-line option (VOUT). 29 | Predicted power and voltage are also more accurate, especially on multi-cells boxes. It needs a few puffs to reach max accuracy, time for the box to estimate battery behavior under high load. 30 | 31 | * Logo: 32 | The myevic firmware accepts logos sizes of 64 pixels wide and from 40 to 63 lines high. Tall logo may partially recover lines of information in the center of the screen; it's up to you to choose the correct design and dimensions so that the display looks fine. 33 | 34 | * Menus: 35 | Menus accessed by pressing Fire and Right button have been completely revamped. See below for new menus description. 36 | ----- 37 | 38 | ← Previous Page: [Usage and Compatibility](usageandcompatibility_en.md) -- Next Page: [How To Build](howtobuild_en.md)→ 39 | -------------------------------------------------------------------------------- /git_doc_en/clock_en.md: -------------------------------------------------------------------------------- 1 | ### Clock 2 | ![Clock Menu](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/clock_zpsmrvulkdd.png) 3 | 4 | * __Set Date/Time__ 5 | 6 | Setup date and time. 7 | Fire change edited field, + and - set value, and long click on fire saves the setting. Since you need to click 2 seconds on the fire button to save, setup the time 2 seconds in advance if you want to achieve best accuracy. I know... 8 | 9 | There is some other ways to setup time: 10 | * use the ```evic-usb time``` command, if you installed the [python-evic](https://github.com/ClockSelect/python-evic "python-evic") command-line utility; 11 | * use the Time synchronization function of the [NToolbox](https://github.com/TBXin/NFirmwareEditor/releases) of the NFirmwareEditor 6.0+; (check the time synch feature in the system tray). 12 | * MicroSur's [FWUpdater](https://www.dropbox.com/s/83zd19gu05pl3r6/EvicVTCFont.rar?dl=1) also as a "Set current time" function. 13 | * Joyetech's official firmware updater also sets date & time when uploading a firmware. 14 | 15 | 16 | 17 | * __Fmt (date format)__ 18 | 19 | Toggle date display format between day.month.year (Western civilized world), month/day/year (US), day/month/year (Eastern civilized world), and year-month-day (Universe) format. 20 | 21 | * __Size__ 22 | 23 | Toggle time display format of the digital dial between a small hh:mm:ss and a big HH:MM. 24 | 25 | * __Dial__ 26 | 27 | Change the format of the clock display between a hand dial clock (A) and a digital clock with date and time (D). This will change the clock display on the main screen as well as on the screen saver, if the clock is chosen as screen saver. 28 | 29 | * __Clk Adjust__ 30 | 31 | Adjust clock: for small adjustments to clock time + and - adjust clock by seconds. Fire to save. For VTwo owners, this option also adjusts the X32 frequency accordingly if done properly. 32 | 33 | * __Clk Speed__ 34 | 35 | *This setting is useless on RTC-enabled boxes (VTwo/Dual, AIO, Basic, eGrip II)* 36 | *This setting is only usefull if you have set the Light Sleep mode "OFF" in the Expert menu. See below the "LSL" setting in the Expert menu description. As long as the Light Sleep mode is "ON" (default setting), there is no real need to adjust the Clock Speed Ratio.* 37 | 38 | Some boxes (VTC-Mini, Cuboid/Mini, Presa 75W, RX75, RX200S, RX2/3) does not have the needed 32kHz crystal soldered on the pcb to regulate the clock speed; so, another time source is used to drive the clock. Since its frequency is quite different, a clock speed ratio is needed to regulate the clock. As long as the box is awake (you're using it), the clock is regulated by the external 12.000MHz crystal, which is an accurate time source. Problem arises when the box enters sleep mode, since the crystal is switched off and the only clock source is the somewhat unreliable 10kHz internal oscillator of the processor. Clock drift mostly occurs when the box is switched off or sleeping. 39 | 40 | The procedure to adjust the clock speed ratio is as follow: 41 | * First, setup time accurately via the date/time menu or the "```evic-usb time```" command line. 42 | * Let the box enter sleep mode (leave it alone or switch it off) for several hours. I suggest you're doing this before sleeping yourself. 43 | * Awake the box and go into the "Clk Speed" menu; do not let the box enter sleep mode again in between, or you'll have to redo the whole thing. 44 | * Using + and - buttons, adjust the time shown on top of the screen to catch up the real time. The number shown in the center of the screen is the clock speed ratio; reasonable values should be around 32~34000. 45 | * Once you have adjusted the time to the real time, click fire to save the new clock speed ratio. Your clock should now be as accurate as it can. If not, try to repeat the procedure. Accuracy of a few seconds per day can be achieved this way. 46 | 47 | ----- 48 | 49 | ← Previous Page: [Vaping](vaping_en.md) -- Next Page: [Interface](interface_en.md)→ 50 | -------------------------------------------------------------------------------- /git_doc_en/coils_en.md: -------------------------------------------------------------------------------- 1 | ### __Coils__ 2 | 3 | * __Management__ 4 | 5 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/coils_zpsn29ef1h5.png) 6 | 7 | * __On each line of the four TC modes:__ 8 | 9 | Click fire to toggle edit mode on the resistance. 10 | While the resistance value is highlighted, click (+) and (-) to edit its value. 11 | If you click fire again without editing the resistance value, this will toggle its locked/unlocked status. 12 | Editing the resistance to any non-zero value automaticaly locks it. 13 | Setting the resistance to zero with (-) will unlock and reset it. 14 | 15 | You may also fire two seconds on one of the four resistances to reset its value; if the selected resistance corresponds to the current vaping mode, this will force an immediate reading of the atomizer, setting and lock of the new value. 16 | ----- 17 | When entering the Coils Management menu, the resistance corresponfing to the current vaping mode (if applicable) will be pre-selected. 18 | 19 | * __Zero All__ 20 | 21 | Zeroes all resistances; also zeroes all "SMART" and "POWER" modes saved resistance settings. 22 | 23 | * __Check: Yes/No__ 24 | 25 | If you feel you need to use this feature in any other situation than a really heavy build with low TCR value (SS and such), you surely have an issue with your coil. Using this feature may be risky and therefore is not recommended. Check your build first.* 26 | 27 | In TC modes, the box checks for suitability of the resistance the first time it is fired (i.e. each time the atomizer in screwed on or after box reset). The test is done in a way that can make heavy builds with low TCR value fail the test (really heavy, like dual twisted clapton or such; more than around 1.7 grams of metal). If a coil fails the first fire test, the box will enforce the power mode. 28 | If you know your heavy build is well done and suitable for temp control, you may set this option to "No". The box will bypass the first fire test and let you vape in the selected temp control mode. 29 | 30 | __Keeping the coil test disabled may get you into unpleasant situations. Use wisely.__ 31 | 32 | * __TCR Submenu__ 33 | 34 | ![](https://www.dropbox.com/s/n09iy9nu57jnv18/tcrset.png?dl=1) 35 | 36 | 37 | *This menu is also accessible by switching off the box and pressing both Fire and Right regulatory button (+) for 5 seconds.* 38 | 39 | In addition to the three usual TCR modes (M1, M2 & M3), the box standard presets for TEMP NI, TI and SS are editable. To edit one of the three preset modes: 40 | * Select the mode you want to edit, 41 | * Long fire to unlock the default (DEF) behavior; a reasonable value is proposed as a default starting value for edition, 42 | * Edit the TCR value. 43 | * Long fire to restore the default (DEF) behavior if needed. 44 | 45 | ----- 46 | 47 | ← Previous Page: [Screen Menu](screen_en.md) -- Next Page: [Vaping Menu](vaping_en.md)→ 48 | -------------------------------------------------------------------------------- /git_doc_en/expert_en.md: -------------------------------------------------------------------------------- 1 | ### Expert 2 | 3 | Some advanced options. 4 | Normal users should barely have anything to do with those options, and can live perfectly well without ever knowing they exist. 5 | I do not recommend "testing" those options just to "see what it does". Deny responsability of everything etc. 6 | You're supposed to have 18+, after all^^ 7 | 8 | * __USB__ 9 | 10 | Choose between several USB modes: 11 | * HID: Normal operation mode - factory setting. Disables any other USB device than HID. 12 | HID is always active, even in the two others modes of operation. This feature permits communication between the box and firmware utilities. 13 | 14 | * COM: A virtual COM interface; mainly used for debugging with a COM terminal such as putty. 15 | May be usefull if you are developping your own version of the firmware. 16 | 17 | * DSK: A virtual drive to download the firmware file. 18 | Connect the box to a PC, and a disk device will appear with a "MYEVIC.BIN" file. This can be read and copied. This file is an encoded firmware file that can be uploaded to another device using evic-usb or the official Joyetech/Wismec firmware tool. 19 | 20 | * __DBG__ 21 | 22 | Enables or disables the debug informations mode. Once the DBG option is set to "ON", Debug informations can be shown/hidden by clicking fire button four times. This option is OFF by default to prevent users to inadvertendly mess up their screen. It's of no interest if you're not developping your own version of the firmware. 23 | 24 | * __X32__ 25 | 26 | Enables or disables usage of the X32 crystal of the PCB. 27 | If this setting is "OFF", the firmware won't try to drive the Real-Time Clock with the 32.768kHz crystal. This may solve freezing issues on some malfunctionning boxes. This setting will be active at next reset. 28 | After reset, if the box cannot use the X32 to drive the RTC, this option will be set back to "OFF" and the Light Sleep feature will be enabled (see "LSL" below). 29 | *This option is useless and forced to "OFF" on boxes known not to have an X32 crystal. Those are all boxes for which the manufacturer did not enable the RTC feature, i.e: VTC-Mini, Cuboid/Mini, Presa 75W and RX series.* 30 | 31 | * __LSL__ 32 | 33 | Light Sleep mode. 34 | *This setting is useless and forced to "OFF" on boxes with a X32 crystal (VTwo/Dual, AIO, Basic, eGrip II), and defaults to "ON" on other boxes.* 35 | On boxes where the Real-Time Clock is emulated (like the VTC-Mini), by setting the Light Sleep mode "ON", the box continues to drive the Real-Time Clock with the external 12.000MHz Crystal instead of the internal LIRC oscillator when entering sleep mode. This makes the Clock far more accurate and eliminates the need for the Clock Speed ratio, at the cost of a greater battery consumption (estimated less than 50 mAh/day). 36 | Using this setting, Clock accuracy is identical to those of real RTC boxes. 37 | 38 | * __NFE__ 39 | 40 | *Warning: You can't use Joyetech's firmware updater while this option is "ON". It may aloso cause issues with third-party firmware management systems.* 41 | Enables or disables partial compatibility with the [NFirmwareEditor 5.x](https://github.com/TBXin/NFirmwareEditor/releases) myEvic Configuration Editor. 42 | This option is disabled by default; set it to "ON" if you plan to use developpement features of the NFE. You'll have access to Monitoring, Screenshot, COM terminal, and Custom Battery Profile editor. 43 | Since compatibility is only partial at the moment, editing parameters other than Battery Profile will have no effect. 44 | 45 | * __SHR__ 46 | 47 | Shunt Resistance (in mΩ). (real resistance in Ohm now) 48 | *Warning: This item is dangerous to your box. Messing with this parameter may cause overcurrent in the atomizer circuitry and lead to definitive box failure.* 49 | This item let you edit the value of the Atomizer's circuit shunt resistance. This resistance is involved in every resistance/current/power measures and computation in the whole firmware. This value should only be changed if you know exactly what you are doing. 50 | To reset the shunt value, select the SHR menu item and press the fire button during 2 seconds. This will revert the value to the default hardware setting. 51 | 52 | * __UCH__ 53 | 54 | USB Battery Charging. 55 | *Multi-cell boxes only. This option has no effect on single-cell boxes.* 56 | Enables or disables battery charging via the USB port. The USB port is still usable for all other purposes: firmware management, debugging, etc. 57 | If you have an external battery charger and want to take care of your batteries, it is recommended to switch off the USB charging feature to avoid potentialy unbalanced charges, or unadapted charge currents at end of charge. 58 | 59 | * __BAT__ 60 | 61 | Battery model. 62 | You can specify your battery brand and model among several ones: 25R, 30Q, HG2, HE4, VTC4, VTC5 and VTC6. "GEN" is the generic battery used by default and should be used for any other model of battery or for built-in battery. 63 | 64 | Custom Battery: 65 | By pressing the Fire button during two seconds while editing this option, the battery model changes to "CUS" (Custom Battery). The box will use the user-defined battery discharge curve and settings. Those informations can be edited using [NFirwareEditor](https://github.com/TBXin/NFirmwareEditor/releases) discharge profile editor (see [NFirwareEditor](https://github.com/TBXin/NFirmwareEditor/releases) documentation for more information). 66 | *The NFE compatibility mode must be set to ON in the expert menu for NFE to recognize the box as compatible.* 67 | 68 | At the moment, battery model information is used by the firmware to compute a more accurate state-of-charge than the generic setting, and to avoid battery stress by limiting max Amp draw. Max Amps by battery model is based on Mooch's stress tests and are fairly reliable. 69 | 70 | *On boxes with built-in battery (AIO, Basic, eGrip II, Cuboid Mini), this option should be kept on the "GEN" setting unless you've taken your box apart and manualy replaced the internal battery pack by something else.* 71 | 72 | * __BVO__ 73 | 74 | Battery Voltage Offset submenu 75 | Corrective offset value of the battery voltage. Depending on your box, the displayed battery voltage may be off by a few tens of millivolts. It's usually not a concern, but it may make the box locking the vape too early (wasting some battery capacity) or too late (box resets due to low voltage when firing). 76 | Use an external accurate voltmeter (your battery charger may do the job) to compare the displayed voltages on the box to the actual battery voltages, then adjust the displayed voltages with this item. 77 | Range is -1.00 to +1.00 Volts by step of 10mV. 78 | * On a single-cell box, only the first setting (B1) is significant. B2 and B3 are ignored. 79 | * On a fixed dual-cells box, the two first settings (B1 & B2) are used, respectively, for the first and the second battery (depending on the box, you'll have to determine wich one wich with your voltmeter). B3 is ignored. 80 | * On a mixed single/dual-cells box, B1 is used for the lone battery in single-cell setting, and B2 & B3 for the two cells in a dual-cell setting. 81 | * On a triple-cell box, B4 is ignored. 82 | * On a quad-cell box, I let you guess. 83 | 84 | ----- 85 | 86 | ← Previous Page: [Interface](interface_en.md) 87 | -------------------------------------------------------------------------------- /git_doc_en/howtobuild_en.md: -------------------------------------------------------------------------------- 1 | ### Build 2 | Follow [evic-sdk::Readme](https://github.com/ReservedField/evic-sdk/blob/master/README.md) instructions to: 3 | 4 | * Setup the environment 5 | 6 | * Install python-evic 7 | 8 | * Install and unpack nuvoton-sdk with the following changes: 9 | * Unpack into this project directory (evic-sdk itself is not required for this project) 10 | * When unpacking nuSDK unpack only ```Library``` directory. For example unpack ```M451 Series BSP CMSIS V3.01.001/Library``` from ```M451_Series_BSP_CMSIS_V3.01.001.zip``` to ```myevic/nuvoton-sdk/Library``` 11 | 12 | * To build invoke: ```EVICSDK=. make``` 13 | ----- 14 | 15 | ← Previous Page: [Behaviour Changes](behaviourchanges_en.md) -- Next Page: [Profiles](profiles_en.md)→ 16 | -------------------------------------------------------------------------------- /git_doc_en/interface_en.md: -------------------------------------------------------------------------------- 1 | ### Interface 2 | 3 | ![Interface menu screen](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/interface_zpshqw8kg89.png) 4 | 5 | * __1Watt On/Off__ 6 | 7 | Enable increment of power setting by plus ±1.0 Watt instead of ±0.1 Watts. 8 | 9 | * __1C/5F On/Off__ 10 | 11 | Enable increment of temperature setting by ±1°C and ±5°F instead of ±5°C and ±10°F 12 | 13 | * __Wake < > On/Off__ 14 | 15 | Enable/Disable box wake up from sleep mode when pressing the + or - button. 16 | 17 | * Font A/B 18 | 19 | Change the display font. You have two fonts available; choose what pleases you more. Choice is purely aesthetic. One may find the bolder font B more readable on some displays. 20 | 21 | * __Temp °C/°F__ 22 | 23 | Choose once and for all your temperature unit, between °C and °F. Nobody needs to switch back and forth between standards. Moreover, Farenheit is not even a standard. Maybe I'll replace it by Kelvins one day. Changing temperature unit by wrapping around the temperature has been disabled. 24 | 25 | * __PPwr On/Off__ 26 | 27 | *__TEMP Mode Only__* 28 | Toggle Priority Power mode On/Off. In temperature control modes, this switches the power and the temperature display; the power is displayed at top of screen and is directly editable by the + and - keys just like in Power mode, and the temperature is displayed on the first of the 3 informations lines in the center of the screen. Temperature remains editable in Edit mode. 29 | The purpose of this function is near the preheat function in PWR mode; once you have set your correct vape temperature (not burning your dry cotton), your comfort come from the heat rise speed. This feature let you adjust this parameter more easily. 30 | 31 | * __Clicks__ 32 | 33 | ![Clicks Menu](http://i345.photobucket.com/albums/p374/ClockSelect/clicks_zpsoqy6ngvh.png) 34 | 35 | The Clicks submenu allows you to configure the action associated to a Fire button multi-clic. Configurable multi-clicks are double, triple and quadruple clicks. 36 | 37 | Possible actions are: 38 | * Nothing 39 | * Enter edit mode 40 | * Toggle display of info lines / clock on the main display 41 | * Toggle the "Priority Power" mode (basically, switches temperature and power on the main screen display in TC mode, see above "PPwr On/Off" doc), *OR* enters the Preheat menu if box is in POWER mode. 42 | * Switch to next vaping mode ( TC -> POWER -> BYPASS -> ... ) 43 | * Switch box On or Off 44 | * Cycle through configuration profiles 45 | 46 | As a security feature, if none of the action are configured to be the "Edit" mode, the firmware will redefine the triple click action to "Edit" at next reset. 47 | 48 | ----- 49 | 50 | ← Previous Page: [Clock](clock_en.md) -- Next Page: [Expert](expert_en.md)→ 51 | -------------------------------------------------------------------------------- /git_doc_en/mainscr_en.md: -------------------------------------------------------------------------------- 1 | ### Main Screen 2 | * Double-click: 3 | 4 | A double fire click switches between standard view and clock screen. 5 | The clock screen is close to the one viewed on the VTwo box; just better, imo. 6 | See below the Clock menu to know how to configure clock. 7 | 8 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/mainscreen_zpsuoh0cthd.png) ![](http://i345.photobucket.com/albums/p374/ClockSelect/mainscreen3_zpsfunjeoct.png) 9 | 10 | * Third info line: 11 | 12 | The third info line of the main screen, used to display amps, puffs or time counters now have a few more options: 13 | - Atomizer voltage 14 | - Battery voltage 15 | - Board temperature 16 | - Real-time clock 17 | - Real-time atomizer resistance 18 | - Estimate of vape velocity in ml or ml/day *(experimental)* 19 | 20 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/mainscreen2_zpsclbvvdah.png) 21 | 22 | * Battery layout: 23 | 24 | In Edit mode (Triple click by default), the battery layout can be chosen between regular battery display, battery percentage, and battery voltage. 25 | 26 | ----- 27 | 28 | ← Previous Page: [Menus](menus_en.md) -- Next Page: [Screen Menu](screen_en.md)→ 29 | -------------------------------------------------------------------------------- /git_doc_en/menus_en.md: -------------------------------------------------------------------------------- 1 | ### Menus 2 | Holding Fire and Right (+) buttons 1/5th of a second enters menus. 3 | 4 | * At any time, you may press simultaneously Fire and Right buttons to get out of the menus and return to the main screen. 5 | * When navigating in sub-menus, you may press simultaneously Left and Right buttons to return to the parent (upper level) menu. 6 | 7 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/menus_zpsb8gftzok.png) 8 | Main menu screen 9 | 10 | If you continue holding Fire and Right (+) buttons after entering menus, after two seconds, you'll enter the Profile selection screen (see the **Profile** section for more informations about configuration profiles). 11 | 12 | ----- 13 | 14 | ← Previous Page: [Profiles](profiles_en.md) -- Next Page: [Main Screen](mainscr_en.md)→ 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /git_doc_en/profiles_en.md: -------------------------------------------------------------------------------- 1 | ### Profiles 2 | 3 | You can switch between seven different configuration profiles. 4 | A Profile stores all data relevant to vaping configuration; that is, vaping mode, coils resistance, preheat and algo settings, etc. Interface, display or others non vape-related settings are not reloaded when switching profiles. 5 | 6 | To access the Profile selection screen, press and hold the Fire and (+) buttons for two seconds. On the Profile selection screen, select the profile and click Fire to activate it. 7 | 8 | ![Profile Screen](https://www.dropbox.com/s/b4y1afx3vbmrgdp/profile.png?dl=1) 9 | 10 | Each line display the Profile number, the selected mode and last used resistance. 11 | Empty lines correspond to empty profiles. 12 | * Create a new profile: 13 | Select an empty profile and single click it. The current profile will be duplicated into the selected one. The selected profile will be made active and the box will return to the main screen. 14 | * Erase a profile: 15 | Select a non-empty profile and long click it (press fire for two seconds). The selected profile will be erased. Currently active profile (the highlighted line) cannot be erased. This won't return you to the main screen so you can delete several profiles in a row. 16 | * Duplicate current profile: 17 | Select an empty profile and long click it (press fire for two seconds). The currently active profile will be duplicated into the selected profile. The selected profile will be made the active profile. This won't return you back to the main screen, allowing you to easily move profiles around by deleting/duplicating them if you wish to reorganize them. 18 | 19 | To exit Profile selection menu, select a profile or click Fire and (+) buttons. 20 | 21 | 22 | ----- 23 | 24 | ← Previous Page: [How To Build](howtobuild_en.md) -- Next Page: [Menus](menus_en.md)→ 25 | -------------------------------------------------------------------------------- /git_doc_en/screen_en.md: -------------------------------------------------------------------------------- 1 | ### Screen 2 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/screenmenu_zpsph9b8ono.png) 3 | 4 | #### Screen management menu: 5 | * __Contrast__ 6 | 7 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/contrast_zpsjuouc0v4.png) 8 | 9 | Default VTC contrast is around 17%. This screen gives you access to the full contrast range of the display. 10 | 11 | * __Protection__ 12 | 13 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/protec_zpsx0jd4aok.png) 14 | 15 | Configure main screen dim timeout and screen saver timing. After the time setup with the "Main" option, (default 30 seconds) of inactivity, the main screen switches to the screen saver animation (see below) for the duration configured with the "Saver" option, after what the box shuts down. 16 | If the "Saver" item is set to "Off", the box will dim after "Main" second, then switch to a black screen for 3 minutes before being shut down. 17 | 18 | * __Saver__ 19 | 20 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/saver_zpsdkyhj1mz.png) 21 | 22 | Select the screen saver animation. You may choose between None (blank screen), the clock (analog or digital depending on the Clock menu setting), 3D spinning objects, the logo, a Qix-like animation, or the snow screen. More to come. Content of this menu will vary from time to time; this document may not always be up to date. Have a look. 23 | When the 3D screen saver is active, the + and - buttons change the animated object. 24 | About the snow screen saver: choose this screen saver if your box experiment burnt pixels; it's a common issue on boxes a few months to a year old, and this screen may help restore the pixels. Se also the Invert option that may serve the same purpose. 25 | 26 | * __Logo__ 27 | 28 | The Logo submenu is used to toggle display of the custom logo On of Off, and to choose where to display it. Logo may be displayed on the top of the screen (in place of the power/temp setting zone) or in the middle of the screen in place of the two first information lines. 29 | 30 | * __Invert__ 31 | 32 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/invert_zpsyowemzqu.png) 33 | 34 | Toggle display mode between white on black and black on white. 35 | Beyond the fact you may find this option fancy and cool-looking, it may have its usefulness if your box experiment burnt pixels on the always-white zones. You may use this option in combination with the snow screen saver to restore the quality of your display (see the snow screen saver above in the Screen>Saver submenu section). 36 | 37 | * __Miscs__ 38 | Sub-menu 39 | * Game 40 | Flappy bird. Guenuine menu. 41 | 42 | * Led 43 | eGrip II / eVic AIO LED Color setting. 44 | 45 | * 3D 46 | Cool 3D spinning shapes. 47 | Come back to this menu and set it to "None" to cancel animation. 48 | Or reset the box. 49 | ![3D cube](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/cube_zpsf9apfiun.png) 50 | ----- 51 | 52 | ← Previous Page: [Main Screen](mainscr_en.md) -- Next Page: [Coils](coils_en.md)→ 53 | -------------------------------------------------------------------------------- /git_doc_en/usageandcompatibility_en.md: -------------------------------------------------------------------------------- 1 | ### Compatible hardwares 2 | * Joyetech 3 | * eVic VTC Mini 4 | * eVic VTC Dual 5 | * eVic VTwo Mini 6 | * eVic VTwo 7 | * eVic AIO 8 | * eVic Basic 9 | * eGrip II / Light 10 | * Cuboid 11 | * Cuboid Mini 12 | * Cuboid 200 13 | * Wismec 14 | * Presa TC75W 15 | * Presa TC100W 16 | * Reuleaux RX75 17 | * Reuleaux RX200S 18 | * Reuleaux RX2/3 19 | * Reuleaux RXmini 20 | * Reuleaux RX300 21 | * Sinuous P228 22 | * Others 23 | * Vaponaute La Petite Box 24 | 25 | ### Usage: 26 | 27 | The binary firmware file is included in the **bin/** subdirectory of the project. 28 | If you are only interested in installing and using the firmware, download it here : [bin/myevic](https://github.com/ClockSelect/myevic/blob/master/bin/myevic.bin) 29 | 30 | Once you've downloaded the firmware binary, you may: 31 | 32 | - Use the manufacturer's firmware updater to upload [myevic.bin](https://github.com/ClockSelect/myevic/blob/master/bin/myevic.bin) like you would with a usual firmware update from Joyetech or Wismec: 33 | - Download the firmware updater package from the manufacturer [Wismec](http://www.wismec.com/software/) or [Joyetech](http://www.joyetech.com/mvr-software/), depending of the brand and model of your box. Be sure to pick the right software for the right box brand and model. 34 | - Unzip the update package and launch the UpdateFirmware.exe (Joyetech) or UpdateWismec.exe (Wismec) found in the package. 35 | - Plug your box into your PC via USB 36 | Be sure you use a data-capable USB cable. Some cheap cables coming with some boxes only ensures box charging. If unsure, use the cable that came with your box. Once done, the updater window should show the model and version of your box. 37 | - Click the "Update" button; a file selection dialog will open. Select the "myevic.bin" file. 38 | - Wait for the update process to complete. 39 | If something goes wrong, retry to update. Update fails sometimes; this shouldn't be a concern. 40 | - Enjoy. 41 | 42 | OR 43 | 44 | - For linux/Cygwin users, use evic-usb to upload [myevic.bin](https://github.com/ClockSelect/myevic/blob/master/bin/myevic.bin) to your box, using command line: 45 | 46 | ```evic-usb upload myevic.bin``` 47 | 48 | OR 49 | 50 | - Use [NFirmwareEditor](https://github.com/TBXin/NFirmwareEditor/releases) or the [FWUpdater](https://www.dropbox.com/s/83zd19gu05pl3r6/EvicVTCFont.rar?dl=1) part of the [VTCFont](https://www.dropbox.com/s/83zd19gu05pl3r6/EvicVTCFont.rar?dl=1) package to upload [myevic.bin](https://github.com/ClockSelect/myevic/blob/master/bin/myevic.bin) to your box. 51 | 52 | ### About Multi-cells boxes 53 | 54 | At the moment, the interface only display one battery icon, percentage or voltage, just like there where only a single battery in the box (this may change in the future). 55 | The displayed values are those of the battery that is in the *lowest state-of-charge* of the set. 56 | A battery set should always be kept in equilibrium and a balance warning is issued if the difference between the lowest and the highest voltage exceeds 0.3 Volts. 57 | So as long as you have no warning (a blinking "balance" on the battery icon or an "imbalanced batteries" screen warning), you know that all batteries are within 300mV of the first. 58 | 59 | ----- 60 | 61 | Next Page: [Behaviour Changes](behaviourchanges_en.md)→ 62 | -------------------------------------------------------------------------------- /git_doc_en/vaping_en.md: -------------------------------------------------------------------------------- 1 | ### Vaping 2 | 3 | 4 | ![Vaping menu](https://www.dropbox.com/s/5nafopmyhl6m8as/vaping2.png?dl=1) 5 | 6 | * __Preheat__ 7 | 8 | ![TCR Set Menu](https://www.dropbox.com/s/d1ncqa9heec6grx/preheat1.png?dl=1) 9 | 10 | __Coil preheat function.__ 11 | 12 | *This function can only be active in "POWER" and "SMART" modes; it is ignored in all other modes.* 13 | Set at which power ( **Pwr** ) and how long ( **Time** ) you want the coil to be preheated when you fire; after this delay, the atomizer will be powered by your regular setting. Set the **Time** to zero to switch preheating off. 14 | The **Unit** may be absolute Watts or percents of the main power setting. 15 | The **Delay** allows to configure a dead time after fire, during which the preheating function will be disabled. This dead time goes from zero (Off) to 3 minutes. The delay runs from the end of fire. Use this feature if you use high inertia (heavy) builds to prevent over-heating when chain-vaping. The **Delay** also apply on power curves, preventing power to fire over 100% of the preset power within the given time. 16 | A small **P** icon will appear on the main screen next to the the power setting to remind you the preheat function is enabled ("POWER" mode only). A blinking **P** indicates the dead time period. 17 | *If you configured a "PPwr" action in the multi-clicks configuration (see **Interface** menu), this action will pop-up this menu when in "POWER" or "SMART" mode.* 18 | 19 | * __Modes__ 20 | 21 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/modes_zpslphwvqhh.png) 22 | 23 | Configure used/useless modes. 24 | Click on each menu item to set 'Y' or 'N' if you want to see any given mode proposed while cycling between modes in menu mode. 25 | Typically, you'll set "SMART" mode to 'N'. Typically. 26 | 27 | * __Algo__ 28 | 29 | *Temperature Control only* 30 | TC Algorithms submenu 31 | 32 | ![Algo submenu](https://www.dropbox.com/s/ecy9oqapftnfwh3/algo.png?dl=1) 33 | 34 | * Algo 35 | Choose betwen several algorithms for temperature control. 36 | * Off: use the default standard agorithm from stock firmware. 37 | * Sweet: much like the default, but smoothes out oscillations in regulation phase. 38 | * Boost: speeds up temperature ramp-up and reduces oscillations, but with the risk of overshooting the target temperature if not configured properly. See the Boost option below. 39 | * PID: A standard PID algorithm 40 | 41 | There is no "best" algorithm; it will essentialy depend on your setup and on your personnal taste. Test and experiment to see what fits best to you. The device monitor of the [NFirmwareEditor](https://github.com/TBXin/NFirmwareEditor/releases) is a great tool to observe the behavior of the algorithms with different setups and parameters. 42 | More algorithms may be implemented with time. Stay tuned. 43 | 44 | * __Boost__ 45 | 46 | A parameter controling the Boost algorithm (see above). 47 | Set the limit, in percentage of the target temperature, at wich the Boost algorithm will stop speeding up the temperature ramp-up phase. The more the value, the faster the ramp-up time, but with a higher risk of overshooting the target temperature. High values are best with heavy resistances such as clapton builds, lower are prefered with light resistances such as single high gauge wire. Also, choosing the right power/wattage setup (not too high nor too low) will help prevent overshooting while keeping a fast ramp-up. You'll have to experiment to see what fits the best for your setup and personal taste. 48 | A long fire resets the parameter to its default value. 49 | 50 | * __P, I, D__ 51 | 52 | The 3 parameters controlling the Proportional, Integral and Derivative part of the PID algorithm. You should familiarize yourself with the PID algorithm before playing with those parameters. Many papers exist over the internet on the subject. 53 | A long fire resets the parameter to its default value. 54 | Default values are (600,850,0). They are general-purpose values that should work in most cases, but may not be perfect and need to be tuned for any particular setup. 55 | Algorithm is implemented in its independant form. 56 | Sample time (50Hz) is scaled to one for parameters uniformity. 57 | Units: **P** is expressed in mW/°C, **I** in mW/°C/s, **D** in mW.s/°C. 58 | 59 | * __Curve__ 60 | 61 | *POWER/SMART mode only.* 62 | Enable, Reset and/or Edit the atomizer power curve. 63 | When power curve is enabled, it take precedence over preheating; a little "C" next to the power setting on main screen indicates the power curve is enabled. 64 | The values of the power curve are percentages (from 0 to 200%) of the main power setting. The whole power curve will thus scale with the main power setting. The default power curve (after reset) is a flat 100% curve, so will have no sensible effect. 65 | The **Delay** setting prevents the power curve to apply a power above 100% during some time after the end of the last puff. See the **Vaping>Preheat** menu documentation for more informations. 66 | You may have one different power curve per configuration profile. 67 | 68 | * __Prot.__ 69 | 70 | Set the long fire protection time. Default is 10.0s. 71 | Admissible values are 2.0s to 15.0s. 72 | 73 | * __Vaped__ 74 | 75 | Choose the unit in wich the liquid consumption (on the 3rd info line of the main screen) is dislayed. You can choose between raw total ml, or consumption speed in ml/day. You must have setup the date and time of the RTC for the ml/d to behave correctly. 76 | 77 | * __ml/kJ__ 78 | 79 | The speed at wich the liquid is vaporized in function of the energy dissipated by the coil. The value is in milliliters per KiloJoules. The proposed value of 360 is rtaher accurate for a standard 30W factory coil. It may need to be adjusted depending on your setup. 80 | 81 | ----- 82 | 83 | ← Previous Page: [Coils](coils_en.md) -- Next Page: [Clock](clock_en.md)→ 84 | -------------------------------------------------------------------------------- /git_doc_it/behaviourchanges_it.md: -------------------------------------------------------------------------------- 1 | ### Cambiamenti ### 2 | Alcuni cambiamenti sono stati apportati rispetto al firmware originale. 3 | Questo paragrafo è consigliato ad i nuovi utenti in modo tale da non identificare le nuove funzioni come "errori". 4 | 5 | * Stealth mode: 6 | La modalità stealth è stata estesa a più schermate. 7 | La schermata di ricarica non verrà più mostrata nella modalità stealth. 8 | Verrà solo mostrata brevemente alla connessione della box per verificarne il corretto collegamento. 9 | La schermata Blocca/Sblocca tasti ritorna sulla schermata nera se i tasti sono bloccati. 10 | La schermata di Attivazione/Disattivazione Stealth ritorna sulla schermata nera quando l'opzione è attiva. 11 | 12 | * Pulsanti Destra (+) e Sinistra (-): 13 | Quando vi sono delle modifiche ad alcuni parametri, la sensibilità dei tasti è stata resa progressiva. 14 | Quando la box si trova nella schermata screen saver, non sarà più svegliata, se non configurata per farlo (dal menu Interface). 15 | Questa modifica è stata apportata per evitare pressioni accidentali dei tasti in tasca. 16 | 17 | * Impsotazioni temperatura in TEMP mode: 18 | Per scegliere la scala( C°/F°) in cui mostrare i gradi bisogna impostarla tramite il menù Interface. 19 | Sono mostrati in C° di default. 20 | Si può oltremodo impostare il range di cambiamento per singola pressione nel menù Interface. 21 | 22 | * Multi-Clicks tasto Fire: 23 | Premendo rapidamente per 2,3 o 4 volte il pulsante Fire esegue varie funzioni. 24 | Si prega di consultare il paragrafo sul menù Interface. 25 | Le 10 pressioni consecutive per la temperatura del circuito e le 20 pressioni per mostrare la versione del firmware, non necessitano più di avere la box spenta. 26 | 27 | * Coils memory: 28 | Nella modalità POWER, la box adesso ricorda i settaggi per ogni resistenza, con dieci valori memorizzabili (come nella modalità SMART). Quindi, ogni volta che l'utente sostituire l'atomizzatore, la box imposterà automaticamente il valore precedentemente inserito per quella coil 29 | Le coil con variazione di +/-10% in resistenza saranno abbinate al valore (qualora presente) conservato in memoria. 30 | I valori memorizzati possono essere cancellati nel menù Coils >> Manage >> Zero All . 31 | 32 | * Bypass mode: 33 | La potenza è ora mostrata in alto al posto del voltaggio, poiché è un'informazione più rilevante per lo svapo. Le informazioni sui voltaggi in uscita sono ancora disponibili sulla terza riga (VOUT). 34 | La predizione della potenza e dei voltaggi sono più accurati, specialmente su box multi-cell. Questa modalità necessita di un paio di tiri per raggiungere il massimo di accuratezza. 35 | 36 | * Logo: 37 | Il firmware myevic accetta loghi di 64 pixels di larghezza e dai 40 alle 63 linee in lunghezza. 38 | Creando un logo con una certa altezza può far si che determinate linee di informazioni continuino ad essere disponibili. 39 | 40 | * Menus: 41 | I menù sono accessibili utilizzando il tasto Fire e + e sono stati completamente rivisitati. 42 | ----- 43 | 44 | ← Previous Page: [Usage and Compatibility](usageandcompatibility_it.md) -- Next Page: [How To Build](howtobuild_it.md)→ 45 | -------------------------------------------------------------------------------- /git_doc_it/clock_it.md: -------------------------------------------------------------------------------- 1 | ### Clock 2 | ![Clock Menu](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/clock_zpsmrvulkdd.png) 3 | 4 | * __Set Date/Time__ 5 | 6 | Imposta data ed ora. 7 | La pressione del tasto fire cambia il campo da modificare ed i tasti + e - impostano il valore. Una pressione prolungata del tasto Fire salva le impostazioni correnti. 8 | 9 | Ci sono anche altri modi per impostarli: 10 | * usando il comando ```evic-usb time``` , se hai installato l'utilità da riga di comando [python-evic](https://github.com/ClockSelect/python-evic "python-evic"); 11 | * usando la funziona di sincronizzazione della [NToolbox](https://github.com/TBXin/NFirmwareEditor/releases) o NFirmwareEditor 6.0+; (controlla la funzione di sincronizzazione nell'icona posizionata nella tray). 12 | * usando MicroSur's [FWUpdater](https://www.dropbox.com/s/83zd19gu05pl3r6/EvicVTCFont.rar?dl=1) con la funzione "Set current time". 13 | * usando il firmware updater della Joyetech. 14 | 15 | 16 | 17 | * __Fmt (date format)__ 18 | 19 | Serve a modificare il formato della data tra i modelli selezionabili. (day.month.year | month/day/year | day/month/year | year-month-day) 20 | 21 | * __Size__ 22 | 23 | Serve a modificare la grandezza del formato dell'ora (hh:mm:ss | HH:MM) 24 | 25 | * __Dial__ 26 | 27 | Serve a cambiare il formato dell'orologio. (A) analogico, (D) digitale. 28 | 29 | * __Clk Adjust__ 30 | 31 | Serve a mettere a punto l'orologio permettendo di modificarne i secondi. Il tasto Fire salva le modifiche. Per i possessori della VTwo questa impostazione mette a punto anche la frequenza X32 se fatta in modo opportuno. 32 | 33 | * __Clk Speed__ 34 | 35 | *Questa impostazione è inutile su box con RTC. (VTwo/Dual, AIO, Basic, eGrip II)* 36 | *Questa impostazione è utile solamente nel caso in cui Light Sleep mode fosse impostata ad "OFF" nel menù Expert.* 37 | 38 | La procedura per regolare il rapporto di velocità dell'orologio è la seguente: 39 | * Imposta l'orologio tramite il menù date/time oppure con la command-line tramite il comando"```evic-usb time```" . 40 | * Lascia che la box entri nella sleep mode per alcune ore. 41 | * Accendi la box e vai nel menù "Clk Speed"; non lasciare che la box entri in modalità sleep, altrimenti dovrai ricominciare tutto il processo. 42 | * Utilizzando i pulsanti + e -, regola l'orologio che vedi in alto per sincronizzarlo con l'ora reale. I valori si attestano tra 32 e 34000 circa. 43 | * Una volta fatto ciò, premi il tasto fire per confermare l'operazione. 44 | 45 | ----- 46 | 47 | ← Previous Page: [Vaping](vaping_it.md) -- Next Page: [Interface](interface_it.md)→ 48 | -------------------------------------------------------------------------------- /git_doc_it/coils_it.md: -------------------------------------------------------------------------------- 1 | ### __Coils__ 2 | 3 | * __Management__ 4 | 5 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/coils_zpsn29ef1h5.png) 6 | 7 | * __Su ogni linea delle 4 disponibili in TC mode:__ 8 | 9 | Premi il tasto fire per attivare la modalità di modifica sulla resistenza. 10 | Mentre il valore della resistenza è evidenziato, clicca + o - per cambiarne il valore. 11 | Se premi di nuovo il tasto fire, senza modificare il valore della resistenza, la suddetta cambierà stato tra locked ed unlocked. 12 | Modificando la resistenza in qualsiasi valore diverso da zero, la bloccherà automaticamente. 13 | Impostando la resistenza a zero con il tasto -, la sbloccherà resettandola. 14 | 15 | E' possibile anche premere il tasto fire per due secondi su uno dei valori della resistenza per resettarne il valore; se la resistenza selezionata corrisponde all'impostazione corrente di svapo, verrà forzata la lettura dell'atomizzatore, impostando e bloccando il nuovo valore. 16 | ----- 17 | Quando si entra nel menu Coils Management, la resistnza che corrisponde alla modalità di svapo attiva (se applicabile) verrà preselezionata. 18 | 19 | * __Zero All__ 20 | 21 | Azzera tutte le resistenza; resetta anche i valori delle resistenze conservate per la modalità SMART e POWER. 22 | 23 | * __Check: Yes/No__ 24 | 25 | 26 | Se hai necessità di utilizzare questa opzione in situazioni diverse da coil pesanti con valori di TCR bassi, c'è qualche problema con la tua coil. Utilizzare questa funzione è potenzialmente pericoloso e si raccomanda di non modificarla. Controlla prima la tua build.* 27 | Nelle modalità TC, la box controlla l'idoneità della resistenza alla prima pressione del tasto fire. Il test è fatto in modo che delle build pesanti con valori di TCR bassi, lo falliscano.; Se una coil fallisce il primo test, la box imposterà forzatamente la modalità power. 28 | Se sai che la tua build è fatta bene ed è utilizzabile in temp control, puoi impostare questa funzione su No. 29 | 30 | __Da usare con cautela. Può creare situazioni tutt'altro che piacevoli.__ 31 | 32 | * __TCR Submenu__ 33 | 34 | ![](https://www.dropbox.com/s/n09iy9nu57jnv18/tcrset.png?dl=1) 35 | 36 | 37 | *Questo menù è anche accessibile spegnendo la box e premendo il tasto Fire e + per 5 secondi.* 38 | 39 | In aggiunta alle tre modalità usuali della TCR (M1, M2 & M3), i preset standard come TEMP NI, TI e SS sono anch'essi modificabili. Quanto segue è per modificare i preset: 40 | * Seleziona la modalità che vuoi modificare. 41 | * Una lunga pressione del tasto fire serve a sbloccare il comportamento di default (DEF); un valore ragionevole viene proposto per le modifiche. 42 | * Modifica il valore TCR. 43 | * Una lunga pressione del tasto fire ripristina il comportamento di default (DEF). 44 | 45 | ----- 46 | 47 | ← Previous Page: [Screen Menu](screen_it.md) -- Next Page: [Vaping Menu](vaping_it.md)→ 48 | -------------------------------------------------------------------------------- /git_doc_it/expert_it.md: -------------------------------------------------------------------------------- 1 | ### Expert 2 | 3 | Alcune imopstazioni avanzate. 4 | Gli utenti normali non hanno nulla a che fare con queste impostazioni e possono perfettamente vivere senza sapere che esistano. 5 | Non consigliamo pertanto alcun tipo di test con queste impostazioni. 6 | Per tanto decliniamo ogni responsabilità, d'altrone si suppone che l'utente sia maggiorenne.^^ 7 | 8 | * __USB__ 9 | 10 | Sceglie diverse modalità USB: 11 | * HID: Modalità operativa normale - impostazione di default. Disabilita qualsiasi device USB oltre l'HID. 12 | L'HID è sempre attiva anche con le altre due modalità operative. Questa funzione permette la comunicazione tra la box e le utilità firmware. 13 | 14 | * COM: Un'interfaccia com virtuale; utilizzata principalmente per il debug con un terminale COM come putty. 15 | Può essere utile se stai sviluppando una versione personalizzata del firmware. 16 | 17 | * DSK: Un drive virtuale per scaricare il file del firmware. 18 | Connettendo la box ad un PC, apparirà un dispositivo di archiviazione con il file MYEVIC.bin . 19 | 20 | * __DBG__ 21 | 22 | Attiva o disattiva le informazioni di debug. Una volta impostata su ON le informazioni di debug possono essere mostrate/nascoste con 4 pressioni consecutive del tasto fire. 23 | 24 | * __X32__ 25 | 26 | Attiva o disattiva l'utilizzo del cristallo X32 della PCB. 27 | *Impostazione inutile per box che non hanno il supporto RTC.* 28 | 29 | * __LSL__ 30 | 31 | Light Sleep mode. 32 | *Impostazione inutile per box che hanno il supporto RTC.* 33 | Utilizzando (su box senza RTC) quest'impostazione l'accuratezza dell'ora è uguale alle box con supporto RTC (al costo di 50mA/giorno). 34 | 35 | 36 | * __NFE__ 37 | 38 | *Attenzione: se quest'impostazione è abilitata non è possibile utilizzare altri firmware updater.* 39 | Abilita o disabilita una parziale compatibilità con il [NFirmwareEditor 5.x](https://github.com/TBXin/NFirmwareEditor/releases) per l'editing delle configurazioni myEvic. 40 | Si avrà accesso alle funzioni Monitoring, Screenshot, COM terminal ed al Custom Battery Profile editor. 41 | 42 | * __SHR__ 43 | 44 | Shunt Resistance (in mΩ). (real resistance in Ohm now) 45 | *ATTENZIONE: Quest'impostazione è dannosa per la tua box. Giocando con questi parametri si potrebbero causare sovraccarichi che porterebbero il circuito della vostra box alla morte definitiva.* 46 | Questa voce permette la modifica del valore dell'atomizzatore relativo alla resistenza del circuito shunt. Questa resistenza è coinvolta in ogni computazione e misurazione relativa alle resistenze/corrente/potenza. 47 | Non modificare questo valore se non sai cosa stai facendo. 48 | Per resettare il valore di shunt, tieni premuto il tasto Fire per 2 secondi. 49 | 50 | * __UCH__ 51 | 52 | USB Battery Charging. 53 | *Solo per box Multi-Cell.* 54 | Abilita o disabilita la ricarica via USB nonostante resti utilizzabile per altri scopi. 55 | 56 | * __BAT__ 57 | 58 | Modello batteria. 59 | Puoi specificare il modello di batteria che stai utilizzando tra i vari preset: 25R, 30Q, HG2, HE4, VTC4, VTC5 and VTC6. 60 | "GEN" è il profilo generico utilizzato di default che comprende le batterie non presenti in lista e le built-in. 61 | 62 | Custom Battery: 63 | Tenendo premuto il tasto Fire per due secondi, si potrà accedere alla modifica del modello di batteria. 64 | La voce verrà mutata in CUS confermando lo stato dell'operazione. 65 | La box quindi utilizzerà i valori impostati dall'utente. 66 | Questi valori possono essere modificati tramite il discharge profile editor di [NFirwareEditor](https://github.com/TBXin/NFirmwareEditor/releases) ( guarda la documentazione del [NFirwareEditor](https://github.com/TBXin/NFirmwareEditor/releases) per maggiori informazioni). 67 | *La compatibilità con NFE deve essere impostata ad ON nel menù Expert.* 68 | 69 | 70 | * __BVO__ 71 | 72 | Battery Voltage Offset submenu 73 | Questa impostazione serve a correggere l'offset dei voltaggi delle batterie. 74 | Utilizzando un voltimetro bisogna comparare i voltaggi con quelli della box.e regolarli come si conviene. 75 | Il range è da -1.00 a +1.00 Volts per ogni step di 10mV. 76 | * Sulle box a singola batteria solo la prima voce (B1) è rilevante. 77 | * Sulle box dual battery, solo i primi due settaggi (B1 & B2) sono rilevanti, rispettivamente, per la prima e seconda batteria. 78 | * Sulle box "miste" (dual e single battery), B1 è utilizzata per la batteria in setup singolo, B2 & B3 per il setup in dual. 79 | * Sulle box a tripla batteria B4 è ignorato. 80 | * Sulle box a quadrupla batteria... beh indovinate. 81 | 82 | ----- 83 | 84 | ← Previous Page: [Interface](interface_it.md) 85 | -------------------------------------------------------------------------------- /git_doc_it/howtobuild_it.md: -------------------------------------------------------------------------------- 1 | ### Build 2 | Segui [evic-sdk::Readme](https://github.com/ReservedField/evic-sdk/blob/master/README.md) per le istruzioni riguardanti: 3 | 4 | * L'impostazione dell'environment. 5 | 6 | * Installazione di python-evic 7 | 8 | * Installazione e spacchettamento del nuvoton-sdk con i cambiamenti sotto riportati: 9 | * Spacchetta nella cartella del progetto (evic-sdk non è richiesto per questo progetto) 10 | * Quando si spacchetta il nuSDK, estrai solo la cartella ```Library```. Esempio:```M451 Series BSP CMSIS V3.01.001/Library``` da```M451_Series_BSP_CMSIS_V3.01.001.zip``` in ```myevic/nuvoton-sdk/Library``` 11 | 12 | * Per dare via alla build invoca il comando: ```EVICSDK=. make``` 13 | ----- 14 | 15 | ← Previous Page: [Behaviour Changes](behaviourchanges_it.md) -- Next Page: [Profiles](profiles_it.md)→ 16 | -------------------------------------------------------------------------------- /git_doc_it/interface_it.md: -------------------------------------------------------------------------------- 1 | ### Interface 2 | 3 | ![Interface menu screen](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/interface_zpshqw8kg89.png) 4 | 5 | * __1Watt On/Off__ 6 | 7 | Abilità l'incerementare dei watt di ±1.0 al posto di ±0.1 8 | 9 | * __1C/5F On/Off__ 10 | 11 | Abilita l'incrementare della temperatura di ±1°C and ±5°F al posto di ±5°C and ±10°F. 12 | 13 | * __Wake < > On/Off__ 14 | 15 | Abilita/disabilita il risveglio della box tramite i tasti + o -. 16 | 17 | * Font A/B 18 | 19 | Cambia il font selezionato. Vi sono due font disponibili. 20 | 21 | * __Temp °C/°F__ 22 | 23 | Permette di scegliere l'unità di misura della temperatura. 24 | 25 | * __PPwr On/Off__ 26 | 27 | *__Solo in TEMP Mode __* 28 | Imposta la priorità della power mod ad on/off. Nelle modalità per il controllo della temperatura quest'impostazione cambia la priorità. La temperatura resta modificabile nella modalità di editing. 29 | Lo scopo di questa funzione è simile a quella di preheat nella modalità PWR. 30 | 31 | * __Clicks__ 32 | 33 | ![Clicks Menu](http://i345.photobucket.com/albums/p374/ClockSelect/clicks_zpsoqy6ngvh.png) 34 | 35 | Il sottomenù Clicks ti permette di configurare l'azione associata alle varie pressioni del tasto fire. 36 | 37 | Le azioni possibili sono: 38 | * Nessuna 39 | * Attiva la modalità di modifica 40 | * Abilita la visualizzazione delle linee informative / orologio sulla schermata principale 41 | * Imosta la "Priority Power" mode (come sopra con la "PPwr On/Off"), *OPPURE* entra nel menù Preheat se la box è in modalità POWER. 42 | * Cambia la modalità di svapo ( TC -> POWER -> BYPASS -> ... ) 43 | * Spegni/accendi box 44 | * Selettore di profili 45 | 46 | Come feature di sicurezza, se nessuna delle combinazioni del tasto fire è associata al menù EDIT il firmware lo impostare alle tre pressioni consecutive. 47 | 48 | ----- 49 | 50 | ← Previous Page: [Clock](clock_it.md) -- Next Page: [Expert](expert_it.md)→ 51 | -------------------------------------------------------------------------------- /git_doc_it/mainscr_it.md: -------------------------------------------------------------------------------- 1 | ### Main Screen 2 | * Double-click: 3 | 4 | Una doppia pressione sul tasto fire mostra l'orologio oppure la schermata standard. 5 | 6 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/mainscreen_zpsuoh0cthd.png) ![](http://i345.photobucket.com/albums/p374/ClockSelect/mainscreen3_zpsfunjeoct.png) 7 | 8 | * Third info line: 9 | 10 | La terza riga sulla schermata principale, utilizzata per mostrare le ampere, i tiri etc. ora ha più opzioni. 11 | Tra cui: 12 | - Atomizer voltage 13 | - Battery voltage 14 | - Board temperature 15 | - Real-time clock 16 | - Real-time atomizer resistance 17 | - Stima della velocità dello svapo in ml or ml/day *(sperimentale)* 18 | 19 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/mainscreen2_zpsclbvvdah.png) 20 | 21 | * Battery layout: 22 | 23 | Nella modalità EDIT (triplo click di default), si può cambiare il layout della batteria tra regolare, batteria percentuale e voltaggio batteria. 24 | 25 | ----- 26 | 27 | ← Previous Page: [Menus](menus_it.md) -- Next Page: [Screen Menu](screen_it.md)→ 28 | -------------------------------------------------------------------------------- /git_doc_it/menus_it.md: -------------------------------------------------------------------------------- 1 | ### Menus 2 | Tenendo premuto il tasto Fire e +, permette l'ingresso nel menù principale. 3 | 4 | * La stessa combinazione è usata anche per ritornare alla schermata principale. 5 | * Se invece vi trovate in un sottomenù e volete accedere a quello precedente, premete + e - simultaneamente. 6 | 7 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/menus_zpsb8gftzok.png) 8 | Main menu screen 9 | 10 | Se si continua a premere il tasto Fire e + dopo due secondi vi ritroverete nel menù di selezione profilo. 11 | 12 | ----- 13 | 14 | ← Previous Page: [Profiles](profiles_it.md) -- Next Page: [Main Screen](mainscr_it.md)→ 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /git_doc_it/profiles_it.md: -------------------------------------------------------------------------------- 1 | ### Profiles 2 | 3 | Si possono impostare fino a 7 profili. 4 | Un profilo salva tutti i dati relativi alla configurazione di svapo, come le resistenze, modalità etc., senza però salvare impostazioni relative ai vari layout. 5 | 6 | Per accedere al selettore di profili, basta tenere premuto il tasto Fire ed il tasto + per due secondi. Nel schermata del selettore del profilo, una volta selezionato uno premi Fire per attivarlo. 7 | 8 | ![Profile Screen](https://www.dropbox.com/s/b4y1afx3vbmrgdp/profile.png?dl=1) 9 | 10 | Ogni linea del display mostra il numero del profilo, la modalità selezionata e l'ultima resistenza usata. 11 | Le linee vuote corrispondono a profili vuoti. 12 | * Crea un nuovo profilo: 13 | Seleziona un profilo vuota e premi una volta il tasto Fire. Il profilo attivo al momento verrà duplicato in quello selezionato. Il profilo selezionato a sua volta diventerà il profilo attivo e la box ritornerà alla schermata principale. 14 | * Cancella un profilo: 15 | Seleziona un profilo non vuoto e premi il tasto Fire per due secondi. Il profilo verrà cancellato. Il profilo in uso non può essere cancellato. 16 | * Duplicare un profilo: 17 | 18 | Seleziona un profilo vuoto e premi il tasto Fire per due secondi. Il profilo correntemente attivo verrà duplicato nel profilo selezionato. Il profilo selezionato sarà quindi attivato. 19 | Per uscire dal selettore del profilo, seleziona un profilo o premi simultaneamente il tasto Fire e +. 20 | 21 | 22 | ----- 23 | 24 | ← Previous Page: [How To Build](howtobuild_it.md) -- Next Page: [Menus](menus_it.md)→ 25 | -------------------------------------------------------------------------------- /git_doc_it/screen_it.md: -------------------------------------------------------------------------------- 1 | ### Screen 2 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/screenmenu_zpsph9b8ono.png) 3 | 4 | #### Screen management menu: 5 | * __Contrast__ 6 | 7 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/contrast_zpsjuouc0v4.png) 8 | 9 | Il contrasto di default è attorno al 17%. Questa schermata da accesso al range completo di valori. 10 | 11 | * __Protection__ 12 | 13 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/protec_zpsx0jd4aok.png) 14 | 15 | Configura il timeout di oscuramento della la schermata principale. Dopo averla impostata con l'opzione Main ad X secondi di inattività, la schermata principale muta nell'animazione dello screensaver. 16 | Se l'opzione Saver è impostata ad OFF la box oscurerà lo schermo dopo aver fatto trascorrere il secondi impostati in Main per poi mutare in una schermata completamente nera per 3 minuti prima dello spegnimento. 17 | 18 | * __Saver__ 19 | 20 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/saver_zpsdkyhj1mz.png) 21 | 22 | Seleziona l'animazione dello screensaver. Puoi scegliere tra None (schermata nera), orologio (analogico o digitale), oggetti 3D in movimento, un'animazione Qix-like oppure un'animazione dei fiocchi di neve. 23 | When the 3D screen saver is active, the + and - buttons change the animated object. 24 | A proposito dei fiocchi di neve come screensaver: scegli questa opzione se la tua box ha problemi di pixels; questo screensever così come la modalità invert, potrebbero aiutare a ripristinarli. 25 | 26 | * __Logo__ 27 | 28 | Il sottomenù Logo serve ad impostare il logo personalizzato On oppure Off e di scegliere dove mostrarlo. Il logo verrà mostrato in cima allo schermo (all'altezza della temperatura/watt) oppure al centro dello stesso. 29 | 30 | * __Invert__ 31 | 32 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/invert_zpsyowemzqu.png) 33 | 34 | Imposta la modalità del display da nero su bianco a bianco su nero. 35 | 36 | 37 | * __Miscs__ 38 | Sub-menu 39 | * Game 40 | Flappy bird. 41 | 42 | * Led 43 | eGrip II / eVic AIO LED Color. 44 | 45 | * 3D 46 | Forme 3D roteanti. 47 | ![3D cube](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/cube_zpsf9apfiun.png) 48 | ----- 49 | 50 | ← Previous Page: [Main Screen](mainscr_it.md) -- Next Page: [Coils](coils_it.md)→ 51 | -------------------------------------------------------------------------------- /git_doc_it/usageandcompatibility_it.md: -------------------------------------------------------------------------------- 1 | ### Hardware Compatibili 2 | * Joyetech 3 | * eVic VTC Mini 4 | * eVic VTC Dual 5 | * eVic VTwo Mini 6 | * eVic VTwo 7 | * eVic AIO 8 | * eVic Basic 9 | * eGrip II / Light 10 | * Cuboid 11 | * Cuboid Mini 12 | * Cuboid 200 13 | * Wismec 14 | * Presa TC75W 15 | * Presa TC100W 16 | * Reuleaux RX75 17 | * Reuleaux RX200S 18 | * Reuleaux RX2/3 19 | * Reuleaux RXmini 20 | * Reuleaux RX300 21 | * Altre 22 | * Vaponaute La Petite Box 23 | 24 | ### Utilizzo: 25 | 26 | Il binario del firmware è incluso nella cartella **bin/** di questo progetto. 27 | Se il tuo unico interesse è installare il firmware, scaricalo qui: [bin/myevic](https://github.com/ClockSelect/myevic/blob/master/bin/myevic.bin) 28 | 29 | Una volta scaricato il binario del firmware puoi: 30 | 31 | - Usare l'utilità del produttore della tua box per installare il firmware [myevic.bin](https://github.com/ClockSelect/myevic/blob/master/bin/myevic.bin) come faresti con qualunque aggiornamento ufficiale: 32 | 33 | oppure 34 | 35 | - Per gli utilizzatori di linux/Cygwin, si può utilizzare evic-usb per l'installazione del firmware [myevic.bin](https://github.com/ClockSelect/myevic/blob/master/bin/myevic.bin) utilizzando la riga di comando: 36 | 37 | ```evic-usb upload myevic.bin``` 38 | 39 | o ancora 40 | 41 | - Utilizzare il [NFirmwareEditor](https://github.com/TBXin/NFirmwareEditor/releases) oppure il [FWUpdater](https://www.dropbox.com/s/83zd19gu05pl3r6/EvicVTCFont.rar?dl=1) parte del pacchetto [VTCFont](https://www.dropbox.com/s/83zd19gu05pl3r6/EvicVTCFont.rar?dl=1). 42 | 43 | ### A proposito delle box con più batterie 44 | 45 | Al momento, l'interfaccia mostra solamente un'icona della batteria (percentile o voltaggio) come se ci fosse una singola batteria inserita. 46 | I valori mostrati, sono quelli della batteria che si trova nello *stato di carica più basso*. 47 | Un set di batterie dovrebbe essere sempre in equilibrio e bilanciato, qualora non lo fosse verrà mostrato un avvertimento.A battery set should always be kept in equilibrium and a balance warning is issued if the difference between the lowest and the highest voltage exceeds 0.3 Volts. 48 | 49 | ----- 50 | 51 | Next Page: [Profiles](behaviourchanges_it.md)→ 52 | -------------------------------------------------------------------------------- /git_doc_it/vaping_it.md: -------------------------------------------------------------------------------- 1 | ### Vaping 2 | 3 | 4 | ![Vaping menu](https://www.dropbox.com/s/5nafopmyhl6m8as/vaping2.png?dl=1) 5 | 6 | * __Preheat__ 7 | 8 | ![TCR Set Menu](https://www.dropbox.com/s/d1ncqa9heec6grx/preheat1.png?dl=1) 9 | 10 | __Coil preheat function.__ 11 | 12 | *Questa funzione può essere attivata solo nella modalità "POWER" ed in quella "SMART"; 13 | Imposta a quale wattaggio ( **Pwr** ) e per quanto tempo ( **Time** ) si vuole che la coil venga pre-riscaldata quando premi il tasto fire; dopo questo ritardo, l'atomizzatore sarà poi alimentato con le tue regolari impostazioni. Imposta il **Time** a zero per disattivare la funzione di preheating. 14 | La **Unit** in cui potrai impostare il preriscaldamento sono: Watt or percentuali. 15 | Il **Delay** permette di configurare un tempo morto dopo il tasto fire, durante il quale la funzione di preheating sarà disabilitata. Questo tempo morto può essere impostato a zero (off) a 3 minuti. Il ritardo ha luogo a pressione rimossa dal tasto Fire. Usa questa funzione se hai un'alta inerzia nella tua build (coil pesanti) per prevenire l'over-heating quando si esegue del chain-vaping. Il **Delay** si applica anche alle power curves. 16 | Una piccola **P** apparirà sulla schermata principale vicino alle impostazioni dei watt per ricordarvi della funzione attiva. A blinking **P** indicates the dead time period. 17 | *Se hai configurato un'azione relativa alla "PPwr" alla pressione multipla del tasto fire, verrà mostrato questo menù nella POWER/SMART mode.* 18 | 19 | * __Modes__ 20 | 21 | ![](http://i345.photobucket.com/albums/p374/ClockSelect/eVic/modes_zpslphwvqhh.png) 22 | 23 | Configura le modalità che usi oppure no.. 24 | Puoi cliccare su ogni elemento del menù affinché tu possa selezionare l'opzione Y o N per rendere una modalità visibile o non. 25 | 26 | * __Algo__ 27 | 28 | *Solo in Temperature Control * 29 | Sotto menù per gli algoritmi in TC 30 | 31 | ![Algo submenu](https://www.dropbox.com/s/ecy9oqapftnfwh3/algo.png?dl=1) 32 | 33 | * Algo 34 | Scegli tra i diversi algoritmi: 35 | * Off: utilizza l'algoritmo di default (lo stesso è presente sul firmware ufficiale) 36 | * Sweet: simile a quello di default, ma ammorbidisce le oscillazioni in fase di regolazione. 37 | * Boost: aumenta la velocità con la quale la temperatura sale riducendo le oscillazioni, ma con il rischio di andare oltre il target configurato di temperature se non settato correttamente. 38 | * PID: Algoritmo PID standard 39 | 40 | Per definizione non c'è un algoritmo migliore. Dipende semplicemente dalle vostre build e dal vostro gusto. 41 | 42 | * __Boost__ 43 | 44 | Un parametro che controlla l'algoritmo Boost. 45 | Imposta il limite, in percentuale, al quale l'algoritmo boost smetterà di velocizzare la fase dell'incremento di temperatura. 46 | Una lunga pressione del tasto fire resetta il parametro al suo valore di default. 47 | 48 | * __P, I, D__ 49 | 50 | I 3 parametri controllano la parte Proporzionale, Integrale e Derivativa dell'algoritmo PID. 51 | Una lunga pressione del tasto fire resetta il parametro al suo valore di default. 52 | I valori di defult sono (600,850,0). 53 | L'algoritmo è implementato nella forma indipendente. 54 | Il tempo di campionamento (50Hz) è scalato a uno per uniformità dei parametri. 55 | Unità: **P** è espresso in mW/°C, **I** in mW/°C/s, **D** in mW.s/°C. 56 | 57 | * __Curve__ 58 | 59 | *Solo in modalità POWER/SMART.* 60 | Abilita, resetta e/o modifica la curva di potenza dell'atomizzatore. 61 | Quando la power curve è attivata, avrà priorità sulla funzione di preheating; una piccola C verrà mostrata per confermare l'operatività della curva. 62 | I valori ammessi nella power curve sono in percentuale (da 0 a 200%). L'intera power curve sarà in scala ai valori precedentemente impostati (watt). The default power curve (after reset) is a flat 100% curve, so will have no sensible effect. 63 | L'impostazione del **Delay** previene che la power curve applichi una potenza superiore al 100%. 64 | Possono essere definite diverse power cure per ogni profilo di configurazione. 65 | 66 | * __Prot.__ 67 | 68 | Imposta la durata massima di un tiro. 69 | I valori ammissibili sono tra 2.0s e 15.0s. 70 | 71 | * __Vaped__ 72 | 73 | Sceglie l'unità nella quale viene mostrata il consumo di liquido. Si può scegliere tra un Totale ml oppure ml/day. 74 | 75 | * __ml/kJ__ 76 | 77 | Indica la velocità con cui il liquido viene vaporizzato in funzione dell'energia dissipata dalla coil. Il valore è in millimetri per KiloJoules. Il valore proposto di 360 è accurato per una coil standard da 30W. 78 | 79 | ----- 80 | 81 | ← Previous Page: [Coils](coils_it.md) -- Next Page: [Clock](clock_it.md)→ 82 | -------------------------------------------------------------------------------- /inc/atomizer.h: -------------------------------------------------------------------------------- 1 | #ifndef __ATOMIZER_H__ 2 | #define __ATOMIZER_H__ 3 | 4 | //============================================================================= 5 | 6 | /* DC/DC converters PWM channels */ 7 | #define BBC_PWMCH_BUCK 0 8 | #define BBC_PWMCH_BOOST 2 9 | 10 | #define BBC_PWMCH_BUCK1 0 11 | #define BBC_PWMCH_BUCK2 2 12 | 13 | 14 | #define SHUNT_MIN_VALUE 75 15 | #define SHUNT_MAX_VALUE 150 16 | 17 | #define VVEL_DEF_RATIO 360 18 | #define VVEL_MIN_RATIO 50 19 | #define VVEL_MAX_RATIO 1000 20 | 21 | #define FIRE_PROTEC_MIN 20 22 | #define FIRE_PROTEC_DEF 100 23 | #define FIRE_PROTEC_MAX 250 24 | 25 | enum 26 | { 27 | TCALGO_JOY = 0, 28 | TCALGO_SWEET, 29 | TCALGO_BOOST, 30 | TCALGO_PID, 31 | TCALGO_MAX 32 | }; 33 | 34 | #define TCALGO_DEF TCALGO_JOY 35 | 36 | #define PID_P_DEF 600 37 | #define PID_P_MIN 1 38 | #define PID_P_MAX 6000 39 | 40 | #define PID_I_DEF 850 41 | #define PID_I_MIN 0 42 | #define PID_I_MAX 10000 43 | 44 | #define PID_D_DEF 0 45 | #define PID_D_MIN 0 46 | #define PID_D_MAX 5000 47 | 48 | 49 | //------------------------------------------------------------------------- 50 | 51 | extern uint32_t AtoVolts; 52 | extern uint32_t TargetVolts; 53 | extern uint32_t AtoRezMilli; 54 | extern uint32_t AtoMinVolts; 55 | extern uint32_t AtoMaxVolts; 56 | extern uint32_t AtoMinPower; 57 | extern uint32_t AtoMaxPower; 58 | extern uint32_t MaxTCPower; 59 | extern uint32_t MaxVolts; 60 | extern uint32_t MaxPower; 61 | extern uint32_t MaxCurrent; 62 | extern uint16_t TCR; 63 | extern uint16_t FireDuration; 64 | extern uint16_t AtoTemp; 65 | extern uint16_t AtoCurrent; 66 | extern uint16_t AtoRez; 67 | extern uint8_t AtoMillis; 68 | extern uint8_t AtoProbeCount; 69 | extern uint8_t AtoShuntRez; 70 | extern uint8_t AtoError; 71 | extern uint8_t AtoStatus; 72 | extern uint8_t BoardTemp; 73 | extern uint8_t ConfigIndex; 74 | extern uint8_t PreheatTimer; 75 | extern uint16_t PreheatPower; 76 | extern uint16_t PreheatDelay; 77 | extern uint32_t MilliJoules; 78 | extern uint8_t RezMillis; 79 | 80 | extern uint8_t byte_200000B3; 81 | extern uint16_t word_200000B8; 82 | extern uint16_t word_200000BA; 83 | extern uint16_t word_200000BC; 84 | extern uint16_t word_200000BE; 85 | 86 | extern const uint8_t TempCoefsNI[]; 87 | extern const uint8_t TempCoefsTI[]; 88 | 89 | //------------------------------------------------------------------------- 90 | 91 | extern void InitPWM(); 92 | extern void SetPWMClock(); 93 | extern void BBC_Configure( uint32_t chan, uint32_t mode ); 94 | 95 | extern void StopFire(); 96 | 97 | extern uint16_t LowestRezMeasure(); 98 | extern uint16_t ClampPower( uint16_t pwr, int clampmax ); 99 | extern uint16_t AtoPowerLimit( uint16_t pwr ); 100 | extern uint16_t AtoPower( uint16_t volts ); 101 | extern uint16_t GetVoltsForPower( uint16_t pwr ); 102 | extern uint16_t GetAtoVWVolts( uint16_t pwr ); 103 | extern void ClampAtoPowers(); 104 | extern void ClampAtoVolts(); 105 | extern void SetMinMaxPower(); 106 | extern void SetMinMaxVolts(); 107 | extern void SetAtoLimits(); 108 | 109 | extern void RegulateBuckBoost(); 110 | extern void AtoWarmUp(); 111 | extern void TweakTargetVoltsVW(); 112 | extern void TweakTargetVoltsTC(); 113 | extern void ProbeAtomizer(); 114 | extern void ReadAtoCurrent(); 115 | extern void ReadAtoTemp(); 116 | extern void ReadAtomizer(); 117 | extern void GetTempCoef( const uint8_t tc[] ); 118 | extern void CheckMode(); 119 | extern void ReadBoardTemp(); 120 | extern void Overtemp(); 121 | extern void ResetResistance(); 122 | 123 | extern void SwitchRezLock(); 124 | 125 | extern int SearchSMARTRez( uint16_t rez ); 126 | extern void SetAtoSMARTParams(); 127 | extern void RoundPowers(); 128 | 129 | extern uint16_t CelsiusToF( uint16_t tc ); 130 | extern uint16_t FarenheitToC( uint16_t tf ); 131 | 132 | extern const uint16_t SMARTRezValues[]; 133 | extern const uint16_t SMARTPowers[]; 134 | 135 | extern void InitTCAlgo(); 136 | extern void TweakTargetVoltsSegments(); 137 | extern void TweakTargetVoltsAlgo(); 138 | 139 | 140 | //============================================================================= 141 | 142 | #endif /* __ATOMIZER_H__ */ 143 | -------------------------------------------------------------------------------- /inc/battery.h: -------------------------------------------------------------------------------- 1 | #ifndef __BATTERY_H__ 2 | #define __BATTERY_H__ 3 | 4 | //========================================================================= 5 | 6 | #define BBC_PWMCH_CHARGER 5 7 | 8 | #define BVO_MIN -100 9 | #define BVO_MAX 100 10 | 11 | #define BATTERY_CUSTOM 255 12 | 13 | //------------------------------------------------------------------------- 14 | 15 | typedef struct 16 | { 17 | uint16_t percent; 18 | uint16_t voltage; 19 | } 20 | BatV2P_t; 21 | 22 | typedef struct 23 | { 24 | const uint8_t *name; 25 | BatV2P_t V2P[11]; 26 | uint16_t cutoff; 27 | uint16_t intrez; 28 | uint16_t maxamp; 29 | } 30 | Battery_t; 31 | 32 | //------------------------------------------------------------------------- 33 | 34 | extern uint16_t RTBattVolts; 35 | extern uint16_t RTBVolts[4]; 36 | extern uint16_t RTBVTotal; 37 | extern uint16_t LowBatVolts; 38 | extern uint32_t PowerScale; 39 | extern uint16_t BatteryVoltage; 40 | extern uint16_t BattVoltsTotal; 41 | extern uint16_t BattVolts[4]; 42 | extern uint16_t BatteryCutOff; 43 | extern uint16_t BatteryIntRez; 44 | extern uint16_t BatteryMaxPwr; 45 | extern uint8_t BatteryPercent; 46 | extern uint8_t SavedBatPercent; 47 | extern uint8_t BatteryTenth; 48 | extern uint8_t NoEventTimer; 49 | extern uint8_t BatReadTimer; 50 | extern uint8_t NumBatteries; 51 | extern uint8_t MaxBatteries; 52 | extern uint16_t ChargerDuty; 53 | extern uint16_t MaxChargerDuty; 54 | extern uint16_t ChBalTimer; 55 | 56 | extern uint8_t BattProbeCount; 57 | 58 | extern uint8_t USBMaxLoad; 59 | extern uint8_t ChargeStatus; 60 | extern uint8_t BatteryStatus; 61 | extern uint8_t BBBits; 62 | extern uint8_t ChargeMode; 63 | extern uint8_t ChargeStep; 64 | 65 | extern Battery_t CustomBattery; 66 | 67 | //------------------------------------------------------------------------- 68 | 69 | extern void ReadBatteryVoltage(); 70 | extern void NewBatteryData(); 71 | extern void NewBatteryVoltage(); 72 | extern int CheckBattery(); 73 | extern int GetNBatteries(); 74 | extern void SetBatteryModel(); 75 | extern const uint8_t *GetBatteryName(); 76 | extern void ReadInternalResistance(); 77 | extern void SetBatMaxPower(); 78 | extern void BatteryChargeDual(); 79 | extern void BatteryCharge(); 80 | extern void SaveCustomBattery( const Battery_t *b ); 81 | extern void LoadCustomBattery(); 82 | extern void ResetCustomBattery(); 83 | extern int CheckCustomBattery(); 84 | 85 | //========================================================================= 86 | #endif /* __BATTERY_H__ */ 87 | -------------------------------------------------------------------------------- /inc/display.h: -------------------------------------------------------------------------------- 1 | #ifndef __DISPLAY_H__ 2 | #define __DISPLAY_H__ 3 | 4 | #include "M451Series.h" 5 | 6 | //========================================================================= 7 | // DISPLAY 8 | //------------------------------------------------------------------------- 9 | 10 | #define SCREEN_BUFFER_SIZE 0x400 11 | 12 | //------------------------------------------------------------------------- 13 | 14 | #define InvertRect(a,b,c,d) DrawFillRect((a),(b),(c),(d),2) 15 | 16 | //------------------------------------------------------------------------- 17 | 18 | typedef struct { 19 | uint8_t width; 20 | uint8_t height; 21 | uint8_t bitmap[]; 22 | } image_t; 23 | 24 | //------------------------------------------------------------------------- 25 | 26 | extern const uint8_t ByteMaskRight[]; 27 | extern const uint8_t ByteMaskLeft[]; 28 | 29 | extern uint8_t DisplayModel; 30 | extern uint8_t ScreenBuffer[]; 31 | 32 | extern const image_t **Images; 33 | 34 | extern const image_t const *font0_1306[]; 35 | extern const image_t const *font0_1327[]; 36 | extern const image_t const *font1_1306[]; 37 | extern const image_t const *font1_1327[]; 38 | 39 | //------------------------------------------------------------------------- 40 | 41 | extern void InitSPI0(); 42 | extern void InitDisplay(); 43 | extern void DisplaySendCommand( const uint8_t ); 44 | extern void DisplaySendData( const uint8_t*, const uint32_t ); 45 | extern void ScreenOff(); 46 | extern void DisplaySetContrast( const uint8_t c ); 47 | extern void DisplaySetInverse( const uint8_t i ); 48 | extern void ClearScreenBuffer(); 49 | extern void DisplayRefresh(); 50 | extern void Screen2Bitmap( uint8_t *pu8Bitmap ); 51 | extern void DisplaySetFont(); 52 | 53 | extern int GetImageWidth( const uint8_t imgnum ); 54 | extern int GetStringWidth( const uint8_t str[] ); 55 | extern int GetStrCenteredX( const uint8_t str[] ); 56 | extern uint8_t* Value2Str( uint8_t *str, int v, int dp, uint8_t z, int nd ); 57 | 58 | extern void DrawTimeSmall( int x, int y, S_RTC_TIME_DATA_T *rtd, int colors ); 59 | extern void DrawTime( int x, int y, S_RTC_TIME_DATA_T *rtd, int colors ); 60 | extern void DrawDate( int x, int y, S_RTC_TIME_DATA_T *rtd, int colors ); 61 | 62 | extern void DrawHLine( const int x1, const int y, const int x2, const int color ); 63 | extern void DrawVLine( const int x, const int y1, const int y2, const int color ); 64 | extern void DrawFillRect( const int x1, const int y1,const int x2, const int y2, const int color); 65 | extern uint32_t DrawImage( const int x, const int y, const uint8_t img ); 66 | extern uint32_t DrawImageInv( const int x, const int y, const uint8_t img ); 67 | extern int GetLogoHeight(); 68 | extern void DrawLOGO( const int x, const int y ); 69 | extern void DrawValue( int x, int y, int v, uint8_t dp, uint8_t z, uint8_t nd ); 70 | extern void DrawValueRight( int x, int y, int v, uint8_t dp, uint8_t z, uint8_t nd ); 71 | extern void DrawValueInv( int x, int y, int v, uint8_t dp, uint8_t z, uint8_t nd ); 72 | extern void DrawString( const uint8_t s[], int x, int y ); 73 | extern void DrawStringInv( const uint8_t s[], int x, int y ); 74 | extern void DrawStringCentered( const uint8_t s[], int y ); 75 | extern void DrawStringRight( const uint8_t s[], int x, int y ); 76 | extern void DrawLine( int x1, int y1, int x2, int y2, int color, int thick ); 77 | extern void DrawCircle( int xc, int yc, int r, int color, int fill ); 78 | 79 | 80 | extern void SSD1306_Init(); 81 | extern void SSD1306_WriteBytes( const int isData, const uint8_t data[], const int len ); 82 | extern void SSD1306_ClearBuffer(); 83 | extern void SSD1306_Refresh(); 84 | extern void SSD1306_ScreenOff(); 85 | extern void SSD1306_SetContrast( const uint8_t c ); 86 | extern void SSD1306_Plot( int x, int y, int color ); 87 | extern uint32_t SSD1306_Image( int x, int y, uint8_t img, int color ); 88 | extern uint32_t SSD1306_Bitmap( int x, int y, const image_t *image, int color ); 89 | extern void SSD1306_Screen2Bitmap( uint8_t *pu8Bitmap ); 90 | extern void SSD1306_SetInverse( const uint8_t i ); 91 | 92 | extern void SSD1327_Init(); 93 | extern void SSD1327_WriteBytes( const int isData, const uint8_t data[], const int len ); 94 | extern void SSD1327_ClearBuffer(); 95 | extern void SSD1327_Refresh(); 96 | extern void SSD1327_ScreenOff(); 97 | extern void SSD1327_SetContrast( const uint8_t c ); 98 | extern void SSD1327_Plot( int x, int y, int color ); 99 | extern uint32_t SSD1327_Image( int x, int y, uint8_t img, int color ); 100 | extern uint32_t SSD1327_Bitmap( int x, int y, const image_t *image, int color ); 101 | extern void SSD1327_Screen2Bitmap( uint8_t *pu8Bitmap ); 102 | extern void SSD1327_SetInverse( const uint8_t i ); 103 | 104 | 105 | //========================================================================= 106 | #endif /* __DISPLAY_H__ */ 107 | -------------------------------------------------------------------------------- /inc/dtmacros.h: -------------------------------------------------------------------------------- 1 | #ifndef __DTMACROS_H__ 2 | #define __DTMACROS_H__ 3 | 4 | //------------------------------------------------------------------------- 5 | // Those macros are quite impressive, but they are all compiled 6 | // to a simple numeral constant. They lead to no run-time computation 7 | // nor memory space. 8 | //------------------------------------------------------------------------- 9 | 10 | // Example of __DATE__ string: "Jul 27 2012" 11 | // 01234567890 12 | 13 | #define MONTH_IS_JAN (__DATE__[0] == 'J' && __DATE__[1] == 'a') 14 | #define MONTH_IS_FEB (__DATE__[0] == 'F') 15 | #define MONTH_IS_MAR (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'r') 16 | #define MONTH_IS_APR (__DATE__[0] == 'A' && __DATE__[1] == 'p') 17 | #define MONTH_IS_MAY (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'y') 18 | #define MONTH_IS_JUN (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'n') 19 | #define MONTH_IS_JUL (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'l') 20 | #define MONTH_IS_AUG (__DATE__[0] == 'A' && __DATE__[1] == 'u') 21 | #define MONTH_IS_SEP (__DATE__[0] == 'S') 22 | #define MONTH_IS_OCT (__DATE__[0] == 'O') 23 | #define MONTH_IS_NOV (__DATE__[0] == 'N') 24 | #define MONTH_IS_DEC (__DATE__[0] == 'D') 25 | 26 | #define __YEAR__ \ 27 | ( \ 28 | (__DATE__[ 7] - '0') * 1000 + \ 29 | (__DATE__[ 8] - '0') * 100 + \ 30 | (__DATE__[ 9] - '0') * 10 + \ 31 | (__DATE__[10] - '0') \ 32 | ) 33 | 34 | #define __MONTH__ \ 35 | ( \ 36 | (MONTH_IS_JAN) ? 1 : \ 37 | (MONTH_IS_FEB) ? 2 : \ 38 | (MONTH_IS_MAR) ? 3 : \ 39 | (MONTH_IS_APR) ? 4 : \ 40 | (MONTH_IS_MAY) ? 5 : \ 41 | (MONTH_IS_JUN) ? 6 : \ 42 | (MONTH_IS_JUL) ? 7 : \ 43 | (MONTH_IS_AUG) ? 8 : \ 44 | (MONTH_IS_SEP) ? 9 : \ 45 | (MONTH_IS_OCT) ? 10 : \ 46 | (MONTH_IS_NOV) ? 11 : \ 47 | (MONTH_IS_DEC) ? 12 : \ 48 | /* error default */ 0 \ 49 | ) 50 | 51 | #define __DAY__ \ 52 | ( \ 53 | (__DATE__[4] == ' ' ? 0 : __DATE__[4] - '0') * 10 + \ 54 | (__DATE__[5] - '0') \ 55 | ) 56 | 57 | 58 | // Example of __TIME__ string: "01:23:45" 59 | // 01234567 60 | 61 | #define __HOURS__ \ 62 | ( \ 63 | (__TIME__[0] - '0') * 10 + \ 64 | (__TIME__[1] - '0') \ 65 | ) 66 | 67 | #define __MINUTES__ \ 68 | ( \ 69 | (__TIME__[3] - '0') * 10 + \ 70 | (__TIME__[4] - '0') \ 71 | ) 72 | 73 | #define __SECONDS__ \ 74 | ( \ 75 | (__TIME__[6] - '0') * 10 + \ 76 | (__TIME__[7] - '0') \ 77 | ) 78 | 79 | 80 | // FAT16 Timestamping 81 | 82 | #define FAT16_TODAY \ 83 | ( \ 84 | (( __YEAR__ - 1980 ) << 9 ) | \ 85 | (( __MONTH__ ) << 5 ) | \ 86 | (( __DAY__ )) \ 87 | ) 88 | 89 | #define FAT16_NOW \ 90 | ( \ 91 | (( __HOURS__ ) << 11 ) | \ 92 | (( __MINUTES__ ) << 5 ) | \ 93 | (( __SECONDS__ )) \ 94 | ) 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /inc/events.h: -------------------------------------------------------------------------------- 1 | #ifndef __EVENTS_H_ 2 | #define __EVENTS_H_ 3 | 4 | //========================================================================= 5 | 6 | extern uint8_t FireClickCount; 7 | extern uint8_t FireClickTimer; 8 | extern int8_t UserInputs; 9 | extern int8_t LastInputs; 10 | extern uint8_t FireClicksEvent; 11 | 12 | extern uint8_t KeyUpTimer; 13 | extern uint16_t KeyTicks; 14 | extern uint16_t KeyPressTime; 15 | 16 | extern uint8_t WattsInc; 17 | 18 | //------------------------------------------------------------------------- 19 | extern volatile uint8_t Event; 20 | extern uint8_t LastEvent; 21 | 22 | // 0 Idle 23 | // 1 Fire button 24 | // 2 Edit (+ button) 25 | // 3 Edit (- button) 26 | // 4 Key Lock/UnLock 27 | // 5 Menus (fire+ buttons) 28 | // 6 Stealth ON/OFF 29 | // 10 USB cable attach 30 | // 11 USB cable detach 31 | // 12 Battery inserted 32 | // 13 Battery removed 33 | // 15 Single fire click 34 | // 16 Enter edit mode 35 | // 17 Switch On/Off 36 | // 18 Flip display 37 | // 20 ? 38 | // 21 ? 39 | // 22 Reset Puff Counter 40 | // 23 Reset Time Counter 41 | // 24 10s Fire 42 | // 25 Ato Short 43 | // 26 Ato Open 44 | // 27 Ato Low 45 | // 28 Battery < 3.1V idle or < 2.8V firing 46 | // 29 FW Version screen select / (Game menu?) 47 | // 30 Key lock violation 48 | // 31 Board temp screen select 49 | // 32 New coil detected 50 | // 33 (unused) Ti ON/OFF select 51 | // 34 Battery voltage screen select 52 | // 38 (unused) Change interface version 53 | // 39 TCR Set menu select 54 | // 40 LOGO menu select 55 | // 41 Game menu select 56 | 57 | 58 | // Events 100+ are custom events not existing in the OFW 59 | 60 | #define EVENT_TOGGLE_CLOCK 100 61 | #define EVENT_DEBUG_MODE 101 62 | #define EVENT_EDIT_CONTRAST 102 63 | #define EVENT_ENTER_MENUS 103 64 | #define EVENT_LONG_FIRE 104 65 | #define EVENT_EXIT_MENUS 105 66 | #define EVENT_PARENT_MENU 106 67 | #define EVENT_SET_TIME 107 68 | #define EVENT_SET_DATE 108 69 | #define EVENT_NEXT_MODE 109 70 | #define EVENT_TOGGLE_TDOM 110 71 | #define EVENT_RESET_VVEL 111 72 | #define EVENT_FORCE_VCOM 112 73 | #define EVENT_AUTO_PUFF 113 74 | #define EVENT_CLK_SPEED 114 75 | #define EVENT_CLK_ADJUST 115 76 | #define EVENT_INVERT_SCREEN 116 77 | #define EVENT_MODE_CHANGE 117 78 | #define EVENT_PROFILE_MENU 118 79 | #define EVENT_NEXT_PROFILE 119 80 | #define EVENT_POWER_CURVE 120 81 | 82 | 83 | //============================================================================== 84 | 85 | enum 86 | { 87 | CLICK_ACTION_NONE = 0, 88 | CLICK_ACTION_EDIT, 89 | CLICK_ACTION_CLOCK, 90 | CLICK_ACTION_TDOM, 91 | CLICK_ACTION_NEXT_MODE, 92 | CLICK_ACTION_ON_OFF, 93 | CLICK_ACTION_PROFILE, 94 | CLICK_ACTION_MAX 95 | }; 96 | 97 | 98 | //============================================================================== 99 | 100 | extern S_RTC_TIME_DATA_T SetTimeRTD; 101 | 102 | //------------------------------------------------------------------------------ 103 | 104 | extern void KeyRepeat(); 105 | extern void GetUserInput(); 106 | extern void EventHandler(); 107 | 108 | extern int CustomEvents(); 109 | 110 | extern void PowerPlus( uint16_t *pwr, uint16_t min, uint16_t max ); 111 | extern void PowerMinus( uint16_t *pwr, uint16_t min, uint16_t max ); 112 | 113 | 114 | //============================================================================== 115 | 116 | #endif /* __EVENTS_H_ */ 117 | -------------------------------------------------------------------------------- /inc/flappy.h: -------------------------------------------------------------------------------- 1 | #ifndef __FLAPPY_BIRD_H__ 2 | #define __FLAPPY_BIRD_H__ 3 | 4 | //========================================================================= 5 | 6 | extern void fbInitTimeouts(); 7 | extern int fbCreateTimeout( void (*cb)( void ) ); 8 | extern void fbDeleteTimeout( int ); 9 | extern void fbSetTimeoutDelay( int ); 10 | extern void fbTickTimeouts(); 11 | extern void fbCallTimeouts(); 12 | 13 | extern void fbStartScreen(); 14 | extern void fbBirdAnim( int ); 15 | extern void fbStartGame(); 16 | 17 | //========================================================================= 18 | 19 | #endif /* __FLAPPY_BIRD_H__ */ 20 | -------------------------------------------------------------------------------- /inc/meadc.h: -------------------------------------------------------------------------------- 1 | #ifndef __MEADC_H__ 2 | #define __MEADC_H__ 3 | 4 | 5 | void InitEADC(); 6 | void SetADCState( uint32_t module, int onoff ); 7 | uint32_t ADC_Read( uint32_t module ); 8 | 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /inc/megpio.h: -------------------------------------------------------------------------------- 1 | #ifndef __MEGPIO_H__ 2 | #define __MEGPIO_H__ 3 | 4 | 5 | 6 | extern void InitGPIO(); 7 | 8 | extern void InitUART0(); 9 | extern void UART0_Cout( uint8_t c ); 10 | 11 | 12 | 13 | #endif /* __MEGPIO_H__ */ 14 | -------------------------------------------------------------------------------- /inc/menus.h: -------------------------------------------------------------------------------- 1 | #ifndef __MENUS_H__ 2 | #define __MENUS_H__ 3 | 4 | 5 | typedef struct menu_s menu_t; 6 | 7 | extern menu_t const *CurrentMenu; 8 | extern unsigned char CurrentMenuItem; 9 | 10 | void DrawMenu(); 11 | int MenuEvent( int event ); 12 | 13 | 14 | #endif /* __MENUS_H__ */ 15 | -------------------------------------------------------------------------------- /inc/meusbd.h: -------------------------------------------------------------------------------- 1 | #ifndef __MEUSBD_H__ 2 | #define __MEUSBD_H__ 3 | 4 | #include "vcom.h" 5 | #include "storage.h" 6 | 7 | //========================================================================= 8 | // Many parts are from Nuvoton sample code 9 | 10 | /* Define the vendor id and product id */ 11 | #define USBD_VID 0x0416 12 | #define USBD_PID 0x5020 13 | 14 | /*! 5 | #include "M451Series.h" 6 | 7 | //========================================================================= 8 | // REAL-TIME CLOCK 9 | //========================================================================= 10 | 11 | #define IS_RTC_OPENED() ((RTC->INIT&RTC_INIT_ACTIVE_Msk)!=0) 12 | 13 | //========================================================================= 14 | // LIRC correction ratio 15 | //------------------------------------------------------------------------- 16 | // On boards without a 32k Xtal, we use the LIRC to drive the RTC. Since 17 | // its frequency is way off, a corrective ratio is necessary to compute the 18 | // real time. Since it may vary from box to box, it is adjustable by the 19 | // "Clk Speed" configuration menu. 20 | // This value is unused if a X32 is soldered on the board. 21 | 22 | #define RTC_DEF_CLK_RATIO 33425 23 | 24 | #define RTC_MIN_CLOCK_RATIO 30000 25 | #define RTC_MAX_CLOCK_RATIO 35000 26 | 27 | //------------------------------------------------------------------------- 28 | // Spare registers usage 29 | //------------------------------------------------------------------------- 30 | 31 | #define RTCSPARE_REF_DATE 0 32 | #define RTCSPARE_VV_BASE 1 33 | #define RTCSPARE_VV_MJOULES 2 34 | 35 | //========================================================================= 36 | // When the RTC is driven by the LIRC, a "second" of the RTC is approx 37 | // 3.3 real seconds, but we'd like the clock to display with a correct 38 | // second tick. The correction value is driven by the 1kHZ TMR2 and reset 39 | // by the RTC tick. 40 | // This value is unused if a X32 is soldered on the board. 41 | 42 | extern volatile int32_t ClockCorrection; 43 | 44 | //========================================================================= 45 | // Functions 46 | 47 | extern void RTCStart( S_RTC_TIME_DATA_T *d ); 48 | extern void GetRTC( S_RTC_TIME_DATA_T *rtd ); 49 | extern void SetRTC( S_RTC_TIME_DATA_T *rtd ); 50 | 51 | extern void RTCWriteRegister( uint32_t r, uint32_t v ); 52 | extern uint32_t RTCReadRegister( uint32_t r ); 53 | 54 | extern void RTCTimeToEpoch( time_t *t, const S_RTC_TIME_DATA_T *d ); 55 | extern void RTCEpochToTime( S_RTC_TIME_DATA_T *d, const time_t *t ); 56 | 57 | extern void RTCSetClockSpeed( const unsigned int cs ); 58 | extern unsigned int RTCGetClockSpeed(); 59 | extern void RTCAdjustClock( int seconds ); 60 | 61 | extern void RTCSleep(); 62 | extern void RTCWakeUp(); 63 | 64 | extern time_t RTCGetEpoch( time_t *t ); 65 | 66 | //========================================================================= 67 | 68 | #endif /* __MERTC_H__ */ 69 | 70 | -------------------------------------------------------------------------------- /inc/screens.h: -------------------------------------------------------------------------------- 1 | #ifndef __SCREENS__ 2 | #define __SCREENS__ 3 | 4 | //============================================================================== 5 | 6 | #define BLINKITEM(i) ((EditModeTimer)&&(!gFlags.draw_edited_item)&&(EditItemIndex==(i))) 7 | 8 | //============================================================================== 9 | 10 | extern uint8_t Screen; 11 | extern uint16_t ScreenDuration; 12 | extern uint16_t ScreenRefreshTimer; 13 | 14 | extern uint8_t HideLogo; 15 | extern uint8_t ShowWeakBatFlag; 16 | extern uint8_t BatAnimLevel; 17 | extern uint8_t ShowProfNum; 18 | extern uint8_t SplashTimer; 19 | 20 | extern uint8_t EditItemIndex; 21 | extern uint16_t EditModeTimer; 22 | 23 | extern const uint8_t ScrSaveTimes[8]; 24 | extern const uint8_t ScrMainTimes[6]; 25 | 26 | extern void DrawClock(); 27 | extern void DrawDigitClock(); 28 | 29 | enum { 30 | SSAVER_NONE = 0, 31 | SSAVER_CLOCK, 32 | SSAVER_3D, 33 | SSAVER_LOGO, 34 | SSAVER_QIX, 35 | SSAVER_SNOW, 36 | SSAVER_SPLASH, 37 | SSAVER_MAX 38 | }; 39 | 40 | //============================================================================== 41 | 42 | extern void DrawScreen(); 43 | extern void ShowMainView(); 44 | extern void ShowBattery(); 45 | extern void ShowBatCharging(); 46 | extern void ShowBattVolts(); 47 | extern void ShowBoardTemp(); 48 | extern void ShowVersion(); 49 | extern void ShowNewCoil(); 50 | extern void ShowTCRSet(); 51 | extern void ShowStealthMode(); 52 | extern void ShowDevTooHot(); 53 | extern void ShowAtoLow(); 54 | extern void ShowAtoShort(); 55 | extern void ShowBatLow(); 56 | extern void ShowBatLowLock(); 57 | extern void ShowKeyLock(); 58 | extern void ShowKeyUnLock(); 59 | extern void ShowNoAtoFound(); 60 | extern void Show10sProtec(); 61 | extern void ShowWeakBat(); 62 | extern void ShowInfos(); 63 | extern void ShowContrast(); 64 | extern void ShowMenus(); 65 | extern void ShowRTCSpeed(); 66 | extern void ShowRTCAdjust(); 67 | extern void ShowScreenSaver(); 68 | extern void ShowSetTime(); 69 | extern void ShowSetDate(); 70 | extern void ShowCheckBattery(); 71 | extern void ShowCheckUSB(); 72 | extern void ShowChargeError(); 73 | extern void ShowImbBatts(); 74 | extern void ShowPowerCurve(); 75 | extern void ShowSplash(); 76 | 77 | extern void ShowFireDuration( int line ); 78 | 79 | extern uint16_t GetScreenProtection(); 80 | extern uint16_t GetMainScreenDuration(); 81 | extern void SetScreen( int screen, int duration ); 82 | 83 | //============================================================================== 84 | 85 | extern void MainView(); 86 | extern void ChargeView(); 87 | extern void AnimateScreenSaver(); 88 | extern int IsClockOnScreen(); 89 | extern int IsMenuScreen(); 90 | extern int SplashExists(); 91 | 92 | 93 | //============================================================================== 94 | // Strings 95 | 96 | extern const uint8_t String_ON[]; 97 | extern const uint8_t String_No[]; 98 | extern const uint8_t String_On[]; 99 | extern const uint8_t String_Key[]; 100 | extern const uint8_t String_OFF[]; 101 | extern const uint8_t String_Low[]; 102 | extern const uint8_t String_Off[]; 103 | extern const uint8_t String_Lock[]; 104 | extern const uint8_t String_UnLock[]; 105 | extern const uint8_t String_Protection[]; 106 | extern const uint8_t String_Version[]; 107 | extern const uint8_t String_Device[]; 108 | extern const uint8_t String_TooHot[]; 109 | extern const uint8_t String_Stealth[]; 110 | extern const uint8_t String_Temp[]; 111 | extern const uint8_t String_Battery[]; 112 | extern const uint8_t String_Atomizer[]; 113 | extern const uint8_t String_Found[]; 114 | extern const uint8_t String_Short[]; 115 | extern const uint8_t String_LongFire[]; 116 | extern const uint8_t String_NewCoil[]; 117 | extern const uint8_t String_SameCoil[]; 118 | extern const uint8_t String_Right[]; 119 | extern const uint8_t String_Left[]; 120 | extern const uint8_t String_Logo[]; 121 | extern const uint8_t String_Game[]; 122 | extern const uint8_t String_Easy[]; 123 | extern const uint8_t String_Normal[]; 124 | extern const uint8_t String_Hard[]; 125 | extern const uint8_t String_Exit[]; 126 | extern const uint8_t String_Back[]; 127 | extern const uint8_t String_NI[]; 128 | extern const uint8_t String_TI[]; 129 | extern const uint8_t String_SS[]; 130 | extern const uint8_t String_BF_s[]; 131 | extern const uint8_t String_TCR[]; 132 | extern const uint8_t String_PWR_s[]; 133 | extern const uint8_t String_AMP_s[]; 134 | extern const uint8_t String_MAX_s[]; 135 | extern const uint8_t String_MIN_s[]; 136 | extern const uint8_t String_Weak[]; 137 | extern const uint8_t String_TEMP[]; 138 | extern const uint8_t String_TCRSet[]; 139 | extern const uint8_t String_POWER[]; 140 | extern const uint8_t String_BYPASS[]; 141 | extern const uint8_t String_VOLT_s[]; 142 | extern const uint8_t String_COIL_s[]; 143 | extern const uint8_t String_TIME_s[]; 144 | extern const uint8_t String_PUFF_s[]; 145 | extern const uint8_t String_SMART[]; 146 | extern const uint8_t String_End[]; 147 | 148 | //------------------------------------------------------------------------- 149 | 150 | // from mainview.c 151 | extern const uint8_t String_BATT_s[]; 152 | extern const uint8_t String_VOUT_s[]; 153 | extern const uint8_t String_TEMP_s[]; 154 | extern const uint8_t String_BOARD_s[]; 155 | extern const uint8_t String_RES_s[]; 156 | extern const uint8_t String_LIQ_s[]; 157 | 158 | // from screens.c 159 | extern const uint8_t String_Contrast[]; 160 | extern const uint8_t String_Fireto[]; 161 | extern const uint8_t String_Edit[]; 162 | extern const uint8_t String_ClkSpeed[]; 163 | extern const uint8_t String_ClkAdjust[]; 164 | extern const uint8_t String_myevic[]; 165 | extern const uint8_t String_Build[]; 166 | extern const uint8_t String_mld[]; 167 | extern const uint8_t String_ml[]; 168 | extern const uint8_t String_Check[]; 169 | extern const uint8_t String_Adapter[]; 170 | extern const uint8_t String_Charge[]; 171 | extern const uint8_t String_Error[]; 172 | extern const uint8_t String_Imbalanced[]; 173 | extern const uint8_t String_Batteries[]; 174 | extern const uint8_t String_BALANCE_s[]; 175 | extern const uint8_t String_BAL_s[]; 176 | 177 | // from menus.c 178 | extern const uint8_t String_Menus[]; 179 | extern const uint8_t String_Modes[]; 180 | extern const uint8_t String_TEMP_NI_s[]; 181 | extern const uint8_t String_TEMP_TI_s[]; 182 | extern const uint8_t String_TEMP_SS_s[]; 183 | extern const uint8_t String_TCR_s[]; 184 | extern const uint8_t String_POWER_s[]; 185 | extern const uint8_t String_BYPASS_s[]; 186 | extern const uint8_t String_SMART_s[]; 187 | extern const uint8_t String_Coils[]; 188 | extern const uint8_t String_Zero_All[]; 189 | extern const uint8_t String_Miscs[]; 190 | extern const uint8_t String_DateTime[]; 191 | extern const uint8_t String_Cancel[]; 192 | extern const uint8_t String_Save[]; 193 | extern const uint8_t String_Clock[]; 194 | extern const uint8_t String_3D[]; 195 | extern const uint8_t String_Cube[]; 196 | extern const uint8_t String_Qix[]; 197 | extern const uint8_t String_None[]; 198 | extern const uint8_t String_Screen[]; 199 | extern const uint8_t String_Min[]; 200 | extern const uint8_t String_VCOM[]; 201 | extern const uint8_t String_Expert[]; 202 | extern const uint8_t String_USB[]; 203 | extern const uint8_t String_HID[]; 204 | extern const uint8_t String_COM[]; 205 | extern const uint8_t String_DSK[]; 206 | extern const uint8_t String_DBG[]; 207 | extern const uint8_t String_X32[]; 208 | extern const uint8_t String_NFE[]; 209 | extern const uint8_t String_Saver[]; 210 | extern const uint8_t String_Preheat[]; 211 | extern const uint8_t String_Time[]; 212 | extern const uint8_t String_Pwr[]; 213 | extern const uint8_t String_Manage[]; 214 | extern const uint8_t String_Unit[]; 215 | extern const uint8_t String_Main[]; 216 | extern const uint8_t String_Interface[]; 217 | extern const uint8_t String_BattPC[]; 218 | extern const uint8_t String_1Watt[]; 219 | extern const uint8_t String_1C5F[]; 220 | extern const uint8_t String_Font[]; 221 | extern const uint8_t String_Date[]; 222 | extern const uint8_t String_SetTime[]; 223 | extern const uint8_t String_SetDate[]; 224 | extern const uint8_t String_WakeMP[]; 225 | extern const uint8_t String_2[]; 226 | extern const uint8_t String_3[]; 227 | extern const uint8_t String_4[]; 228 | extern const uint8_t String_OnOff[]; 229 | extern const uint8_t String_ModePlus[]; 230 | extern const uint8_t String_PPwr[]; 231 | extern const uint8_t String_Clicks[]; 232 | extern const uint8_t String_BAT[]; 233 | extern const uint8_t String_GEN[]; 234 | extern const uint8_t String_25R[]; 235 | extern const uint8_t String_HG2[]; 236 | extern const uint8_t String_HE4[]; 237 | extern const uint8_t String_30Q[]; 238 | extern const uint8_t String_VT4[]; 239 | extern const uint8_t String_VT5[]; 240 | extern const uint8_t String_VT6[]; 241 | extern const uint8_t String_CUS[]; 242 | extern const uint8_t String_Vaping[]; 243 | extern const uint8_t String_Prot[]; 244 | extern const uint8_t String_Snow[]; 245 | extern const uint8_t String_Fmt[]; 246 | extern const uint8_t String_DMY1[]; 247 | extern const uint8_t String_DMY2[]; 248 | extern const uint8_t String_MDY[]; 249 | extern const uint8_t String_YMD[]; 250 | extern const uint8_t String_Dial[]; 251 | extern const uint8_t String_Invert[]; 252 | extern const uint8_t String_SHR[]; 253 | extern const uint8_t String_Tetra[]; 254 | extern const uint8_t String_Vaped[]; 255 | extern const uint8_t String_BVO[]; 256 | extern const uint8_t String_mlkJ[]; 257 | extern const uint8_t String_LSL[]; 258 | extern const uint8_t String_Show[]; 259 | extern const uint8_t String_Where[]; 260 | extern const uint8_t String_Top[]; 261 | extern const uint8_t String_Mid[]; 262 | extern const uint8_t String_Size[]; 263 | extern const uint8_t String_hms[]; 264 | extern const uint8_t String_HM[]; 265 | extern const uint8_t String_Octa[]; 266 | extern const uint8_t String_Dodeca[]; 267 | extern const uint8_t String_Isoca[]; 268 | extern const uint8_t String_B1[]; 269 | extern const uint8_t String_B2[]; 270 | extern const uint8_t String_B3[]; 271 | extern const uint8_t String_B4[]; 272 | extern const uint8_t String_M1[]; 273 | extern const uint8_t String_M2[]; 274 | extern const uint8_t String_M3[]; 275 | extern const uint8_t String_DEF[]; 276 | extern const uint8_t String_UCH[]; 277 | extern const uint8_t String_Algo[]; 278 | extern const uint8_t String_Auto[]; 279 | extern const uint8_t String_Sweet[]; 280 | extern const uint8_t String_Boost[]; 281 | extern const uint8_t String_PID[]; 282 | extern const uint8_t String_P[]; 283 | extern const uint8_t String_I[]; 284 | extern const uint8_t String_D[]; 285 | extern const uint8_t String_Yes[]; 286 | extern const uint8_t String_Led[]; 287 | extern const uint8_t String_Red[]; 288 | extern const uint8_t String_Green[]; 289 | extern const uint8_t String_Blue[]; 290 | extern const uint8_t String_Delay[]; 291 | extern const uint8_t String_Profile[]; 292 | extern const uint8_t String_TC[]; 293 | extern const uint8_t String_PW[]; 294 | extern const uint8_t String_BY[]; 295 | extern const uint8_t String_SM[]; 296 | extern const uint8_t String_ProfPlus[]; 297 | extern const uint8_t String_Curve[]; 298 | extern const uint8_t String_Enable[]; 299 | extern const uint8_t String_Reset[]; 300 | extern const uint8_t String_Splash[]; 301 | 302 | 303 | //============================================================================== 304 | 305 | #endif 306 | -------------------------------------------------------------------------------- /inc/storage.h: -------------------------------------------------------------------------------- 1 | #ifndef __STORAGE_H__ 2 | #define __STORAGE_H__ 3 | 4 | #include "myevic.h" 5 | #include "meusbd.h" 6 | 7 | //========================================================================= 8 | 9 | #define MSC_INTERFACE 2 10 | 11 | /*! ROM 60 | 61 | . = ALIGN(4); 62 | Data_Start_ROM = .; 63 | 64 | .data : AT (Data_Start_ROM) { 65 | Data_Start_RAM = .; 66 | *(vtable) 67 | *(.data*) 68 | 69 | . = ALIGN(4); 70 | Data_End_RAM = .; 71 | } > RAM 72 | 73 | Data_Size = Data_End_RAM - Data_Start_RAM; 74 | 75 | .sram : { 76 | SRAMZ_Start = .; 77 | 78 | . = ALIGN(4); 79 | *(COMMON) 80 | *(.bss*) 81 | 82 | end = .; 83 | 84 | . = ALIGN(8); 85 | *(.stack) 86 | 87 | SRAMZ_End = .; 88 | } > RAM 89 | 90 | SRAMZ_Size = SRAMZ_End - SRAMZ_Start; 91 | 92 | .text : { 93 | . = ALIGN(4); 94 | RAMInitTable = .; 95 | 96 | LONG(Data_Start_ROM) 97 | LONG(Data_Start_RAM) 98 | LONG(Data_Size) 99 | 100 | LONG(SRAMZ_Start) 101 | LONG(SRAMZ_Start) 102 | LONG(SRAMZ_Size) 103 | 104 | RAMInitEnd = .; 105 | 106 | } > ROM 107 | } 108 | -------------------------------------------------------------------------------- /src/SSD1306.c: -------------------------------------------------------------------------------- 1 | #include "myevic.h" 2 | #include "dataflash.h" 3 | #include "timers.h" 4 | #include "display.h" 5 | 6 | 7 | //========================================================================= 8 | //----- (00005714) -------------------------------------------------------- 9 | __myevic__ void SSD1306_Refresh() 10 | { 11 | uint8_t *sb; 12 | 13 | sb = ScreenBuffer; 14 | 15 | for ( int l = 0 ; l < 0x10 ; ++l ) 16 | { 17 | DisplaySendCommand( 0xB0 + l ); 18 | DisplaySendCommand( 0 ); 19 | DisplaySendCommand( ( dfStatus.flipped ) ? 0x12 : 0x10 ); 20 | DisplaySendData( sb, 0x40 ); 21 | sb += 0x40; 22 | } 23 | } 24 | 25 | 26 | //========================================================================= 27 | //----- (000055D8) -------------------------------------------------------- 28 | __myevic__ void SSD1306_ClearBuffer() 29 | { 30 | uint8_t *v0; 31 | int v1; 32 | int v2; 33 | 34 | v0 = ScreenBuffer; 35 | v1 = 0; 36 | do 37 | { 38 | v2 = 0; 39 | do 40 | { 41 | ++v2; 42 | *v0++ = 0; 43 | } 44 | while ( v2 < 0x40 ); 45 | ++v1; 46 | } 47 | while ( v1 < 0x10 ); 48 | } 49 | 50 | 51 | //========================================================================= 52 | //----- (00005594) -------------------------------------------------------- 53 | __myevic__ void SSD1306_CLS() 54 | { 55 | SSD1306_ClearBuffer(); 56 | SSD1306_Refresh(); 57 | } 58 | 59 | 60 | //========================================================================= 61 | //----- (000055A4) -------------------------------------------------------- 62 | __myevic__ void SSD1306_PowerOn() 63 | { 64 | PA1 = 1; 65 | PC4 = 1; 66 | WaitOnTMR2( 1 ); 67 | PA0 = 0; 68 | WaitOnTMR2( 1 ); 69 | PA0 = 1; 70 | WaitOnTMR2( 10 ); 71 | } 72 | 73 | 74 | //========================================================================= 75 | 76 | const uint8_t SSD1306_InitSeq[] = 77 | { 0xAE, 78 | 0xA8, 79 | 0x3F, 80 | 0xD5, 81 | 0xF1, 82 | 0xC8, 83 | 0xD3, 84 | 0x20, 85 | 0xDC, 86 | 0x00, 87 | 0x20, 88 | 0x81, 89 | 0x2F, 90 | 0xA1, 91 | 0xA4, 92 | 0xA6, 93 | 0xAD, 94 | 0x8A, 95 | 0xD9, 96 | 0x22, 97 | 0xDB, 98 | 0x35 }; 99 | 100 | //----- (00005530) -------------------------------------------------------- 101 | __myevic__ void SSD1306_Init() 102 | { 103 | SSD1306_PowerOn(); 104 | 105 | for ( int i = 0 ; i < sizeof( SSD1306_InitSeq ) ; ++i ) 106 | { 107 | DisplaySendCommand( SSD1306_InitSeq[i] ); 108 | } 109 | 110 | if ( dfStatus.flipped ) 111 | { 112 | DisplaySendCommand( 0xC0 ); 113 | DisplaySendCommand( 0xD3 ); 114 | DisplaySendCommand( 0x60 ); 115 | DisplaySendCommand( 0xDC ); 116 | DisplaySendCommand( 0x20 ); 117 | DisplaySendCommand( 0xA0 ); 118 | } 119 | 120 | SSD1306_CLS(); 121 | DisplaySendCommand( 0xAF ); 122 | WaitOnTMR2( 20 ); 123 | } 124 | 125 | 126 | //========================================================================= 127 | __myevic__ void SSD1306_SetContrast( const uint8_t c ) 128 | { 129 | DisplaySendCommand( 0x81 ); 130 | DisplaySendCommand( c ); 131 | } 132 | 133 | 134 | //========================================================================= 135 | __myevic__ void SSD1306_SetInverse( const uint8_t i ) 136 | { 137 | DisplaySendCommand( i ? 0xA7 : 0xA6 ); 138 | } 139 | 140 | 141 | //========================================================================= 142 | //----- (000056E0) -------------------------------------------------------- 143 | __myevic__ void SSD1306_ScreenOff() 144 | { 145 | DisplaySendCommand( 0xAE ); 146 | PC4 = 0; 147 | WaitOnTMR2( 100 ); 148 | PA1 = 0; 149 | WaitOnTMR2( 100 ); 150 | PA0 = 0; 151 | WaitOnTMR2( 100 ); 152 | } 153 | 154 | 155 | //========================================================================= 156 | //----- (00005500) -------------------------------------------------------- 157 | __myevic__ void SSD1306_Plot( int x, int y, int color ) 158 | { 159 | uint8_t mask; 160 | uint32_t i; 161 | 162 | if (( x < 0 ) || ( x > 63 )) return; 163 | if (( y < 0 ) || ( y > 127 )) return; 164 | 165 | mask = 1 << ( y & 7 ); 166 | i = x + ( ( y & ~7 ) << 3 ); 167 | 168 | if ( color == 1 ) 169 | { 170 | ScreenBuffer[i] |= mask; 171 | } 172 | else if ( color == 0 ) 173 | { 174 | ScreenBuffer[i] &= ~mask; 175 | } 176 | else 177 | { 178 | ScreenBuffer[i] ^= mask; 179 | } 180 | } 181 | 182 | 183 | //========================================================================= 184 | //----- (000055FC) -------------------------------------------------------- 185 | __myevic__ uint32_t SSD1306_Image( int x, int y, uint8_t img, int color ) 186 | { 187 | if ( img == 0x88 || img == 0x8B || img == 0x91 || img == 0x92 || img == 0x9A ) 188 | { 189 | y += 2; 190 | } 191 | return SSD1306_Bitmap( x, y, Images[img - 1], color ); 192 | } 193 | 194 | 195 | //========================================================================= 196 | //----- (00005628) -------------------------------------------------------- 197 | __myevic__ uint32_t SSD1306_Bitmap( int x, int y, const image_t *image, int color ) 198 | { 199 | uint32_t shift; 200 | uint32_t h, w; 201 | uint32_t bm_ptr; 202 | uint32_t addr; 203 | uint32_t lines; 204 | uint8_t pixels; 205 | 206 | shift = y & 7; 207 | 208 | bm_ptr = 0; 209 | 210 | lines = image->height >> 3; 211 | 212 | for ( h = 0 ; h < lines ; ++h ) 213 | { 214 | addr = 0x40 * ( ( y >> 3 ) + h ) + x; 215 | 216 | for ( w = 0 ; w < image->width ; ++w ) 217 | { 218 | pixels = image->bitmap[bm_ptr++]; 219 | 220 | if ( color ) pixels = ~pixels; 221 | 222 | if ( shift ) 223 | { 224 | if ( addr < SCREEN_BUFFER_SIZE ) 225 | { 226 | ScreenBuffer[ addr ] &= ByteMaskRight[shift]; 227 | ScreenBuffer[ addr ] |= ( pixels << shift ) & ByteMaskLeft[shift]; 228 | } 229 | if ( addr + 0x40 < SCREEN_BUFFER_SIZE ) 230 | { 231 | ScreenBuffer[ addr + 0x40 ] &= ByteMaskLeft[shift]; 232 | ScreenBuffer[ addr + 0x40 ] |= ( pixels >> ( 8 - shift )) & ByteMaskRight[shift]; 233 | } 234 | } 235 | else 236 | { 237 | if ( addr < SCREEN_BUFFER_SIZE ) 238 | { 239 | ScreenBuffer[ addr ] = pixels; 240 | } 241 | } 242 | 243 | ++addr; 244 | } 245 | } 246 | 247 | return image->width; 248 | } 249 | 250 | 251 | //========================================================================= 252 | //----- (000064C8) -------------------------------------------------------- 253 | __myevic__ void SSD1306_WriteBytes( const int isData, const uint8_t data[], const int len ) 254 | { 255 | register int is_data = ( isData == 0x40 ); 256 | register int byte; 257 | 258 | PE10 = is_data ? 1 : 0; 259 | 260 | for ( int l = 0 ; l < len ; ++l ) 261 | { 262 | byte = data[l]; 263 | while ( SPI_IS_BUSY( SPI0 ) ) 264 | ; 265 | SPI_WRITE_TX( SPI0, byte ); 266 | } 267 | while ( SPI_IS_BUSY( SPI0 ) ) 268 | ; 269 | } 270 | 271 | 272 | //========================================================================= 273 | __myevic__ void SSD1306_Screen2Bitmap( uint8_t *pu8Bitmap ) 274 | { 275 | MemClear( pu8Bitmap, SCREEN_BUFFER_SIZE ); 276 | 277 | for ( int line = 0 ; line < 16 ; ++line ) 278 | { 279 | for ( int bit = 0 ; bit < 8 ; ++bit ) 280 | { 281 | int y = line * 8 + bit; 282 | int mask = 1 << bit; 283 | for ( int x = 0 ; x < 64 ; ++x ) 284 | { 285 | if ( ScreenBuffer[ line * 64 + x ] & mask ) 286 | { 287 | pu8Bitmap[ y * 8 + ( x >> 3 ) ] |= ( 0x80 >> ( x & 7 ) ); 288 | } 289 | } 290 | } 291 | } 292 | } 293 | 294 | -------------------------------------------------------------------------------- /src/SSD1327.c: -------------------------------------------------------------------------------- 1 | #include "myevic.h" 2 | #include "dataflash.h" 3 | #include "timers.h" 4 | #include "display.h" 5 | 6 | 7 | //========================================================================= 8 | //----- (000017B0) -------------------------------------------------------- 9 | __myevic__ void SSD1327_SetColsRowsAddrs(char col_start, char col_end, char row_start, char row_end) 10 | { 11 | DisplaySendCommand( 0x15 ); 12 | DisplaySendCommand( col_start ); 13 | DisplaySendCommand( col_end ); 14 | DisplaySendCommand( 0x75 ); 15 | DisplaySendCommand( row_start ); 16 | DisplaySendCommand( row_end ); 17 | } 18 | 19 | 20 | //========================================================================= 21 | //----- (000054E0) -------------------------------------------------------- 22 | __myevic__ void SSD1327_Refresh() 23 | { 24 | SSD1327_SetColsRowsAddrs( 16, 47, 0, 127 ); 25 | DisplaySendData( ScreenBuffer, 0x400 ); 26 | } 27 | 28 | 29 | //========================================================================= 30 | //----- (00005320) -------------------------------------------------------- 31 | __myevic__ void SSD1327_ClearBuffer() 32 | { 33 | for ( int i = 0 ; i < 0x400 ; ++i ) 34 | { 35 | ScreenBuffer[i] = 0; 36 | } 37 | } 38 | 39 | 40 | //========================================================================= 41 | //----- (000052E4) -------------------------------------------------------- 42 | __myevic__ void SSD1327_CLS() 43 | { 44 | SSD1327_ClearBuffer(); 45 | SSD1327_Refresh(); 46 | } 47 | 48 | 49 | //========================================================================= 50 | //----- (000052F4) -------------------------------------------------------- 51 | __myevic__ void SSD1327_PowerOn() 52 | { 53 | PA1 = 1; 54 | WaitOnTMR2( 1 ); 55 | PA0 = 0; 56 | WaitOnTMR2( 10 ); 57 | PA0 = 1; 58 | WaitOnTMR2( 1 ); 59 | } 60 | 61 | 62 | //========================================================================= 63 | 64 | const uint8_t SSD1327_InitSeq[] = 65 | { 0xAE, 66 | 0xA0, 67 | 0x40, 68 | 0xA1, 69 | 0x00, 70 | 0xA2, 71 | 0x00, 72 | 0xA4, 73 | 0xA8, 74 | 0x7F, 75 | 0xAB, 76 | 0x01, 77 | 0x81, 78 | 0xA6, 79 | 0xB1, 80 | 0x31, 81 | 0xB3, 82 | 0xB1, 83 | 0xB4, 84 | 0xB5, 85 | 0xB6, 86 | 0x0D, 87 | 0xBC, 88 | 0x07, 89 | 0xBE, 90 | 0x07, 91 | 0xD5, 92 | 0x02 }; 93 | 94 | //----- (00005280) -------------------------------------------------------- 95 | __myevic__ void SSD1327_Init() 96 | { 97 | SSD1327_PowerOn(); 98 | 99 | for ( int i = 0 ; i < sizeof( SSD1327_InitSeq ) ; ++i ) 100 | { 101 | DisplaySendCommand( SSD1327_InitSeq[i] ); 102 | } 103 | 104 | if ( dfStatus.flipped ) 105 | { 106 | DisplaySendCommand( 0xA2 ); 107 | DisplaySendCommand( 0x80 ); 108 | DisplaySendCommand( 0xA0 ); 109 | DisplaySendCommand( 0x53 ); 110 | } 111 | 112 | SSD1327_CLS(); 113 | 114 | PC4 = 1; 115 | WaitOnTMR2( 1 ); 116 | DisplaySendCommand( 0xAF ); 117 | WaitOnTMR2( 20 ); 118 | } 119 | 120 | 121 | //========================================================================= 122 | __myevic__ void SSD1327_SetContrast( const uint8_t c ) 123 | { 124 | DisplaySendCommand( 0x81 ); 125 | DisplaySendCommand( c ); 126 | } 127 | 128 | 129 | //========================================================================= 130 | __myevic__ void SSD1327_SetInverse( const uint8_t i ) 131 | { 132 | DisplaySendCommand( i ? 0xA7 : 0xA4 ); 133 | } 134 | 135 | 136 | //========================================================================= 137 | //----- (000054AC) -------------------------------------------------------- 138 | __myevic__ void SSD1327_ScreenOff() 139 | { 140 | DisplaySendCommand( 0xAE ); 141 | PC4 = 0; 142 | WaitOnTMR2( 100 ); 143 | PA1 = 0; 144 | WaitOnTMR2( 100 ); 145 | PA0 = 0; 146 | WaitOnTMR2( 100 ); 147 | } 148 | 149 | 150 | //========================================================================= 151 | //----- (00005258) -------------------------------------------------------- 152 | __myevic__ void SSD1327_Plot( int x, int y, int color ) 153 | { 154 | uint8_t mask; 155 | uint32_t i; 156 | 157 | if (( x < 0 ) || ( x > 63 )) return; 158 | if (( y < 0 ) || ( y > 127 )) return; 159 | 160 | mask = 1 << ( 7 - ( x & 7 )); 161 | i = 8 * y + ( x >> 3 ); 162 | 163 | if ( color == 1 ) 164 | { 165 | ScreenBuffer[i] |= mask; 166 | } 167 | else if ( color == 0 ) 168 | { 169 | ScreenBuffer[i] &= ~mask; 170 | } 171 | else 172 | { 173 | ScreenBuffer[i] ^= mask; 174 | } 175 | } 176 | 177 | 178 | //========================================================================= 179 | //----- (0000533C) -------------------------------------------------------- 180 | __myevic__ uint32_t SSD1327_Image( int x, int y, uint8_t img, int color ) 181 | { 182 | if ( img == 0x88 || img == 0x8B || img == 0x91 || img == 0x92 || img == 0x9A ) 183 | { 184 | y += 2; 185 | } 186 | return SSD1327_Bitmap( x, y, Images[img - 1], color ); 187 | } 188 | 189 | 190 | //========================================================================= 191 | // Modified SSD1327 Bitmap drawing function to draw SSD1306 Bitmaps. 192 | //------------------------------------------------------------------------- 193 | __myevic__ uint32_t SSD1327_Bitmap( int x, int y, const image_t *image, int color ) 194 | { 195 | int sblinebase, sbi; 196 | uint8_t sbbyte; 197 | 198 | const uint8_t *pixline; 199 | uint8_t bitline; 200 | uint8_t pixel; 201 | 202 | int h; 203 | h = ( y < 0 ) ? -y : 0; 204 | 205 | sblinebase = ( ( y + h ) << 3 ) + ( x >> 3 ); 206 | 207 | pixline = &image->bitmap[ ( h << 3 ) * image->width ]; 208 | bitline = h & 7; 209 | 210 | for ( ; h < image->height ; ++h ) 211 | { 212 | if ( y + h >= 128 ) 213 | break; 214 | 215 | sbi = sblinebase; 216 | 217 | uint8_t pixmask = ( 1 << ( 7 - ( x & 7 ) ) ); 218 | uint8_t bitmask = ( 1 << bitline ); 219 | 220 | int w; 221 | w = ( x < 0 ) ? -x : 0; 222 | 223 | for ( ; w < image->width; ++w ) 224 | { 225 | if ( x + w >= 64 ) 226 | break; 227 | 228 | sbbyte = ScreenBuffer[sbi]; 229 | sbbyte &= ~pixmask; 230 | 231 | pixel = pixline[w]; 232 | if ( color ) pixel = ~pixel; 233 | pixel &= bitmask; 234 | 235 | ScreenBuffer[sbi] = sbbyte | ( pixel ? pixmask : 0 ); 236 | 237 | pixmask >>= 1; 238 | if ( !pixmask ) 239 | { 240 | pixmask = 0x80; 241 | ++sbi; 242 | } 243 | } 244 | 245 | sblinebase += 8; 246 | 247 | if ( ++bitline == 8 ) 248 | { 249 | bitline = 0; 250 | pixline += image->width; 251 | } 252 | } 253 | 254 | return image->width; 255 | } 256 | 257 | 258 | //========================================================================= 259 | //----- (00006444) -------------------------------------------------------- 260 | __myevic__ void SSD1327_WriteBytes( const int isData, const uint8_t data[], const int len ) 261 | { 262 | register int is_data; 263 | unsigned int pairs; 264 | unsigned int mask; 265 | uint8_t d; 266 | uint8_t byte; 267 | 268 | is_data = ( isData == 0x40 ); 269 | 270 | PE10 = is_data ? 1 : 0; 271 | 272 | for ( int l = 0 ; l < len ; ++l ) 273 | { 274 | d = data[l]; 275 | 276 | if ( is_data ) 277 | { 278 | for ( pairs = 0 ; pairs < 4 ; ++pairs ) 279 | { 280 | mask = ( 1 << ( 7 - 2 * pairs )); 281 | byte = 0x00; 282 | if ( d & mask ) byte = 0x0F; 283 | if ( d & ( mask >> 1 )) byte |= 0xF0; 284 | 285 | SPI_WRITE_TX( SPI0, byte ); 286 | while ( SPI_IS_BUSY( SPI0 ) ) 287 | ; 288 | } 289 | } 290 | else 291 | { 292 | SPI_WRITE_TX( SPI0, d ); 293 | while ( SPI_IS_BUSY( SPI0 ) ) 294 | ; 295 | } 296 | } 297 | } 298 | 299 | 300 | //========================================================================= 301 | // Advantage: SSD1327! 302 | //------------------------------------------------------------------------- 303 | __myevic__ void SSD1327_Screen2Bitmap( uint8_t *pu8Bitmap ) 304 | { 305 | MemCpy( pu8Bitmap, ScreenBuffer, SCREEN_BUFFER_SIZE ); 306 | } 307 | 308 | -------------------------------------------------------------------------------- /src/fbdata.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //========================================================================= 5 | // Sprites and font data for Flappy Bird 6 | //------------------------------------------------------------------------- 7 | 8 | const uint8_t fbColumnBody[] = 9 | { 10 | 0b00011000, 0b00000000, 0b00011000, 11 | 0b01011000, 0b00000000, 0b00011000, 12 | 0b01011000, 0b00000000, 0b00011000, 13 | 0b01011000, 0b00000000, 0b00011000, 14 | 0b00011000, 0b00000000, 0b00011000, 15 | 0b01011000, 0b00000000, 0b00011000, 16 | 0b01011000, 0b00000000, 0b00011000, 17 | 0b00011000, 0b00000000, 0b00011000 18 | }; 19 | 20 | const uint8_t fbColumnBottom[] = 21 | { 22 | 0b11111110, 0b11111111, 0b01111111, 23 | 0b11111110, 0b11111111, 0b01111111, 24 | 0b00000110, 0b00000000, 0b01100000, 25 | 0b00000110, 0b00000000, 0b01100000, 26 | 0b00000110, 0b00000000, 0b01100000, 27 | 0b11111110, 0b11111111, 0b01111111, 28 | 0b11111110, 0b11111111, 0b01111111, 29 | 0b00000000, 0b00000000, 0b00000000 30 | }; 31 | 32 | const uint8_t fbColumnTop[] = 33 | { 34 | 0b00000000, 0b00000000, 0b00000000, 35 | 0b11111110, 0b11111111, 0b01111111, 36 | 0b11111110, 0b11111111, 0b01111111, 37 | 0b00000110, 0b00000000, 0b01100000, 38 | 0b00000110, 0b00000000, 0b01100000, 39 | 0b00000110, 0b00000000, 0b01100000, 40 | 0b11111110, 0b11111111, 0b01111111, 41 | 0b11111110, 0b11111111, 0b01111111 42 | }; 43 | 44 | const uint8_t fbBird0[] = 45 | { 46 | 0b00000000, 0b00000000, 47 | 0b11000000, 0b00001111, 48 | 0b00110000, 0b00010010, 49 | 0b00001000, 0b00100001, 50 | 0b00000100, 0b01010001, 51 | 0b00000100, 0b01010001, 52 | 0b01111110, 0b01000010, 53 | 0b01000001, 0b01111100, 54 | 0b00100001, 0b10000010, 55 | 0b00010001, 0b01111101, 56 | 0b00001110, 0b01000010, 57 | 0b00011000, 0b00111100, 58 | 0b11100000, 0b00000011, 59 | 0b00000000, 0b00000000, 60 | 0b00000000, 0b00000000, 61 | 0b00000000, 0b00000000 62 | }; 63 | 64 | const uint8_t fbBird1[] = 65 | { 66 | 0b00000000, 0b00000000, 67 | 0b11000000, 0b00001111, 68 | 0b00110000, 0b00010010, 69 | 0b00001000, 0b00100001, 70 | 0b00000100, 0b01010001, 71 | 0b00111110, 0b01010001, 72 | 0b01000001, 0b01000010, 73 | 0b01000001, 0b01111100, 74 | 0b00111110, 0b10000010, 75 | 0b00000100, 0b01111101, 76 | 0b00000100, 0b01000010, 77 | 0b00011000, 0b00111100, 78 | 0b11100000, 0b00000011, 79 | 0b00000000, 0b00000000, 80 | 0b00000000, 0b00000000, 81 | 0b00000000, 0b00000000 82 | }; 83 | 84 | const uint8_t fbBird2[] = 85 | { 86 | 0b00000000, 0b00000000, 87 | 0b11000000, 0b00001111, 88 | 0b00110000, 0b00010010, 89 | 0b00001000, 0b00100001, 90 | 0b00011110, 0b01010001, 91 | 0b00100001, 0b01010001, 92 | 0b01000001, 0b01000010, 93 | 0b01000001, 0b01111100, 94 | 0b01000010, 0b10000010, 95 | 0b00111100, 0b01111101, 96 | 0b00000100, 0b01000010, 97 | 0b00011000, 0b00111100, 98 | 0b11100000, 0b00000011, 99 | 0b00000000, 0b00000000, 100 | 0b00000000, 0b00000000, 101 | 0b00000000, 0b00000000 102 | }; 103 | 104 | const uint8_t fbBirdDead[] = 105 | { 106 | 0b00000000, 0b00000011, 107 | 0b10000000, 0b00000100, 108 | 0b11100000, 0b00001100, 109 | 0b10010000, 0b00010100, 110 | 0b10010000, 0b00100100, 111 | 0b10001000, 0b00100100, 112 | 0b00001000, 0b01000011, 113 | 0b00001000, 0b01000000, 114 | 0b01001000, 0b01011100, 115 | 0b10101000, 0b01100010, 116 | 0b01010000, 0b01000001, 117 | 0b01010000, 0b01000001, 118 | 0b01010000, 0b00101101, 119 | 0b01010000, 0b00010001, 120 | 0b01100000, 0b00001111, 121 | 0b10000000, 0b00000000 122 | }; 123 | 124 | const uint8_t fbFont[95][16] = 125 | { 126 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 127 | { 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00 }, 128 | { 0x00, 0x48, 0x6C, 0x24, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 129 | { 0x00, 0x00, 0x00, 0x24, 0x24, 0x24, 0x7F, 0x12, 0x12, 0x12, 0x7F, 0x12, 0x12, 0x12, 0x00, 0x00 }, 130 | { 0x00, 0x00, 0x08, 0x1C, 0x2A, 0x2A, 0x0A, 0x0C, 0x18, 0x28, 0x28, 0x2A, 0x2A, 0x1C, 0x08, 0x08 }, 131 | { 0x00, 0x00, 0x00, 0x22, 0x25, 0x15, 0x15, 0x15, 0x2A, 0x58, 0x54, 0x54, 0x54, 0x22, 0x00, 0x00 }, 132 | { 0x00, 0x00, 0x00, 0x0C, 0x12, 0x12, 0x12, 0x0A, 0x76, 0x25, 0x29, 0x11, 0x91, 0x6E, 0x00, 0x00 }, 133 | { 0x00, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 134 | { 0x00, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x00 }, 135 | { 0x00, 0x02, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x02, 0x00 }, 136 | { 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x1C, 0x1C, 0x6B, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00 }, 137 | { 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x7F, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00 }, 138 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x04, 0x03 }, 139 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 140 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00 }, 141 | { 0x00, 0x00, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x00 }, 142 | { 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00 }, 143 | { 0x00, 0x00, 0x00, 0x08, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, 144 | { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x20, 0x20, 0x10, 0x08, 0x04, 0x42, 0x7E, 0x00, 0x00 }, 145 | { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x20, 0x18, 0x20, 0x40, 0x40, 0x42, 0x22, 0x1C, 0x00, 0x00 }, 146 | { 0x00, 0x00, 0x00, 0x20, 0x30, 0x28, 0x24, 0x24, 0x22, 0x22, 0x7E, 0x20, 0x20, 0x78, 0x00, 0x00 }, 147 | { 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x02, 0x1A, 0x26, 0x40, 0x40, 0x42, 0x22, 0x1C, 0x00, 0x00 }, 148 | { 0x00, 0x00, 0x00, 0x38, 0x24, 0x02, 0x02, 0x1A, 0x26, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00 }, 149 | { 0x00, 0x00, 0x00, 0x7E, 0x22, 0x22, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00 }, 150 | { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x24, 0x18, 0x24, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00 }, 151 | { 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x64, 0x58, 0x40, 0x40, 0x24, 0x1C, 0x00, 0x00 }, 152 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00 }, 153 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x04 }, 154 | { 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00 }, 155 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00 }, 156 | { 0x00, 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00 }, 157 | { 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x46, 0x40, 0x20, 0x10, 0x10, 0x00, 0x18, 0x18, 0x00, 0x00 }, 158 | { 0x00, 0x00, 0x00, 0x1C, 0x22, 0x5A, 0x55, 0x55, 0x55, 0x55, 0x2D, 0x42, 0x22, 0x1C, 0x00, 0x00 }, 159 | { 0x00, 0x00, 0x00, 0x08, 0x08, 0x18, 0x14, 0x14, 0x24, 0x3C, 0x22, 0x42, 0x42, 0xE7, 0x00, 0x00 }, 160 | { 0x00, 0x00, 0x00, 0x1F, 0x22, 0x22, 0x22, 0x1E, 0x22, 0x42, 0x42, 0x42, 0x22, 0x1F, 0x00, 0x00 }, 161 | { 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x01, 0x01, 0x01, 0x01, 0x01, 0x42, 0x22, 0x1C, 0x00, 0x00 }, 162 | { 0x00, 0x00, 0x00, 0x1F, 0x22, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x22, 0x1F, 0x00, 0x00 }, 163 | { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x12, 0x12, 0x1E, 0x12, 0x12, 0x02, 0x42, 0x42, 0x3F, 0x00, 0x00 }, 164 | { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x12, 0x12, 0x1E, 0x12, 0x12, 0x02, 0x02, 0x02, 0x07, 0x00, 0x00 }, 165 | { 0x00, 0x00, 0x00, 0x3C, 0x22, 0x22, 0x01, 0x01, 0x01, 0x71, 0x21, 0x22, 0x22, 0x1C, 0x00, 0x00 }, 166 | { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00 }, 167 | { 0x00, 0x00, 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, 168 | { 0x00, 0x00, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x0F }, 169 | { 0x00, 0x00, 0x00, 0x77, 0x22, 0x12, 0x0A, 0x0E, 0x0A, 0x12, 0x12, 0x22, 0x22, 0x77, 0x00, 0x00 }, 170 | { 0x00, 0x00, 0x00, 0x07, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x42, 0x7F, 0x00, 0x00 }, 171 | { 0x00, 0x00, 0x00, 0x77, 0x36, 0x36, 0x36, 0x36, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x6B, 0x00, 0x00 }, 172 | { 0x00, 0x00, 0x00, 0xE3, 0x46, 0x46, 0x4A, 0x4A, 0x52, 0x52, 0x52, 0x62, 0x62, 0x47, 0x00, 0x00 }, 173 | { 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1C, 0x00, 0x00 }, 174 | { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x42, 0x42, 0x42, 0x3E, 0x02, 0x02, 0x02, 0x02, 0x07, 0x00, 0x00 }, 175 | { 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x4D, 0x53, 0x32, 0x1C, 0x60, 0x00 }, 176 | { 0x00, 0x00, 0x00, 0x3F, 0x42, 0x42, 0x42, 0x3E, 0x12, 0x12, 0x22, 0x22, 0x42, 0xC7, 0x00, 0x00 }, 177 | { 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x02, 0x04, 0x18, 0x20, 0x40, 0x42, 0x42, 0x3E, 0x00, 0x00 }, 178 | { 0x00, 0x00, 0x00, 0x7F, 0x49, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00 }, 179 | { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00 }, 180 | { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x22, 0x24, 0x24, 0x14, 0x14, 0x18, 0x08, 0x08, 0x00, 0x00 }, 181 | { 0x00, 0x00, 0x00, 0x6B, 0x49, 0x49, 0x49, 0x49, 0x55, 0x55, 0x36, 0x22, 0x22, 0x22, 0x00, 0x00 }, 182 | { 0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x18, 0x18, 0x18, 0x24, 0x24, 0x42, 0xE7, 0x00, 0x00 }, 183 | { 0x00, 0x00, 0x00, 0x77, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00 }, 184 | { 0x00, 0x00, 0x00, 0x7E, 0x21, 0x20, 0x10, 0x10, 0x08, 0x04, 0x04, 0x42, 0x42, 0x3F, 0x00, 0x00 }, 185 | { 0x00, 0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00 }, 186 | { 0x00, 0x00, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x20, 0x40, 0x40 }, 187 | { 0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1E, 0x00 }, 188 | { 0x00, 0x38, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 189 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF }, 190 | { 0x00, 0x06, 0x06, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 191 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x78, 0x44, 0x42, 0x42, 0xFC, 0x00, 0x00 }, 192 | { 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x1A, 0x26, 0x42, 0x42, 0x42, 0x26, 0x1A, 0x00, 0x00 }, 193 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x02, 0x02, 0x02, 0x44, 0x38, 0x00, 0x00 }, 194 | { 0x00, 0x00, 0x00, 0x60, 0x40, 0x40, 0x40, 0x78, 0x44, 0x42, 0x42, 0x42, 0x64, 0xD8, 0x00, 0x00 }, 195 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x7E, 0x02, 0x02, 0x42, 0x3C, 0x00, 0x00 }, 196 | { 0x00, 0x00, 0x00, 0xF0, 0x88, 0x08, 0x08, 0x7E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, 197 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x22, 0x22, 0x1C, 0x02, 0x3C, 0x42, 0x42, 0x3C }, 198 | { 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x3A, 0x46, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00 }, 199 | { 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, 200 | { 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x1E }, 201 | { 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x72, 0x12, 0x0A, 0x16, 0x12, 0x22, 0x77, 0x00, 0x00 }, 202 | { 0x00, 0x00, 0x00, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00 }, 203 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x92, 0x92, 0x92, 0x92, 0x92, 0xB7, 0x00, 0x00 }, 204 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, 0x46, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00 }, 205 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00 }, 206 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x26, 0x42, 0x42, 0x42, 0x22, 0x1E, 0x02, 0x07 }, 207 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x42, 0x44, 0x78, 0x40, 0xE0 }, 208 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x4C, 0x04, 0x04, 0x04, 0x04, 0x1F, 0x00, 0x00 }, 209 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x02, 0x3C, 0x40, 0x42, 0x3E, 0x00, 0x00 }, 210 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x30, 0x00, 0x00 }, 211 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x42, 0x42, 0x42, 0x42, 0x62, 0xDC, 0x00, 0x00 }, 212 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x14, 0x08, 0x08, 0x00, 0x00 }, 213 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEB, 0x49, 0x49, 0x55, 0x55, 0x22, 0x22, 0x00, 0x00 }, 214 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x24, 0x18, 0x18, 0x18, 0x24, 0x6E, 0x00, 0x00 }, 215 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x14, 0x18, 0x08, 0x08, 0x07 }, 216 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x22, 0x10, 0x08, 0x08, 0x44, 0x7E, 0x00, 0x00 }, 217 | { 0x00, 0xC0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xC0, 0x00 }, 218 | { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 }, 219 | { 0x00, 0x06, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x06, 0x00 }, 220 | { 0x0C, 0x32, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } 221 | }; 222 | 223 | -------------------------------------------------------------------------------- /src/meadc.c: -------------------------------------------------------------------------------- 1 | #include "myevic.h" 2 | #include "timers.h" 3 | 4 | 5 | //============================================================================= 6 | 7 | volatile uint32_t ADC00_IRQ_Flag; 8 | 9 | //============================================================================= 10 | //----- (00000558) -------------------------------------------------------- 11 | __myevic__ void ADC00_IRQHandler() 12 | { 13 | ADC00_IRQ_Flag = 1; 14 | EADC_CLR_INT_FLAG( EADC, 1 << 0 ); 15 | } 16 | 17 | 18 | //============================================================================= 19 | __myevic__ void InitEADC() 20 | { 21 | if ( ISCUBO200 || ISRX200S || ISRX23 || ISRX300 ) 22 | { 23 | // Configure PB.0 - PB.7 analog input pins 24 | SYS->GPB_MFPL &= ~(SYS_GPB_MFPL_PB0MFP_Msk | SYS_GPB_MFPL_PB1MFP_Msk | 25 | SYS_GPB_MFPL_PB2MFP_Msk | SYS_GPB_MFPL_PB3MFP_Msk | 26 | SYS_GPB_MFPL_PB4MFP_Msk | SYS_GPB_MFPL_PB5MFP_Msk | 27 | SYS_GPB_MFPL_PB6MFP_Msk | SYS_GPB_MFPL_PB7MFP_Msk); 28 | 29 | SYS->GPB_MFPL |= (SYS_GPB_MFPL_PB0MFP_EADC_CH0 | SYS_GPB_MFPL_PB1MFP_EADC_CH1 | 30 | SYS_GPB_MFPL_PB2MFP_EADC_CH2 | SYS_GPB_MFPL_PB3MFP_EADC_CH3 | 31 | SYS_GPB_MFPL_PB4MFP_EADC_CH4 | SYS_GPB_MFPL_PB5MFP_EADC_CH13 | 32 | SYS_GPB_MFPL_PB6MFP_EADC_CH14 | SYS_GPB_MFPL_PB7MFP_EADC_CH15); 33 | 34 | // Disable PB.0 - PB.7 digital input paths to avoid leakage currents 35 | GPIO_DISABLE_DIGITAL_PATH( PB, 0xFF ); 36 | } 37 | else if ( ISEGRIPII || ISEVICAIO ) 38 | { 39 | // Configure PB.0,1,2,6 analog input pins 40 | SYS->GPB_MFPL &= ~(SYS_GPB_MFPL_PB0MFP_Msk | SYS_GPB_MFPL_PB1MFP_Msk | 41 | SYS_GPB_MFPL_PB2MFP_Msk | 42 | SYS_GPB_MFPL_PB6MFP_Msk ); 43 | 44 | SYS->GPB_MFPL |= (SYS_GPB_MFPL_PB0MFP_EADC_CH0 | SYS_GPB_MFPL_PB1MFP_EADC_CH1 | 45 | SYS_GPB_MFPL_PB2MFP_EADC_CH2 | 46 | SYS_GPB_MFPL_PB6MFP_EADC_CH14 ); 47 | 48 | // Disable PB.0,1,2,6 digital input paths to avoid leakage currents 49 | GPIO_DISABLE_DIGITAL_PATH( PB, 0x47 ); 50 | } 51 | else 52 | { 53 | // Configure PB.0 - PB.6 analog input pins 54 | SYS->GPB_MFPL &= ~(SYS_GPB_MFPL_PB0MFP_Msk | SYS_GPB_MFPL_PB1MFP_Msk | 55 | SYS_GPB_MFPL_PB2MFP_Msk | SYS_GPB_MFPL_PB3MFP_Msk | 56 | SYS_GPB_MFPL_PB4MFP_Msk | SYS_GPB_MFPL_PB5MFP_Msk | 57 | SYS_GPB_MFPL_PB6MFP_Msk ); 58 | 59 | SYS->GPB_MFPL |= (SYS_GPB_MFPL_PB0MFP_EADC_CH0 | SYS_GPB_MFPL_PB1MFP_EADC_CH1 | 60 | SYS_GPB_MFPL_PB2MFP_EADC_CH2 | SYS_GPB_MFPL_PB3MFP_EADC_CH3 | 61 | SYS_GPB_MFPL_PB4MFP_EADC_CH4 | SYS_GPB_MFPL_PB5MFP_EADC_CH13 | 62 | SYS_GPB_MFPL_PB6MFP_EADC_CH14); 63 | 64 | // Disable PB.0 - PB.6 digital input paths to avoid leakage currents 65 | GPIO_DISABLE_DIGITAL_PATH( PB, 0x7F ); 66 | } 67 | } 68 | 69 | 70 | //============================================================================= 71 | 72 | __myevic__ void SetADCState( uint32_t module, int onoff ) 73 | { 74 | uint32_t pin, mode; 75 | 76 | switch ( module ) 77 | { 78 | case 0: 79 | pin = GPIO_PIN_PIN0_Msk; 80 | 81 | SYS->GPB_MFPL &= ~SYS_GPB_MFPL_PB0MFP_Msk; 82 | 83 | if ( onoff ) 84 | { 85 | SYS->GPB_MFPL |= SYS_GPB_MFPL_PB0MFP_EADC_CH0; 86 | } 87 | else 88 | { 89 | PB0 = 0; 90 | } 91 | break; 92 | 93 | case 1: 94 | pin = GPIO_PIN_PIN1_Msk; 95 | 96 | SYS->GPB_MFPL &= ~SYS_GPB_MFPL_PB1MFP_Msk; 97 | 98 | if ( onoff ) 99 | { 100 | SYS->GPB_MFPL |= SYS_GPB_MFPL_PB1MFP_EADC_CH1; 101 | } 102 | else 103 | { 104 | PB1 = 0; 105 | } 106 | break; 107 | 108 | case 2: 109 | pin = GPIO_PIN_PIN2_Msk; 110 | 111 | SYS->GPB_MFPL &= ~SYS_GPB_MFPL_PB2MFP_Msk; 112 | 113 | if ( onoff ) 114 | { 115 | SYS->GPB_MFPL |= SYS_GPB_MFPL_PB2MFP_EADC_CH2; 116 | } 117 | else 118 | { 119 | PB2 = 0; 120 | } 121 | break; 122 | 123 | case 3: 124 | pin = GPIO_PIN_PIN3_Msk; 125 | 126 | SYS->GPB_MFPL &= ~SYS_GPB_MFPL_PB3MFP_Msk; 127 | 128 | if ( onoff ) 129 | { 130 | SYS->GPB_MFPL |= SYS_GPB_MFPL_PB3MFP_EADC_CH3; 131 | } 132 | else 133 | { 134 | PB3 = 0; 135 | } 136 | break; 137 | 138 | case 4: 139 | pin = GPIO_PIN_PIN4_Msk; 140 | 141 | SYS->GPB_MFPL &= ~SYS_GPB_MFPL_PB4MFP_Msk; 142 | 143 | if ( onoff ) 144 | { 145 | SYS->GPB_MFPL |= SYS_GPB_MFPL_PB4MFP_EADC_CH4; 146 | } 147 | else 148 | { 149 | PB4 = 0; 150 | } 151 | break; 152 | 153 | case 13: 154 | pin = GPIO_PIN_PIN5_Msk; 155 | 156 | SYS->GPB_MFPL &= ~SYS_GPB_MFPL_PB5MFP_Msk; 157 | 158 | if ( onoff ) 159 | { 160 | SYS->GPB_MFPL |= SYS_GPB_MFPL_PB5MFP_EADC_CH13; 161 | } 162 | else 163 | { 164 | PB5 = 0; 165 | } 166 | break; 167 | 168 | case 14: 169 | pin = GPIO_PIN_PIN6_Msk; 170 | 171 | SYS->GPB_MFPL &= ~SYS_GPB_MFPL_PB6MFP_Msk; 172 | 173 | if ( onoff ) 174 | { 175 | SYS->GPB_MFPL |= SYS_GPB_MFPL_PB6MFP_EADC_CH14; 176 | } 177 | else 178 | { 179 | PB6 = 0; 180 | } 181 | break; 182 | 183 | case 15: 184 | pin = GPIO_PIN_PIN7_Msk; 185 | 186 | SYS->GPB_MFPL &= ~SYS_GPB_MFPL_PB7MFP_Msk; 187 | 188 | if ( onoff ) 189 | { 190 | SYS->GPB_MFPL |= SYS_GPB_MFPL_PB7MFP_EADC_CH15; 191 | } 192 | else 193 | { 194 | PB7 = 0; 195 | } 196 | break; 197 | 198 | default: 199 | return; 200 | } 201 | 202 | mode = onoff ? GPIO_MODE_INPUT : GPIO_MODE_OUTPUT; 203 | 204 | GPIO_SetMode( PB, pin, mode ); 205 | } 206 | 207 | 208 | //========================================================================= 209 | //----- (0000184C) -------------------------------------------------------- 210 | // Average total conversion time: 329 ticks (4.57us) 211 | //------------------------------------------------------------------------- 212 | __myevic__ uint32_t ADC_Read( uint32_t module ) 213 | { 214 | uint32_t result; 215 | // Total conversion time 15+6=21 ADC_CLK = 2.33us 216 | EADC_Open( EADC, EADC_CTL_DIFFEN_SINGLE_END ); 217 | EADC_SetInternalSampleTime( EADC, 6 ); // 0.67 us 218 | EADC_ConfigSampleModule( EADC, module, EADC_SOFTWARE_TRIGGER, module ); 219 | 220 | EADC_CLR_INT_FLAG( EADC, 1 << 0 ); 221 | EADC_ENABLE_INT( EADC, 1 << 0 ); 222 | EADC_ENABLE_SAMPLE_MODULE_INT( EADC, 0, 1 << module ); 223 | NVIC_EnableIRQ( ADC00_IRQn ); 224 | 225 | ADC00_IRQ_Flag = 0; 226 | EADC_START_CONV( EADC, 1 << module ); 227 | while ( !ADC00_IRQ_Flag ) 228 | ; 229 | 230 | EADC_DISABLE_INT( EADC, 1 << 0 ); 231 | result = EADC_GET_CONV_DATA( EADC, module ); 232 | 233 | return result; 234 | } 235 | -------------------------------------------------------------------------------- /src/megpio.c: -------------------------------------------------------------------------------- 1 | #include "myevic.h" 2 | #include "dataflash.h" 3 | #include "events.h" 4 | #include "atomizer.h" 5 | #include "battery.h" 6 | 7 | 8 | //========================================================================= 9 | //----- (000022EC) -------------------------------------------------------- 10 | __myevic__ void GPD_IRQHandler() 11 | { 12 | if ( GPIO_GET_INT_FLAG( PD, GPIO_PIN_PIN7_Msk ) ) 13 | { 14 | GPIO_CLR_INT_FLAG( PD, GPIO_PIN_PIN7_Msk ); 15 | 16 | if ( gFlags.usb_attached ) 17 | { 18 | BattProbeCount = 1; 19 | 20 | if ( gFlags.battery_charging ) 21 | { 22 | Event = 13; 23 | } 24 | } 25 | } 26 | else if ( GPIO_GET_INT_FLAG( PD, GPIO_PIN_PIN1_Msk ) ) 27 | { 28 | GPIO_CLR_INT_FLAG( PD, GPIO_PIN_PIN1_Msk ); 29 | 30 | if ( gFlags.usb_attached && ( NumBatteries == 1 ) && ( BatteryVoltage >= 414 ) ) 31 | { 32 | BattProbeCount = 1; 33 | 34 | if ( gFlags.battery_charging ) 35 | { 36 | Event = 13; 37 | } 38 | } 39 | } 40 | else if ( GPIO_GET_INT_FLAG( PD, GPIO_PIN_PIN0_Msk ) ) 41 | { 42 | GPIO_CLR_INT_FLAG( PD, GPIO_PIN_PIN0_Msk ); 43 | 44 | if ( ISPRESA75W || ISVTCDUAL || ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 || ISPRIMO1 || ISPRIMO2 || ISPREDATOR ) 45 | { 46 | if ( gFlags.firing || gFlags.probing_ato ) 47 | { 48 | if ( Event != 28 ) 49 | { 50 | Event = 28; 51 | StopFire(); 52 | } 53 | } 54 | } 55 | } 56 | else if ( GPIO_GET_INT_FLAG( PD, GPIO_PIN_PIN2_Msk|GPIO_PIN_PIN3_Msk ) ) 57 | { 58 | GPIO_CLR_INT_FLAG( PD, GPIO_PIN_PIN2_Msk|GPIO_PIN_PIN3_Msk ); 59 | 60 | if ( dfStatus.wakeonpm ) 61 | { 62 | gFlags.wake_up = 1; 63 | } 64 | } 65 | else 66 | { 67 | PD->INTSRC = PD->INTSRC; 68 | } 69 | } 70 | 71 | //----- (00002334) -------------------------------------------------------- 72 | __myevic__ void GPE_IRQHandler() 73 | { 74 | if ( GPIO_GET_INT_FLAG( PE, GPIO_PIN_PIN0_Msk ) ) 75 | { 76 | GPIO_CLR_INT_FLAG( PE, GPIO_PIN_PIN0_Msk ); 77 | 78 | gFlags.wake_up = 1; 79 | } 80 | else 81 | { 82 | PE->INTSRC = PE->INTSRC; 83 | } 84 | } 85 | 86 | //----- (00002342) -------------------------------------------------------- 87 | __myevic__ void GPF_IRQHandler() 88 | { 89 | PF->INTSRC = PF->INTSRC; 90 | } 91 | 92 | 93 | //========================================================================= 94 | //----- (00002384) -------------------------------------------------------- 95 | __myevic__ void InitGPIO() 96 | { 97 | if ( ISVTCDUAL ) 98 | { 99 | PA3 = 0; 100 | GPIO_SetMode( PA, GPIO_PIN_PIN3_Msk, GPIO_MODE_OUTPUT ); 101 | } 102 | 103 | if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 ) 104 | { 105 | SYS->GPF_MFPL &= ~SYS_GPF_MFPL_PF0MFP_Msk; 106 | SYS->GPF_MFPL |= SYS_GPF_MFPL_PF0MFP_GPIO; 107 | PF0 = 0; 108 | GPIO_SetMode( PF, GPIO_PIN_PIN0_Msk, GPIO_MODE_OUTPUT ); 109 | } 110 | 111 | if ( ISPRIMO1 || ISPRIMO2 || ISPREDATOR ) 112 | { 113 | //? 114 | //SYS->GPD_MFPL &= ~SYS_GPD_MFPL_PD1MFP_Msk; 115 | //SYS->GPD_MFPL |= SYS_GPD_MFPL_PD1MFP_GPIO; 116 | PD1 = 0; 117 | GPIO_SetMode( PD, GPIO_PIN_PIN1_Msk, GPIO_MODE_OUTPUT ); 118 | } 119 | 120 | // PD1 = Data transmitter output pin for UART0 121 | #if (ENABLE_UART) 122 | SYS->GPD_MFPL |= SYS_GPD_MFPL_PD1MFP_UART0_TXD; 123 | #endif 124 | 125 | if ( ISRX300 || ISPRIMO1 || ISPRIMO2 || ISPRIMOMINI || ISPREDATOR ) 126 | { 127 | SYS->GPD_MFPL &= ~(SYS_GPD_MFPL_PD0MFP_Msk|SYS_GPD_MFPL_PD1MFP_Msk); 128 | SYS->GPD_MFPL |= SYS_GPD_MFPL_PD0MFP_GPIO|SYS_GPD_MFPL_PD1MFP_GPIO; 129 | } 130 | 131 | // PC0 = PWM0 CH0 132 | BBC_Configure( BBC_PWMCH_BUCK, 1 ); 133 | // PC2 = PWM0 CH2 134 | BBC_Configure( BBC_PWMCH_BOOST, 1 ); 135 | 136 | if ( ISVTCDUAL || ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 || ISPRIMO1 || ISPRIMO2 || ISPREDATOR ) 137 | { 138 | PD7 = 0; 139 | BBC_Configure( BBC_PWMCH_CHARGER, 0 ); 140 | PD7 = 0; 141 | } 142 | 143 | // BUTTONS 144 | GPIO_SetMode( PE, GPIO_PIN_PIN0_Msk, GPIO_MODE_INPUT ); 145 | GPIO_SetMode( PD, GPIO_PIN_PIN2_Msk, GPIO_MODE_INPUT ); 146 | GPIO_SetMode( PD, GPIO_PIN_PIN3_Msk, GPIO_MODE_INPUT ); 147 | 148 | if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 ) 149 | { 150 | PF2 = 1; 151 | GPIO_SetMode( PF, GPIO_PIN_PIN2_Msk, GPIO_MODE_OUTPUT ); 152 | } 153 | else if ( ISRX300 ) 154 | { 155 | SYS->GPF_MFPL &= ~(SYS_GPF_MFPL_PF5MFP_Msk|SYS_GPF_MFPL_PF6MFP_Msk); 156 | SYS->GPF_MFPL |= SYS_GPF_MFPL_PF5MFP_GPIO|SYS_GPF_MFPL_PF6MFP_GPIO; 157 | PF5 = 0; 158 | GPIO_SetMode( PF, GPIO_PIN_PIN5_Msk, GPIO_MODE_OUTPUT ); 159 | PF6 = 0; 160 | GPIO_SetMode( PF, GPIO_PIN_PIN6_Msk, GPIO_MODE_OUTPUT ); 161 | PA3 = 0; 162 | GPIO_SetMode( PA, GPIO_PIN_PIN3_Msk, GPIO_MODE_OUTPUT ); 163 | PA2 = 0; 164 | GPIO_SetMode( PA, GPIO_PIN_PIN2_Msk, GPIO_MODE_OUTPUT ); 165 | } 166 | else if ( ISPRIMO1 || ISPRIMO2 || ISPREDATOR ) 167 | { 168 | PA3 = 0; 169 | GPIO_SetMode( PA, GPIO_PIN_PIN3_Msk, GPIO_MODE_OUTPUT ); 170 | PA2 = 0; 171 | GPIO_SetMode( PA, GPIO_PIN_PIN2_Msk, GPIO_MODE_OUTPUT ); 172 | } 173 | 174 | // BUCK/BOOST CONVERTER CONTROL LINES 175 | PC1 = 0; 176 | GPIO_SetMode( PC, GPIO_PIN_PIN1_Msk, GPIO_MODE_OUTPUT ); 177 | PC3 = 0; 178 | GPIO_SetMode( PC, GPIO_PIN_PIN3_Msk, GPIO_MODE_OUTPUT ); 179 | 180 | // SSD RESET/VDD/VCC 181 | PA0 = 0; 182 | GPIO_SetMode( PA, GPIO_PIN_PIN0_Msk, GPIO_MODE_OUTPUT ); 183 | PA1 = 0; 184 | GPIO_SetMode( PA, GPIO_PIN_PIN1_Msk, GPIO_MODE_OUTPUT ); 185 | PC4 = 0; 186 | GPIO_SetMode( PC, GPIO_PIN_PIN4_Msk, GPIO_MODE_OUTPUT ); 187 | 188 | // BATTERY 189 | GPIO_SetMode( PD, GPIO_PIN_PIN0_Msk, GPIO_MODE_INPUT ); 190 | GPIO_EnableInt( PD, 0, GPIO_INT_FALLING ); 191 | if ( ISVTCDUAL ) 192 | { 193 | PA2 = 0; 194 | GPIO_SetMode( PA, GPIO_PIN_PIN2_Msk, GPIO_MODE_OUTPUT ); 195 | PF2 = 0; 196 | GPIO_SetMode( PF, GPIO_PIN_PIN2_Msk, GPIO_MODE_OUTPUT ); 197 | 198 | GPIO_SetMode( PD, GPIO_PIN_PIN1_Msk, GPIO_MODE_INPUT ); 199 | GPIO_EnableInt( PD, 1, GPIO_INT_RISING ); 200 | GPIO_ENABLE_DEBOUNCE( PD, GPIO_PIN_PIN1_Msk ); 201 | } 202 | else if ( !ISCUBOID && !ISCUBO200 && !ISRX200S && !ISRX23 && !ISRX300 && !ISPRIMO1 && !ISPRIMO2 && !ISPREDATOR ) 203 | { 204 | GPIO_SetMode( PD, GPIO_PIN_PIN7_Msk, GPIO_MODE_INPUT ); 205 | GPIO_EnableInt( PD, 7, GPIO_INT_RISING ); 206 | GPIO_ENABLE_DEBOUNCE( PD, GPIO_PIN_PIN7_Msk ); 207 | } 208 | 209 | // SPI0 (Display control) 210 | PE10 = 0; 211 | GPIO_SetMode( PE, GPIO_PIN_PIN10_Msk, GPIO_MODE_OUTPUT ); 212 | PE12 = 0; 213 | GPIO_SetMode( PE, GPIO_PIN_PIN12_Msk, GPIO_MODE_OUTPUT ); 214 | 215 | // LED Control 216 | if ( ISEGRIPII || ISEVICAIO ) 217 | { 218 | PB3 = 0; // Blue 219 | PB4 = 0; // Red 220 | PB5 = 0; // Green 221 | GPIO_SetMode( PB, GPIO_PIN_PIN3_Msk|GPIO_PIN_PIN4_Msk|GPIO_PIN_PIN5_Msk, GPIO_MODE_OUTPUT ); 222 | } 223 | 224 | if ( ISCUBO200 || ISRX200S || ISRX23 ) 225 | { 226 | SYS->GPF_MFPL &= ~SYS_GPF_MFPL_PF1MFP_Msk; 227 | SYS->GPF_MFPL |= SYS_GPF_MFPL_PF1MFP_GPIO; 228 | PF1 = 1; 229 | GPIO_SetMode( PF, GPIO_PIN_PIN1_Msk, GPIO_MODE_OUTPUT ); 230 | } 231 | else if ( ISRX300 ) 232 | { 233 | SYS->GPD_MFPL &= ~SYS_GPD_MFPL_PD1MFP_Msk; 234 | SYS->GPD_MFPL |= SYS_GPD_MFPL_PD1MFP_GPIO; 235 | PD1 = 1; 236 | GPIO_SetMode( PD, GPIO_PIN_PIN1_Msk, GPIO_MODE_OUTPUT ); 237 | } 238 | else 239 | { 240 | // ? (What is PB.7?) 241 | PB7 = 1; 242 | GPIO_SetMode( PB, GPIO_PIN_PIN7_Msk, GPIO_MODE_OUTPUT ); 243 | } 244 | 245 | NVIC_EnableIRQ( GPD_IRQn ); 246 | NVIC_EnableIRQ( GPE_IRQn ); 247 | NVIC_EnableIRQ( GPF_IRQn ); 248 | 249 | // Debounce time = 100ms 250 | GPIO_SET_DEBOUNCE_TIME( GPIO_DBCTL_DBCLKSRC_LIRC, GPIO_DBCTL_DBCLKSEL_1024 ); 251 | } 252 | 253 | 254 | #if (ENABLE_UART) 255 | 256 | //========================================================================= 257 | //----- (00006738) -------------------------------------------------------- 258 | __myevic__ void UART0_Cout( uint8_t c ) 259 | { 260 | UART_WAIT_TX_EMPTY( UART0 ); 261 | UART_WRITE( UART0, c ); 262 | 263 | if ( c == '\n' ) 264 | { 265 | UART_WAIT_TX_EMPTY( UART0 ); 266 | UART_WRITE( UART0, '\r' ); 267 | } 268 | } 269 | 270 | 271 | //========================================================================= 272 | __myevic__ char UART0_Putc( char c, FILE *out ) 273 | { 274 | UART0_Cout( (uint8_t)c ); 275 | return c; 276 | } 277 | 278 | 279 | //========================================================================= 280 | //----- (00007EF4) -------------------------------------------------------- 281 | __myevic__ void InitUART0() 282 | { 283 | SYS_ResetModule( UART0_RST ); 284 | UART_Open( UART0, 115200 ); 285 | 286 | myputc = (FPUTC_FUNC*)&UART0_Putc; 287 | } 288 | 289 | #endif 290 | -------------------------------------------------------------------------------- /src/myevic.s: -------------------------------------------------------------------------------- 1 | @ 2 | @ +-------------------------------------------------------------------------+ 3 | @ | This file has been generated by The Interactive Disassembler (IDA) | 4 | @ | Copyright (c) 2015 Hex-Rays, | 5 | @ | Doskey Lee, Kingsoft Internet Security Software | 6 | @ +-------------------------------------------------------------------------+ 7 | @ 8 | @ Input MD5 : 5366F56114EBD4C7FC252D3D56164D9D 9 | @ Input CRC32 : ACCB3046 10 | 11 | @ Format : Binary file 12 | 13 | @ Processor : ARM 14 | @ ARM architecture: ARMv7-M 15 | @ Target assembler: GNU assembler 16 | @ Byte sex : Little endian 17 | 18 | @ =========================================================================== 19 | 20 | .syntax unified 21 | 22 | @ =========================================================================== 23 | 24 | .section .isr_vectors 25 | 26 | .long Stack_Top 27 | .long Reset_Handler+1 28 | .long NMI_Handler+1 29 | .long HardFault_Handler+1 30 | .long MemManage_Handler+1 31 | .long BusFault_Handler+1 32 | .long UsageFault_Handler+1 33 | .long 0 34 | .long 0 35 | .long 0 36 | .long 0 37 | .long SVC_Handler+1 38 | .long DebugMon_Handler+1 39 | .long 0 40 | .long PendSV_Handler+1 41 | .long SysTick_Handler+1 42 | .long Default_Handler+1 @ 0 : Brown-Out Detector 43 | .long Default_Handler+1 @ 1 : Internal RC 44 | .long Default_Handler+1 @ 2 : Power down wake up 45 | .long Default_Handler+1 @ 3 : RAM parity error 46 | .long Default_Handler+1 @ 4 : Clock detection fail 47 | .long Default_Handler+1 @ 5 : Reserved 48 | .long RTC_IRQHandler+1 @ 6 : Real Time Clock 49 | .long Default_Handler+1 @ 7 : Backup register tamper interrupt 50 | .long Default_Handler+1 @ 8 : Watchdog timer 51 | .long Default_Handler+1 @ 9 : Window watchdog timer 52 | .long Default_Handler+1 @ 10 : External Input 0 53 | .long Default_Handler+1 @ 11 : External Input 1 54 | .long Default_Handler+1 @ 12 : External Input 2 55 | .long Default_Handler+1 @ 13 : External Input 3 56 | .long Default_Handler+1 @ 14 : External Input 4 57 | .long Default_Handler+1 @ 15 : External Input 5 58 | .long Default_Handler+1 @ 16 : GPIO Port A 59 | .long Default_Handler+1 @ 17 : GPIO Port B 60 | .long Default_Handler+1 @ 18 : GPIO Port C 61 | .long GPD_IRQHandler+1 @ 19 : GPIO Port D 62 | .long GPE_IRQHandler+1 @ 20 : GPIO Port E 63 | .long GPF_IRQHandler+1 @ 21 : GPIO Port F 64 | .long Default_Handler+1 @ 22 : SPI0 65 | .long Default_Handler+1 @ 23 : SPI1 66 | .long Default_Handler+1 @ 24 : PWM0 brake 67 | .long Default_Handler+1 @ 25 : PWM0 pair 0 68 | .long Default_Handler+1 @ 26 : PWM0 pair 1 69 | .long Default_Handler+1 @ 27 : PWM0 pair 2 70 | .long Default_Handler+1 @ 28 : PWM1 brake 71 | .long Default_Handler+1 @ 29 : PWM1 pair 0 72 | .long Default_Handler+1 @ 30 : PWM1 pair 1 73 | .long Default_Handler+1 @ 31 : PWM1 pair 2 74 | .long TMR0_IRQHandler+1 @ 32 : Timer 0 75 | .long TMR1_IRQHandler+1 @ 33 : Timer 1 76 | .long TMR2_IRQHandler+1 @ 34 : Timer 2 77 | .long TMR3_IRQHandler+1 @ 35 : Timer 3 78 | .long Default_Handler+1 @ 36 : UART0 79 | .long Default_Handler+1 @ 37 : UART1 80 | .long Default_Handler+1 @ 38 : I2C0 81 | .long Default_Handler+1 @ 39 : I2C1 82 | .long Default_Handler+1 @ 40 : Peripheral DMA 83 | .long Default_Handler+1 @ 41 : DAC 84 | .long ADC00_IRQHandler+1 @ 42 : ADC0 interrupt source 0 85 | .long Default_Handler+1 @ 43 : ADC0 interrupt source 1 86 | .long Default_Handler+1 @ 44 : ACMP0 and ACMP1 87 | .long Default_Handler+1 @ 45 : Reserved 88 | .long Default_Handler+1 @ 46 : ADC0 interrupt source 2 89 | .long Default_Handler+1 @ 47 : ADC0 interrupt source 3 90 | .long Default_Handler+1 @ 48 : UART2 91 | .long Default_Handler+1 @ 49 : UART3 92 | .long Default_Handler+1 @ 50 : Reserved 93 | .long Default_Handler+1 @ 51 : SPI2 94 | .long Default_Handler+1 @ 52 : Reserved 95 | .long USBD_IRQHandler+1 @ 53 : USB device 96 | .long Default_Handler+1 @ 54 : USB host 97 | .long Default_Handler+1 @ 55 : USB OTG 98 | .long Default_Handler+1 @ 56 : CAN0 99 | .long Default_Handler+1 @ 57 : Reserved 100 | .long Default_Handler+1 @ 58 : Smart card host 0 interrupt 101 | .long Default_Handler+1 @ 59 : Reserved 102 | .long Default_Handler+1 @ 60 : Reserved 103 | .long Default_Handler+1 @ 61 : Reserved 104 | .long Default_Handler+1 @ 62 : Reserved 105 | .long Default_Handler+1 @ 63 : Touch key interrupt 106 | 107 | @ =========================================================================== 108 | 109 | .section .stack 110 | 111 | .balign 8,0 112 | Stack_Bottom: .ds.b 0x1000 @ Stack space 113 | Stack_Top: 114 | 115 | 116 | @ =========================================================================== 117 | @ Segment type: Pure code 118 | 119 | .text 120 | .code 16 121 | 122 | @ =============== S U B R O U T I N E ======================================= 123 | 124 | .global Reset_Handler 125 | 126 | Reset_Handler: 127 | LDR R0, =0x40000100 @ SYS_REGLCTL 128 | MOV.W R1, #0x59 @ Unlock sequence 129 | STR R1, [R0] 130 | MOV.W R1, #0x16 131 | STR R1, [R0] 132 | MOV.W R1, #0x88 133 | STR R1, [R0] 134 | LDR R2, =0x40000024 @ SYS_PORCTL 135 | MOVW R1, #0x5AA5 @ POROFF 136 | STR R1, [R2] 137 | LDR R2, =0x40000200 138 | LDR R1, [R2] @ CLK_PWRCTL 139 | BIC.W R1, R1, #0x1000 @ HTX Crystal type INV 140 | STR R1, [R2] 141 | MOVS R1, #0 @ Lock registers 142 | STR R1, [R0] 143 | LDR R0, =(EnableFPU+1) 144 | BLX R0 @ EnableFPU 145 | LDR R0, =(Startup+1) 146 | BX R0 @ Startup 147 | 148 | .balign 4,0 149 | .pool 150 | 151 | @ End of function Reset_Handler 152 | 153 | @ =============== S U B R O U T I N E ======================================= 154 | 155 | EnableFPU: 156 | LDR R0, =0xE000ED88 157 | LDR R1, [R0] @ CPACR 158 | ORR.W R1, R1, #0x00F00000 159 | STR R1, [R0] @ Full access to coprocessors 10 & 11 160 | BX LR 161 | 162 | .balign 4,0 163 | .pool 164 | 165 | @ End of function EnableFPU 166 | @ --------------------------------------------------------------------------- 167 | 168 | 169 | @ =============== S U B R O U T I N E ======================================= 170 | @ Unused Handlers 171 | @ --------------------------------------------------------------------------- 172 | 173 | NMI_Handler: 174 | SVC_Handler: 175 | DebugMon_Handler: 176 | PendSV_Handler: 177 | SysTick_Handler: 178 | Default_Handler: 179 | 180 | B . 181 | 182 | 183 | @ =============== S U B R O U T I N E ======================================= 184 | 185 | 186 | Startup: @ ... 187 | ldr.w sp, =Stack_Top 188 | 189 | ldr r4, =RAMInitTable 190 | ldr r5, =RAMInitEnd 191 | 2: cmp r4, r5 192 | beq 1f 193 | ldmia r4!, {r0, r1, r2} 194 | cmp r0, r1 195 | beq 3f 196 | bl MemCpy2 197 | b 2b 198 | 3: bl MemClear2 199 | b 2b 200 | 1: 201 | ldr r0, =(Main+1) 202 | bx r0 203 | 204 | .balign 4,0 205 | .pool 206 | 207 | 208 | @ =============== S U B R O U T I N E ======================================= 209 | 210 | .global MemCpy 211 | 212 | MemCpy: 213 | ORR.W R3, R0, R1 214 | LSLS R3, R3, #30 215 | BEQ loc_200 216 | B loc_20E 217 | @ --------------------------------------------------------------------------- 218 | 219 | loc_1FA: 220 | LDMIA R1!, {R3} 221 | SUBS R2, R2, #4 222 | STMIA R0!, {R3} 223 | 224 | loc_200: 225 | CMP R2, #4 226 | BCS loc_1FA 227 | B loc_20E 228 | @ --------------------------------------------------------------------------- 229 | 230 | loc_206: 231 | LDRB.W R3, [R1],#1 232 | STRB.W R3, [R0],#1 233 | 234 | loc_20E: 235 | SUBS R2, R2, #1 236 | BCS loc_206 237 | BX LR 238 | 239 | @ End of function MemCpy 240 | 241 | 242 | @ =============== S U B R O U T I N E ======================================= 243 | 244 | .global MemSet2 245 | 246 | MemSet2: 247 | UXTB R2, R2 248 | B loc_21C 249 | @ --------------------------------------------------------------------------- 250 | 251 | loc_218: 252 | STRB.W R2, [R0],#1 253 | 254 | loc_21C: 255 | SUBS R1, R1, #1 256 | BCS loc_218 257 | BX LR 258 | 259 | @ End of function MemSet2 260 | 261 | 262 | @ =============== S U B R O U T I N E ======================================= 263 | 264 | .global MemClear 265 | 266 | MemClear: 267 | MOVS R2, #0 268 | B MemSet2 269 | 270 | @ End of function MemClear 271 | 272 | 273 | @ =============== S U B R O U T I N E ======================================= 274 | 275 | 276 | @ void *__fastcall MemSet(void *, char, unsigned int) 277 | 278 | .global MemSet 279 | 280 | MemSet: 281 | PUSH {R4,LR} 282 | MOV R3, R2 283 | MOV R2, R1 284 | MOV R4, R0 285 | MOV R1, R3 286 | BL MemSet2 287 | MOV R0, R4 288 | POP {R4,PC} 289 | 290 | @ End of function MemSet 291 | 292 | 293 | @ =============== S U B R O U T I N E ======================================= 294 | 295 | .global MemCpy2 296 | 297 | MemCpy2: 298 | B loc_8A7A 299 | @ --------------------------------------------------------------------------- 300 | 301 | loc_8A74: @ ... 302 | LDMIA R0!, {R3} 303 | SUBS R2, R2, #4 304 | STMIA R1!, {R3} 305 | 306 | loc_8A7A: @ ... 307 | CMP R2, #0 308 | BNE loc_8A74 309 | BX LR 310 | @ End of function MemCpy2 311 | 312 | 313 | @ =============== S U B R O U T I N E ======================================= 314 | 315 | .global MemClear2 316 | 317 | MemClear2: 318 | MOVS R0, #0 319 | B loc_8A8A 320 | @ --------------------------------------------------------------------------- 321 | 322 | loc_8A86: @ ... 323 | STMIA R1!, {R0} 324 | SUBS R2, R2, #4 325 | 326 | loc_8A8A: @ ... 327 | CMP R2, #0 328 | BNE loc_8A86 329 | BX LR 330 | @ End of function MemClear2 331 | 332 | 333 | @ =========================================================================== 334 | 335 | .section .myevic 336 | 337 | .global DrawHexDigit 338 | 339 | DrawHexDigit: 340 | and r2, #0xF 341 | add r2, #1 342 | cmp r2, #0xB 343 | blt 1f 344 | add r2, #0x5D 345 | 1: mov r3, #1 346 | b DrawImage 347 | 348 | .global DrawHexDigit2 349 | 350 | DrawHexDigit2: 351 | and r2, #0xF 352 | add r2, #0x1F 353 | cmp r2, #0x29 354 | blt 1f 355 | add r2, #0x73 356 | add r1, #2 357 | 1: mov r3, #1 358 | b DrawImage 359 | 360 | .global DrawHexLong 361 | 362 | DrawHexLong: 363 | push {r4-r8,lr} 364 | mov r5, r0 365 | mov r6, r1 366 | mov r7, r2 367 | mov r8, r3 368 | movs r4, #28 369 | 1: lsr r2, r4 370 | mov r3, r8 371 | cbz r3, 2f 372 | bl DrawHexDigit2 373 | add r5, #8 374 | b 3f 375 | 2: bl DrawHexDigit 376 | add r5, #6 377 | 3: mov r0, r5 378 | mov r1, r6 379 | mov r2, r7 380 | subs r4, #4 381 | bpl 1b 382 | pop {r4-r8,pc} 383 | 384 | 385 | @ --------------------------------------------------------------------------- 386 | @ BSOD 387 | 388 | HardFault_Handler: 389 | MemManage_Handler: 390 | BusFault_Handler: 391 | UsageFault_Handler: 392 | 393 | mov r0, #4 394 | mov r1, lr 395 | tst r0, r1 396 | beq 2f 397 | mrs r6, psp 398 | b 3f 399 | 2: mrs r6, msp 400 | 3: 401 | mrs r4, xpsr 402 | 403 | mov r0, r4 404 | mov r1, r6 405 | bl Plantouille 406 | b . 407 | 408 | 409 | @ --------------------------------------------------------------------------- 410 | @ ul sqrtul( ul ) 411 | 412 | .global sqrtul 413 | 414 | sqrtul: 415 | fmsr s0, r0 416 | fuitos s0, s0 417 | fsqrts s0, s0 418 | ftouis s0, s0 419 | fmrs r0, s0 420 | bx lr 421 | 422 | @ --------------------------------------------------------------------------- 423 | @ 424 | .global GetFirmwareSize 425 | 426 | GetFirmwareSize: 427 | ldr r2, =RAMInitTable 428 | ldr r0, [r2] 429 | ldr r1, [r2, #8] 430 | add r0, r1 431 | bx lr 432 | 433 | .balign 4,0 434 | .pool 435 | 436 | @ --------------------------------------------------------------------------- 437 | 438 | @ =========================================================================== 439 | .end 440 | 441 | -------------------------------------------------------------------------------- /src/myprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "myprintf.h" 6 | 7 | //========================================================================= 8 | 9 | FILE *stdout = 0; 10 | FPUTC_FUNC *myputc = 0; 11 | 12 | //========================================================================= 13 | // Supported formats: 14 | // %d, %u, %x, %X with optional sizing and padding (e.g. %08X, %5d) 15 | // Yes, this is minimalist - I warned you. 16 | //------------------------------------------------------------------------- 17 | 18 | #define FL_NULL 0 19 | #define FL_FORMAT 0x01 20 | #define FL_ZEROPAD 0x02 21 | #define FL_SIZED 0x04 22 | #define FL_UPCASE 0x08 23 | #define FL_HEX 0x10 24 | #define FL_DECIMAL 0x20 25 | #define FL_UNSIGNED 0x40 26 | 27 | int my_doprnt( const char *format, va_list ap, FILE *out ) 28 | { 29 | int sent; 30 | char c; 31 | int flags, size; 32 | 33 | sent = 0; 34 | flags = 0; 35 | size = 0; 36 | 37 | while ( ( c = *format++ ) ) 38 | { 39 | if ( flags == FL_NULL ) 40 | { 41 | switch ( c ) 42 | { 43 | case '%': 44 | flags |= FL_FORMAT; 45 | break; 46 | 47 | default: 48 | myputc( c, out ); 49 | ++sent; 50 | break; 51 | } 52 | } 53 | else if ( flags & FL_FORMAT ) 54 | { 55 | switch ( c ) 56 | { 57 | case '0': 58 | if ( size | ( flags & FL_ZEROPAD ) ) 59 | { 60 | size = size * 10; 61 | } 62 | else 63 | { 64 | flags |= FL_ZEROPAD; 65 | } 66 | break; 67 | 68 | case '%': 69 | myputc( c, out ); 70 | ++sent; 71 | flags = FL_NULL; 72 | break; 73 | 74 | case 'u': 75 | flags |= FL_UNSIGNED; 76 | case 'd': 77 | flags |= FL_DECIMAL; 78 | flags &= ~FL_FORMAT; 79 | break; 80 | 81 | case 'X': 82 | flags |= FL_UPCASE; 83 | case 'x': 84 | flags |= FL_HEX; 85 | flags &= ~FL_FORMAT; 86 | break; 87 | 88 | case '1': 89 | case '2': 90 | case '3': 91 | case '4': 92 | case '5': 93 | case '6': 94 | case '7': 95 | case '8': 96 | case '9': 97 | flags |= FL_SIZED; 98 | size = size * 10 + ( c - '0' ); 99 | break; 100 | 101 | default: 102 | myputc( '?', out ); 103 | ++sent; 104 | flags = FL_NULL; 105 | break; 106 | } 107 | } 108 | 109 | if ( ( flags != FL_NULL ) && !( flags & FL_FORMAT ) ) 110 | { 111 | if ( flags & (FL_DECIMAL|FL_HEX) ) 112 | { 113 | uint32_t n = va_arg( ap, uint32_t ); 114 | 115 | if ( !size ) size = 1; 116 | 117 | if ( flags & FL_DECIMAL ) 118 | { 119 | int nd = 0; 120 | char sign = 0; 121 | char nstr[11]; 122 | 123 | if ( size > 10 ) size = 10; 124 | 125 | if (!( flags & FL_UNSIGNED )) 126 | { 127 | if ( n > 0x7fffffff ) 128 | { 129 | sign = '-'; 130 | n = ~n + 1; 131 | } 132 | } 133 | 134 | do 135 | { 136 | nstr[nd++] = '0' + n % 10; 137 | n /= 10; 138 | } 139 | while ( n ); 140 | 141 | if ( flags & FL_ZEROPAD ) 142 | { 143 | while ( nd < size ) { nstr[nd++] = '0'; } 144 | } 145 | 146 | if ( sign ) nstr[nd++] = sign; 147 | 148 | while ( size-- > nd ) 149 | { 150 | myputc( ' ', out ); 151 | ++sent; 152 | } 153 | 154 | while ( nd ) 155 | { 156 | myputc( nstr[--nd], out ); 157 | ++sent; 158 | } 159 | } 160 | else 161 | { 162 | int nd = 8; 163 | int zp = (( flags & FL_ZEROPAD ) != 0 ); 164 | int put = 0; 165 | 166 | do 167 | { 168 | --nd; 169 | char d = n >> ( nd * 4 ) & 0xf; 170 | if ( put || ( zp && ( size > nd )) || d || !nd ) 171 | { 172 | if ( ! put ) 173 | { 174 | put = 1; 175 | while ( nd < --size ) 176 | { 177 | myputc( ' ', out ); 178 | ++sent; 179 | } 180 | } 181 | if ( flags & FL_UPCASE ) 182 | { 183 | d = "0123456789ABCDEF"[(int)d]; 184 | } 185 | else 186 | { 187 | d = "0123456789abcdef"[(int)d]; 188 | } 189 | myputc( d, out ); 190 | ++sent; 191 | } 192 | } 193 | while ( nd ); 194 | } 195 | } 196 | 197 | flags = FL_NULL; 198 | size = 0; 199 | } 200 | } 201 | 202 | return sent; 203 | } 204 | 205 | //========================================================================= 206 | 207 | int myprintf( const char *format, ... ) 208 | { 209 | va_list ap; 210 | int retval; 211 | 212 | if ( !myputc ) return 0; 213 | 214 | va_start( ap, format ); 215 | 216 | retval = my_doprnt( format, ap, stdout ); 217 | 218 | va_end( ap ); 219 | 220 | return retval; 221 | } 222 | 223 | //========================================================================= 224 | -------------------------------------------------------------------------------- /src/myrtc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ClockSelect/myevic/546394bcf1ac9ab63381fa2fb484a0dfa11d443f/src/myrtc.c -------------------------------------------------------------------------------- /src/timers.c: -------------------------------------------------------------------------------- 1 | #include "myevic.h" 2 | #include "dataflash.h" 3 | #include "screens.h" 4 | #include "events.h" 5 | #include "myrtc.h" 6 | #include "battery.h" 7 | #include "atomizer.h" 8 | #include "flappy.h" 9 | #include "display.h" 10 | #include "miscs.h" 11 | 12 | //========================================================================= 13 | 14 | volatile uint32_t TMR0Counter; 15 | volatile uint32_t TMR1Counter; 16 | volatile uint32_t TMR2Counter; 17 | volatile uint32_t TMR3Counter; 18 | 19 | volatile uint32_t WarmUpCounter; 20 | volatile uint32_t TickCount; 21 | 22 | uint16_t SleepTimer; 23 | uint16_t AutoPuffTimer; 24 | uint16_t FadeOutTimer; 25 | 26 | 27 | //========================================================================= 28 | //----- (00007CD4) -------------------------------------------------------- 29 | __myevic__ void InitTimers() 30 | { 31 | TIMER_Open( TIMER0, TIMER_PERIODIC_MODE, 100000 ); 32 | TIMER_EnableInt( TIMER0 ); 33 | TIMER_Open( TIMER1, TIMER_PERIODIC_MODE, 5000 ); 34 | TIMER_EnableInt( TIMER1 ); 35 | TIMER_Open( TIMER2, TIMER_PERIODIC_MODE, 1000 ); 36 | TIMER_EnableInt( TIMER2 ); 37 | TIMER_Open( TIMER3, TIMER_PERIODIC_MODE, 10 ); 38 | TIMER_EnableInt( TIMER3 ); 39 | 40 | NVIC_EnableIRQ( TMR0_IRQn ); 41 | NVIC_EnableIRQ( TMR1_IRQn ); 42 | NVIC_EnableIRQ( TMR2_IRQn ); 43 | NVIC_EnableIRQ( TMR3_IRQn ); 44 | 45 | TMR3Counter = 0; 46 | TMR2Counter = 0; 47 | TMR1Counter = 0; 48 | TMR0Counter = 0; 49 | 50 | TIMER_Start( TIMER0 ); 51 | TIMER_Start( TIMER1 ); 52 | TIMER_Start( TIMER2 ); 53 | TIMER_Start( TIMER3 ); 54 | } 55 | 56 | 57 | //========================================================================= 58 | //----- (00007A2C) -------------------------------------------------------- 59 | // 100kHz Timer (HXT) 60 | 61 | __myevic__ void TMR0_IRQHandler() 62 | { 63 | if ( TIMER_GetIntFlag( TIMER0 ) ) 64 | { 65 | TIMER_ClearIntFlag( TIMER0 ); 66 | 67 | ++TMR0Counter; 68 | 69 | if ( WarmUpCounter ) 70 | --WarmUpCounter; 71 | } 72 | } 73 | 74 | 75 | //========================================================================= 76 | //----- (00007A5C) -------------------------------------------------------- 77 | // 5000Hz Timer (PCLK0) 78 | 79 | __myevic__ void TMR1_IRQHandler() 80 | { 81 | if ( TIMER_GetIntFlag( TIMER1 ) ) 82 | { 83 | TIMER_ClearIntFlag( TIMER1 ); 84 | 85 | gFlags.tick_5khz = 1; 86 | ++TMR1Counter; 87 | 88 | if ( gFlags.led_on ) 89 | { 90 | LEDControl(); 91 | } 92 | } 93 | } 94 | 95 | 96 | //========================================================================= 97 | //----- (00007A94) -------------------------------------------------------- 98 | // Millisecond timer (1000Hz) (HIRC) 99 | 100 | __myevic__ void TMR2_IRQHandler() 101 | { 102 | if ( TIMER_GetIntFlag( TIMER2 ) ) 103 | { 104 | TIMER_ClearIntFlag( TIMER2 ); 105 | 106 | gFlags.tick_1khz = 1; 107 | gFlags.tick_us = 1; 108 | 109 | if ( !(++TMR2Counter % 10) ) 110 | { 111 | gFlags.tick_100hz = 1; 112 | } 113 | 114 | if ( gFlags.playing_fb ) 115 | { 116 | if ( (!(TMR2Counter % 16) && dfFBSpeed == 0) 117 | || (!(TMR2Counter % 13) && dfFBSpeed == 1) 118 | || (!(TMR2Counter % 10) && dfFBSpeed == 2) ) 119 | { 120 | fbTickTimeouts(); 121 | } 122 | } 123 | } 124 | } 125 | 126 | 127 | //========================================================================= 128 | //----- (00007B20) -------------------------------------------------------- 129 | // 10 Hz Timer (HXT) 130 | 131 | __myevic__ void TMR3_IRQHandler() 132 | { 133 | if ( TIMER_GetIntFlag( TIMER3 ) ) 134 | { 135 | TIMER_ClearIntFlag( TIMER3 ); 136 | 137 | gFlags.tick_10hz = 1; 138 | 139 | if ( !gFlags.has_x32 ) 140 | { 141 | ClockCorrection += 1000; 142 | } 143 | 144 | if ( !(++TMR3Counter & 1) ) 145 | gFlags.tick_5hz = 1; 146 | 147 | if ( !(TMR3Counter % 5) ) 148 | gFlags.tick_2hz = 1; 149 | 150 | if ( !(TMR3Counter % 10) ) 151 | gFlags.tick_1hz = 1; 152 | } 153 | } 154 | 155 | 156 | //========================================================================= 157 | //----- (00007D8C) -------------------------------------------------------- 158 | // Called at 100Hz 159 | 160 | __myevic__ void TimedItems() 161 | { 162 | static uint8_t BatAnimTimer = 0; 163 | 164 | if ( !Screen && SleepTimer ) 165 | --SleepTimer; 166 | 167 | if ( ISVTCDUAL ) 168 | { 169 | if ( !PD1 && ( BattProbeCount >= 2 ) && ( BattProbeCount < 50 ) && ( NumBatteries == 1 ) ) 170 | ++BattProbeCount; 171 | } 172 | else if ( !ISCUBOID && !ISCUBO200 && !ISRX200S && !ISRX23 && !ISRX300 && !ISPRIMO1 && !ISPRIMO2 && !ISPREDATOR ) 173 | { 174 | if ( !PD7 && ( BattProbeCount >= 2 ) && ( BattProbeCount < 50 ) ) 175 | ++BattProbeCount; 176 | } 177 | 178 | if ( NoEventTimer ) 179 | --NoEventTimer; 180 | 181 | if ( EditModeTimer ) 182 | { 183 | if ( --EditModeTimer ) 184 | { 185 | if ( !(EditModeTimer % 25) ) 186 | { 187 | gFlags.draw_edited_item ^= 1; 188 | gFlags.refresh_display = 1; 189 | } 190 | } 191 | else 192 | { 193 | gFlags.edit_capture_evt = 0; 194 | gFlags.draw_edited_item = 1; 195 | UpdateDFTimer = 50; 196 | MainView(); 197 | } 198 | } 199 | 200 | if ( BatReadTimer ) 201 | { 202 | if ( !--BatReadTimer ) 203 | gFlags.refresh_battery = 1; 204 | } 205 | 206 | if ( FireClickTimer ) 207 | { 208 | if ( !--FireClickTimer ) 209 | FireClickCount = 0; 210 | } 211 | 212 | if ( AutoPuffTimer ) 213 | --AutoPuffTimer; 214 | 215 | if ( ++BatAnimTimer >= 100 ) 216 | { 217 | BatAnimTimer = 0; 218 | 219 | if ( gFlags.battery_charging ) 220 | { 221 | gFlags.draw_battery_charging ^= 1; 222 | 223 | if ( Screen == 1 || Screen == 5 ) 224 | { 225 | if ( BatAnimLevel < 10 ) 226 | ++BatAnimLevel; 227 | else 228 | BatAnimLevel = BatteryTenth; 229 | 230 | if (( Screen == 5 ) && ( dfScreenSaver == SSAVER_NONE )) 231 | ScreenDuration = GetMainScreenDuration(); 232 | 233 | gFlags.refresh_display = 1; 234 | } 235 | } 236 | else if ( gFlags.battery_10pc || gFlags.batteries_ooe ) 237 | { 238 | gFlags.draw_battery ^= 1; 239 | 240 | if ( Screen == 1 ) 241 | { 242 | gFlags.refresh_display = 1; 243 | } 244 | } 245 | else if ( gFlags.draw_battery_charging || gFlags.draw_battery ) 246 | { 247 | gFlags.draw_battery = 1; 248 | gFlags.draw_battery_charging = 1; 249 | 250 | if ( Screen == 1 ) 251 | { 252 | gFlags.refresh_display = 1; 253 | } 254 | } 255 | } 256 | 257 | if ( FadeOutTimer ) 258 | { 259 | --FadeOutTimer; 260 | 261 | if ( FadeOutTimer < dfContrast ) 262 | { 263 | DisplaySetContrast( FadeOutTimer ); 264 | } 265 | } 266 | 267 | if ( PreheatDelay ) 268 | { 269 | --PreheatDelay; 270 | if ( ( Screen == 1 ) && !( PreheatDelay % 25 ) ) 271 | { 272 | gFlags.refresh_display = 1; 273 | } 274 | } 275 | 276 | ++ChBalTimer; 277 | } 278 | 279 | 280 | //========================================================================= 281 | //----- (00001380) -------------------------------------------------------- 282 | __myevic__ void ResetWatchDog() 283 | { 284 | SYS_UnlockReg(); 285 | WDT_RESET_COUNTER(); 286 | SYS_LockReg(); 287 | } 288 | 289 | 290 | //========================================================================= 291 | //----- (0000174C) -------------------------------------------------------- 292 | // Waits R0 ms 293 | __myevic__ void WaitOnTMR2( int ms ) 294 | { 295 | gFlags.tick_us = 0; 296 | while ( ms ) 297 | { 298 | if ( gFlags.tick_us ) 299 | { 300 | --ms; 301 | gFlags.tick_us = 0; 302 | } 303 | ResetWatchDog(); 304 | } 305 | } 306 | 307 | 308 | //========================================================================= 309 | // Tick Counter 310 | //------------------------------------------------------------------------- 311 | // The TickCount variable will sum up ticks between each pair of calls 312 | // to StartTickCount and StopTickCount. It's the responsability of the 313 | // caller to reset the TickCount variable when appropriate. 314 | //------------------------------------------------------------------------- 315 | 316 | __myevic__ void StartTickCount() 317 | { 318 | SysTick->LOAD = 0xFFFFFF; 319 | SysTick->VAL = (0x00); 320 | SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk; 321 | } 322 | 323 | __myevic__ void StopTickCount() 324 | { 325 | TickCount += 0xFFFFFF - SysTick->VAL; 326 | SysTick->CTRL = 0; 327 | } 328 | -------------------------------------------------------------------------------- /src/vcom.c: -------------------------------------------------------------------------------- 1 | #include "vcom.h" 2 | 3 | //========================================================================= 4 | // VCOM 5 | //------------------------------------------------------------------------- 6 | 7 | #define DESC_LEN_WITH_VCOM \ 8 | (LEN_CONFIG + LEN_INTERFACE * 3 + LEN_HID + LEN_ENDPOINT * 5 + 8 + 19) 9 | 10 | const uint8_t usbdVCOMConfigDesc[] = 11 | { 12 | LEN_CONFIG, /* bLength */ 13 | DESC_CONFIG, /* bDescriptorType */ 14 | /* wTotalLength */ 15 | DESC_LEN_WITH_VCOM & 0x00FF, 16 | (DESC_LEN_WITH_VCOM & 0xFF00) >> 8, 17 | 0x03, /* bNumInterfaces */ 18 | 0x01, /* bConfigurationValue */ 19 | 0x00, /* iConfiguration */ 20 | 0x80 | (USBD_SELF_POWERED << 6) | (USBD_REMOTE_WAKEUP << 5),/* bmAttributes */ 21 | USBD_MAX_POWER, /* MaxPower */ 22 | 23 | /* I/F descr: HID */ 24 | LEN_INTERFACE, /* bLength */ 25 | DESC_INTERFACE, /* bDescriptorType */ 26 | 0x00, /* bInterfaceNumber */ 27 | 0x00, /* bAlternateSetting */ 28 | 0x02, /* bNumEndpoints */ 29 | 0x03, /* bInterfaceClass */ 30 | 0x00, /* bInterfaceSubClass */ 31 | 0x00, /* bInterfaceProtocol */ 32 | 0x00, /* iInterface */ 33 | 34 | /* HID Descriptor */ 35 | LEN_HID, /* Size of this descriptor in UINT8s. */ 36 | DESC_HID, /* HID descriptor type. */ 37 | 0x10, 0x01, /* HID Class Spec. release number. */ 38 | 0x00, /* H/W target country. */ 39 | 0x01, /* Number of HID class descriptors to follow. */ 40 | DESC_HID_RPT, /* Descriptor type. */ 41 | /* Total length of report descriptor. */ 42 | sizeof(usbdHIDReport) & 0x00FF, 43 | (sizeof(usbdHIDReport) & 0xFF00) >> 8, 44 | 45 | /* EP Descriptor: interrupt in. */ 46 | LEN_ENDPOINT, /* bLength */ 47 | DESC_ENDPOINT, /* bDescriptorType */ 48 | (HID_INT_IN_EP_NUM | EP_INPUT), /* bEndpointAddress */ 49 | EP_INT, /* bmAttributes */ 50 | /* wMaxPacketSize */ 51 | EP2_MAX_PKT_SIZE & 0x00FF, 52 | (EP2_MAX_PKT_SIZE & 0xFF00) >> 8, 53 | HID_DEFAULT_INT_IN_INTERVAL, /* bInterval */ 54 | 55 | /* EP Descriptor: interrupt out. */ 56 | LEN_ENDPOINT, /* bLength */ 57 | DESC_ENDPOINT, /* bDescriptorType */ 58 | (HID_INT_OUT_EP_NUM | EP_OUTPUT), /* bEndpointAddress */ 59 | EP_INT, /* bmAttributes */ 60 | /* wMaxPacketSize */ 61 | EP3_MAX_PKT_SIZE & 0x00FF, 62 | (EP3_MAX_PKT_SIZE & 0xFF00) >> 8, 63 | HID_DEFAULT_INT_IN_INTERVAL, /* bInterval */ 64 | 65 | /* I/F descr: VCOM */ 66 | // IAD 67 | 0x08, // bLength: Interface Descriptor size 68 | 0x0B, // bDescriptorType: IAD 69 | 0x01, // bFirstInterface 70 | 0x02, // bInterfaceCount 71 | 0x02, // bFunctionClass: CDC 72 | 0x02, // bFunctionSubClass: Abstract Control Model 73 | 0x01, // bFunctionProtocol: AT Commands [V250] etc. 74 | 0x00, /*0x02 */ // iFunction 75 | 76 | /* INTERFACE descriptor */ 77 | LEN_INTERFACE, /* bLength */ 78 | DESC_INTERFACE, /* bDescriptorType */ 79 | 0x01, /* bInterfaceNumber */ 80 | 0x00, /* bAlternateSetting */ 81 | 0x01, /* bNumEndpoints */ 82 | 0x02, /* bInterfaceClass */ 83 | 0x02, /* bInterfaceSubClass */ 84 | 0x01, /* bInterfaceProtocol */ 85 | 0x00, /* iInterface */ 86 | 87 | /* Communication Class Specified INTERFACE descriptor */ 88 | 0x05, /* Size of the descriptor, in bytes */ 89 | 0x24, /* CS_INTERFACE descriptor type */ 90 | 0x00, /* Header functional descriptor subtype */ 91 | 0x10, 0x01, /* Communication device compliant to the communication spec. ver. 1.10 */ 92 | 93 | /* Communication Class Specified INTERFACE descriptor */ 94 | 0x05, /* Size of the descriptor, in bytes */ 95 | 0x24, /* CS_INTERFACE descriptor type */ 96 | 0x01, /* Call management functional descriptor */ 97 | 0x00, /* BIT0: Whether device handle call management itself. */ 98 | /* BIT1: Whether device can send/receive call management information over a Data Class Interface 0 */ 99 | 0x02, /* Interface number of data class interface optionally used for call management */ 100 | 101 | /* Communication Class Specified INTERFACE descriptor */ 102 | 0x04, /* Size of the descriptor, in bytes */ 103 | 0x24, /* CS_INTERFACE descriptor type */ 104 | 0x02, /* Abstract control management functional descriptor subtype */ 105 | 0x00, /* bmCapabilities */ 106 | 107 | /* Communication Class Specified INTERFACE descriptor */ 108 | 0x05, /* bLength */ 109 | 0x24, /* bDescriptorType: CS_INTERFACE descriptor type */ 110 | 0x06, /* bDescriptorSubType */ 111 | 0x01, /* bMasterInterface */ 112 | 0x02, /* bSlaveInterface0 */ 113 | 114 | /* ENDPOINT descriptor */ 115 | LEN_ENDPOINT, /* bLength */ 116 | DESC_ENDPOINT, /* bDescriptorType */ 117 | (EP_INPUT | VCOM_INT_IN_EP_NUM),/* bEndpointAddress */ 118 | EP_INT, /* bmAttributes */ 119 | EP4_MAX_PKT_SIZE, /* wMaxPacketSize */ 120 | (EP4_MAX_PKT_SIZE & 0xFF00) >> 8, 121 | 0x01, /* bInterval */ 122 | 123 | /* INTERFACE descriptor */ 124 | LEN_INTERFACE, /* bLength */ 125 | DESC_INTERFACE, /* bDescriptorType */ 126 | 0x02, /* bInterfaceNumber */ 127 | 0x00, /* bAlternateSetting */ 128 | 0x02, /* bNumEndpoints */ 129 | 0x0A, /* bInterfaceClass */ 130 | 0x00, /* bInterfaceSubClass */ 131 | 0x00, /* bInterfaceProtocol */ 132 | 0x00, /* iInterface */ 133 | 134 | /* ENDPOINT descriptor */ 135 | LEN_ENDPOINT, /* bLength */ 136 | DESC_ENDPOINT, /* bDescriptorType */ 137 | (EP_INPUT | VCOM_BULK_IN_EP_NUM), /* bEndpointAddress */ 138 | EP_BULK, /* bmAttributes */ 139 | EP5_MAX_PKT_SIZE, /* wMaxPacketSize */ 140 | (EP5_MAX_PKT_SIZE & 0xFF00) >> 8, 141 | 0x00, /* bInterval */ 142 | 143 | /* ENDPOINT descriptor */ 144 | LEN_ENDPOINT, /* bLength */ 145 | DESC_ENDPOINT, /* bDescriptorType */ 146 | (EP_OUTPUT | VCOM_BULK_OUT_EP_NUM), /* bEndpointAddress */ 147 | EP_BULK, /* bmAttributes */ 148 | EP6_MAX_PKT_SIZE, /* wMaxPacketSize */ 149 | (EP6_MAX_PKT_SIZE & 0xFF00) >> 8, 150 | 0x00, /* bInterval */ 151 | }; 152 | 153 | 154 | //------------------------------------------------------------------------- 155 | 156 | typedef struct { 157 | uint32_t u32DTERate; /* Baud rate */ 158 | uint8_t u8CharFormat; /* stop bit */ 159 | uint8_t u8ParityType; /* parity */ 160 | uint8_t u8DataBits; /* data bits */ 161 | } STR_VCOM_LINE_CODING; 162 | 163 | //------------------------------------------------------------------------- 164 | 165 | static STR_VCOM_LINE_CODING gLineCoding = {115200, 0, 0, 8}; 166 | volatile uint16_t gCtrlSignal = 0; 167 | 168 | 169 | //========================================================================= 170 | // VCOM 171 | //------------------------------------------------------------------------- 172 | #define RXBUFSIZE 512 /* RX buffer size */ 173 | 174 | volatile uint8_t comRbuf[RXBUFSIZE]; 175 | volatile uint16_t comRbytes = 0; 176 | volatile uint16_t comRhead = 0; 177 | volatile uint16_t comRtail = 0; 178 | 179 | uint8_t gTxBuf[64] = {0}; 180 | volatile uint8_t *gpu8RxBuf = 0; 181 | volatile uint32_t gu32RxSize = 0; 182 | volatile uint32_t gu32TxSize = 0; 183 | 184 | volatile uint8_t VCOM_TxReady = 1; 185 | 186 | //------------------------------------------------------------------------- 187 | __myevic__ void VCOM_Poll() 188 | { 189 | int32_t i, i32Len; 190 | 191 | if ( VCOM_TxReady ) 192 | { 193 | /* Check whether we have new COM Rx data to send to USB or not */ 194 | if ( comRbytes ) 195 | { 196 | i32Len = comRbytes; 197 | if( i32Len > EP5_MAX_PKT_SIZE ) 198 | i32Len = EP5_MAX_PKT_SIZE; 199 | 200 | for ( i = 0; i < i32Len; i++ ) 201 | { 202 | gTxBuf[i] = comRbuf[comRhead++]; 203 | if ( comRhead >= RXBUFSIZE ) 204 | comRhead = 0; 205 | } 206 | 207 | __set_PRIMASK(1); 208 | comRbytes -= i32Len; 209 | __set_PRIMASK(0); 210 | 211 | VCOM_TxReady = 0; 212 | USBD_MemCopy( (uint8_t*)(USBD_BUF_BASE + USBD_GET_EP_BUF_ADDR(EP5)), 213 | (uint8_t *)gTxBuf, i32Len ); 214 | USBD_SET_PAYLOAD_LEN( EP5, i32Len ); 215 | } 216 | else 217 | { 218 | /* Prepare a zero packet if previous packet size is EP2_MAX_PKT_SIZE and 219 | no more data to send at this moment to note Host the transfer has been done */ 220 | i32Len = USBD_GET_PAYLOAD_LEN( EP5 ); 221 | if( i32Len == EP5_MAX_PKT_SIZE ) 222 | { 223 | USBD_SET_PAYLOAD_LEN( EP5, 0 ); 224 | } 225 | } 226 | } 227 | } 228 | 229 | //------------------------------------------------------------------------- 230 | __myevic__ void VCOM_EP5Handler() 231 | { 232 | /* Bulk IN */ 233 | VCOM_TxReady = 1; 234 | } 235 | 236 | __myevic__ void VCOM_EP6Handler() 237 | { 238 | /* Bulk OUT */ 239 | // int32_t i, i32Len; 240 | // 241 | // i32Len = USBD_GET_PAYLOAD_LEN( EP6 ); 242 | // if ( i32Len ) 243 | // { 244 | // USBD_MemCopy( (uint8_t *)gRxBuf, (uint8_t*)(USBD_BUF_BASE + USBD_GET_EP_BUF_ADDR(EP6)), 245 | // i32Len ); 246 | // } 247 | 248 | USBD_SET_PAYLOAD_LEN( EP6, EP6_MAX_PKT_SIZE ); 249 | } 250 | 251 | 252 | //------------------------------------------------------------------------- 253 | __myevic__ void VCOM_Cout( uint8_t c ) 254 | { 255 | __set_PRIMASK(1); 256 | 257 | comRbuf[comRtail++] = c; 258 | 259 | if ( comRtail >= RXBUFSIZE ) 260 | comRtail = 0; 261 | 262 | ++comRbytes; 263 | 264 | __set_PRIMASK(0); 265 | } 266 | 267 | __myevic__ char VCOM_Putc( char c, FILE *out ) 268 | { 269 | if ( !USBD_IS_ATTACHED() 270 | || !( gCtrlSignal & VCOM_LINESTATE_MASK_DTR )) 271 | { 272 | // Don't send if no one is listening 273 | return c; 274 | } 275 | 276 | VCOM_Cout( (uint8_t)c ); 277 | 278 | if ( c == '\n' ) 279 | { 280 | VCOM_Cout( (uint8_t)'\r' ); 281 | } 282 | 283 | return c; 284 | } 285 | 286 | 287 | //------------------------------------------------------------------------- 288 | __myevic__ void VCOM_ClassRequest( uint8_t *token ) 289 | { 290 | if( token[0] & 0x80 ) /* request data transfer direction */ 291 | { 292 | // Device to host 293 | switch ( token[1] ) 294 | { 295 | case CDC_GET_LINE_CODE: 296 | { 297 | USBD_MemCopy( (uint8_t*)(USBD_BUF_BASE + USBD_GET_EP_BUF_ADDR( EP0 )), 298 | (uint8_t*)&gLineCoding, 7 ); 299 | 300 | /* Data stage */ 301 | USBD_SET_DATA1( EP0 ); 302 | USBD_SET_PAYLOAD_LEN( EP0, 7 ); 303 | /* Status stage */ 304 | USBD_PrepareCtrlOut( 0, 0 ); 305 | break; 306 | } 307 | 308 | default: 309 | { 310 | myprintf( "CLASS GET RQ 0x%02X IF %d\n", token[1], token[4] ); 311 | /* Setup error, stall the device */ 312 | USBD_SetStall( EP0 ); 313 | USBD_SetStall( EP1 ); 314 | break; 315 | } 316 | } 317 | } 318 | else 319 | { 320 | // Host to device 321 | switch ( token[1] ) 322 | { 323 | case CDC_SET_CONTROL_LINE_STATE: 324 | { 325 | if ( token[4] == VCOM_INTERFACE ) 326 | { /* VCOM-1 */ 327 | gCtrlSignal = token[3]; 328 | gCtrlSignal = ( gCtrlSignal << 8 ) | token[2]; 329 | myprintf( "RTS=%d DTR=%d\n", (gCtrlSignal >> 1) & 1, gCtrlSignal & 1 ); 330 | if ( !(gCtrlSignal & 1) ) 331 | { 332 | gFlags.monitoring = 0; 333 | } 334 | } 335 | 336 | /* Status stage */ 337 | USBD_SET_DATA1( EP0 ); 338 | USBD_SET_PAYLOAD_LEN( EP0, 0 ); 339 | break; 340 | } 341 | 342 | case CDC_SET_LINE_CODE: 343 | { 344 | //g_usbd_UsbConfig = 0100; 345 | USBD_PrepareCtrlOut( (uint8_t *)&gLineCoding, 7 ); 346 | 347 | /* Status stage */ 348 | USBD_SET_DATA1( EP0 ); 349 | USBD_SET_PAYLOAD_LEN( EP0, 0 ); 350 | break; 351 | } 352 | 353 | default: 354 | { 355 | myprintf( "CLASS SET RQ 0x%02X IF %d\n", token[1], token[4] ); 356 | // Stall 357 | /* Setup error, stall the device */ 358 | USBD_SetStall( EP0 ); 359 | USBD_SetStall( EP1 ); 360 | break; 361 | } 362 | } 363 | } 364 | } 365 | --------------------------------------------------------------------------------