├── .gitattributes
├── .gitignore
├── Document
├── Arduino Uno running sevenseg_test.ino with multiplexed displays.jpg
├── I2C-LED.html
├── I2C_Slave.vsd
├── Modification step 1.jpg
├── Modification step 2.jpg
├── Modification step 3.jpg
├── Modified Hardware.jpg
├── Original Hardware (back, type 1).jpg
├── Original Hardware (back, type 2).jpg
├── Original Hardware (front).jpg
├── Original Hardware (front, alternate).jpg
└── Programming with STM8S discovery.jpg
├── Firmware
├── Example
│ └── sevenseg_test
│ │ └── sevenseg_test.ino
├── Project
│ ├── I2C-LED.ewp
│ └── I2C-LED.eww
└── Source
│ ├── adafruit_i2c_led_emu.c
│ ├── adafruit_i2c_led_emu.h
│ ├── led.c
│ ├── led.h
│ ├── main.c
│ ├── soft_i2c_slave.c
│ ├── soft_i2c_slave.h
│ ├── stm8s_conf.h
│ ├── stm8s_it.c
│ └── stm8s_it.h
├── Hardware
├── eagle.epf
├── voltmeter-hack.png
├── voltmeter-hack.sch
├── voltmeter.png
└── voltmeter.sch
└── readme.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 |
46 | [Dd]ebug/
47 | [Rr]elease/
48 | x64/
49 | build/
50 | [Bb]in/
51 | [Oo]bj/
52 |
53 | # MSTest test Results
54 | [Tt]est[Rr]esult*/
55 | [Bb]uild[Ll]og.*
56 |
57 | *_i.c
58 | *_p.c
59 | *.ilk
60 | *.meta
61 | *.obj
62 | *.pch
63 | *.pdb
64 | *.pgc
65 | *.pgd
66 | *.rsp
67 | *.sbr
68 | *.tlb
69 | *.tli
70 | *.tlh
71 | *.tmp
72 | *.tmp_proj
73 | *.log
74 | *.vspscc
75 | *.vssscc
76 | .builds
77 | *.pidb
78 | *.log
79 | *.scc
80 |
81 | # Visual C++ cache files
82 | ipch/
83 | *.aps
84 | *.ncb
85 | *.opensdf
86 | *.sdf
87 | *.cachefile
88 |
89 | # Visual Studio profiler
90 | *.psess
91 | *.vsp
92 | *.vspx
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 |
101 | # TeamCity is a build add-in
102 | _TeamCity*
103 |
104 | # DotCover is a Code Coverage Tool
105 | *.dotCover
106 |
107 | # NCrunch
108 | *.ncrunch*
109 | .*crunch*.local.xml
110 |
111 | # Installshield output folder
112 | [Ee]xpress/
113 |
114 | # DocProject is a documentation generator add-in
115 | DocProject/buildhelp/
116 | DocProject/Help/*.HxT
117 | DocProject/Help/*.HxC
118 | DocProject/Help/*.hhc
119 | DocProject/Help/*.hhk
120 | DocProject/Help/*.hhp
121 | DocProject/Help/Html2
122 | DocProject/Help/html
123 |
124 | # Click-Once directory
125 | publish/
126 |
127 | # Publish Web Output
128 | *.Publish.xml
129 | *.pubxml
130 |
131 | # NuGet Packages Directory
132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
133 | #packages/
134 |
135 | # Windows Azure Build Output
136 | csx
137 | *.build.csdef
138 |
139 | # Windows Store app package directory
140 | AppPackages/
141 |
142 | # Others
143 | sql/
144 | *.Cache
145 | ClientBin/
146 | [Ss]tyle[Cc]op.*
147 | ~$*
148 | *~
149 | *.dbmdl
150 | *.[Pp]ublish.xml
151 | *.pfx
152 | *.publishsettings
153 |
154 | # RIA/Silverlight projects
155 | Generated_Code/
156 |
157 | # Backup & report files from converting an old project file to a newer
158 | # Visual Studio version. Backup files are not needed, because we have git ;-)
159 | _UpgradeReport_Files/
160 | Backup*/
161 | UpgradeLog*.XML
162 | UpgradeLog*.htm
163 |
164 | # SQL Server files
165 | App_Data/*.mdf
166 | App_Data/*.ldf
167 |
168 | #############
169 | ## Windows detritus
170 | #############
171 |
172 | # Windows image file caches
173 | Thumbs.db
174 | ehthumbs.db
175 |
176 | # Folder config file
177 | Desktop.ini
178 |
179 | # Recycle Bin used on file shares
180 | $RECYCLE.BIN/
181 |
182 | # Mac crap
183 | .DS_Store
184 |
185 |
186 | #############
187 | ## Python
188 | #############
189 |
190 | *.py[co]
191 |
192 | # Packages
193 | *.egg
194 | *.egg-info
195 | dist/
196 | build/
197 | eggs/
198 | parts/
199 | var/
200 | sdist/
201 | develop-eggs/
202 | .installed.cfg
203 |
204 | # Installer logs
205 | pip-log.txt
206 |
207 | # Unit test / coverage reports
208 | .coverage
209 | .tox
210 |
211 | #Translations
212 | *.mo
213 |
214 | #Mr Developer
215 | .mr.developer.cfg
216 |
217 | ###############
218 | ## EWSTM8
219 | ###############
220 | Firmware/Project/*.dep
221 | Firmware/Project/*.ewd
222 | Firmware/Project/[Ss]ettings/
223 | Firmware/Project/[Dd]ebug/
224 | Firmware/Project/[Rd]elease/
225 |
226 |
227 | ###############
228 | ## KiCad
229 | ###############
230 | Hardware/*.bak
231 | Hardware/*cache.lib
232 | Hardware/*.bck
233 |
--------------------------------------------------------------------------------
/Document/Arduino Uno running sevenseg_test.ino with multiplexed displays.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Document/Arduino Uno running sevenseg_test.ino with multiplexed displays.jpg
--------------------------------------------------------------------------------
/Document/I2C-LED.html:
--------------------------------------------------------------------------------
1 | LED voltmeters are a cheap source of 7 segment displays and can easily be repurposed. Using the I2C protocol, a master microcontroller such as an Arduino Uno can govern multiple displays with just 2 I/O pins.
2 |
3 |
4 |
5 |
6 |
7 |
8 | Hello, Pleased to Meter You
9 |
10 |
11 | The
Adafruit 4-digit 7-segment LED backpack is a handy little board, and Ladyada's
tutorial and
Arduino library make it a snap to use. It's as easy to connect 8 displays as a single one: just set them to have different slave addresses and hook them all up to your Arduino's I2C pins. The trouble is that 8 displays will set you back around $80 (or a little more if you like the colour blue).
12 |
13 |
14 | Looking around for an alternative, I discovered an
internet retailer selling cheap LED voltmeters in both
red and
blue . The listing titles mentioned "Stm8s003", the name of a series of small microcontrollers. For around $30 I bought myself 8 of the voltmeters and the
STM8S discovery development board to reprogram them with. Similar voltmeters are available elsewhere, including
eBay .
15 |
16 |
17 | Then I had the most amazing stroke of luck. While I was waiting for the voltmeters to ship from the Far East, I came across an
excellent blog post documenting a very similar project. The author had done an amazing job of writing firmware that would emulate the Adafruit board so that the hacked voltmeter would be compatible with the existing Arduino libraries. The hard work had all been done for me. All that remained to adapt the firmware to the slightly different voltmeter that I would be using.
18 |
19 |
20 |
21 |
22 |
23 |
24 | Hardware
25 |
26 |
27 | The voltmeters accepted between 3.5V to 30V on the red (V+) and black (V-) wires. On the reverse of I identified a
voltage regulator that provided 3.3V to the
STM8S003F3P6 MCU which drives the LEDs.
28 |
29 |
30 |
31 |
32 |
33 |
34 | One or two of the voltmeters looked slightly different with a trimmer resistor for R3 and and extra capacitor C1:
35 |
36 |
37 |
38 |
39 |
40 |
41 | With soldering iron and tweezers in hand, I sacrificed one of the voltmeters to recreate the schematic as best I could. The hardware I2C pins on the MCU were both in use, but it was apparent that pins 19 and 20 on the MCU could be reassigned to bit bang the I2C protocol.
42 |
43 |
44 |
45 |
46 |
47 |
48 | Next up, a step-by-step surgery guide to repurposing the voltmeters.
49 |
50 | Step 1. Orient the voltmeter face down with the chip on the left hand side. Desolder resistors R3 and RX. Solder a wire in hole 1 (marked with a square), trim and strip the loose end, and solder to the left hand pad under resistor RX. Solder two more wires into holes 4 and 5 of header HV. These connect to pins 4 (NRST) and 18 (SWIM) and are used in programming the STM8S chip.
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | Step 2. Solder a wire to the pad marked "IN" next to the red wire that carries the positive voltage. The next part is slightly tricky . Apply flux to the very bottom pin on the left hand side the chip and very carefully solder to a length of solid core hookup wire. These two wires connect to pins 19 and 20 and carry the I2C SCL and SDA signals, respectively.
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | Step 3. Add shrink wrap and hot glue for strain relief. Solder pin headers to the loose ends of the wires. Bada bing!
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | The hacked hardware should now have a layout something like this:
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | Firmware
89 |
90 | The firmware is archived in a
github repository .
As explained by the firmware's author, the majority of the source code is devoted to recreating the I2C slave protocol in software. The code is optimized to allow transfer speeds of up to 50kHz. An additional layer has been implemented to emulate the
Adafruit Backpack . Because of the different pin assignments I made a few changes here and there.
91 |
92 |
The source code should be compiled using IAR Embedded Workbench for STMicroelectronics STM8 . The “KickStarter” edition is usable free with registration. T he STM8S/A Standard Peripherals Library (STM8S_StdPeriph_Driver V2.1.0) is required and can be downloaded as stsw-stm8069.zip from the
http://www.st.com STM8 firmware page.
93 | .
94 | For one of the voltmeters, I had difficulty programming the MCU because it had Read-out Protection activated. I couldn't figure out how to disable this option using IAR Embedded Workbench, but it was straightforward to do from the "option bytes" menu in the STVD visual development IDE, which I also downloaded from
http://www.st.com .
95 |
96 |
97 |
98 | The
STM8S discovery development board (see picture below) can be used to program the chip using the SWIM protocol. First remove the solder bridges connecting the emulator to the evaluation board, then connect the pins on the SWIM header to the correct terminals on the hacked voltmeter: VDD to V+, VSS to V-, NRST and SWIM to holes 4 and 5 of header HV, respectively.
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | Because the firmware emulates the
Adafruit Backpack , the
original Adafruit demo sketch can be used for testing. Just be aware that the Arduino I2C clock must first be reduced to 50 kHz by editing the TWI_FREQ variable in the Arduino /
libraries/Wire/utility/twi.h file. To enable communication at the correct voltage the Arduino SCL and SDA pins, respectively, should be connected via a logic level converter to the wires joined to pins 19 and 20 on the display's MCU.
107 |
108 |
109 |
110 | Resources
111 |
112 |
123 |
--------------------------------------------------------------------------------
/Document/I2C_Slave.vsd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Document/I2C_Slave.vsd
--------------------------------------------------------------------------------
/Document/Modification step 1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Document/Modification step 1.jpg
--------------------------------------------------------------------------------
/Document/Modification step 2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Document/Modification step 2.jpg
--------------------------------------------------------------------------------
/Document/Modification step 3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Document/Modification step 3.jpg
--------------------------------------------------------------------------------
/Document/Modified Hardware.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Document/Modified Hardware.jpg
--------------------------------------------------------------------------------
/Document/Original Hardware (back, type 1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Document/Original Hardware (back, type 1).jpg
--------------------------------------------------------------------------------
/Document/Original Hardware (back, type 2).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Document/Original Hardware (back, type 2).jpg
--------------------------------------------------------------------------------
/Document/Original Hardware (front).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Document/Original Hardware (front).jpg
--------------------------------------------------------------------------------
/Document/Original Hardware (front, alternate).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Document/Original Hardware (front, alternate).jpg
--------------------------------------------------------------------------------
/Document/Programming with STM8S discovery.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Document/Programming with STM8S discovery.jpg
--------------------------------------------------------------------------------
/Firmware/Example/sevenseg_test/sevenseg_test.ino:
--------------------------------------------------------------------------------
1 | /***************************************************
2 | This is a test sketch for Adafruit I2C LED Backpacks
3 |
4 | Designed specifically to work with the Adafruit LED 7-Segment backpacks
5 | ----> http://www.adafruit.com/products/881
6 | ----> http://www.adafruit.com/products/880
7 | ----> http://www.adafruit.com/products/879
8 | ----> http://www.adafruit.com/products/878
9 |
10 | These displays use I2C to communicate, 2 pins are required to
11 | interface. There are multiple selectable I2C addresses. For backpacks
12 | with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
13 | with 3 Address Select pins: 0x70 thru 0x77
14 |
15 | Adafruit invests time and resources providing this open source code,
16 | please support Adafruit and open-source hardware by purchasing
17 | products from Adafruit!
18 |
19 | Written by Tom Price after Limor Fried.
20 | BSD license, all text above must be included in any redistribution
21 | ****************************************************/
22 |
23 | #include
24 | #include "Adafruit_LEDBackpack.h"
25 | #include "Adafruit_GFX.h"
26 |
27 | Adafruit_7segment matrix1 = Adafruit_7segment();
28 | Adafruit_7segment matrix2 = Adafruit_7segment();
29 | Adafruit_7segment matrix3 = Adafruit_7segment();
30 | Adafruit_7segment matrix4 = Adafruit_7segment();
31 |
32 | void setup() {
33 | Serial.begin(9600);
34 | Serial.println("7 Segment Backpack Test");
35 |
36 | matrix1.begin(0x70);
37 | matrix2.begin(0x71);
38 | matrix3.begin(0x72);
39 | matrix4.begin(0x73);
40 | }
41 |
42 | void loop() {
43 | matrix1.writeDigitNum( 0, 0xa, false );
44 | matrix1.writeDigitNum( 1, 0xd, true );
45 | matrix1.writeDigitNum( 3, 0x7, false );
46 | matrix1.writeDigitNum( 4, 0x0, false );
47 | matrix1.writeDisplay();
48 | matrix2.writeDigitNum( 0, 0xa, false );
49 | matrix2.writeDigitNum( 1, 0xd, true );
50 | matrix2.writeDigitNum( 3, 0x7, false );
51 | matrix2.writeDigitNum( 4, 0x1, false );
52 | matrix2.writeDisplay();
53 | matrix3.writeDigitNum( 0, 0xa, false );
54 | matrix3.writeDigitNum( 1, 0xd, true );
55 | matrix3.writeDigitNum( 3, 0x7, false );
56 | matrix3.writeDigitNum( 4, 0x2, false );
57 | matrix3.writeDisplay();
58 | matrix4.writeDigitNum( 0, 0xa, false );
59 | matrix4.writeDigitNum( 1, 0xd, true );
60 | matrix4.writeDigitNum( 3, 0x7, false );
61 | matrix4.writeDigitNum( 4, 0x3, false );
62 | matrix4.writeDisplay();
63 | delay(500);
64 | }
65 |
--------------------------------------------------------------------------------
/Firmware/Project/I2C-LED.ewp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2
5 |
6 | Debug
7 |
8 | STM8
9 |
10 | 1
11 |
12 | General
13 | 3
14 |
15 | 1
16 | 1
17 | 1
18 |
19 | GenDeviceSelectMenu
20 | STM8S003F3 STM8S003F3
21 |
22 |
23 | GenCodeModel
24 | 0
25 | 0
26 |
27 |
28 | GenDataModel
29 | 0
30 | 1
31 |
32 |
33 | GOutputBinary
34 | 0
35 |
36 |
37 | ExePath
38 | Debug\Exe
39 |
40 |
41 | ObjPath
42 | Debug\Obj
43 |
44 |
45 | ListPath
46 | Debug\List
47 |
48 |
49 | GenRuntimeLibSelect
50 | 0
51 | 1
52 |
53 |
54 | GenRuntimeLibSelectSlave
55 | 0
56 | 1
57 |
58 |
59 | GenRTDescription
60 | Use the normal configuration of the C/EC++ runtime library. No locale interface, C locale, no file descriptor support, no multibytes in printf and scanf, and no hex floats in strtod.
61 |
62 |
63 | GenRTConfigPath
64 | $TOOLKIT_DIR$\LIB\dlstm8smn.h
65 |
66 |
67 | GenLibInFormatter
68 | 0
69 | 2
70 |
71 |
72 | GenLibInFormatterDescription
73 | Full formatting, without multibytes.
74 |
75 |
76 | GenLibOutFormatter
77 | 0
78 | 2
79 |
80 |
81 | GenLibOutFormatterDescription
82 | Full formatting, without multibytes.
83 |
84 |
85 | GenStackSize
86 | 0x100
87 |
88 |
89 | GenHeapSize
90 | 0x100
91 |
92 |
93 | GeneralEnableMisra
94 | 0
95 |
96 |
97 | GeneralMisraVerbose
98 | 0
99 |
100 |
101 | GeneralMisraVer
102 | 0
103 |
104 |
105 | GeneralMisraRules04
106 | 0
107 | 111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111
108 |
109 |
110 | GeneralMisraRules98
111 | 0
112 | 1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111
113 |
114 |
115 |
116 |
117 | ICCSTM8
118 | 3
119 |
120 | 9
121 | 1
122 | 1
123 |
124 | IccRequirePrototypes
125 | 0
126 |
127 |
128 | IccLanguageConformance
129 | 0
130 |
131 |
132 | IccCharIs
133 | 1
134 |
135 |
136 | IccMultibyteSupport
137 | 0
138 |
139 |
140 | IccOptLevel
141 | 3
142 |
143 |
144 | IccOptStrategy
145 | 0
146 | 2
147 |
148 |
149 | IccOptLevelSlave
150 | 3
151 |
152 |
153 | IccOptAllowList
154 | 0
155 | 110111
156 |
157 |
158 | IccGenerateDebugInfo
159 | 1
160 |
161 |
162 | IccOutputFile
163 | $FILE_BNAME$.o
164 |
165 |
166 | IccCodeModel
167 | 0
168 |
169 |
170 | IccDataModel
171 | 0
172 |
173 |
174 | IccObjPrefix
175 | 1
176 |
177 |
178 | IccLibConfigHeader
179 | 1
180 |
181 |
182 | CCDefines
183 | STM8S003
184 |
185 |
186 | CCPreprocFile
187 | 0
188 |
189 |
190 | CCPreprocComments
191 | 0
192 |
193 |
194 | CCPreprocLine
195 | 0
196 |
197 |
198 | CCListCFile
199 | 0
200 |
201 |
202 | CCListCMnemonics
203 | 0
204 |
205 |
206 | CCListCMessages
207 | 0
208 |
209 |
210 | CCListAssFile
211 | 0
212 |
213 |
214 | CCListAssSource
215 | 0
216 |
217 |
218 | CCEnableRemarks
219 | 0
220 |
221 |
222 | CCDiagSuppress
223 |
224 |
225 |
226 | CCDiagRemark
227 |
228 |
229 |
230 | CCDiagWarning
231 |
232 |
233 |
234 | CCDiagError
235 |
236 |
237 |
238 | CCDiagWarnAreErr
239 | 0
240 |
241 |
242 | CCCompilerRuntimeInfo
243 | 0
244 |
245 |
246 | PreInclude
247 |
248 |
249 |
250 | CCIncludePath2
251 | $PROJ_DIR$\..\..\..\STM8S_StdPeriph_Lib_V2.1.0\Libraries\STM8S_StdPeriph_Driver\inc
252 | $PROJ_DIR$\..\Source
253 |
254 |
255 | CCStdIncCheck
256 | 0
257 |
258 |
259 | CompilerMisraOverride
260 | 0
261 |
262 |
263 | CompilerMisraRules04
264 | 0
265 | 111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111
266 |
267 |
268 | CompilerMisraRules98
269 | 0
270 | 1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111
271 |
272 |
273 | IccUseExtraOptions
274 | 0
275 |
276 |
277 | IccExtraOptions
278 |
279 |
280 |
281 | IccLang
282 | 0
283 |
284 |
285 | IccCDialect
286 | 1
287 |
288 |
289 | IccAllowVLA
290 | 0
291 |
292 |
293 | IccCppDialect
294 | 1
295 |
296 |
297 | IccNoVregs
298 | 0
299 | 1
300 |
301 |
302 | IccOptNoSizeConstraints
303 | 1
304 |
305 |
306 | IccCppInlineSemantics
307 | 0
308 |
309 |
310 | IccStaticDestr
311 | 1
312 |
313 |
314 | IccFloatSemantics
315 | 0
316 |
317 |
318 |
319 |
320 | ASTM8
321 | 3
322 |
323 | 2
324 | 1
325 | 1
326 |
327 | AsmCaseSensitivity
328 | 1
329 |
330 |
331 | AsmMultibyteSupport
332 | 0
333 |
334 |
335 | AsmAllowMnemonics
336 | 0
337 |
338 |
339 | AsmAllowDirectives
340 | 0
341 |
342 |
343 | AsmMacroChars
344 | 0
345 | 0
346 |
347 |
348 | AsmDebugInfo
349 | 1
350 |
351 |
352 | AsmListFile
353 | 0
354 |
355 |
356 | AsmListNoDiagnostics
357 | 0
358 |
359 |
360 | AsmListIncludeCrossRef
361 | 0
362 |
363 |
364 | AsmListMacroDefinitions
365 | 0
366 |
367 |
368 | AsmListNoMacroExpansion
369 | 0
370 |
371 |
372 | AsmListAssembledOnly
373 | 0
374 |
375 |
376 | AsmListTruncateMultiline
377 | 0
378 |
379 |
380 | AsmStdIncludeIgnore
381 | 0
382 |
383 |
384 | AsmIncludePath
385 |
386 |
387 |
388 | AsmDefines
389 |
390 |
391 |
392 | AsmPreprocOutput
393 | 0
394 |
395 |
396 | AsmPreprocComment
397 | 0
398 |
399 |
400 | AsmPreprocLine
401 | 0
402 |
403 |
404 | AsmEnableRemarks
405 | 0
406 |
407 |
408 | AsmDiagnosticsSuppress
409 |
410 |
411 |
412 | AsmDiagnosticsRemark
413 |
414 |
415 |
416 | AsmDiagnosticsWarning
417 |
418 |
419 |
420 | AsmDiagnosticsError
421 |
422 |
423 |
424 | AsmDiagnosticsWarningsAreErrors
425 | 0
426 |
427 |
428 | AsmLimitNumberOfErrors
429 | 0
430 |
431 |
432 | AsmMaxNumberOfErrors
433 | 100
434 |
435 |
436 | AsmCodeModel
437 | 0
438 |
439 |
440 | AsmDataModel
441 | 0
442 |
443 |
444 | AsmObjPrefix
445 | 1
446 |
447 |
448 | AsmOutputFile
449 | $FILE_BNAME$.o
450 |
451 |
452 | AsmUseExtraOptions
453 | 0
454 |
455 |
456 | AsmExtraOptions
457 |
458 |
459 |
460 | AsmPreInclude
461 |
462 |
463 |
464 |
465 |
466 | OBJCOPY
467 | 0
468 |
469 | 0
470 | 1
471 | 1
472 |
473 | OOCOutputFormat
474 | 2
475 | 0
476 |
477 |
478 | OCOutputOverride
479 | 0
480 |
481 |
482 | OOCOutputFile
483 | I2C-LED.srec
484 |
485 |
486 | OOCCommandLineProducer
487 | 1
488 |
489 |
490 | OOCObjCopyEnable
491 | 0
492 |
493 |
494 |
495 |
496 | CUSTOM
497 | 3
498 |
499 |
500 |
501 |
502 |
503 |
504 | BICOMP
505 | 0
506 |
507 |
508 |
509 | BUILDACTION
510 | 1
511 |
512 |
513 |
514 |
515 |
516 |
517 | ILINK
518 | 3
519 |
520 | 2
521 | 1
522 | 1
523 |
524 | IlinkLibIOConfig
525 | 1
526 |
527 |
528 | XLinkMisraHandler
529 | 0
530 |
531 |
532 | IlinkInputFileSlave
533 | 0
534 |
535 |
536 | IlinkOutputFile
537 | I2C-LED.out
538 |
539 |
540 | IlinkDebugInfoEnable
541 | 1
542 |
543 |
544 | IlinkKeepSymbols
545 |
546 |
547 |
548 | IlinkRawBinaryFile
549 |
550 |
551 |
552 | IlinkRawBinarySymbol
553 |
554 |
555 |
556 | IlinkRawBinarySegment
557 |
558 |
559 |
560 | IlinkRawBinaryAlign
561 |
562 |
563 |
564 | IlinkDefines
565 |
566 |
567 |
568 | IlinkConfigDefines
569 |
570 |
571 |
572 | IlinkMapFile
573 | 1
574 |
575 |
576 | IlinkLogFile
577 | 0
578 |
579 |
580 | IlinkLogInitialization
581 | 0
582 |
583 |
584 | IlinkLogModule
585 | 0
586 |
587 |
588 | IlinkLogSection
589 | 0
590 |
591 |
592 | IlinkLogVeneer
593 | 0
594 |
595 |
596 | IlinkIcfOverride
597 | 0
598 |
599 |
600 | IlinkIcfFile
601 | $TOOLKIT_DIR$\config\lnkstm8s003f3.icf
602 |
603 |
604 | IlinkIcfFileSlave
605 |
606 |
607 |
608 | IlinkEnableRemarks
609 | 0
610 |
611 |
612 | IlinkSuppressDiags
613 |
614 |
615 |
616 | IlinkTreatAsRem
617 |
618 |
619 |
620 | IlinkTreatAsWarn
621 |
622 |
623 |
624 | IlinkTreatAsErr
625 |
626 |
627 |
628 | IlinkWarningsAreErrors
629 | 0
630 |
631 |
632 | IlinkStackSize
633 | 1
634 |
635 |
636 | IlinkHeapSize
637 | 1
638 |
639 |
640 | IlinkUseExtraOptions
641 | 0
642 |
643 |
644 | IlinkExtraOptions
645 |
646 |
647 |
648 | IlinkAutoLibEnable
649 | 1
650 |
651 |
652 | IlinkAdditionalLibs
653 |
654 |
655 |
656 | IlinkOverrideProgramEntryLabel
657 | 0
658 |
659 |
660 | IlinkProgramEntryLabelSelect
661 | 0
662 |
663 |
664 | IlinkProgramEntryLabel
665 | __iar_program_start
666 |
667 |
668 | DoFill
669 | 0
670 |
671 |
672 | FillerByte
673 | 0xFF
674 |
675 |
676 | FillerStart
677 | 0x0
678 |
679 |
680 | FillerEnd
681 | 0x0
682 |
683 |
684 | CrcSize
685 | 0
686 | 1
687 |
688 |
689 | CrcAlign
690 | 1
691 |
692 |
693 | CrcPoly
694 | 0x11021
695 |
696 |
697 | CrcCompl
698 | 0
699 | 0
700 |
701 |
702 | CrcBitOrder
703 | 0
704 | 0
705 |
706 |
707 | CrcInitialValue
708 | 0x0
709 |
710 |
711 | DoCrc
712 | 0
713 |
714 |
715 | CrcFullSize
716 | 0
717 |
718 |
719 | IlinkCspyDebugSupportEnable
720 | 1
721 |
722 |
723 | IlinkCspyBufferedWrite
724 | 0
725 |
726 |
727 | IlinkLogAutoLibSelect
728 | 0
729 |
730 |
731 | IlinkLogRedirSymbols
732 | 0
733 |
734 |
735 | IlinkLogUnusedFragments
736 | 0
737 |
738 |
739 | IlinkCrcReverseByteOrder
740 | 0
741 |
742 |
743 | IlinkCrcUseAsInput
744 | 1
745 |
746 |
747 | CrcAlgorithm
748 | 0
749 | 1
750 |
751 |
752 | CrcUnitSize
753 | 0
754 | 0
755 |
756 |
757 | IlinkOptMergeDuplSections
758 | 0
759 |
760 |
761 |
762 |
763 | IARCHIVE
764 | 3
765 |
766 | 0
767 | 1
768 | 1
769 |
770 | IarchiveInputs
771 |
772 |
773 |
774 | IarchiveOverride
775 | 0
776 |
777 |
778 | IarchiveOutput
779 | ###Unitialized###
780 |
781 |
782 |
783 |
784 | BILINK
785 | 0
786 |
787 |
788 |
789 |
790 | Release
791 |
792 | STM8
793 |
794 | 0
795 |
796 | General
797 | 3
798 |
799 | 1
800 | 1
801 | 0
802 |
803 | GenDeviceSelectMenu
804 | STM8S003F3 STM8S003F3
805 |
806 |
807 | GenCodeModel
808 | 0
809 | 0
810 |
811 |
812 | GenDataModel
813 | 0
814 | 1
815 |
816 |
817 | GOutputBinary
818 | 0
819 |
820 |
821 | ExePath
822 | Release\Exe
823 |
824 |
825 | ObjPath
826 | Release\Obj
827 |
828 |
829 | ListPath
830 | Release\List
831 |
832 |
833 | GenRuntimeLibSelect
834 | 0
835 | 1
836 |
837 |
838 | GenRuntimeLibSelectSlave
839 | 0
840 | 1
841 |
842 |
843 | GenRTDescription
844 | Use the normal configuration of the C/EC++ runtime library. No locale interface, C locale, no file descriptor support, no multibytes in printf and scanf, and no hex floats in strtod.
845 |
846 |
847 | GenRTConfigPath
848 | $TOOLKIT_DIR$\LIB\dlstm8smn.h
849 |
850 |
851 | GenLibInFormatter
852 | 0
853 | 2
854 |
855 |
856 | GenLibInFormatterDescription
857 | Full formatting, without multibytes.
858 |
859 |
860 | GenLibOutFormatter
861 | 0
862 | 2
863 |
864 |
865 | GenLibOutFormatterDescription
866 | Full formatting, without multibytes.
867 |
868 |
869 | GenStackSize
870 | 0x100
871 |
872 |
873 | GenHeapSize
874 | 0x100
875 |
876 |
877 | GeneralEnableMisra
878 | 0
879 |
880 |
881 | GeneralMisraVerbose
882 | 0
883 |
884 |
885 | GeneralMisraVer
886 | 0
887 |
888 |
889 | GeneralMisraRules04
890 | 0
891 | 111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111
892 |
893 |
894 | GeneralMisraRules98
895 | 0
896 | 1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111
897 |
898 |
899 |
900 |
901 | ICCSTM8
902 | 3
903 |
904 | 9
905 | 1
906 | 0
907 |
908 | IccRequirePrototypes
909 | 0
910 |
911 |
912 | IccLanguageConformance
913 | 0
914 |
915 |
916 | IccCharIs
917 | 1
918 |
919 |
920 | IccMultibyteSupport
921 | 0
922 |
923 |
924 | IccOptLevel
925 | 3
926 |
927 |
928 | IccOptStrategy
929 | 0
930 | 2
931 |
932 |
933 | IccOptLevelSlave
934 | 3
935 |
936 |
937 | IccOptAllowList
938 | 0
939 | 111111
940 |
941 |
942 | IccGenerateDebugInfo
943 | 0
944 |
945 |
946 | IccOutputFile
947 | $FILE_BNAME$.o
948 |
949 |
950 | IccCodeModel
951 | 0
952 |
953 |
954 | IccDataModel
955 | 0
956 |
957 |
958 | IccObjPrefix
959 | 1
960 |
961 |
962 | IccLibConfigHeader
963 | 1
964 |
965 |
966 | CCDefines
967 | NDEBUG
968 | STM8S003
969 |
970 |
971 | CCPreprocFile
972 | 0
973 |
974 |
975 | CCPreprocComments
976 | 0
977 |
978 |
979 | CCPreprocLine
980 | 0
981 |
982 |
983 | CCListCFile
984 | 1
985 |
986 |
987 | CCListCMnemonics
988 | 0
989 |
990 |
991 | CCListCMessages
992 | 0
993 |
994 |
995 | CCListAssFile
996 | 0
997 |
998 |
999 | CCListAssSource
1000 | 0
1001 |
1002 |
1003 | CCEnableRemarks
1004 | 0
1005 |
1006 |
1007 | CCDiagSuppress
1008 |
1009 |
1010 |
1011 | CCDiagRemark
1012 |
1013 |
1014 |
1015 | CCDiagWarning
1016 |
1017 |
1018 |
1019 | CCDiagError
1020 |
1021 |
1022 |
1023 | CCDiagWarnAreErr
1024 | 0
1025 |
1026 |
1027 | CCCompilerRuntimeInfo
1028 | 0
1029 |
1030 |
1031 | PreInclude
1032 |
1033 |
1034 |
1035 | CCIncludePath2
1036 | d:\Workspace\STM8\STM8S_StdPeriph_Lib_V2.1.0\Libraries\STM8S_StdPeriph_Driver\inc\
1037 | $PROJ_DIR$\..\Source
1038 |
1039 |
1040 | CCStdIncCheck
1041 | 0
1042 |
1043 |
1044 | CompilerMisraOverride
1045 | 0
1046 |
1047 |
1048 | CompilerMisraRules04
1049 | 0
1050 | 111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111
1051 |
1052 |
1053 | CompilerMisraRules98
1054 | 0
1055 | 1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111
1056 |
1057 |
1058 | IccUseExtraOptions
1059 | 0
1060 |
1061 |
1062 | IccExtraOptions
1063 |
1064 |
1065 |
1066 | IccLang
1067 | 0
1068 |
1069 |
1070 | IccCDialect
1071 | 1
1072 |
1073 |
1074 | IccAllowVLA
1075 | 0
1076 |
1077 |
1078 | IccCppDialect
1079 | 1
1080 |
1081 |
1082 | IccNoVregs
1083 | 0
1084 | 1
1085 |
1086 |
1087 | IccOptNoSizeConstraints
1088 | 1
1089 |
1090 |
1091 | IccCppInlineSemantics
1092 | 0
1093 |
1094 |
1095 | IccStaticDestr
1096 | 1
1097 |
1098 |
1099 | IccFloatSemantics
1100 | 0
1101 |
1102 |
1103 |
1104 |
1105 | ASTM8
1106 | 3
1107 |
1108 | 2
1109 | 1
1110 | 0
1111 |
1112 | AsmCaseSensitivity
1113 | 1
1114 |
1115 |
1116 | AsmMultibyteSupport
1117 | 0
1118 |
1119 |
1120 | AsmAllowMnemonics
1121 | 0
1122 |
1123 |
1124 | AsmAllowDirectives
1125 | 0
1126 |
1127 |
1128 | AsmMacroChars
1129 | 0
1130 | 0
1131 |
1132 |
1133 | AsmDebugInfo
1134 | 0
1135 |
1136 |
1137 | AsmListFile
1138 | 0
1139 |
1140 |
1141 | AsmListNoDiagnostics
1142 | 0
1143 |
1144 |
1145 | AsmListIncludeCrossRef
1146 | 0
1147 |
1148 |
1149 | AsmListMacroDefinitions
1150 | 0
1151 |
1152 |
1153 | AsmListNoMacroExpansion
1154 | 0
1155 |
1156 |
1157 | AsmListAssembledOnly
1158 | 0
1159 |
1160 |
1161 | AsmListTruncateMultiline
1162 | 0
1163 |
1164 |
1165 | AsmStdIncludeIgnore
1166 | 0
1167 |
1168 |
1169 | AsmIncludePath
1170 |
1171 |
1172 |
1173 | AsmDefines
1174 |
1175 |
1176 |
1177 | AsmPreprocOutput
1178 | 0
1179 |
1180 |
1181 | AsmPreprocComment
1182 | 0
1183 |
1184 |
1185 | AsmPreprocLine
1186 | 0
1187 |
1188 |
1189 | AsmEnableRemarks
1190 | 0
1191 |
1192 |
1193 | AsmDiagnosticsSuppress
1194 |
1195 |
1196 |
1197 | AsmDiagnosticsRemark
1198 |
1199 |
1200 |
1201 | AsmDiagnosticsWarning
1202 |
1203 |
1204 |
1205 | AsmDiagnosticsError
1206 |
1207 |
1208 |
1209 | AsmDiagnosticsWarningsAreErrors
1210 | 0
1211 |
1212 |
1213 | AsmLimitNumberOfErrors
1214 | 0
1215 |
1216 |
1217 | AsmMaxNumberOfErrors
1218 | 100
1219 |
1220 |
1221 | AsmCodeModel
1222 | 0
1223 |
1224 |
1225 | AsmDataModel
1226 | 0
1227 |
1228 |
1229 | AsmObjPrefix
1230 | 1
1231 |
1232 |
1233 | AsmOutputFile
1234 | $FILE_BNAME$.o
1235 |
1236 |
1237 | AsmUseExtraOptions
1238 | 0
1239 |
1240 |
1241 | AsmExtraOptions
1242 |
1243 |
1244 |
1245 | AsmPreInclude
1246 |
1247 |
1248 |
1249 |
1250 |
1251 | OBJCOPY
1252 | 0
1253 |
1254 | 0
1255 | 1
1256 | 0
1257 |
1258 | OOCOutputFormat
1259 | 2
1260 | 0
1261 |
1262 |
1263 | OCOutputOverride
1264 | 0
1265 |
1266 |
1267 | OOCOutputFile
1268 |
1269 |
1270 |
1271 | OOCCommandLineProducer
1272 | 1
1273 |
1274 |
1275 | OOCObjCopyEnable
1276 | 0
1277 |
1278 |
1279 |
1280 |
1281 | CUSTOM
1282 | 3
1283 |
1284 |
1285 |
1286 |
1287 |
1288 |
1289 | BICOMP
1290 | 0
1291 |
1292 |
1293 |
1294 | BUILDACTION
1295 | 1
1296 |
1297 |
1298 |
1299 |
1300 |
1301 |
1302 | ILINK
1303 | 3
1304 |
1305 | 2
1306 | 1
1307 | 0
1308 |
1309 | IlinkLibIOConfig
1310 | 1
1311 |
1312 |
1313 | XLinkMisraHandler
1314 | 0
1315 |
1316 |
1317 | IlinkInputFileSlave
1318 | 0
1319 |
1320 |
1321 | IlinkOutputFile
1322 | I2C-LED.out
1323 |
1324 |
1325 | IlinkDebugInfoEnable
1326 | 1
1327 |
1328 |
1329 | IlinkKeepSymbols
1330 |
1331 |
1332 |
1333 | IlinkRawBinaryFile
1334 |
1335 |
1336 |
1337 | IlinkRawBinarySymbol
1338 |
1339 |
1340 |
1341 | IlinkRawBinarySegment
1342 |
1343 |
1344 |
1345 | IlinkRawBinaryAlign
1346 |
1347 |
1348 |
1349 | IlinkDefines
1350 |
1351 |
1352 |
1353 | IlinkConfigDefines
1354 |
1355 |
1356 |
1357 | IlinkMapFile
1358 | 1
1359 |
1360 |
1361 | IlinkLogFile
1362 | 0
1363 |
1364 |
1365 | IlinkLogInitialization
1366 | 0
1367 |
1368 |
1369 | IlinkLogModule
1370 | 0
1371 |
1372 |
1373 | IlinkLogSection
1374 | 0
1375 |
1376 |
1377 | IlinkLogVeneer
1378 | 0
1379 |
1380 |
1381 | IlinkIcfOverride
1382 | 0
1383 |
1384 |
1385 | IlinkIcfFile
1386 | $TOOLKIT_DIR$\config\lnkstm8s003f3.icf
1387 |
1388 |
1389 | IlinkIcfFileSlave
1390 |
1391 |
1392 |
1393 | IlinkEnableRemarks
1394 | 0
1395 |
1396 |
1397 | IlinkSuppressDiags
1398 |
1399 |
1400 |
1401 | IlinkTreatAsRem
1402 |
1403 |
1404 |
1405 | IlinkTreatAsWarn
1406 |
1407 |
1408 |
1409 | IlinkTreatAsErr
1410 |
1411 |
1412 |
1413 | IlinkWarningsAreErrors
1414 | 0
1415 |
1416 |
1417 | IlinkStackSize
1418 | 1
1419 |
1420 |
1421 | IlinkHeapSize
1422 | 1
1423 |
1424 |
1425 | IlinkUseExtraOptions
1426 | 0
1427 |
1428 |
1429 | IlinkExtraOptions
1430 |
1431 |
1432 |
1433 | IlinkAutoLibEnable
1434 | 1
1435 |
1436 |
1437 | IlinkAdditionalLibs
1438 |
1439 |
1440 |
1441 | IlinkOverrideProgramEntryLabel
1442 | 0
1443 |
1444 |
1445 | IlinkProgramEntryLabelSelect
1446 | 0
1447 |
1448 |
1449 | IlinkProgramEntryLabel
1450 | __iar_program_start
1451 |
1452 |
1453 | DoFill
1454 | 0
1455 |
1456 |
1457 | FillerByte
1458 | 0xFF
1459 |
1460 |
1461 | FillerStart
1462 | 0x0
1463 |
1464 |
1465 | FillerEnd
1466 | 0x0
1467 |
1468 |
1469 | CrcSize
1470 | 0
1471 | 1
1472 |
1473 |
1474 | CrcAlign
1475 | 1
1476 |
1477 |
1478 | CrcPoly
1479 | 0x11021
1480 |
1481 |
1482 | CrcCompl
1483 | 0
1484 | 0
1485 |
1486 |
1487 | CrcBitOrder
1488 | 0
1489 | 0
1490 |
1491 |
1492 | CrcInitialValue
1493 | 0x0
1494 |
1495 |
1496 | DoCrc
1497 | 0
1498 |
1499 |
1500 | CrcFullSize
1501 | 0
1502 |
1503 |
1504 | IlinkCspyDebugSupportEnable
1505 | 0
1506 |
1507 |
1508 | IlinkCspyBufferedWrite
1509 | 0
1510 |
1511 |
1512 | IlinkLogAutoLibSelect
1513 | 0
1514 |
1515 |
1516 | IlinkLogRedirSymbols
1517 | 0
1518 |
1519 |
1520 | IlinkLogUnusedFragments
1521 | 0
1522 |
1523 |
1524 | IlinkCrcReverseByteOrder
1525 | 0
1526 |
1527 |
1528 | IlinkCrcUseAsInput
1529 | 1
1530 |
1531 |
1532 | CrcAlgorithm
1533 | 0
1534 | 1
1535 |
1536 |
1537 | CrcUnitSize
1538 | 0
1539 | 0
1540 |
1541 |
1542 | IlinkOptMergeDuplSections
1543 | 0
1544 |
1545 |
1546 |
1547 |
1548 | IARCHIVE
1549 | 3
1550 |
1551 | 0
1552 | 1
1553 | 0
1554 |
1555 | IarchiveInputs
1556 |
1557 |
1558 |
1559 | IarchiveOverride
1560 | 0
1561 |
1562 |
1563 | IarchiveOutput
1564 | ###Unitialized###
1565 |
1566 |
1567 |
1568 |
1569 | BILINK
1570 | 0
1571 |
1572 |
1573 |
1574 |
1575 | FWLib
1576 |
1577 | $PROJ_DIR$\..\..\..\STM8S_StdPeriph_Lib_V2.1.0\Libraries\STM8S_StdPeriph_Driver\src\stm8s_clk.c
1578 |
1579 |
1580 | $PROJ_DIR$\..\..\..\STM8S_StdPeriph_Lib_V2.1.0\Libraries\STM8S_StdPeriph_Driver\src\stm8s_gpio.c
1581 |
1582 |
1583 | $PROJ_DIR$\..\..\..\STM8S_StdPeriph_Lib_V2.1.0\Libraries\STM8S_StdPeriph_Driver\src\stm8s_itc.c
1584 |
1585 |
1586 | $PROJ_DIR$\..\..\..\STM8S_StdPeriph_Lib_V2.1.0\Libraries\STM8S_StdPeriph_Driver\src\stm8s_tim1.c
1587 |
1588 |
1589 | $PROJ_DIR$\..\..\..\STM8S_StdPeriph_Lib_V2.1.0\Libraries\STM8S_StdPeriph_Driver\src\stm8s_tim2.c
1590 |
1591 |
1592 |
1593 | Source
1594 |
1595 | $PROJ_DIR$\..\Source\adafruit_i2c_led_emu.c
1596 |
1597 |
1598 | $PROJ_DIR$\..\Source\led.c
1599 |
1600 |
1601 | $PROJ_DIR$\..\Source\main.c
1602 |
1603 |
1604 | $PROJ_DIR$\..\Source\soft_i2c_slave.c
1605 |
1606 |
1607 | $PROJ_DIR$\..\Source\stm8s_it.c
1608 |
1609 |
1610 |
1611 |
1612 |
1613 |
--------------------------------------------------------------------------------
/Firmware/Project/I2C-LED.eww:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $WS_DIR$\I2C-LED.ewp
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Firmware/Source/adafruit_i2c_led_emu.c:
--------------------------------------------------------------------------------
1 | #include "stm8s.h"
2 | #include "led.h"
3 | #include "adafruit_i2c_led_emu.h"
4 |
5 | /******************************************************************************
6 | * As the software emulated I2C slave is interrupt driven, any callbacks must *
7 | * hog as little CPU as possible so not to mess up I2C timing. *
8 | * A command buffer is hence implemented. I2C data callback will just *
9 | * validate received data and fill the command buffer. *
10 | * Real excution of the command is in "emu_run" function call *
11 | ******************************************************************************/
12 |
13 |
14 | /******************************************************************************
15 | * Cyclic FIFO command buffer *
16 | ******************************************************************************/
17 |
18 | typedef enum
19 | {
20 | CMD_UNKNOWN = (uint8_t)0,
21 | CMD_DISPLAY_ADDRESS_POINTER,
22 | CMD_SYSTEM_SETUP,
23 | CMD_DISPLAY_SETUP,
24 | CMD_DIMMING_SET,
25 | DATA_DISPLAY_DATA
26 | } COMMANDTYPE;
27 |
28 |
29 | typedef struct
30 | {
31 | uint8_t value;
32 | COMMANDTYPE type;
33 | } COMMANDENTRY;
34 |
35 |
36 | #define COMMAND_BUFFER_SIZE 32
37 | COMMANDENTRY _command_buffer[COMMAND_BUFFER_SIZE]; // cyclic command buffer
38 | uint8_t _command_buffer_head = 0;
39 | uint8_t _command_buffer_tail = 0;
40 | uint8_t _command_buffer_used = 0;
41 |
42 |
43 | // Store command into the buffer. Return 0 if buffer full
44 | static uint8_t _store_command(uint8_t value, COMMANDTYPE type)
45 | {
46 | if (_command_buffer_used < COMMAND_BUFFER_SIZE)
47 | {
48 | _command_buffer[_command_buffer_tail].value = value;
49 | _command_buffer[_command_buffer_tail].type = type;
50 | _command_buffer_tail = (_command_buffer_tail + 1) & COMMAND_BUFFER_SIZE;
51 | ++_command_buffer_used;
52 | return 1;
53 | }
54 | return 0;
55 | }
56 |
57 |
58 | // Get command out of the buffer. Return 0 if buffer empty
59 | static uint8_t _retrieve_command(uint8_t *value, COMMANDTYPE *type)
60 | {
61 | if (_command_buffer_used == 0)
62 | return 0;
63 | *value = _command_buffer[_command_buffer_head].value;
64 | *type = _command_buffer[_command_buffer_head].type;
65 | _command_buffer_head = (_command_buffer_head + 1) & COMMAND_BUFFER_SIZE;
66 | --_command_buffer_used;
67 | return 1;
68 | }
69 |
70 |
71 | // Peek command from the buffer without remove it. Return 0 if buffer empty
72 | static uint8_t _peek_command(uint8_t *value, COMMANDTYPE *type)
73 | {
74 | if (_command_buffer_used == 0)
75 | return 0;
76 | *value = _command_buffer[_command_buffer_head].value;
77 | *type = _command_buffer[_command_buffer_head].type;
78 | return 1;
79 | }
80 |
81 |
82 | /******************************************************************************
83 | * Pre-process received data *
84 | ******************************************************************************/
85 |
86 | #define HT16K33_SYSTEM_SETUP 0x20
87 | #define HT16K33_DISPLAY_SETUP 0x80
88 | #define HT16K33_DIMMING_SET 0xe0
89 |
90 | // reciving state
91 | typedef enum
92 | {
93 | WAIT_VALID_COMMAND = (uint8_t)0,
94 | WAIT_ANY_DATA,
95 | COMMAND_BUFFER_FULL
96 | } PREPROCESSSTATE;
97 | static PREPROCESSSTATE _preprocess_state;
98 |
99 |
100 | void emu_on_i2c_start_write(void)
101 | {
102 | _preprocess_state = WAIT_VALID_COMMAND;
103 | }
104 |
105 |
106 | void emu_on_i2c_stop(void)
107 | {
108 | _preprocess_state = WAIT_VALID_COMMAND;
109 | }
110 |
111 |
112 | uint8_t emu_on_i2c_data_received(uint8_t data)
113 | {
114 | uint8_t validation;
115 | uint8_t result = 1;
116 |
117 | // Verify data
118 | switch (_preprocess_state)
119 | {
120 | case WAIT_VALID_COMMAND:
121 | validation = data & 0xf0;
122 | if (validation == 0)
123 | {
124 | if (_store_command(data, CMD_DISPLAY_ADDRESS_POINTER))
125 | {
126 | _preprocess_state = WAIT_ANY_DATA;
127 | }
128 | else
129 | {
130 | // Buffer full. Skip data until next I2C start or stop
131 | _preprocess_state = COMMAND_BUFFER_FULL;
132 | result = 0;
133 | }
134 | }
135 | else if (validation == HT16K33_SYSTEM_SETUP)
136 | {
137 | if (!_store_command(data, CMD_SYSTEM_SETUP))
138 | {
139 | _preprocess_state = COMMAND_BUFFER_FULL;
140 | result = 0;
141 | }
142 | }
143 | else if (validation == HT16K33_DISPLAY_SETUP)
144 | {
145 | if (!_store_command(data, CMD_DISPLAY_SETUP))
146 | {
147 | _preprocess_state = COMMAND_BUFFER_FULL;
148 | result = 0;
149 | }
150 | }
151 | else if (validation == HT16K33_DIMMING_SET)
152 | {
153 | if (!_store_command(data, CMD_DIMMING_SET))
154 | {
155 | _preprocess_state = COMMAND_BUFFER_FULL;
156 | result = 0;
157 | }
158 | }
159 | else
160 | {
161 | // Not valid command
162 | result = 0;
163 | }
164 | break;
165 | case WAIT_ANY_DATA:
166 | if (!_store_command(data, DATA_DISPLAY_DATA))
167 | {
168 | _preprocess_state = COMMAND_BUFFER_FULL;
169 | }
170 | break;
171 | case COMMAND_BUFFER_FULL:
172 | result = 0;
173 | break;
174 | default:
175 | result = 0;
176 | }
177 | return result;
178 | }
179 |
180 |
181 | static const uint8_t _adafruit_number_table[] =
182 | {
183 | 0x3F, /* 0 */
184 | 0x06, /* 1 */
185 | 0x5B, /* 2 */
186 | 0x4F, /* 3 */
187 | 0x66, /* 4 */
188 | 0x6D, /* 5 */
189 | 0x7D, /* 6 */
190 | 0x07, /* 7 */
191 | 0x7F, /* 8 */
192 | 0x6F, /* 9 */
193 | 0x77, /* a */
194 | 0x7C, /* b */
195 | 0x39, /* C */
196 | 0x5E, /* d */
197 | 0x79, /* E */
198 | 0x71 /* F */
199 | };
200 | static uint8_t _translate_adafruit_display_data(uint8_t data)
201 | {
202 | uint8_t i, x;
203 | x = data & 0x7f; // bit 7 is DP
204 | for (i = 0; i < 16; ++i)
205 | {
206 | if (x == _adafruit_number_table[i])
207 | {
208 | return (i | (data & 0x80));
209 | }
210 | }
211 | return 0x7f;
212 | }
213 |
214 |
215 | static uint8_t _display_ram[16] = {0}; // HT16K33 has 16 byte display ram
216 | static uint8_t _display_address = 0;
217 |
218 | static void _handle_display_address_pointer(uint8_t cmd)
219 | {
220 | // Command syntax: is (0 0 0 0 A3 A2 A1 A0)
221 | _display_address = cmd & 0x0f;
222 | }
223 |
224 |
225 | static void _handle_display_data(uint8_t data)
226 | {
227 | _display_ram[_display_address] = data;
228 | switch (_display_address)
229 | {
230 | case 8:
231 | led_set_digit(4, _translate_adafruit_display_data(_display_ram[8]));
232 | break;
233 | case 6:
234 | led_set_digit(3, _translate_adafruit_display_data(_display_ram[6]));
235 | break;
236 | case 2:
237 | led_set_digit(2, _translate_adafruit_display_data(_display_ram[2]));
238 | break;
239 | case 0:
240 | led_set_digit(1, _translate_adafruit_display_data(_display_ram[0]));
241 | break;
242 | }
243 | _display_address = (_display_address + 1) & 0x0f;
244 | }
245 |
246 |
247 | static void _handle_system_setup(uint8_t cmd)
248 | {
249 | // Command syntax: 0 0 1 0 X X X S
250 | // S=1: Oscillator on; S=0: Oscillator off;
251 | if (cmd & 0x01)
252 | led_on();
253 | else
254 | led_off();
255 | }
256 |
257 |
258 | static void _handle_display_setup(uint8_t cmd)
259 | {
260 | // Command syntax: 1 0 0 0 X B1 B0 D
261 | // D=1: Display on; D=0: Display 0ff;
262 | // {B1,B0} = {0,0}: Blink off;
263 | // {B1,B0} = {0,1}: Blink 2Hz
264 | // {B1,B0} = {1,0}: Blink 1Hz;
265 | // {B1,B0} = {1,1}: Blink 0.5Hz;
266 | // D=0 is ignored. Use system setup to turn led off
267 | switch (cmd & 0x06)
268 | {
269 | case 0x00:
270 | led_set_blink(LED_BLINK_OFF);
271 | break;
272 | case 0x02:
273 | led_set_blink(LED_BLINK_2HZ);
274 | break;
275 | case 0x04:
276 | led_set_blink(LED_BLINK_1HZ);
277 | break;
278 | case 0x06:
279 | led_set_blink(LED_BLINK_HALFHZ);
280 | break;
281 | }
282 | }
283 |
284 |
285 | static void _handle_dimming_set(uint8_t cmd)
286 | {
287 | // Command synatx: 1 1 1 0 P3 P2 P1 P0
288 | // {P3,P2,P1,P0} is duty
289 | led_set_duty(cmd & 0x0f);
290 | }
291 |
292 |
293 | void emu_run(void)
294 | {
295 | uint8_t value;
296 | COMMANDTYPE type;
297 | while (_retrieve_command(&value, &type))
298 | {
299 | switch (type)
300 | {
301 | case CMD_DISPLAY_ADDRESS_POINTER:
302 | _handle_display_address_pointer(value);
303 | //led_off(); //***
304 | break;
305 | case DATA_DISPLAY_DATA:
306 | _handle_display_data(value);
307 | //led_off(); //***
308 | break;
309 | case CMD_SYSTEM_SETUP:
310 | _handle_system_setup(value);
311 | //led_off(); //***
312 | break;
313 | case CMD_DISPLAY_SETUP:
314 | _handle_display_setup(value);
315 | //led_off(); //***
316 | break;
317 | case CMD_DIMMING_SET:
318 | _handle_dimming_set(value);
319 | //led_off(); //***
320 | break;
321 | default:
322 | // Unknown command, skip
323 | //led_off(); //***
324 | break;
325 | }
326 | }
327 | }
328 |
329 |
330 |
--------------------------------------------------------------------------------
/Firmware/Source/adafruit_i2c_led_emu.h:
--------------------------------------------------------------------------------
1 | #ifndef ADAFRUIT_I2C_LED_EMU
2 | #define ADAFRUIT_I2C_LED_EMU
3 |
4 |
5 | void emu_on_i2c_start_write(void);
6 | void emu_on_i2c_stop(void);
7 | uint8_t emu_on_i2c_data_received(uint8_t data);
8 |
9 | void emu_run(void);
10 |
11 |
12 | #endif
--------------------------------------------------------------------------------
/Firmware/Source/led.c:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2013, Thomas S. Price
2 | # All rights reserved.
3 | #
4 | # Redistribution and use in source and binary forms, with or without modification,
5 | # are permitted provided that the following conditions are met:
6 | #
7 | # * Redistributions of source code must retain the above copyright notice, this
8 | # list of conditions and the following disclaimer.
9 | # * Redistributions in binary form must reproduce the above copyright notice, this
10 | # list of conditions and the following disclaimer in the documentation and/or
11 | # other materials provided with the distribution.
12 | #
13 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
17 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
20 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
21 | # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
22 | # OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
24 | #include "stm8s.h"
25 | #include "led.h"
26 |
27 | #define DEFAULT_LED_DUTY 10
28 |
29 |
30 | static char _display_buf[4] = {0};
31 |
32 | static uint8_t _duty;
33 |
34 | static led_blink_type _blink;
35 |
36 | static void _led_write_segments(char ch)
37 | {
38 | /* Character Map
39 | *
40 | * 0 1 2 3 4 5 6 7 8 9 A B C D E F
41 | * A: PB5 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0
42 | * F: PA1 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0
43 | * B: PB4 0 0 0 0 0 1 1 0 0 0 0 1 1 0 1 1
44 | * G: PC3 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0
45 | * C: PC4 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 1
46 | * E: PC7 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0
47 | * D: PC6 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 1
48 | */
49 | switch (ch & 0x7f)
50 | {
51 | case 0: // 0
52 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
53 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_5));
54 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7));
55 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3));
56 | break;
57 | case 1: // 1
58 | GPIO_WriteHigh(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
59 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
60 | GPIO_WriteHigh(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_5));
61 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
62 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_6 | GPIO_PIN_7));
63 | break;
64 | case 2: // 2
65 | GPIO_WriteHigh(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
66 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_5));
67 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_6 | GPIO_PIN_7));
68 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
69 | break;
70 | case 3: // 3
71 | GPIO_WriteHigh(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
72 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_5));
73 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6));
74 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_7));
75 | break;
76 | case 4: // 4
77 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
78 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
79 | GPIO_WriteHigh(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_5));
80 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4));
81 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_6 | GPIO_PIN_7));
82 | break;
83 | case 5: // 5
84 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
85 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_5));
86 | GPIO_WriteHigh(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
87 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6));
88 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_7));
89 | break;
90 | case 6: // 6
91 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
92 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_5));
93 | GPIO_WriteHigh(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
94 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7));
95 | break;
96 | case 7: // 7
97 | GPIO_WriteHigh(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
98 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_5));
99 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
100 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_6 | GPIO_PIN_7));
101 | break;
102 | case 8: // 8
103 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
104 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_5));
105 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7));
106 | break;
107 | case 9: // 9
108 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
109 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_5));
110 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6));
111 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_7));
112 | break;
113 | case 10: // A
114 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
115 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_5));
116 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_7));
117 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_6));
118 | break;
119 | case 11: // B
120 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
121 | GPIO_WriteHigh(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_5));
122 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7));
123 | break;
124 | case 12: // C
125 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
126 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_5));
127 | GPIO_WriteHigh(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
128 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_6 | GPIO_PIN_7));
129 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4));
130 | break;
131 | case 13: // D
132 | GPIO_WriteHigh(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
133 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
134 | GPIO_WriteHigh(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_5));
135 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7));
136 | break;
137 | case 14: // E
138 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
139 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_5));
140 | GPIO_WriteHigh(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
141 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_6 | GPIO_PIN_7));
142 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
143 | break;
144 | case 15: // F
145 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
146 | GPIO_WriteLow(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_5));
147 | GPIO_WriteHigh(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4));
148 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_7));
149 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_6));
150 | break;
151 | default: // Blank
152 | GPIO_WriteHigh(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1));
153 | GPIO_WriteHigh(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_5));
154 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7));
155 | }
156 | if (ch & 0x80) // DP
157 | {
158 | GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_5));
159 | }
160 | else
161 | {
162 | GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_5));
163 | }
164 | }
165 |
166 |
167 | static void _led_write_com(char digit)
168 | {
169 | // LED_COM_4: PD1
170 | // LED_COM_3: PD4
171 | // LED_COM_2: PD6
172 | // LED_COM_1: PA3
173 | switch (digit)
174 | {
175 | case 1:
176 | GPIO_WriteHigh(GPIOA, (GPIO_Pin_TypeDef)GPIO_PIN_3);
177 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_6);
178 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_4);
179 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_1);
180 | break;
181 | case 2:
182 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)GPIO_PIN_3);
183 | GPIO_WriteHigh(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_6);
184 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_4);
185 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_1);
186 | break;
187 | case 3:
188 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)GPIO_PIN_3);
189 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_6);
190 | GPIO_WriteHigh(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_4);
191 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_1);
192 | break;
193 | case 4:
194 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)GPIO_PIN_3);
195 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_6);
196 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_4);
197 | GPIO_WriteHigh(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_1);
198 | break;
199 | case 0:
200 | GPIO_WriteLow(GPIOA, (GPIO_Pin_TypeDef)GPIO_PIN_3);
201 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_6);
202 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_4);
203 | GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef)GPIO_PIN_1);
204 | break;
205 | }
206 | }
207 |
208 |
209 | // Display character at position 1-4.
210 | // If digit = 0, turn off all digits
211 | void _led_display_char(uint8_t digit)
212 | {
213 | char ch;
214 | if (digit == 0 || digit > 4)
215 | {
216 | _led_write_segments(0x7f);
217 | _led_write_com(0);
218 | return;
219 | }
220 | ch = _display_buf[digit - 1];
221 | _led_write_com(0);
222 | _led_write_segments(ch);
223 | _led_write_com(digit);
224 | }
225 |
226 |
227 | void led_init(void)
228 | {
229 | // GPIO Initialize
230 | // From left->right, Digit 1, 2, 3, 4 (_display_buf[0], _display_buf[1], _display_buf[2], _display_buf[3])
231 | // LED_COM_1: PA3
232 | // LED_COM_2: PD6
233 | // LED_COM_3: PD4
234 | // LED_COM_4: PD1
235 | // LED_SEG_A: PB5
236 | // LED_SEG_B: PB4
237 | // LED_SEG_C: PC4
238 | // LED_SEG_D: PC6
239 | // LED_SEG_E: PC7
240 | // LED_SEG_F: PA1
241 | // LED_SEG_G: PC3
242 | // LED_SEG_DP: PC5
243 | GPIO_Init(GPIOA, (GPIO_Pin_TypeDef)(GPIO_PIN_1 | GPIO_PIN_3), GPIO_MODE_OUT_PP_HIGH_FAST);
244 | GPIO_Init(GPIOB, (GPIO_Pin_TypeDef)(GPIO_PIN_4 | GPIO_PIN_5), GPIO_MODE_OUT_PP_HIGH_FAST);
245 | GPIO_Init(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_7), GPIO_MODE_OUT_PP_HIGH_FAST);
246 | GPIO_Init(GPIOD, (GPIO_Pin_TypeDef)(GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_6), GPIO_MODE_OUT_PP_HIGH_FAST);
247 | // Clear buffer
248 | _display_buf[0] = 0x0b;
249 | _display_buf[1] = 0x0e;
250 | _display_buf[2] = 0x0e;
251 | _display_buf[3] = 0x0f;
252 | // Default values
253 | _duty = DEFAULT_LED_DUTY;
254 | _blink = LED_BLINK_OFF;
255 | // Disable update
256 | led_off();
257 | /*
258 | // Test
259 | led_set_digit( 1, 0x0 );
260 | led_set_digit( 2, 0x1 );
261 | led_set_digit( 3, 0x2 );
262 | led_set_digit( 4, 0x3 );
263 | led_on();
264 | */
265 | }
266 |
267 |
268 | void led_on(void)
269 | {
270 | TIM1_DeInit();
271 |
272 | /* TIM1 configuration:
273 | * TIM1 in PWM mode without output disabled. We only interest in the interrupts.
274 | * Period of PWM is 1024us; Duty cycle adjustable from 1/16 - 15/16.
275 | * With 16Mhz clock, we use:
276 | * TIM1_Period = 16 - 1
277 | * TIM1_Prescaler = 1024 - 1
278 | * TIM1_Pulse = [0..15]
279 | */
280 | TIM1_TimeBaseInit(1023, TIM1_COUNTERMODE_UP, 15, 0);
281 | /*
282 | TIM1_OCMode = TIM1_OCMODE_PWM1
283 | TIM1_OutputState = TIM1_OUTPUTSTATE_DISABLED
284 | TIM1_OutputNState = TIM1_OUTPUTNSTATE_DISABLED
285 | TIM1_Pulse = [1..16], change using TIM1_SetCompare1
286 | TIM1_OCPolarity = TIM1_OCPOLARITY_LOW; Doesn't matter as output is disabled
287 | TIM1_OCNPolarity = TIM1_OCNPOLARITY_HIGH; Doesn't matter as output is disabled
288 | TIM1_OCIdleState = TIM1_OCIDLESTATE_SET; Doesn't matter as output is disabled
289 | TIM1_OCNIdleState = TIM1_OCIDLESTATE_RESET; Doesn't matter as output is disabled
290 | */
291 | TIM1_OC1Init
292 | (
293 | TIM1_OCMODE_PWM1,
294 | TIM1_OUTPUTSTATE_DISABLE, TIM1_OUTPUTNSTATE_DISABLE,
295 | _duty,
296 | TIM1_OCPOLARITY_LOW, TIM1_OCNPOLARITY_HIGH,
297 | TIM1_OCIDLESTATE_SET, TIM1_OCNIDLESTATE_RESET
298 | );
299 | TIM1_ITConfig((TIM1_IT_TypeDef)(TIM1_IT_UPDATE | TIM1_IT_CC1), ENABLE);
300 | /* TIM1 Main Output disabled */
301 | TIM1_CtrlPWMOutputs(DISABLE);
302 | /* TIM1 counter enable */
303 | TIM1_Cmd(ENABLE);
304 | }
305 |
306 |
307 | void led_off(void)
308 | {
309 | TIM1_ITConfig((TIM1_IT_TypeDef)(TIM1_IT_UPDATE | TIM1_IT_CC1), DISABLE);
310 | TIM1_ClearITPendingBit((TIM1_IT_TypeDef)(TIM1_IT_UPDATE | TIM1_IT_CC1));
311 | TIM1_Cmd(DISABLE);
312 | // Display Off
313 | _led_write_segments(0x7f);
314 | _led_write_com(0);
315 | }
316 |
317 |
318 | void led_set_duty(uint8_t duty)
319 | {
320 | if (duty > 15) duty = 15;
321 | TIM1_SetCompare1((uint16_t)duty);
322 | }
323 |
324 | void led_set_blink(led_blink_type blink)
325 | {
326 | _blink = blink;
327 | }
328 |
329 |
330 | void led_set_digit(uint8_t digit, uint8_t value)
331 | {
332 | if (digit == 0 || digit > 4)
333 | {
334 | return;
335 | }
336 | _display_buf[digit - 1] = value;
337 | }
338 |
339 |
340 | // Called from TIM2 UEV ISR
341 | void LED_TIM1_UPDATE_ISR(void)
342 | {
343 | // turn on next digit
344 | static uint8_t digit = 1;
345 | static uint8_t turn_on = 1;
346 | static uint16_t blink_count = 0;
347 |
348 | // This function will be called every 1024us, for the fastest blink rate of 2Hz,
349 | // LED should toggle every 244 cycles
350 | ++blink_count;
351 | switch (_blink)
352 | {
353 | case LED_BLINK_OFF:
354 | turn_on = 1;
355 | blink_count = 0;
356 | break;
357 | case LED_BLINK_2HZ:
358 | if (blink_count > 244)
359 | {
360 | turn_on = !turn_on;
361 | blink_count = 0;
362 | }
363 | break;
364 | case LED_BLINK_1HZ:
365 | if (blink_count > 488)
366 | {
367 | turn_on = !turn_on;
368 | blink_count = 0;
369 | }
370 | break;
371 | case LED_BLINK_HALFHZ:
372 | if (blink_count > 977)
373 | {
374 | turn_on = !turn_on;
375 | blink_count = 0;
376 | }
377 | break;
378 | }
379 | if (turn_on)
380 | _led_display_char(digit);
381 | digit++;
382 | if (digit > 4)
383 | digit = 1;
384 | }
385 |
386 |
387 | // Called from ISR
388 | void LED_TIM1_CC1_ISR(void)
389 | {
390 | // turn off
391 | _led_display_char(0);
392 | }
393 |
--------------------------------------------------------------------------------
/Firmware/Source/led.h:
--------------------------------------------------------------------------------
1 | #ifndef LED_H
2 | #define LED_H
3 |
4 |
5 | typedef enum
6 | {
7 | LED_BLINK_OFF = (uint8_t)0,
8 | LED_BLINK_2HZ,
9 | LED_BLINK_1HZ,
10 | LED_BLINK_HALFHZ
11 | } led_blink_type;
12 |
13 |
14 | void led_init(void);
15 | void led_on(void);
16 | void led_off(void);
17 | void led_set_duty(uint8_t duty);
18 | void led_set_blink(led_blink_type blink);
19 | void led_set_digit(uint8_t digit, uint8_t valuie);
20 | #endif
21 |
--------------------------------------------------------------------------------
/Firmware/Source/main.c:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2013, Thomas S. Price
2 | # All rights reserved.
3 | #
4 | # Redistribution and use in source and binary forms, with or without modification,
5 | # are permitted provided that the following conditions are met:
6 | #
7 | # * Redistributions of source code must retain the above copyright notice, this
8 | # list of conditions and the following disclaimer.
9 | # * Redistributions in binary form must reproduce the above copyright notice, this
10 | # list of conditions and the following disclaimer in the documentation and/or
11 | # other materials provided with the distribution.
12 | #
13 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
17 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
20 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
21 | # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
22 | # OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
24 | #include "stm8s.h"
25 | #include "soft_i2c_slave.h"
26 | #include "adafruit_i2c_led_emu.h"
27 | #include "led.h"
28 |
29 | #define i2c_slave_address 0x70
30 |
31 | /**
32 | * @brief Configure system clock
33 | * @param None
34 | * @retval None
35 | */
36 | static void CLK_Config(void)
37 | {
38 | CLK_DeInit();
39 |
40 | /* Configure the Fcpu to DIV1 */
41 | CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1);
42 |
43 | /* Configure the HSI prescaler */
44 | CLK_SYSCLKConfig(CLK_PRESCALER_HSIDIV1);
45 |
46 | /* Output Fcpu on CLK_CCO pin */
47 | //CLK_CCOConfig(CLK_OUTPUT_CPU);
48 |
49 | /* Configure the system clock to use HSI clock source */
50 | CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);
51 | }
52 |
53 |
54 | static void ITC_Config(void)
55 | {
56 | ITC_SetSoftwarePriority(ITC_IRQ_PORTD, ITC_PRIORITYLEVEL_3); // I2C Pin interrupt
57 | ITC_SetSoftwarePriority(ITC_IRQ_TIM2_OVF, ITC_PRIORITYLEVEL_3); // I2C timeout
58 | ITC_SetSoftwarePriority(ITC_IRQ_TIM1_OVF, ITC_PRIORITYLEVEL_1); // LED main interrupt
59 | ITC_SetSoftwarePriority(ITC_IRQ_TIM1_CAPCOM, ITC_PRIORITYLEVEL_1); // LED dimming interrupt
60 | }
61 |
62 |
63 | void main( void )
64 | {
65 | CFG->GCR |= 0x01; /* disable SWIM to use PD1 as a standard I/O */
66 | CLK_Config();
67 | ITC_Config();
68 | enableInterrupts();
69 | led_init();
70 | i2c_listen(i2c_slave_address, emu_on_i2c_start_write, 0, emu_on_i2c_stop, emu_on_i2c_data_received, 0);
71 |
72 | while (1)
73 | {
74 | emu_run();
75 | wfi();
76 | }
77 |
78 | }
79 |
80 |
81 | #ifdef USE_FULL_ASSERT
82 |
83 | /**
84 | * @brief Reports the name of the source file and the source line number
85 | * where the assert_param error has occurred.
86 | * @param file: pointer to the source file name
87 | * @param line: assert_param error line source number
88 | * @retval : None
89 | */
90 | void assert_failed(u8* file, u32 line)
91 | {
92 | /* User can add his own implementation to report the file name and line number,
93 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
94 |
95 | /* Infinite loop */
96 | while (1)
97 | {
98 | }
99 | }
100 | #endif
--------------------------------------------------------------------------------
/Firmware/Source/soft_i2c_slave.c:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2013, Thomas S. Price
2 | # All rights reserved.
3 | #
4 | # Redistribution and use in source and binary forms, with or without modification,
5 | # are permitted provided that the following conditions are met:
6 | #
7 | # * Redistributions of source code must retain the above copyright notice, this
8 | # list of conditions and the following disclaimer.
9 | # * Redistributions in binary form must reproduce the above copyright notice, this
10 | # list of conditions and the following disclaimer in the documentation and/or
11 | # other materials provided with the distribution.
12 | #
13 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
17 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
20 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
21 | # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
22 | # OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
24 | #include "stm8s.h"
25 | #include "soft_i2c_slave.h"
26 |
27 | /*
28 | SCL = PD2 pin 19
29 | SDA = PD3 pin 20
30 | */
31 | #define I2C_PORT GPIOD
32 | #define I2C_SCL_PIN GPIO_PIN_2
33 | #define I2C_SDA_PIN GPIO_PIN_3
34 |
35 | #define I2C_EXTI_PORT EXTI_PORT_GPIOD
36 | #define I2C_EXTI_SENSITIVITY_MASK EXTI_CR1_PDIS
37 |
38 |
39 | /*
40 | STM8 does not allow per-pin configuration of external interrupt.
41 | So we setup a flag and track the interrupt state we desire.
42 | */
43 |
44 | // Quick interrupt mode consts
45 | typedef enum {
46 | INTR_SDA_ERF_SCL_EF = (uint8_t)0,
47 | INTR_SDA_EF_SCL_DR,
48 | INTR_SDA_DR_SCL_ER,
49 | INTR_SDA_DR_SCL_EF
50 | } INTERRUPTMODE;
51 |
52 | static INTERRUPTMODE _interrupt_mode;
53 |
54 |
55 | /* SCL states */
56 | typedef enum
57 | {
58 | SCL_W1LH = (uint8_t)0,
59 | SCL_W1HL,
60 | SCL_W2to6LH,
61 | SCL_W7LH,
62 | SCL_W8LH,
63 | SCL_W8HL,
64 | SCL_W9HL
65 | } SCLSTATE;
66 |
67 | static const SCLSTATE _SCL_WRT[] =
68 | {
69 | SCL_W1LH,
70 | SCL_W1HL,
71 | SCL_W2to6LH,
72 | SCL_W2to6LH,
73 | SCL_W2to6LH,
74 | SCL_W2to6LH,
75 | SCL_W2to6LH,
76 | SCL_W7LH,
77 | SCL_W8LH,
78 | SCL_W8HL,
79 | SCL_W9HL
80 | };
81 | static const SCLSTATE* _scl_state;
82 |
83 |
84 | // branching flag during 8th bit falling clock
85 | static enum
86 | {
87 | WRITE_IN = (uint8_t)0, // Receiving data
88 | RW_BIT // Receiving address
89 | } _br_clk8lh; // Bit 8 is read/write or data
90 |
91 |
92 | // branching flag during 8th bit rising clock
93 | static enum
94 | {
95 | N_ACK = (uint8_t)0,
96 | W_ACK,
97 | W_CALLBACK,
98 | R_ACK
99 | } _br_clk8hl; // Whether to send ACK
100 |
101 |
102 | // I2C Address
103 | static uint8_t _my_address;
104 |
105 |
106 | // Data received
107 | static uint8_t _i2c_data;
108 |
109 |
110 | // callbacks
111 | static i2c_start_write_callback _on_start_write;
112 | static i2c_start_read_callback _on_start_read;
113 | static i2c_stop_callback _on_stop;
114 | static i2c_data_received_callback _on_data_received;
115 | static i2c_data_needed_callback _on_data_needed;
116 |
117 |
118 | static void _init_port(void)
119 | {
120 | // Disable interrupt
121 | I2C_PORT->CR2 &= (uint8_t)(~(I2C_SCL_PIN | I2C_SDA_PIN));
122 | // Init state
123 | // SCL Input, Interrupt on rising edge, Disabled
124 | // SDA Input, Interrupt on falling edge, Enabled
125 | _interrupt_mode = INTR_SDA_EF_SCL_DR;
126 | //GPIO_Init(I2C_PORT, I2C_SDA_PIN, GPIO_MODE_IN_FL_IT);
127 | I2C_PORT->DDR &= (uint8_t)(~(I2C_SDA_PIN)); // Input
128 | I2C_PORT->CR1 &= (uint8_t)(~(I2C_SDA_PIN)); // Float
129 | //GPIO_Init(I2C_PORT, I2C_SCL_PIN, GPIO_MODE_IN_FL_NO_IT);
130 | I2C_PORT->DDR &= (uint8_t)(~(I2C_SCL_PIN)); // Input
131 | I2C_PORT->CR1 &= (uint8_t)(~(I2C_SCL_PIN)); // Float
132 | //EXTI_SetExtIntSensitivity(I2C_EXTI_PORT, EXTI_SENSITIVITY_FALL_ONLY);
133 | EXTI->CR1 &= (uint8_t)(~I2C_EXTI_SENSITIVITY_MASK);
134 | EXTI->CR1 |= 0x80;
135 | I2C_PORT->CR2 &= (uint8_t)(~(I2C_SCL_PIN)); // SCL No Interrupt
136 | I2C_PORT->CR2 |= (uint8_t)I2C_SDA_PIN; // SDA Interrupt
137 | }
138 |
139 |
140 | void i2c_listen
141 | (
142 | uint8_t address,
143 | i2c_start_write_callback on_start_write,
144 | i2c_start_read_callback on_start_read,
145 | i2c_stop_callback on_stop,
146 | i2c_data_received_callback on_data_received,
147 | i2c_data_needed_callback on_data_needed
148 | )
149 | {
150 | _my_address = address;
151 | _on_start_write = on_start_write;
152 | _on_start_read = on_start_read;
153 | _on_stop = on_stop;
154 | _on_data_received = on_data_received;
155 | _on_data_needed = on_data_needed;
156 |
157 | // Initialize TIM2 for incoming timeout.
158 | // An AVR running at 8MHz has minimal TWI speed of 16KHz.
159 | // Transfer complete buffer takes 11.49ms (Adafruit's Arduino library), we
160 | // set timeout 16ms
161 | // Clock is 16MHz, use Prescaler 2048, each counter is 2048 / 16MHz = 128us,
162 | // Period = (16ms / 128us - 1) = (125 - 1) = 124
163 | // TIM2_TimeBaseInit(TIM2_PRESCALER_2048, 132);
164 | TIM2->PSCR = (uint8_t)(TIM2_PRESCALER_2048);
165 | TIM2->ARRH = (uint8_t)(0);
166 | TIM2->ARRL = (uint8_t)(124);
167 | //TIM2_UpdateRequestConfig(TIM2_UPDATESOURCE_GLOBAL);
168 | TIM2->CR1 &= (uint8_t)(~TIM2_CR1_URS); // Only update event will set UIF
169 | TIM2->EGR = TIM2_PSCRELOADMODE_IMMEDIATE; // Cause immediate update
170 | // TIM2_ITConfig(TIM2_IT_UPDATE, ENABLE);
171 | TIM2->IER |= (uint8_t)(TIM2_IT_UPDATE);
172 | // TIM2_Cmd(ENABLE);
173 | TIM2->CR1 |= (uint8_t)(TIM2_CR1_CEN);
174 | // Once timer enables, an update event will be immediately generated.
175 | // I2C listener will be initialized inside update event handler.
176 | }
177 |
178 |
179 | static void _SDA_ISR(uint8_t SDA, uint8_t SCL)
180 | {
181 | // Was INTR_SDA_EF_SCL_DR (initial waiting start/stop)
182 | // or Was INTR_SDA_ERF_SCL_EF (looking for start/stop after SCL_W1LH
183 | if (SCL)
184 | {
185 | // Start/Stop condition
186 | if (SDA)
187 | {
188 | // SDA rise, Stop condition
189 | // Disable timeout
190 | //TIM2_Cmd(DISABLE);
191 | TIM2->CR1 &= (uint8_t)(~TIM2_CR1_CEN);
192 | //TIM2_ITConfig(TIM2_IT_UPDATE, DISABLE);
193 | TIM2->IER &= (uint8_t)(~TIM2_IT_UPDATE);
194 | // OnStop Callback
195 | if (_on_stop)
196 | _on_stop();
197 | // Restart listening
198 | _scl_state = &(_SCL_WRT[0]);
199 | _init_port();
200 | }
201 | else
202 | {
203 | // SDA fall, Start condition
204 | _i2c_data = 0;
205 | _scl_state = &(_SCL_WRT[0]);
206 | _br_clk8hl = N_ACK; // Default not acknowledged
207 | // Enable timeout
208 | //TIM2_SetCounter(0);
209 | TIM2->CNTRH = (uint8_t)(0);
210 | TIM2->CNTRL = (uint8_t)(0);
211 | //TIM2_ITConfig(TIM2_IT_UPDATE, ENABLE);
212 | TIM2->IER |= (uint8_t)TIM2_IT_UPDATE;
213 | //TIM2_Cmd(ENABLE);
214 | TIM2->CR1 |= (uint8_t)TIM2_CR1_CEN;
215 | // Was INTR_SDA_ERF_SCL_DR
216 | //GPIO_Init(I2C_PORT, I2C_SDA_PIN, GPIO_MODE_IN_FL_NO_IT);
217 | I2C_PORT->DDR &= (uint8_t)(~(I2C_SDA_PIN)); // Input
218 | I2C_PORT->CR1 &= (uint8_t)(~(I2C_SDA_PIN)); // Float
219 | // GPIO_Init(I2C_PORT, I2C_SCL_PIN, GPIO_MODE_IN_FL_IT);
220 | I2C_PORT->DDR &= (uint8_t)(~(I2C_SCL_PIN)); // Input
221 | I2C_PORT->CR1 &= (uint8_t)(~(I2C_SCL_PIN)); // Float
222 | //EXTI_SetExtIntSensitivity(I2C_EXTI_PORT, EXTI_SENSITIVITY_RISE_ONLY);
223 | EXTI->CR1 &= (uint8_t)(~I2C_EXTI_SENSITIVITY_MASK);
224 | EXTI->CR1 |= 0x40;
225 | _interrupt_mode = INTR_SDA_DR_SCL_ER;
226 | I2C_PORT->CR2 |= (uint8_t)I2C_SCL_PIN; // Enable SCL Interrupt
227 | // Now INTR_SDA_DR_SCL_ER
228 | }
229 | }
230 | else
231 | {
232 | // Not Start/Stop condition, SCL/SDA lines are used by other transfers
233 | // Or after SCL_W7LH and determined not my address
234 | // Must re-arm the interrupts since we disable them inside PORT ISR
235 | I2C_PORT->CR2 |= (uint8_t)I2C_SDA_PIN; // Enable SDA Interrupt
236 | }
237 | }
238 |
239 |
240 | static void _SCL_ISR(uint8_t SDA, uint8_t SCL)
241 | {
242 | switch (*_scl_state)
243 | {
244 | case SCL_W1LH: // Bit 1 (first SCL rising edge
245 | _i2c_data = SDA ? (_i2c_data << 1 | 0x01) : (_i2c_data << 1); // Shift bit in
246 | ++_scl_state; // Next state
247 | // Was INTR_SDA_DR_SCL_ER
248 | //GPIO_Init(I2C_PORT, I2C_SDA_PIN, GPIO_MODE_IN_FL_IT);
249 | I2C_PORT->DDR &= (uint8_t)(~(I2C_SDA_PIN)); // Input
250 | I2C_PORT->CR1 &= (uint8_t)(~(I2C_SDA_PIN)); // Float
251 | //EXTI_SetExtIntSensitivity(I2C_EXTI_PORT, EXTI_SENSITIVITY_RISE_FALL);
252 | EXTI->CR1 &= (uint8_t)(~I2C_EXTI_SENSITIVITY_MASK);
253 | EXTI->CR1 |= 0xc0;
254 | _interrupt_mode = INTR_SDA_ERF_SCL_EF;
255 | I2C_PORT->CR2 |= (uint8_t)(I2C_SCL_PIN | I2C_SDA_PIN); // Enable SCL/SDA Interrupt
256 | // Now INTR_SDA_ERF_SCL_EF
257 | break;
258 | case SCL_W1HL:
259 | ++_scl_state; // Next state
260 | // Was INTR_SDA_ERF_SCL_EF
261 | //GPIO_Init(I2C_PORT, I2C_SDA_PIN, GPIO_MODE_IN_FL_NO_IT);
262 | I2C_PORT->DDR &= (uint8_t)(~(I2C_SDA_PIN)); // Input
263 | I2C_PORT->CR1 &= (uint8_t)(~(I2C_SDA_PIN)); // Float
264 | //EXTI_SetExtIntSensitivity(I2C_EXTI_PORT, EXTI_SENSITIVITY_RISE_ONLY);
265 | EXTI->CR1 &= (uint8_t)(~I2C_EXTI_SENSITIVITY_MASK);
266 | EXTI->CR1 |= 0x40;
267 | _interrupt_mode = INTR_SDA_DR_SCL_ER;
268 | I2C_PORT->CR2 |= (uint8_t)I2C_SCL_PIN; // Enable SCL Interrupt
269 | // Now INTR_SDA_DR_SCL_ER
270 | break;
271 | case SCL_W2to6LH:
272 | // Was INTR_SDA_DR_SCL_ER
273 | _i2c_data = SDA ? (_i2c_data << 1 | 0x01) : (_i2c_data << 1); // Shift bit in
274 | ++_scl_state; // Next state
275 | I2C_PORT->CR2 |= (uint8_t)I2C_SCL_PIN; // Enable SCL Interrupt
276 | // Now INTR_SDA_DR_SCL_ER (no change)
277 | break;
278 | case SCL_W7LH:
279 | // Was INTR_SDA_DR_SCL_ER
280 | _i2c_data = SDA ? (_i2c_data << 1 | 0x01) : (_i2c_data << 1); // Shift bit in
281 | if (_br_clk8hl == W_ACK || _br_clk8hl == W_CALLBACK)
282 | {
283 | // Write operation and already acknowledged
284 | _br_clk8lh = WRITE_IN;
285 | ++_scl_state; // Next state
286 | I2C_PORT->CR2 |= (uint8_t)I2C_SCL_PIN; // Enable SCL Interrupt
287 | // Now INTR_SDA_DR_SCL_ER (no change)
288 | }
289 | else
290 | {
291 | if (_i2c_data == _my_address)
292 | {
293 | // This is for me
294 | _br_clk8lh = RW_BIT;
295 | ++_scl_state; // Next state
296 | I2C_PORT->CR2 |= (uint8_t)I2C_SCL_PIN; // Enable SCL Interrupt
297 | _interrupt_mode = INTR_SDA_DR_SCL_ER;
298 | // Now INTR_SDA_DR_SCL_ER (no change)
299 | }
300 | else
301 | {
302 | // Not my address
303 | // Disable timeout
304 | //TIM2_Cmd(DISABLE);
305 | TIM2->CR1 &= (uint8_t)(~TIM2_CR1_CEN);
306 | //TIM2_ITConfig(TIM2_IT_UPDATE, DISABLE);
307 | TIM2->IER &= (uint8_t)(~TIM2_IT_UPDATE);
308 | // Restart listening
309 | _scl_state = &(_SCL_WRT[0]);
310 | _init_port();
311 | }
312 | }
313 | break;
314 | case SCL_W8LH:
315 | // Was INTR_SDA_DR_SCL_ER
316 | switch (_br_clk8lh)
317 | {
318 | case RW_BIT:
319 | if (SDA)
320 | {
321 | _br_clk8hl = R_ACK; // Read
322 | if (_on_start_read) // Callback
323 | _on_start_read();
324 | }
325 | else
326 | {
327 | _br_clk8hl = W_ACK; // Write
328 | if (_on_start_write) // Callback
329 | _on_start_write();
330 | }
331 | break;
332 | case WRITE_IN:
333 | _i2c_data = SDA ? (_i2c_data << 1 | 0x01) : (_i2c_data << 1); // Shift bit in
334 | _br_clk8hl = W_CALLBACK;
335 | break;
336 | }
337 | ++_scl_state; // Next state
338 | //EXTI_SetExtIntSensitivity(I2C_EXTI_PORT, EXTI_SENSITIVITY_FALL_ONLY);
339 | EXTI->CR1 &= (uint8_t)(~I2C_EXTI_SENSITIVITY_MASK);
340 | EXTI->CR1 |= 0x80;
341 | _interrupt_mode = INTR_SDA_DR_SCL_EF;
342 | I2C_PORT->CR2 |= (uint8_t)I2C_SCL_PIN; // Enable SCL Interrupt
343 | // Now INTR_SDA_DR_SCL_EF
344 | break;
345 | case SCL_W8HL:
346 | // Was INTR_SDA_DR_SCL_EF
347 | switch (_br_clk8hl)
348 | {
349 | case W_ACK:
350 | // Acknowledge slave address
351 | //GPIO_Init(I2C_PORT, I2C_SDA_PIN, GPIO_MODE_OUT_OD_LOW_FAST);
352 | I2C_PORT->ODR &= (uint8_t)(~(I2C_SDA_PIN)); // Low
353 | I2C_PORT->DDR |= (uint8_t)I2C_SDA_PIN; // Output
354 | I2C_PORT->CR1 &= (uint8_t)(~(I2C_SDA_PIN)); // Open-Drain
355 | I2C_PORT->CR2 |= (uint8_t)I2C_SDA_PIN; // Fast
356 | ++_scl_state; // Next state
357 | I2C_PORT->CR2 |= (uint8_t)I2C_SCL_PIN; // Enable SCL Interrupt
358 | // Now ., no change but SDA is output if data acknowldged
359 | break;
360 | case W_CALLBACK:
361 | // Clock stretching, pull SCL low until we finish data_received callback
362 | //GPIO_Init(I2C_PORT, I2C_SCL_PIN, GPIO_MODE_OUT_OD_LOW_FAST);
363 | I2C_PORT->ODR &= (uint8_t)(~(I2C_SCL_PIN)); // Low
364 | I2C_PORT->DDR |= (uint8_t)I2C_SCL_PIN; // Output
365 | I2C_PORT->CR1 &= (uint8_t)(~(I2C_SCL_PIN)); // Open-Drain
366 | I2C_PORT->CR2 |= (uint8_t)I2C_SCL_PIN; // Fast
367 | // Callback _on_data_received
368 | if (_on_data_received && _on_data_received(_i2c_data))
369 | {
370 | // Send ACK if data acknowledged
371 | //GPIO_Init(I2C_PORT, I2C_SDA_PIN, GPIO_MODE_OUT_OD_LOW_FAST);
372 | I2C_PORT->ODR &= (uint8_t)(~(I2C_SDA_PIN)); // Low
373 | I2C_PORT->DDR |= (uint8_t)I2C_SDA_PIN; // Output
374 | I2C_PORT->CR1 &= (uint8_t)(~(I2C_SDA_PIN)); // Open-Drain
375 | I2C_PORT->CR2 |= (uint8_t)I2C_SDA_PIN; // Fast
376 | }
377 | // Restore SCL pin state EF
378 | GPIO_Init(I2C_PORT, I2C_SCL_PIN, GPIO_MODE_IN_FL_IT);
379 | I2C_PORT->DDR &= (uint8_t)(~(I2C_SCL_PIN)); // Input
380 | I2C_PORT->CR1 &= (uint8_t)(~(I2C_SCL_PIN)); // Float
381 | ++_scl_state; // Next state
382 | I2C_PORT->CR2 |= (uint8_t)I2C_SCL_PIN; // Enable SCL Interrupt
383 | // Now INTR_SDA_DR_SCL_EF, no change but SDA is output if data acknowldged
384 | break;
385 | case R_ACK:
386 | // I'm too busy to implement I2C read at this time :D
387 | // The actual implementation should look like
388 | // _i2c_data = _on_data_needed();
389 | // _scl_state = &(_SCL_RD[0]);
390 | // ...
391 | // break;
392 | // Now I simply ignore write
393 | case N_ACK:
394 | // Disable timeout
395 | //TIM2_Cmd(DISABLE);
396 | TIM2->CR1 &= (uint8_t)(~TIM2_CR1_CEN);
397 | //TIM2_ITConfig(TIM2_IT_UPDATE, DISABLE);
398 | TIM2->IER &= (uint8_t)(~TIM2_IT_UPDATE);
399 | // Restart listening
400 | _scl_state = &(_SCL_WRT[0]);
401 | _init_port();
402 | break;
403 | }
404 | break;
405 | case SCL_W9HL:
406 | // Was INTR_SDA_DR_SCL_EF and SDA possible in output state
407 | //GPIO_Init(I2C_PORT, I2C_SDA_PIN, GPIO_MODE_IN_FL_NO_IT); // Set SDA input
408 | I2C_PORT->DDR &= (uint8_t)(~(I2C_SDA_PIN)); // Input
409 | I2C_PORT->CR1 &= (uint8_t)(~(I2C_SDA_PIN)); // Float
410 | _i2c_data = 0; // Reset data for next byte
411 | _scl_state = &(_SCL_WRT[0]);
412 | //EXTI_SetExtIntSensitivity(I2C_EXTI_PORT, EXTI_SENSITIVITY_RISE_ONLY);
413 | EXTI->CR1 &= (uint8_t)(~I2C_EXTI_SENSITIVITY_MASK);
414 | EXTI->CR1 |= 0x40;
415 | _interrupt_mode = INTR_SDA_DR_SCL_ER;
416 | I2C_PORT->CR2 |= (uint8_t)I2C_SCL_PIN; // Enable SCL Interrupt
417 | // Now INTR_SDA_DR_SCL_ER
418 | break;
419 | }
420 | }
421 |
422 |
423 | // ISR for SDA and SCL pins
424 | void I2C_GPIO_ISR(void)
425 | {
426 | uint8_t Port, SCL, SDA;
427 |
428 | Port = I2C_PORT->IDR;
429 | SDA = Port & I2C_SDA_PIN;
430 | SCL = Port & I2C_SCL_PIN;
431 |
432 | // Disable interrupt
433 | I2C_PORT->CR2 &= (uint8_t)(~(I2C_SCL_PIN | I2C_SDA_PIN));
434 |
435 | switch (_interrupt_mode)
436 | {
437 | case INTR_SDA_DR_SCL_EF:
438 | // call SCL ISR
439 | _SCL_ISR(SDA, SCL);
440 | break;
441 | case INTR_SDA_DR_SCL_ER:
442 | // call SCL ISR
443 | _SCL_ISR(SDA, SCL);
444 | break;
445 | case INTR_SDA_EF_SCL_DR:
446 | // SDA ISR
447 | _SDA_ISR(SDA, SCL);
448 | break;
449 | case INTR_SDA_ERF_SCL_EF:
450 | // Could be SDA rise/fall or SCL fall
451 | if (!SCL)
452 | _SCL_ISR(SDA, SCL); // SCL fall
453 | else
454 | _SDA_ISR(SDA, SCL); // SDA rise/fall
455 | break;
456 | }
457 | }
458 |
459 |
460 | // ISR for timeout
461 | void I2C_TIM2_UPDATE_ISR(void)
462 | {
463 | // Disable timeout
464 | //TIM2_Cmd(DISABLE);
465 | TIM2->CR1 &= (uint8_t)(~TIM2_CR1_CEN);
466 | //TIM2_ITConfig(TIM2_IT_UPDATE, DISABLE);
467 | TIM2->IER &= (uint8_t)(~TIM2_IT_UPDATE);
468 | // Restart listening
469 | _scl_state = &(_SCL_WRT[0]);
470 | _init_port();
471 | }
472 |
473 |
474 |
--------------------------------------------------------------------------------
/Firmware/Source/soft_i2c_slave.h:
--------------------------------------------------------------------------------
1 | #ifndef I2C_SLAVE_H
2 | #define I2C_SLAVE_H
3 |
4 | typedef void (*i2c_start_write_callback)(void);
5 | typedef void (*i2c_start_read_callback)(void);
6 | typedef void (*i2c_stop_callback)(void);
7 | typedef uint8_t (*i2c_data_received_callback)(uint8_t data);
8 | typedef uint8_t (*i2c_data_needed_callback)(void);
9 |
10 |
11 | void i2c_listen
12 | (
13 | uint8_t address,
14 | i2c_start_write_callback on_start_write,
15 | i2c_start_read_callback on_start_read,
16 | i2c_stop_callback on_stop,
17 | i2c_data_received_callback on_data_received,
18 | i2c_data_needed_callback on_data_needed
19 | );
20 |
21 |
22 |
23 | #endif // I2C_SLAVE_H
24 |
--------------------------------------------------------------------------------
/Firmware/Source/stm8s_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm8s_conf.h
4 | * @author MCD Application Team
5 | * @version V2.1.0
6 | * @date 18-November-2011
7 | * @brief This file is used to configure the Library.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __STM8S_CONF_H
24 | #define __STM8S_CONF_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "stm8s.h"
28 |
29 | /* Uncomment the line below to enable peripheral header file inclusion */
30 | #if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) ||\
31 | defined(STM8S903) || defined (STM8AF626x)
32 | #include "stm8s_adc1.h"
33 | #endif /* (STM8S105) ||(STM8S103) || (STM8S903) || STM8AF626x*/
34 | #if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\
35 | defined (STM8AF62Ax)
36 | #include "stm8s_adc2.h"
37 | #endif /* (STM8S208) || (STM8S207) || (STM8AF62Ax) || (STM8AF52Ax) */
38 | #include "stm8s_awu.h"
39 | #include "stm8s_beep.h"
40 | #if defined (STM8S208) || defined (STM8AF52Ax)
41 | #include "stm8s_can.h"
42 | #endif /* STM8S208 || STM8AF52Ax */
43 | #include "stm8s_clk.h"
44 | #include "stm8s_exti.h"
45 | #include "stm8s_flash.h"
46 | #include "stm8s_gpio.h"
47 | #include "stm8s_i2c.h"
48 | #include "stm8s_itc.h"
49 | #include "stm8s_iwdg.h"
50 | #include "stm8s_rst.h"
51 | #include "stm8s_spi.h"
52 | #include "stm8s_tim1.h"
53 | #ifndef STM8S903
54 | #include "stm8s_tim2.h"
55 | #endif /* STM8S903 */
56 | #if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) ||\
57 | defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x)
58 | #include "stm8s_tim3.h"
59 | #endif /* (STM8S208) ||defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) */
60 | #ifndef STM8S903
61 | #include "stm8s_tim4.h"
62 | #endif /* STM8S903 */
63 | #ifdef STM8S903
64 | #include "stm8s_tim5.h"
65 | #include "stm8s_tim6.h"
66 | #endif /* STM8S903 */
67 | #if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) ||defined(STM8S103) ||\
68 | defined(STM8S003) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
69 | #include "stm8s_uart1.h"
70 | #endif /* STM8S208 || STM8S207 || STM8S103 ||STM8S903 || STM8AF52Ax || STM8AF62Ax */
71 | #if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
72 | #include "stm8s_uart2.h"
73 | #endif /* STM8S105 || STM8AF626x */
74 | #if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\
75 | defined (STM8AF62Ax)
76 | #include "stm8s_uart3.h"
77 | #endif /* STM8S208 || STM8S207 || STM8AF52Ax || STM8AF62Ax */
78 | #include "stm8s_wwdg.h"
79 |
80 | /* Exported types ------------------------------------------------------------*/
81 | /* Exported constants --------------------------------------------------------*/
82 | /* Uncomment the line below to expanse the "assert_param" macro in the
83 | Standard Peripheral Library drivers code */
84 | //#define USE_FULL_ASSERT (1)
85 |
86 | /* Exported macro ------------------------------------------------------------*/
87 | #ifdef USE_FULL_ASSERT
88 |
89 | /**
90 | * @brief The assert_param macro is used for function's parameters check.
91 | * @param expr: If expr is false, it calls assert_failed function
92 | * which reports the name of the source file and the source
93 | * line number of the call that failed.
94 | * If expr is true, it returns no value.
95 | * @retval : None
96 | */
97 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
98 | /* Exported functions ------------------------------------------------------- */
99 | void assert_failed(uint8_t* file, uint32_t line);
100 | #else
101 | #define assert_param(expr) ((void)0)
102 | #endif /* USE_FULL_ASSERT */
103 |
104 | #endif /* __STM8S_CONF_H */
105 |
106 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
107 |
--------------------------------------------------------------------------------
/Firmware/Source/stm8s_it.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm8s_it.c
4 | * @author MCD Application Team
5 | * @version V2.1.0
6 | * @date 18-November-2011
7 | * @brief Main Interrupt Service Routines.
8 | * This file provides template for all peripherals interrupt service
9 | * routine.
10 | ******************************************************************************
11 | * @attention
12 | *
13 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
14 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
15 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
16 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
17 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
18 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
19 | *
20 | * © COPYRIGHT 2011 STMicroelectronics
21 | ******************************************************************************
22 | */
23 |
24 | /* Includes ------------------------------------------------------------------*/
25 | #include "stm8s_it.h"
26 |
27 | /** @addtogroup Template_Project
28 | * @{
29 | */
30 |
31 | /* Private typedef -----------------------------------------------------------*/
32 | /* Private define ------------------------------------------------------------*/
33 | /* Private macro -------------------------------------------------------------*/
34 | /* Private variables ---------------------------------------------------------*/
35 | /* Private function prototypes -----------------------------------------------*/
36 | /* Private functions ---------------------------------------------------------*/
37 | /* Public functions ----------------------------------------------------------*/
38 |
39 | #ifdef _COSMIC_
40 | /**
41 | * @brief Dummy Interrupt routine
42 | * @par Parameters:
43 | * None
44 | * @retval
45 | * None
46 | */
47 | INTERRUPT_HANDLER(NonHandledInterrupt, 25)
48 | {
49 | /* In order to detect unexpected events during development,
50 | it is recommended to set a breakpoint on the following instruction.
51 | */
52 | }
53 | #endif /*_COSMIC_*/
54 |
55 | /**
56 | * @brief TRAP Interrupt routine
57 | * @param None
58 | * @retval None
59 | */
60 | INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler)
61 | {
62 | /* In order to detect unexpected events during development,
63 | it is recommended to set a breakpoint on the following instruction.
64 | */
65 | }
66 |
67 | /**
68 | * @brief Top Level Interrupt routine.
69 | * @param None
70 | * @retval None
71 | */
72 | INTERRUPT_HANDLER(TLI_IRQHandler, 0)
73 |
74 | {
75 | /* In order to detect unexpected events during development,
76 | it is recommended to set a breakpoint on the following instruction.
77 | */
78 | }
79 |
80 | /**
81 | * @brief Auto Wake Up Interrupt routine.
82 | * @param None
83 | * @retval None
84 | */
85 | INTERRUPT_HANDLER(AWU_IRQHandler, 1)
86 | {
87 | /* In order to detect unexpected events during development,
88 | it is recommended to set a breakpoint on the following instruction.
89 | */
90 | }
91 |
92 | /**
93 | * @brief Clock Controller Interrupt routine.
94 | * @param None
95 | * @retval None
96 | */
97 | INTERRUPT_HANDLER(CLK_IRQHandler, 2)
98 | {
99 | /* In order to detect unexpected events during development,
100 | it is recommended to set a breakpoint on the following instruction.
101 | */
102 | }
103 |
104 | /**
105 | * @brief External Interrupt PORTA Interrupt routine.
106 | * @param None
107 | * @retval None
108 | */
109 | INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3)
110 | {
111 | /* In order to detect unexpected events during development,
112 | it is recommended to set a breakpoint on the following instruction.
113 | */
114 | }
115 |
116 | /**
117 | * @brief External Interrupt PORTB Interrupt routine.
118 | * @param None
119 | * @retval None
120 | */
121 | INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4)
122 | {
123 | /* In order to detect unexpected events during development,
124 | it is recommended to set a breakpoint on the following instruction.
125 | */
126 | }
127 |
128 | /**
129 | * @brief External Interrupt PORTC Interrupt routine.
130 | * @param None
131 | * @retval None
132 | */
133 | INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5)
134 | {
135 | /* In order to detect unexpected events during development,
136 | it is recommended to set a breakpoint on the following instruction.
137 | */
138 | }
139 |
140 | /**
141 | * @brief External Interrupt PORTD Interrupt routine.
142 | * @param None
143 | * @retval None
144 | */
145 | extern void I2C_GPIO_ISR(void);
146 | INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6)
147 | {
148 | /* In order to detect unexpected events during development,
149 | it is recommended to set a breakpoint on the following instruction.
150 | */
151 | I2C_GPIO_ISR();
152 | }
153 |
154 | /**
155 | * @brief External Interrupt PORTE Interrupt routine.
156 | * @param None
157 | * @retval None
158 | */
159 | INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7)
160 | {
161 | /* In order to detect unexpected events during development,
162 | it is recommended to set a breakpoint on the following instruction.
163 | */
164 | }
165 |
166 | #ifdef STM8S903
167 | /**
168 | * @brief External Interrupt PORTF Interrupt routine.
169 | * @param None
170 | * @retval None
171 | */
172 | INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8)
173 | {
174 | /* In order to detect unexpected events during development,
175 | it is recommended to set a breakpoint on the following instruction.
176 | */
177 | }
178 | #endif /*STM8S903*/
179 |
180 | #if defined (STM8S208) || defined (STM8AF52Ax)
181 | /**
182 | * @brief CAN RX Interrupt routine.
183 | * @param None
184 | * @retval None
185 | */
186 | INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8)
187 | {
188 | /* In order to detect unexpected events during development,
189 | it is recommended to set a breakpoint on the following instruction.
190 | */
191 | }
192 |
193 | /**
194 | * @brief CAN TX Interrupt routine.
195 | * @param None
196 | * @retval None
197 | */
198 | INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9)
199 | {
200 | /* In order to detect unexpected events during development,
201 | it is recommended to set a breakpoint on the following instruction.
202 | */
203 | }
204 | #endif /*STM8S208 || STM8AF52Ax */
205 |
206 | /**
207 | * @brief SPI Interrupt routine.
208 | * @param None
209 | * @retval None
210 | */
211 | INTERRUPT_HANDLER(SPI_IRQHandler, 10)
212 | {
213 | /* In order to detect unexpected events during development,
214 | it is recommended to set a breakpoint on the following instruction.
215 | */
216 | }
217 |
218 | /**
219 | * @brief Timer1 Update/Overflow/Trigger/Break Interrupt routine.
220 | * @param None
221 | * @retval None
222 | */
223 | extern void LED_TIM1_UPDATE_ISR(void);
224 | INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)
225 | {
226 | /* In order to detect unexpected events during development,
227 | it is recommended to set a breakpoint on the following instruction.
228 | */
229 | if (TIM1->SR1 & TIM1_IT_UPDATE)
230 | {
231 | LED_TIM1_UPDATE_ISR();
232 | TIM1->SR1 = (uint8_t)(~(uint8_t)TIM1_IT_UPDATE);
233 | }
234 | }
235 |
236 | /**
237 | * @brief Timer1 Capture/Compare Interrupt routine.
238 | * @param None
239 | * @retval None
240 | */
241 | extern void LED_TIM1_CC1_ISR(void);
242 | INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12)
243 | {
244 | /* In order to detect unexpected events during development,
245 | it is recommended to set a breakpoint on the following instruction.
246 | */
247 | if (TIM1->SR1 & TIM1_IT_CC1)
248 | {
249 | LED_TIM1_CC1_ISR();
250 | TIM1->SR1 = (uint8_t)(~(uint8_t)TIM1_IT_CC1);
251 | }
252 | }
253 |
254 | #ifdef STM8S903
255 | /**
256 | * @brief Timer5 Update/Overflow/Break/Trigger Interrupt routine.
257 | * @param None
258 | * @retval None
259 | */
260 | INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13)
261 | {
262 | /* In order to detect unexpected events during development,
263 | it is recommended to set a breakpoint on the following instruction.
264 | */
265 | }
266 |
267 | /**
268 | * @brief Timer5 Capture/Compare Interrupt routine.
269 | * @param None
270 | * @retval None
271 | */
272 | INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14)
273 | {
274 | /* In order to detect unexpected events during development,
275 | it is recommended to set a breakpoint on the following instruction.
276 | */
277 | }
278 |
279 | #else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
280 | /**
281 | * @brief Timer2 Update/Overflow/Break Interrupt routine.
282 | * @param None
283 | * @retval None
284 | */
285 | extern void I2C_TIM2_UPDATE_ISR(void);
286 | INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13)
287 | {
288 | /* In order to detect unexpected events during development,
289 | it is recommended to set a breakpoint on the following instruction.
290 | */
291 | if (TIM2_GetITStatus(TIM2_IT_UPDATE))
292 | {
293 | I2C_TIM2_UPDATE_ISR();
294 | TIM2->SR1 = (uint8_t)(~(uint8_t)TIM2_IT_UPDATE);
295 | }
296 | }
297 |
298 | /**
299 | * @brief Timer2 Capture/Compare Interrupt routine.
300 | * @param None
301 | * @retval None
302 | */
303 | INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14)
304 | {
305 | /* In order to detect unexpected events during development,
306 | it is recommended to set a breakpoint on the following instruction.
307 | */
308 | }
309 | #endif /*STM8S903*/
310 |
311 | #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
312 | defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x)
313 | /**
314 | * @brief Timer3 Update/Overflow/Break Interrupt routine.
315 | * @param None
316 | * @retval None
317 | */
318 | INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15)
319 | {
320 | /* In order to detect unexpected events during development,
321 | it is recommended to set a breakpoint on the following instruction.
322 | */
323 | }
324 |
325 | /**
326 | * @brief Timer3 Capture/Compare Interrupt routine.
327 | * @param None
328 | * @retval None
329 | */
330 | INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16)
331 | {
332 | /* In order to detect unexpected events during development,
333 | it is recommended to set a breakpoint on the following instruction.
334 | */
335 | }
336 | #endif /*STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
337 |
338 | #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
339 | defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903)
340 | /**
341 | * @brief UART1 TX Interrupt routine.
342 | * @param None
343 | * @retval None
344 | */
345 | INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17)
346 | {
347 | /* In order to detect unexpected events during development,
348 | it is recommended to set a breakpoint on the following instruction.
349 | */
350 | }
351 |
352 | /**
353 | * @brief UART1 RX Interrupt routine.
354 | * @param None
355 | * @retval None
356 | */
357 | INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18)
358 | {
359 | /* In order to detect unexpected events during development,
360 | it is recommended to set a breakpoint on the following instruction.
361 | */
362 | }
363 | #endif /*STM8S208 or STM8S207 or STM8S103 or STM8S903 or STM8AF62Ax or STM8AF52Ax */
364 |
365 | /**
366 | * @brief I2C Interrupt routine.
367 | * @param None
368 | * @retval None
369 | */
370 | INTERRUPT_HANDLER(I2C_IRQHandler, 19)
371 | {
372 | /* In order to detect unexpected events during development,
373 | it is recommended to set a breakpoint on the following instruction.
374 | */
375 | }
376 |
377 | #if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
378 | /**
379 | * @brief UART2 TX interrupt routine.
380 | * @param None
381 | * @retval None
382 | */
383 | INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20)
384 | {
385 | /* In order to detect unexpected events during development,
386 | it is recommended to set a breakpoint on the following instruction.
387 | */
388 | }
389 |
390 | /**
391 | * @brief UART2 RX interrupt routine.
392 | * @param None
393 | * @retval None
394 | */
395 | INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21)
396 | {
397 | /* In order to detect unexpected events during development,
398 | it is recommended to set a breakpoint on the following instruction.
399 | */
400 | }
401 | #endif /* STM8S105 or STM8AF626x */
402 |
403 | #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
404 | /**
405 | * @brief UART3 TX interrupt routine.
406 | * @param None
407 | * @retval None
408 | */
409 | INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20)
410 | {
411 | /* In order to detect unexpected events during development,
412 | it is recommended to set a breakpoint on the following instruction.
413 | */
414 | }
415 |
416 | /**
417 | * @brief UART3 RX interrupt routine.
418 | * @param None
419 | * @retval None
420 | */
421 | INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21)
422 | {
423 | /* In order to detect unexpected events during development,
424 | it is recommended to set a breakpoint on the following instruction.
425 | */
426 | }
427 | #endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */
428 |
429 | #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
430 | /**
431 | * @brief ADC2 interrupt routine.
432 | * @param None
433 | * @retval None
434 | */
435 | INTERRUPT_HANDLER(ADC2_IRQHandler, 22)
436 | {
437 | /* In order to detect unexpected events during development,
438 | it is recommended to set a breakpoint on the following instruction.
439 | */
440 | }
441 | #else /*STM8S105, STM8S103 or STM8S903 or STM8AF626x */
442 | /**
443 | * @brief ADC1 interrupt routine.
444 | * @par Parameters:
445 | * None
446 | * @retval
447 | * None
448 | */
449 | INTERRUPT_HANDLER(ADC1_IRQHandler, 22)
450 | {
451 | /* In order to detect unexpected events during development,
452 | it is recommended to set a breakpoint on the following instruction.
453 | */
454 | }
455 | #endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */
456 |
457 | #ifdef STM8S903
458 | /**
459 | * @brief Timer6 Update/Overflow/Trigger Interrupt routine.
460 | * @param None
461 | * @retval None
462 | */
463 | INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23)
464 | {
465 | /* In order to detect unexpected events during development,
466 | it is recommended to set a breakpoint on the following instruction.
467 | */
468 | }
469 | #else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x */
470 | /**
471 | * @brief Timer4 Update/Overflow Interrupt routine.
472 | * @param None
473 | * @retval None
474 | */
475 | INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23)
476 | {
477 | /* In order to detect unexpected events during development,
478 | it is recommended to set a breakpoint on the following instruction.
479 | */
480 | }
481 | #endif /*STM8S903*/
482 |
483 | /**
484 | * @brief Eeprom EEC Interrupt routine.
485 | * @param None
486 | * @retval None
487 | */
488 | INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24)
489 | {
490 | /* In order to detect unexpected events during development,
491 | it is recommended to set a breakpoint on the following instruction.
492 | */
493 | }
494 |
495 | /**
496 | * @}
497 | */
498 |
499 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
--------------------------------------------------------------------------------
/Firmware/Source/stm8s_it.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm8s_it.h
4 | * @author MCD Application Team
5 | * @version V2.1.0
6 | * @date 18-November-2011
7 | * @brief This file contains the headers of the interrupt handlers
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __STM8S_IT_H
24 | #define __STM8S_IT_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "stm8s.h"
28 |
29 | /* Exported types ------------------------------------------------------------*/
30 | /* Exported constants --------------------------------------------------------*/
31 | /* Exported macro ------------------------------------------------------------*/
32 | /* Exported functions ------------------------------------------------------- */
33 | #ifdef _COSMIC_
34 | void _stext(void); /* RESET startup routine */
35 | INTERRUPT void NonHandledInterrupt(void);
36 | #endif /* _COSMIC_ */
37 |
38 | #ifndef _RAISONANCE_
39 | INTERRUPT void TRAP_IRQHandler(void); /* TRAP */
40 | INTERRUPT void TLI_IRQHandler(void); /* TLI */
41 | INTERRUPT void AWU_IRQHandler(void); /* AWU */
42 | INTERRUPT void CLK_IRQHandler(void); /* CLOCK */
43 | INTERRUPT void EXTI_PORTA_IRQHandler(void); /* EXTI PORTA */
44 | INTERRUPT void EXTI_PORTB_IRQHandler(void); /* EXTI PORTB */
45 | INTERRUPT void EXTI_PORTC_IRQHandler(void); /* EXTI PORTC */
46 | INTERRUPT void EXTI_PORTD_IRQHandler(void); /* EXTI PORTD */
47 | INTERRUPT void EXTI_PORTE_IRQHandler(void); /* EXTI PORTE */
48 |
49 | #ifdef STM8S903
50 | INTERRUPT void EXTI_PORTF_IRQHandler(void); /* EXTI PORTF */
51 | #endif /*STM8S903*/
52 |
53 | #if defined (STM8S208) || defined (STM8AF52Ax)
54 | INTERRUPT void CAN_RX_IRQHandler(void); /* CAN RX */
55 | INTERRUPT void CAN_TX_IRQHandler(void); /* CAN TX/ER/SC */
56 | #endif /* STM8S208 || STM8AF52Ax */
57 |
58 | INTERRUPT void SPI_IRQHandler(void); /* SPI */
59 | INTERRUPT void TIM1_CAP_COM_IRQHandler(void); /* TIM1 CAP/COM */
60 | INTERRUPT void TIM1_UPD_OVF_TRG_BRK_IRQHandler(void); /* TIM1 UPD/OVF/TRG/BRK */
61 |
62 | #ifdef STM8S903
63 | INTERRUPT void TIM5_UPD_OVF_BRK_TRG_IRQHandler(void); /* TIM5 UPD/OVF/BRK/TRG */
64 | INTERRUPT void TIM5_CAP_COM_IRQHandler(void); /* TIM5 CAP/COM */
65 | #else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8A626x*/
66 | INTERRUPT void TIM2_UPD_OVF_BRK_IRQHandler(void); /* TIM2 UPD/OVF/BRK */
67 | INTERRUPT void TIM2_CAP_COM_IRQHandler(void); /* TIM2 CAP/COM */
68 | #endif /*STM8S903*/
69 |
70 | #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
71 | defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x)
72 | INTERRUPT void TIM3_UPD_OVF_BRK_IRQHandler(void); /* TIM3 UPD/OVF/BRK */
73 | INTERRUPT void TIM3_CAP_COM_IRQHandler(void); /* TIM3 CAP/COM */
74 | #endif /*STM8S208, STM8S207 or STM8S105 or STM8AF52Ax or STM8AF62Ax or STM8A626x */
75 |
76 | #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
77 | defined(STM8S003) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903)
78 | INTERRUPT void UART1_TX_IRQHandler(void); /* UART1 TX */
79 | INTERRUPT void UART1_RX_IRQHandler(void); /* UART1 RX */
80 | #endif /*STM8S208, STM8S207, STM8S903 or STM8S103 or STM8AF52Ax or STM8AF62Ax */
81 |
82 | INTERRUPT void I2C_IRQHandler(void); /* I2C */
83 |
84 | #if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
85 | INTERRUPT void UART2_RX_IRQHandler(void); /* UART2 RX */
86 | INTERRUPT void UART2_TX_IRQHandler(void); /* UART2 TX */
87 | #endif /* STM8S105 or STM8AF626x */
88 |
89 | #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
90 | INTERRUPT void UART3_RX_IRQHandler(void); /* UART3 RX */
91 | INTERRUPT void UART3_TX_IRQHandler(void); /* UART3 TX */
92 | #endif /*STM8S207, STM8S208, STM8AF62Ax or STM8AF52Ax */
93 |
94 | #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
95 | INTERRUPT void ADC2_IRQHandler(void); /* ADC2 */
96 | #else /*STM8S105, STM8S103 or STM8S903*/
97 | INTERRUPT void ADC1_IRQHandler(void); /* ADC1 */
98 | #endif /*STM8S207, STM8S208, STM8AF62Ax or STM8AF52Ax */
99 |
100 | #ifdef STM8S903
101 | INTERRUPT void TIM6_UPD_OVF_TRG_IRQHandler(void); /* TIM6 UPD/OVF/TRG */
102 | #else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
103 | INTERRUPT void TIM4_UPD_OVF_IRQHandler(void); /* TIM4 UPD/OVF */
104 | #endif /*STM8S903*/
105 | INTERRUPT void EEPROM_EEC_IRQHandler(void); /* EEPROM ECC CORRECTION */
106 | #endif /* _RAISONANCE_ */
107 |
108 | #endif /* __STM8S_IT_H */
109 |
110 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
111 |
--------------------------------------------------------------------------------
/Hardware/eagle.epf:
--------------------------------------------------------------------------------
1 | [Eagle]
2 | Version="06 03 00"
3 | Platform="Mac OS X"
4 | Serial="62191E841E-LSR-WLM-1EL"
5 | Globals="Globals"
6 | Desktop="Desktop"
7 |
8 | [Globals]
9 | AutoSaveProject=1
10 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/19inch.lbr"
11 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/40xx.lbr"
12 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/41xx.lbr"
13 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/45xx.lbr"
14 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/74ac-logic.lbr"
15 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/74ttl-din.lbr"
16 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/74xx-eu.lbr"
17 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/74xx-little-de.lbr"
18 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/74xx-little-us.lbr"
19 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/74xx-us.lbr"
20 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/751xx.lbr"
21 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/SparkFun.lbr"
22 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/TI_MSP430_v16.lbr"
23 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/adafruit.lbr"
24 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/advanced-test-technologies.lbr"
25 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/agilent-technologies.lbr"
26 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/allegro.lbr"
27 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/altera-cyclone-II.lbr"
28 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/altera-cyclone-III.lbr"
29 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/altera-stratix-iv.lbr"
30 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/altera.lbr"
31 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/am29-memory.lbr"
32 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/amd-mach.lbr"
33 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/amd.lbr"
34 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/amis.lbr"
35 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/analog-devices.lbr"
36 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/ase.lbr"
37 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/atmel.lbr"
38 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/austriamicrosystems.lbr"
39 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/avago.lbr"
40 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/axis.lbr"
41 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/battery.lbr"
42 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/belton-engineering.lbr"
43 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/burr-brown.lbr"
44 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/busbar.lbr"
45 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/buzzer.lbr"
46 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/c-trimm.lbr"
47 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/california-micro-devices.lbr"
48 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/capacitor-wima.lbr"
49 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/chipcard-siemens.lbr"
50 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/cirrus-logic.lbr"
51 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-3m.lbr"
52 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-4ucon.lbr"
53 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-amp-champ.lbr"
54 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-amp-micromatch.lbr"
55 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-amp-mt.lbr"
56 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-amp-mt6.lbr"
57 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-amp-quick.lbr"
58 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-amp-te.lbr"
59 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-amp.lbr"
60 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-amphenol.lbr"
61 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-avx.lbr"
62 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-berg.lbr"
63 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-bosch.lbr"
64 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-chipcard-iso7816.lbr"
65 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-coax.lbr"
66 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-commcon.lbr"
67 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-conrad.lbr"
68 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-cpci.lbr"
69 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-cui.lbr"
70 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-cypressindustries.lbr"
71 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-deutsch.lbr"
72 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-dil.lbr"
73 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-ebyelectro.lbr"
74 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-elco.lbr"
75 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-erni.lbr"
76 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-faston.lbr"
77 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-fci.lbr"
78 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-friwo.lbr"
79 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-garry.lbr"
80 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-harting-h.lbr"
81 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-harting-ml.lbr"
82 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-harting-v.lbr"
83 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-harting.lbr"
84 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-hirose.lbr"
85 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-hirschmann.lbr"
86 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-jack.lbr"
87 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-jae.lbr"
88 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-jst.lbr"
89 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-kycon.lbr"
90 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-kyocera-elco.lbr"
91 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-lemo.lbr"
92 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-leotronics.lbr"
93 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-lsta.lbr"
94 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-lstb.lbr"
95 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-lumberg.lbr"
96 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-ml.lbr"
97 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-molex.lbr"
98 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-neutrik_ag.lbr"
99 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-omron.lbr"
100 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-panasonic.lbr"
101 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-panduit.lbr"
102 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-pc.lbr"
103 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-pc104.lbr"
104 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-phoenix-254.lbr"
105 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-phoenix-3.81.lbr"
106 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-phoenix-350.lbr"
107 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-phoenix-500.lbr"
108 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-phoenix-508.lbr"
109 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-phoenix-762.lbr"
110 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-phoenix-me_max.lbr"
111 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-phoenix-mkds_5.lbr"
112 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-phoenix-smkdsp.lbr"
113 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-ptr500.lbr"
114 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-pulse.lbr"
115 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-rib.lbr"
116 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-samtec.lbr"
117 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-shallin.lbr"
118 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-shiua-chyuan.lbr"
119 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-stewart.lbr"
120 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-stocko.lbr"
121 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-subd.lbr"
122 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-sullinselectronics.lbr"
123 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-thomas-betts.lbr"
124 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-tyco.lbr"
125 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-tycoelectronics.lbr"
126 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-vg.lbr"
127 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-wago-500.lbr"
128 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-wago-508.lbr"
129 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-wago.lbr"
130 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-wago255.lbr"
131 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-weidmueller-sl35.lbr"
132 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-wenzhou-yihua.lbr"
133 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-xmultiple.lbr"
134 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/con-yamaichi.lbr"
135 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/crystal.lbr"
136 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/csr.lbr"
137 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/cypress.lbr"
138 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/davicom.lbr"
139 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/dc-dc-converter.lbr"
140 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/dimensions.lbr"
141 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/diode.lbr"
142 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/discrete.lbr"
143 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/display-hp.lbr"
144 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/display-kingbright.lbr"
145 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/display-lcd.lbr"
146 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/docu-dummy.lbr"
147 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/dp_devices.lbr"
148 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/ecl.lbr"
149 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/em-microelectronic.lbr"
150 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/etx-board.lbr"
151 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/exar.lbr"
152 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/fairchild-semic.lbr"
153 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/farnell.lbr"
154 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/fiber-optic-hp.lbr"
155 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/fiber-optic-siemens.lbr"
156 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/fifo.lbr"
157 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/flexipanel.lbr"
158 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/fox-electronics.lbr"
159 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/frames.lbr"
160 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/freescale.lbr"
161 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/ftdichip.lbr"
162 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/fujitsu.lbr"
163 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/fuse.lbr"
164 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/gennum.lbr"
165 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/halo-electronics.lbr"
166 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/heatsink.lbr"
167 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/holes.lbr"
168 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/holtek.lbr"
169 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/ic-package.lbr"
170 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/inductor-coilcraft.lbr"
171 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/inductor-neosid.lbr"
172 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/inductor-nkl.lbr"
173 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/inductors.lbr"
174 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/infineon-tricore.lbr"
175 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/infineon.lbr"
176 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/intersil-techwell.lbr"
177 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/intersil.lbr"
178 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/ir.lbr"
179 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/isd.lbr"
180 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/johanson-technology.lbr"
181 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/jump-0r-smd.lbr"
182 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/jumper.lbr"
183 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/lantronix.lbr"
184 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/lattice.lbr"
185 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/lc-filter.lbr"
186 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/led-7-segment.lbr"
187 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/led-citizen-electronics.lbr"
188 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/led-lumiled.lbr"
189 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/led.lbr"
190 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/lem.lbr"
191 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/linear-technology.lbr"
192 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/linear.lbr"
193 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/linx.lbr"
194 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/logo.lbr"
195 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/lprs.lbr"
196 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/lsi-computer-systems.lbr"
197 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/lumiled.lbr"
198 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/marks.lbr"
199 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/maxim.lbr"
200 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/maxstream.lbr"
201 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/melexis.lbr"
202 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/memory-hitachi.lbr"
203 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/memory-idt.lbr"
204 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/memory-micron.lbr"
205 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/memory-motorola-dram.lbr"
206 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/memory-nec.lbr"
207 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/memory-samsung.lbr"
208 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/memory-sram.lbr"
209 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/memory.lbr"
210 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/mems.lbr"
211 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micrel.lbr"
212 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-cyrod.lbr"
213 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-fujitsu.lbr"
214 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-harris.lbr"
215 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-hitachi.lbr"
216 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-infineon.lbr"
217 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-intel.lbr"
218 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-mc68000.lbr"
219 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-motorola.lbr"
220 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-philips.lbr"
221 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-renesas.lbr"
222 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-samsung.lbr"
223 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micro-siemens.lbr"
224 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/microchip.lbr"
225 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micron.lbr"
226 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/micronas.lbr"
227 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/microphon.lbr"
228 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/microwave.lbr"
229 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/midori-sensor.lbr"
230 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/minicircuits.lbr"
231 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/mitsubishi-semiconductor.lbr"
232 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/motorola-sensor-driver.lbr"
233 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/murata-filter.lbr"
234 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/murata-sensor.lbr"
235 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/nanotec.lbr"
236 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/national-instruments.lbr"
237 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/national-semiconductor.lbr"
238 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/nec-lqfp100-pack.lbr"
239 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/nec.lbr"
240 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/nrj-semiconductor.lbr"
241 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/omnivision.lbr"
242 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/on-semiconductor.lbr"
243 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/opto-honeywell-3000.lbr"
244 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/opto-honeywell-4000.lbr"
245 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/opto-honeywell.lbr"
246 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/opto-micro-linear.lbr"
247 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/opto-trans-siemens.lbr"
248 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/opto-transmittter-hp.lbr"
249 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/opto-vishay.lbr"
250 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/optocoupler.lbr"
251 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/pal.lbr"
252 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/philips-semiconductors.lbr"
253 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/photo-elements.lbr"
254 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/piher.lbr"
255 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/pinhead.lbr"
256 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/plcc-socket.lbr"
257 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/pld-intel.lbr"
258 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/plxtech.lbr"
259 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/pot-vitrohm.lbr"
260 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/pot-xicor.lbr"
261 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/pot.lbr"
262 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/ptc-ntc.lbr"
263 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/quantum-research-group.lbr"
264 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/rcl.lbr"
265 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/recom-international.lbr"
266 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/rectifier.lbr"
267 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/ref-packages-longpad.lbr"
268 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/ref-packages.lbr"
269 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/relay.lbr"
270 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/renesas.lbr"
271 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/resistor-bourns.lbr"
272 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/resistor-dil.lbr"
273 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/resistor-net.lbr"
274 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/resistor-power.lbr"
275 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/resistor-ruf.lbr"
276 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/resistor-shunt.lbr"
277 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/resistor-sil.lbr"
278 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/resistor.lbr"
279 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/rf-micro-devices.lbr"
280 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/rf-solutions.lbr"
281 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/rohm.lbr"
282 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/semicon-smd-ipc.lbr"
283 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/sensor-comus-group.lbr"
284 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/sensor-heraeus.lbr"
285 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/sensor-infratec.lbr"
286 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/sharp.lbr"
287 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/silabs.lbr"
288 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/sim-technology.lbr"
289 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/sipex.lbr"
290 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/smd-ipc.lbr"
291 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/smd-special.lbr"
292 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/solomon-systech.lbr"
293 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/solpad.lbr"
294 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/special-drill.lbr"
295 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/special.lbr"
296 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/st-microelectronics.lbr"
297 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/supertex.lbr"
298 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/supply1.lbr"
299 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/supply2.lbr"
300 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/switch-alps.lbr"
301 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/switch-coto.lbr"
302 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/switch-dil.lbr"
303 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/switch-misc.lbr"
304 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/switch-omron.lbr"
305 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/switch-raychem.lbr"
306 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/switch-reed.lbr"
307 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/switch.lbr"
308 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/telcom.lbr"
309 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/telecontrolli.lbr"
310 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/telefunken.lbr"
311 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/testpad.lbr"
312 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/texas-sn55-sn75.lbr"
313 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/texas.lbr"
314 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/toshiba.lbr"
315 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/traco-electronic.lbr"
316 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/trafo-bei.lbr"
317 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/trafo-hammondmfg.lbr"
318 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/trafo-siemens.lbr"
319 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/trafo-xicon.lbr"
320 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/trafo.lbr"
321 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/transformer-pulse.lbr"
322 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/transistor-fet.lbr"
323 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/transistor-neu-to92.lbr"
324 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/transistor-npn.lbr"
325 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/transistor-pnp.lbr"
326 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/transistor-power.lbr"
327 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/transistor-small-signal.lbr"
328 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/transistor.lbr"
329 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/triac.lbr"
330 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/trimble.lbr"
331 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/tripas.lbr"
332 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/u-blox.lbr"
333 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/uln-udn.lbr"
334 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/v-reg-micrel.lbr"
335 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/v-reg.lbr"
336 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/varistor.lbr"
337 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/wafer-scale-psd.lbr"
338 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/wirepad.lbr"
339 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/xicor.lbr"
340 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/xilinx-virtex-v5.lbr"
341 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/xilinx-xc18v.lbr"
342 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/xilinx-xc9.lbr"
343 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/xilinx-xcv.lbr"
344 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/zetex.lbr"
345 | UsedLibrary="/Applications/EAGLE-6.3.0/lbr/zilog.lbr"
346 |
347 | [Win_1]
348 | Type="Control Panel"
349 | Loc="320 218 919 617"
350 | State=2
351 | Number=0
352 |
353 | [Desktop]
354 | Screen="1280 800"
355 | Window="Win_1"
356 |
--------------------------------------------------------------------------------
/Hardware/voltmeter-hack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Hardware/voltmeter-hack.png
--------------------------------------------------------------------------------
/Hardware/voltmeter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t0mpr1c3/I2C-LED/44852b6c8021e8b276859c43958f3ee2ea019c2a/Hardware/voltmeter.png
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # 7 segment LED display with I2C interface hacked from cheap voltmeter
2 |
3 | This project is described on a blog page (http://smokedprojects.blogspot.com/2013/08/i2c-led-display-from-hacked-voltmeter.html) and archived in a github repository (https://github.com/t0mpr1c3/I2C-LED).
4 |
5 | The original hardware was designed as a 4-digit voltmeter using a STM8S003F3P6 MCU. They can be bought from http://www.buyincoins.com/item/26010.html ("New 4 Digit 4.5-30V Stm8s003 Master Control Two Lines Red LED Digital Voltmeter") or http://www.buyincoins.com/item/26011.html ("4 Digit 4.5-30V Stm8s003 Master Control Two Lines Blue LED Digital in any way). Please note that I'm not associated with the seller in any way.
6 |
7 | I adapted a similar project (documented http://www.ba0sh1.com/hacking-a-cheap-led-voltmeter/ and https://github.com/baoshi/I2C-LED) to modify the voltmeter into an I2C display device. The majority of the source code goes into bit banging the I2C slave protocol, as the original I2C pins are occupied by the LED. With full compiler optimization I2C clock up to 50kHz is supported.
8 |
9 | A emulation layer for the "Adafruit 4-Digit 7-Segment Display Backpack" http://www.adafruit.com/products/878 is also implemented. Original Adafruit Arduino demo codes are used for testing. Note that in order to run the Arduino code, the I2C clock needs to be reduced to 50 kHz.
10 |
11 | The free KickStart edition of "IAR Embedded Workbench for STMicroelectronics STM8" was used for development. STM8S/A Standard Peripherals Library (STM8S_StdPeriph_Driver V2.1.0: stsw-stm8069.zip from the http://www.st.com STM8 firmware page) was also needed.
--------------------------------------------------------------------------------