├── README.md
├── STM32F0-FastADC.cogui
├── STM32F0-FastADC.comarker
├── STM32F0-FastADC.coproj
├── STM32F0-FastADC
├── Debug
│ ├── bin
│ │ ├── STM32F0-FastADC.bin
│ │ ├── STM32F0-FastADC.elf
│ │ ├── STM32F0-FastADC.hex
│ │ ├── STM32F0-FastADC.map
│ │ └── history.xml
│ └── obj
│ │ ├── history.xml
│ │ ├── main.o
│ │ ├── startup_stm32f0xx.o
│ │ ├── stm32f0xx_adc.o
│ │ ├── stm32f0xx_dma.o
│ │ ├── stm32f0xx_gpio.o
│ │ ├── stm32f0xx_misc.o
│ │ ├── stm32f0xx_rcc.o
│ │ ├── stm32f0xx_syscfg.o
│ │ ├── stm32f0xx_tim.o
│ │ └── system_stm32f0xx_temp.o
└── STM32F0-FastADC.elf.xcodeproj
│ └── project.pbxproj
├── cmsis_boot
├── startup
│ └── startup_stm32f0xx.s
├── stm32f0xx.h
├── stm32f0xx_conf.h
├── system_stm32f0xx.h
└── system_stm32f0xx_temp.c
├── cmsis_core
├── core_cm0.h
├── core_cmFunc.h
└── core_cmInstr.h
├── main.c
└── stm32_lib
├── inc
├── stm32f0xx_adc.h
├── stm32f0xx_dma.h
├── stm32f0xx_gpio.h
├── stm32f0xx_misc.h
├── stm32f0xx_rcc.h
├── stm32f0xx_syscfg.h
└── stm32f0xx_tim.h
└── src
├── stm32f0xx_adc.c
├── stm32f0xx_dma.c
├── stm32f0xx_gpio.c
├── stm32f0xx_misc.c
├── stm32f0xx_rcc.c
├── stm32f0xx_syscfg.c
└── stm32f0xx_tim.c
/README.md:
--------------------------------------------------------------------------------
1 | # STM32F0-FastADC
2 | Testing the maximum speeds for the internal STM32F0 ADCs!
3 |
--------------------------------------------------------------------------------
/STM32F0-FastADC.comarker:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/STM32F0-FastADC.coproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/bin/STM32F0-FastADC.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/bin/STM32F0-FastADC.bin
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/bin/STM32F0-FastADC.elf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/bin/STM32F0-FastADC.elf
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/bin/STM32F0-FastADC.hex:
--------------------------------------------------------------------------------
1 | :020000040800F2
2 | :1000000000200020E10800082D0900082D09000843
3 | :1000100000000000000000000000000000000000E0
4 | :100020000000000000000000000000002D09000892
5 | :1000300000000000000000002D0900082D09000844
6 | :100040002D0900082D0900082D0900082D090008B8
7 | :100050002D0900082D0900082D0900082D090008A8
8 | :100060002D0900082D0900082D0900082D09000898
9 | :100070002D0900082D0900082D0900082D09000888
10 | :100080002D0900082D090008000000002D090008B6
11 | :100090002D0900082D0900082D0900082D09000868
12 | :1000A0002D0900082D0900082D0900082D09000858
13 | :1000B0002D090008000000002D09000800000000C4
14 | :1000C0005FF808F180B582B000AF021CFB1D1A700A
15 | :1000D000044B00221A70034AFB1D1B781370BD46A7
16 | :1000E00002B080BD0210024080B582B000AF7860DF
17 | :1000F0003960084B074A526807490A405A60054B65
18 | :10010000044A516878683A6802430A435A60BD4617
19 | :1001100002B080BD00100240FFFFC2FF80B582B078
20 | :1001200000AF021CFB1D1A70FB1D1B78002B07D0B3
21 | :10013000084B084A1268802149040A431A6005E006
22 | :10014000044B044A126804490A401A60BD4602B0D2
23 | :1001500080BDC04600100240FFFFFFFE80B584B0A6
24 | :1001600000AF78600023FB60084BDB6AFB60FB6834
25 | :100170000F229343FB60FA687B681343FB60034BD9
26 | :10018000FA68DA62BD4604B080BDC0460010024085
27 | :1001900080B584B000AF78600023FB60084B5B68DB
28 | :1001A000FB60FB6803229343FB60FA687B681343A0
29 | :1001B000FB60034BFA685A60BD4604B080BDC04680
30 | :1001C0000010024080B582B000AF78600E4B0E4A3E
31 | :1001D00052680E490A405A600B4B0B4A51687A68C4
32 | :1001E0001204120C0A435A60074B074A126B084963
33 | :1001F0000A401A63044B044A116B7A68120C0A43D2
34 | :100200001A63BD4602B080BD00100240FFBFFFFF71
35 | :10021000FFFEFFFF80B588B000AF78600023FB6170
36 | :100220000023BB6100237B6100233B610023FB6053
37 | :10023000654B5B680C221340FB61FB69042B07D004
38 | :10024000082B09D0002B31D17B68604A1A6031E05D
39 | :100250007B685E4A1A602DE05B4B5A68F0239B0373
40 | :100260001340BB61584B5A6880235B0213407B618B
41 | :10027000BB699B0C0233BB617B69002B05D1BB6959
42 | :10028000534A5A437B681A6014E04F4BDB6A0F22D3
43 | :10029000134001333B614D48396900F0CBFD031C2D
44 | :1002A0001A1CBB695A437B681A6003E07B68474AA3
45 | :1002B0001A60C046444B5B68F0221340FB61FB6947
46 | :1002C0001B09FB61434AFB69D3181B78DBB2FB6057
47 | :1002D0007B681A68FB68DA407B685A603A4B5A6858
48 | :1002E000E023DB001340FB61FB691B0AFB61394A19
49 | :1002F000FB69D3181B78DBB2FB607B685A68FB682C
50 | :10030000DA407B689A60304B1A6B80235B001340A5
51 | :1003100003D17B68304ADA6010E02B4B5A688023A7
52 | :10032000DB01134005D17B689B685A087B68DA6063
53 | :1003300004E07B689B689A087B68DA60224B1B6B41
54 | :100340004022134003D17B68244A1A6103E07B6892
55 | :10035000802212021A611C4B1B6B1022134003D126
56 | :100360007B681A4A5A6103E07B681A687B685A61A5
57 | :10037000154B1B6B0322134004D17B689A687B6882
58 | :100380009A611EE0104B1B6B03221340012B04D11A
59 | :100390007B681A687B689A6113E00B4B1B6B032226
60 | :1003A0001340022B04D17B68802212029A6108E07C
61 | :1003B000054B1B6B03221340032B02D17B68034ABE
62 | :1003C0009A61BD4608B080BD0010024000127A005C
63 | :1003D00000093D0000000020809FD5001280000031
64 | :1003E00080B582B000AF78600A1CFB1C1A70FB1C41
65 | :1003F0001B78002B06D0084B074A51697A680A43DC
66 | :100400005A6106E0044B044A52697968C9430A40BC
67 | :100410005A61BD4602B080BD0010024080B582B076
68 | :1004200000AF78600A1CFB1C1A70FB1C1B78002BA9
69 | :1004300006D0084B074A91697A680A439A6106E038
70 | :10044000044B044A92697968C9430A409A61BD46DF
71 | :1004500002B080BD0010024080B586B000AF021C23
72 | :10046000FB1D1A700023FB6000237B611323FB1824
73 | :1004700000221A70FB1D1B785B09DBB2FB60FB6876
74 | :10048000002B03D1184B1B687B6110E0FB68012B2C
75 | :1004900003D1154B1B6A7B6109E0FB68022B03D17A
76 | :1004A000114B5B6A7B6102E00F4B5B6B7B61FB1D59
77 | :1004B0001B781F221340FB60FB687A69DA40131C2B
78 | :1004C0000122134004D01323FB1801221A7003E009
79 | :1004D0001323FB1800221A701323FB181B78181C17
80 | :1004E000BD4606B080BDC0460010024080B584B055
81 | :1004F00000AF786039600023FB607B68DB68FB60DD
82 | :10050000FB680F4A1340FB603B681A683B681B7925
83 | :100510005B031A433B689B681A433B68DB681A43DA
84 | :100520003B681B691A433B685B691343FA681343D2
85 | :10053000FB607B68FA68DA60BD4604B080BDC046E7
86 | :1005400003D2FFFF80B582B000AF78600A1CFB1CAD
87 | :100550001A70FB1C1B78002B06D07B689B6801225D
88 | :100560001A437B689A6005E07B689B6802221A4305
89 | :100570007B689A60BD4602B080BDC04680B586B03B
90 | :1005800000AFF860B9607A6000237B61FB689A6A0B
91 | :10059000BB681A43FB689A627B69072293437B61BD
92 | :1005A0007A697B6813437B61FB687A695A61BD464F
93 | :1005B00006B080BD80B586B000AF786000237B6157
94 | :1005C00000233B610023FB607B689B68802212064E
95 | :1005D0001A437B689A607B689B68DB0FDB07FB60D4
96 | :1005E0003B6901333B613A69F0231B029A4202D016
97 | :1005F000FB68002BEFD17B689B68002B03DB7B68DB
98 | :100600001B6C7B6101E000237B617B69181CBD468C
99 | :1006100006B080BD80B582B000AF78607B689B6813
100 | :1006200004221A437B689A60BD4602B080BDC04672
101 | :1006300080B582B000AF78600A1CFB1C1A70FB1CEE
102 | :100640001B78002B06D07B68DB6801221A437B688D
103 | :10065000DA6006E07B68DB68012293431A1C7B6842
104 | :10066000DA60BD4602B080BD80B584B000AF78606E
105 | :1006700039600F23FB1800221A700023BB603A6810
106 | :1006800080235B04134005D07B689B680D4A1340B0
107 | :10069000BB6002E07B681B68BB60BB683A681340C4
108 | :1006A00004D00F23FB1801221A7003E00F23FB185C
109 | :1006B00000221A700F23FB181B78181CBD4604B0CB
110 | :1006C00080BDC046FFFFFFFE80B582B000AF0020B6
111 | :1006D000FFF75EFD0520FFF7F5FC0120FFF73EFD6B
112 | :1006E0000020FFF71BFD80235A02A0239B03101C50
113 | :1006F000191CFFF7F9FC0120FFF710FDC046192077
114 | :10070000FFF7AAFE031EFAD00220FFF741FD802367
115 | :100710009B02181C0121FFF763FE01200121FFF756
116 | :100720005FFE80239B00181C0121FFF777FE8023CA
117 | :100730005B02181C0121FFF771FE5D4B181CFFF7CF
118 | :1007400069FD80235B04181CFFF73CFD594B012217
119 | :100750001A60584B03221A71564B00229A71554B5E
120 | :100760000122DA71534B03225A719023DA05514B5F
121 | :10077000101C191C00F018FA4F4B00221A714E4B36
122 | :1007800000221A614C4B80225200DA604A4B8022D0
123 | :10079000D2009A60484B10221A60474B00225A61DF
124 | :1007A000464A454B101C191CFFF7A0FE434B181C72
125 | :1007B000FFF700FF414B181C0121FFF739FF3F4BAA
126 | :1007C000181C0121FFF7BEFEC0463C4B181C01213E
127 | :1007D000FFF74AFF031EF8D0384B181C01210022F6
128 | :1007E000FFF7CCFE364B00221A81354B00225A808F
129 | :1007F0002F4B9B68181C334900F01CFB031C5A1E2E
130 | :100800002F4B5A602E4B00221A802D4B00229A72D9
131 | :100810002D4A2B4B101C191C00F058FA2A4B181C9F
132 | :10082000202100F0EBFA294B294ADA60274B0022FD
133 | :100830009A60264B00229A62264A244B5A60234B28
134 | :100840000022DA61214B80225A61204B20221A6259
135 | :100850001E4B214A1A601D4B00229A611B4B00223D
136 | :100860001A611A4BC02292015A621C4A174B101C83
137 | :10087000191C00F05DF8194B181C012100F094F8C8
138 | :10088000114B181C012100F099FA00237B600B4BDF
139 | :10089000181CFFF7BFFEC046022000F0A3F8031E9D
140 | :1008A000FAD0022000F0BEF87B6801337B60EEE7EF
141 | :1008B000C81D0020C01D0020881D0020002401400C
142 | :1008C000B41D002040420F00004001405C1D00208C
143 | :1008D0004C1D000010000020402401400800024090
144 | :1008E0000C488546002103E00B4B5B584350043114
145 | :1008F0000A480B4B42189A42F6D30A4A02E00023F8
146 | :1009000013600432084B9A42F9D300F097F8FFF7CE
147 | :10091000DBFEFEE700200020580F0008000000204A
148 | :100920001000002010000020E41D0020FEE7000061
149 | :1009300080B584B000AF786039600023FB607B68CD
150 | :100940001B68FB60FB68174A1340FB603B689A68B2
151 | :100950003B681B6A1A433B681B691A433B685B6927
152 | :100960001A433B689B691A433B68DB691A433B683F
153 | :100970005B6A1A433B689B6A1343FA681343FB6044
154 | :100980007B68FA681A603B68DA687B685A603B6883
155 | :100990001A687B689A603B685A687B68DA60BD4673
156 | :1009A00004B080BD0F80FFFF80B582B000AF7860DB
157 | :1009B0000A1CFB1C1A70FB1C1B78002B06D07B68E2
158 | :1009C0001B6801221A437B681A6005E07B681B687C
159 | :1009D000034A1A407B681A60BD4602B080BDC0461B
160 | :1009E000FEFF000080B584B000AF78600F23FB18D5
161 | :1009F00000221A700A4B1B687A68134004D00F2338
162 | :100A0000FB1801221A7003E00F23FB1800221A7052
163 | :100A10000F23FB181B78181CBD4604B080BDC046D0
164 | :100A20000000024080B582B000AF7860024B7A6867
165 | :100A30005A60BD4602B080BD0000024080B500AFE4
166 | :100A40001B4B1B4A126801210A431A60184B184AB3
167 | :100A5000526818490A405A60154B154A12681649DF
168 | :100A60000A401A60124B124A126814490A401A606E
169 | :100A70000F4B0F4A526812490A405A600C4B0C4AFD
170 | :100A8000D26A0F218A43DA62094B094A126B0D4977
171 | :100A90000A401A63064B064A526B01218A435A6385
172 | :100AA000034B00229A6000F00FF8BD4680BDC0469F
173 | :100AB000001002400CB8FFF8FFFFF6FEFFFFFBFF3F
174 | :100AC000FFFFC0FFACFEFFFF80B582B000AF002388
175 | :100AD0007B6000233B60314B304A12688021490221
176 | :100AE0000A431A602D4B1A6880239B0213403B6017
177 | :100AF0007B6801337B603B68002B04D17A68A023BC
178 | :100B0000DB019A42EED1254B1A6880239B021340E9
179 | :100B100002D001233B6001E000233B603B68012BD6
180 | :100B200038D11F4B11221A601C4B1C4A52685A6064
181 | :100B30001A4B1A4A52685A60184B184A5268194997
182 | :100B40000A405A60154B154A5268882149030A43E6
183 | :100B50005A60124B114A1268802149040A431A60F4
184 | :100B6000C0460E4B1A6880239B041340F9D00B4BF0
185 | :100B70000A4A526803218A435A60084B074A52685E
186 | :100B800002210A435A60C046044B5B680C221340A2
187 | :100B9000082BF9D1BD4602B080BDC046001002400E
188 | :100BA00000200240FFFFC0FF80B586B000AF786034
189 | :100BB000396000237B6100233B610023FB6000233D
190 | :100BC0007B617CE07B6901229A40131C3B613B689E
191 | :100BD0001B683A691340FB60FA683B699A426BD123
192 | :100BE0003B681B79012B03D03B681B79022B34D166
193 | :100BF0007B689B687A695200111C03228A40D243A9
194 | :100C00001A407B689A607B689A683B685B79191C1C
195 | :100C10007B695B0099400B1C1A437B689A607B6878
196 | :100C20009B889BB27A6992B2111C01228A4092B2CF
197 | :100C3000D24392B213409AB27B689A807B689B88B9
198 | :100C40009AB23B689B79191C7B699BB299400B1C3B
199 | :100C50009BB213439AB27B689A807B681B687A695F
200 | :100C60005200111C03228A40D2431A407B681A604A
201 | :100C70007B681A683B681B79191C7B695B0099408B
202 | :100C80000B1C1A437B681A607B68DB687A6992B236
203 | :100C90005200032191400A1CD2431A407B68DA605B
204 | :100CA0007B68DA683B68DB79191C7B695B009940DB
205 | :100CB0000B1C1A437B68DA607B6901337B617B69BB
206 | :100CC0000F2B00D87EE7BD4606B080BD80B584B04E
207 | :100CD00000AF786039600E23FB1800221A800E23C3
208 | :100CE000FB187A6812881A807B682D4A934208D0D4
209 | :100CF0007A688023DB059A4203D07B68294A9342B5
210 | :100D000010D10E23FB180E22BA18128870218A43C4
211 | :100D10001A803B6859880E23FB180E22BA181288D5
212 | :100D20000A431A807B68204A934210D00E23FB1896
213 | :100D30000E22BA1812881D490A401A803B68198988
214 | :100D40000E23FB180E22BA1812880A431A807B68F9
215 | :100D50000E22BA1812881A803B685A687B68DA62D9
216 | :100D60003B681A887B681A857B680D4A93420BD0D2
217 | :100D70007B680F4A934207D07B680E4A934203D0A8
218 | :100D80007B680D4A934204D13B689B7A9AB27B6898
219 | :100D90001A867B6801229A82BD4604B080BDC04697
220 | :100DA000002C01400004004000100040FFFCFFFF49
221 | :100DB00000400140004401400048014080B582B03D
222 | :100DC00000AF78600A1CFB1C1A70FB1C1B78002B00
223 | :100DD00008D07B681B889BB2012213439AB27B68C0
224 | :100DE0001A8007E07B681B889BB2012293439AB26A
225 | :100DF0007B681A80BD4602B080BDC04680B582B017
226 | :100E000000AF78600A1CBB1C1A807B689B889BB271
227 | :100E1000702293439AB27B689A807B689B889AB2CF
228 | :100E2000BB1C1B8813439AB27B689A80BD4602B0F4
229 | :100E300080BDC046002243088B4274D303098B4215
230 | :100E40005FD3030A8B4244D3030B8B4228D3030C9A
231 | :100E50008B420DD3FF22090212BA030C8B4202D33C
232 | :100E60001212090265D0030B8B4219D300E0090A64
233 | :100E7000C30B8B4201D3CB03C01A5241830B8B426D
234 | :100E800001D38B03C01A5241430B8B4201D34B0356
235 | :100E9000C01A5241030B8B4201D30B03C01A5241BB
236 | :100EA000C30A8B4201D3CB02C01A5241830A8B4240
237 | :100EB00001D38B02C01A5241430A8B4201D34B0229
238 | :100EC000C01A5241030A8B4201D30B02C01A52418D
239 | :100ED000CDD2C3098B4201D3CB01C01A5241830941
240 | :100EE0008B4201D38B01C01A524143098B4201D37B
241 | :100EF0004B01C01A524103098B4201D30B01C01AA6
242 | :100F00005241C3088B4201D3CB00C01A524183081F
243 | :100F10008B4201D38B00C01A524143088B4201D34C
244 | :100F20004B00C01A5241411A00D2014652411046AC
245 | :100F30007047FFE701B5002000F00CF802BDC04685
246 | :100F40000029F7D003B5FFF775FF0EBC4243891A9D
247 | :080F50001847C0467047C04677
248 | :100F58000000000001020304010203040607080957
249 | :0400000508000000EF
250 | :00000001FF
251 |
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/bin/history.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/obj/history.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/obj/main.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/obj/main.o
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/obj/startup_stm32f0xx.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/obj/startup_stm32f0xx.o
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/obj/stm32f0xx_adc.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/obj/stm32f0xx_adc.o
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/obj/stm32f0xx_dma.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/obj/stm32f0xx_dma.o
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/obj/stm32f0xx_gpio.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/obj/stm32f0xx_gpio.o
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/obj/stm32f0xx_misc.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/obj/stm32f0xx_misc.o
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/obj/stm32f0xx_rcc.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/obj/stm32f0xx_rcc.o
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/obj/stm32f0xx_syscfg.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/obj/stm32f0xx_syscfg.o
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/obj/stm32f0xx_tim.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/obj/stm32f0xx_tim.o
--------------------------------------------------------------------------------
/STM32F0-FastADC/Debug/obj/system_stm32f0xx_temp.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pyrohaz/STM32F0-FastADC/0e45bb26c2cd768c31762a701daed5e96c41de84/STM32F0-FastADC/Debug/obj/system_stm32f0xx_temp.o
--------------------------------------------------------------------------------
/STM32F0-FastADC/STM32F0-FastADC.elf.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | archiveVersion1classesobjectVersion42objects000000000000000000000000isaPBXFileReferencenamemain.cpath../main.csourceTreeSOURCE_ROOT000000000000000000000001isaPBXFileReferencenamestartup_stm32f0xx.spath../cmsis_boot/startup/startup_stm32f0xx.ssourceTreeSOURCE_ROOT000000000000000000000002isaPBXFileReferencenamestm32f0xx_adc.cpath../stm32_lib/src/stm32f0xx_adc.csourceTreeSOURCE_ROOT000000000000000000000003isaPBXFileReferencenamestm32f0xx_dma.cpath../stm32_lib/src/stm32f0xx_dma.csourceTreeSOURCE_ROOT000000000000000000000004isaPBXFileReferencenamestm32f0xx_gpio.cpath../stm32_lib/src/stm32f0xx_gpio.csourceTreeSOURCE_ROOT000000000000000000000005isaPBXFileReferencenamestm32f0xx_misc.cpath../stm32_lib/src/stm32f0xx_misc.csourceTreeSOURCE_ROOT000000000000000000000006isaPBXFileReferencenamestm32f0xx_rcc.cpath../stm32_lib/src/stm32f0xx_rcc.csourceTreeSOURCE_ROOT000000000000000000000007isaPBXFileReferencenamestm32f0xx_syscfg.cpath../stm32_lib/src/stm32f0xx_syscfg.csourceTreeSOURCE_ROOT000000000000000000000008isaPBXFileReferencenamestm32f0xx_tim.cpath../stm32_lib/src/stm32f0xx_tim.csourceTreeSOURCE_ROOT000000000000000000000009isaPBXFileReferencenamesystem_stm32f0xx_temp.cpath../cmsis_boot/system_stm32f0xx_temp.csourceTreeSOURCE_ROOT00000000000000000000000achildren000000000000000000000000000000000000000000000001000000000000000000000002000000000000000000000003000000000000000000000004000000000000000000000005000000000000000000000006000000000000000000000007000000000000000000000008000000000000000000000009isaPBXGroupnameSourcesourceTree<source>00000000000000000000000bexplicitFileTypecompiled.mach-o.executableincludeInIndex0isaPBXFileReferencenameSTM32F0-FastADC.elfpath../../../STM32F0-FastADC/Debug/bin/STM32F0-FastADC.elfsourceTreeBUILD_PRODUCTS_DIR00000000000000000000000cchildren00000000000000000000000bisaPBXGroupnameProductssourceTree<source>00000000000000000000000dchildrenisaPBXGroupnameDocumentationsourceTree<source>00000000000000000000000echildren00000000000000000000000a00000000000000000000000d00000000000000000000000cisaPBXGroupnameSTM32F0-FastADC.elfsourceTree<source>00000000000000000000000fbuildSettingsGCC_PREPROCESSOR_DEFINITIONSSTM32F051R8STM32F0XX_MDUSE_STDPERIPH_DRIVER__ASSEMBLY__$(inherited)GCC_WARN_ABOUT_RETURN_TYPEYESGCC_WARN_UNUSED_VARIABLEYESHEADER_SEARCH_PATHS../stm32_lib/inc../stm32_lib../cmsis_boot../..../cmsis_core..${inherited)LIBRARY_SEARCH_PATHSOTHER_LDFLAGSPREBINDINGNOSDKROOT/Developer/SDKs/MacOSX10.4u.sdkisaXCBuildConfigurationnameDebug000000000000000000000010buildSettingsGCC_PREPROCESSOR_DEFINITIONSSTM32F051R8STM32F0XX_MDUSE_STDPERIPH_DRIVER__ASSEMBLY__$(inherited)GCC_WARN_ABOUT_RETURN_TYPEYESGCC_WARN_UNUSED_VARIABLEYESHEADER_SEARCH_PATHS../stm32_lib/inc../stm32_lib../cmsis_boot../..../cmsis_core..${inherited)LIBRARY_SEARCH_PATHSOTHER_LDFLAGSPREBINDINGNOSDKROOT/Developer/SDKs/MacOSX10.4u.sdkisaXCBuildConfigurationnameRelease000000000000000000000011buildConfigurations00000000000000000000000f000000000000000000000010defaultConfigurationIsVisible0defaultConfigurationNameDebugisaXCConfigurationList000000000000000000000012buildConfigurationList000000000000000000000011hasScannedForEncodings0isaPBXProjectmainGroup00000000000000000000000eprojectDirPathprojectRoot../../../configuration/ProgramData/STM32F0-FastADCtargets000000000000000000000023000000000000000000000013buildSettingsCOPY_PHASE_STRIPNOGCC_DYNAMIC_NO_PICNOGCC_ENABLE_FIX_AND_CONTINUEYESGCC_MODEL_TUNINGG5GCC_OPTIMIZATION_LEVEL0INSTALL_PATH$(HOME)/binPRODUCT_NAMESTM32F0-FastADC.elfZERO_LINKYESisaXCBuildConfigurationnameDebug000000000000000000000014buildSettingsARCHSppci386GCC_GENERATE_DEBUGGING_SYMBOLSNOGCC_MODEL_TUNINGG5INSTALL_PATH$(HOME)/binPRODUCT_NAMESTM32F0-FastADC.elfisaXCBuildConfigurationnameRelease000000000000000000000015buildConfigurations000000000000000000000013000000000000000000000014isaXCConfigurationList000000000000000000000016fileRef000000000000000000000000isaPBXBuildFilesettingsATTRIBUTES000000000000000000000017fileRef000000000000000000000001isaPBXBuildFilesettingsATTRIBUTES000000000000000000000018fileRef000000000000000000000002isaPBXBuildFilesettingsATTRIBUTES000000000000000000000019fileRef000000000000000000000003isaPBXBuildFilesettingsATTRIBUTES00000000000000000000001afileRef000000000000000000000004isaPBXBuildFilesettingsATTRIBUTES00000000000000000000001bfileRef000000000000000000000005isaPBXBuildFilesettingsATTRIBUTES00000000000000000000001cfileRef000000000000000000000006isaPBXBuildFilesettingsATTRIBUTES00000000000000000000001dfileRef000000000000000000000007isaPBXBuildFilesettingsATTRIBUTES00000000000000000000001efileRef000000000000000000000008isaPBXBuildFilesettingsATTRIBUTES00000000000000000000001ffileRef000000000000000000000009isaPBXBuildFilesettingsATTRIBUTES000000000000000000000020buildActionMask2147483647files00000000000000000000001600000000000000000000001700000000000000000000001800000000000000000000001900000000000000000000001a00000000000000000000001b00000000000000000000001c00000000000000000000001d00000000000000000000001e00000000000000000000001fisaPBXSourcesBuildPhaserunOnlyForDeploymentPostprocessing0000000000000000000000021buildActionMask8filesisaPBXFrameworksBuildPhaserunOnlyForDeploymentPostprocessing0000000000000000000000022buildActionMask8dstPath/usr/share/man/man1dstSubfolderSpec0filesisaPBXCopyFilesBuildPhaserunOnlyForDeploymentPostprocessing1000000000000000000000023buildConfigurationList000000000000000000000015buildPhases000000000000000000000020000000000000000000000021000000000000000000000022buildRulesdependenciesisaPBXNativeTargetnameSTM32F0-FastADC.elfproductInstallPath$(HOME)/binproductNameSTM32F0-FastADC.elfproductReference00000000000000000000000bproductTypecom.apple.product-type.toolrootObject000000000000000000000012
--------------------------------------------------------------------------------
/cmsis_boot/startup/startup_stm32f0xx.s:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file startup_stm32f0xx.s
4 | * @author MCD Application Team
5 | * @version V1.2.0
6 | * @date 31-July-2013
7 | * @brief STM32F0xx Medium-density devices vector table for RIDE7 toolchain.
8 | * This module performs:
9 | * - Set the initial SP
10 | * - Set the initial PC == Reset_Handler,
11 | * - Set the vector table entries with the exceptions ISR address
12 | * - Configure the system clock
13 | * - Branches to main in the C library (which eventually
14 | * calls main()).
15 | * After Reset the Cortex-M0 processor is in Thread mode,
16 | * priority is Privileged, and the Stack is set to Main.
17 | ******************************************************************************
18 | * @attention
19 | *
20 | *
© COPYRIGHT 2013 STMicroelectronics
21 | *
22 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
23 | * You may not use this file except in compliance with the License.
24 | * You may obtain a copy of the License at:
25 | *
26 | * http://www.st.com/software_license_agreement_liberty_v2
27 | *
28 | * Unless required by applicable law or agreed to in writing, software
29 | * distributed under the License is distributed on an "AS IS" BASIS,
30 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 | * See the License for the specific language governing permissions and
32 | * limitations under the License.
33 | *
34 | ******************************************************************************
35 | */
36 |
37 | .syntax unified
38 | .cpu cortex-m0
39 | .fpu softvfp
40 | .thumb
41 |
42 | .global g_pfnVectors
43 | .global Default_Handler
44 |
45 | /* start address for the initialization values of the .data section.
46 | defined in linker script */
47 | .word _sidata
48 | /* start address for the .data section. defined in linker script */
49 | .word _sdata
50 | /* end address for the .data section. defined in linker script */
51 | .word _edata
52 | /* start address for the .bss section. defined in linker script */
53 | .word _sbss
54 | /* end address for the .bss section. defined in linker script */
55 | .word _ebss
56 |
57 | .equ BootRAM, 0xF108F85F
58 | /**
59 | * @brief This is the code that gets called when the processor first
60 | * starts execution following a reset event. Only the absolutely
61 | * necessary set is performed, after which the application
62 | * supplied main() routine is called.
63 | * @param None
64 | * @retval : None
65 | */
66 |
67 | .section .text.Reset_Handler
68 | .weak Reset_Handler
69 | .type Reset_Handler, %function
70 | Reset_Handler:
71 | ldr r0, =_eram
72 | mov sp, r0 /* set stack pointer */
73 |
74 | /* Copy the data segment initializers from flash to SRAM */
75 | movs r1, #0
76 | b LoopCopyDataInit
77 |
78 | CopyDataInit:
79 | ldr r3, =_sidata
80 | ldr r3, [r3, r1]
81 | str r3, [r0, r1]
82 | adds r1, r1, #4
83 |
84 | LoopCopyDataInit:
85 | ldr r0, =_sdata
86 | ldr r3, =_edata
87 | adds r2, r0, r1
88 | cmp r2, r3
89 | bcc CopyDataInit
90 | ldr r2, =_sbss
91 | b LoopFillZerobss
92 | /* Zero fill the bss segment. */
93 | FillZerobss:
94 | movs r3, #0
95 | str r3, [r2]
96 | adds r2, r2, #4
97 |
98 |
99 | LoopFillZerobss:
100 | ldr r3, = _ebss
101 | cmp r2, r3
102 | bcc FillZerobss
103 |
104 | /* Call the clock system intitialization function.*/
105 | bl SystemInit
106 |
107 | /* Call the application's entry point.*/
108 | bl main
109 |
110 | LoopForever:
111 | b LoopForever
112 |
113 |
114 | .size Reset_Handler, .-Reset_Handler
115 |
116 | /**
117 | * @brief This is the code that gets called when the processor receives an
118 | * unexpected interrupt. This simply enters an infinite loop, preserving
119 | * the system state for examination by a debugger.
120 | *
121 | * @param None
122 | * @retval : None
123 | */
124 | .section .text.Default_Handler,"ax",%progbits
125 | Default_Handler:
126 | Infinite_Loop:
127 | b Infinite_Loop
128 | .size Default_Handler, .-Default_Handler
129 | /******************************************************************************
130 | *
131 | * The minimal vector table for a Cortex M0. Note that the proper constructs
132 | * must be placed on this to ensure that it ends up at physical address
133 | * 0x0000.0000.
134 | *
135 | ******************************************************************************/
136 | .section .isr_vector,"a",%progbits
137 | .type g_pfnVectors, %object
138 | .size g_pfnVectors, .-g_pfnVectors
139 |
140 |
141 | g_pfnVectors:
142 | .word _eram
143 | .word Reset_Handler
144 | .word NMI_Handler
145 | .word HardFault_Handler
146 | .word 0
147 | .word 0
148 | .word 0
149 | .word 0
150 | .word 0
151 | .word 0
152 | .word 0
153 | .word SVC_Handler
154 | .word 0
155 | .word 0
156 | .word PendSV_Handler
157 | .word SysTick_Handler
158 | .word WWDG_IRQHandler
159 | .word PVD_IRQHandler
160 | .word RTC_IRQHandler
161 | .word FLASH_IRQHandler
162 | .word RCC_IRQHandler
163 | .word EXTI0_1_IRQHandler
164 | .word EXTI2_3_IRQHandler
165 | .word EXTI4_15_IRQHandler
166 | .word TS_IRQHandler
167 | .word DMA1_Channel1_IRQHandler
168 | .word DMA1_Channel2_3_IRQHandler
169 | .word DMA1_Channel4_5_IRQHandler
170 | .word ADC1_COMP_IRQHandler
171 | .word TIM1_BRK_UP_TRG_COM_IRQHandler
172 | .word TIM1_CC_IRQHandler
173 | .word TIM2_IRQHandler
174 | .word TIM3_IRQHandler
175 | .word TIM6_DAC_IRQHandler
176 | .word 0
177 | .word TIM14_IRQHandler
178 | .word TIM15_IRQHandler
179 | .word TIM16_IRQHandler
180 | .word TIM17_IRQHandler
181 | .word I2C1_IRQHandler
182 | .word I2C2_IRQHandler
183 | .word SPI1_IRQHandler
184 | .word SPI2_IRQHandler
185 | .word USART1_IRQHandler
186 | .word USART2_IRQHandler
187 | .word 0
188 | .word CEC_IRQHandler
189 | .word 0
190 | .word BootRAM /* @0x108. This is for boot in RAM mode for
191 | STM32F0xx devices. */
192 |
193 | /*******************************************************************************
194 | *
195 | * Provide weak aliases for each Exception handler to the Default_Handler.
196 | * As they are weak aliases, any function with the same name will override
197 | * this definition.
198 | *
199 | *******************************************************************************/
200 |
201 | .weak NMI_Handler
202 | .thumb_set NMI_Handler,Default_Handler
203 |
204 | .weak HardFault_Handler
205 | .thumb_set HardFault_Handler,Default_Handler
206 |
207 | .weak SVC_Handler
208 | .thumb_set SVC_Handler,Default_Handler
209 |
210 | .weak PendSV_Handler
211 | .thumb_set PendSV_Handler,Default_Handler
212 |
213 | .weak SysTick_Handler
214 | .thumb_set SysTick_Handler,Default_Handler
215 |
216 | .weak WWDG_IRQHandler
217 | .thumb_set WWDG_IRQHandler,Default_Handler
218 |
219 | .weak PVD_IRQHandler
220 | .thumb_set PVD_IRQHandler,Default_Handler
221 |
222 | .weak RTC_IRQHandler
223 | .thumb_set RTC_IRQHandler,Default_Handler
224 |
225 | .weak FLASH_IRQHandler
226 | .thumb_set FLASH_IRQHandler,Default_Handler
227 |
228 | .weak RCC_IRQHandler
229 | .thumb_set RCC_IRQHandler,Default_Handler
230 |
231 | .weak EXTI0_1_IRQHandler
232 | .thumb_set EXTI0_1_IRQHandler,Default_Handler
233 |
234 | .weak EXTI2_3_IRQHandler
235 | .thumb_set EXTI2_3_IRQHandler,Default_Handler
236 |
237 | .weak EXTI4_15_IRQHandler
238 | .thumb_set EXTI4_15_IRQHandler,Default_Handler
239 |
240 | .weak TS_IRQHandler
241 | .thumb_set TS_IRQHandler,Default_Handler
242 |
243 | .weak DMA1_Channel1_IRQHandler
244 | .thumb_set DMA1_Channel1_IRQHandler,Default_Handler
245 |
246 | .weak DMA1_Channel2_3_IRQHandler
247 | .thumb_set DMA1_Channel2_3_IRQHandler,Default_Handler
248 |
249 | .weak DMA1_Channel4_5_IRQHandler
250 | .thumb_set DMA1_Channel4_5_IRQHandler,Default_Handler
251 |
252 | .weak ADC1_COMP_IRQHandler
253 | .thumb_set ADC1_COMP_IRQHandler,Default_Handler
254 |
255 | .weak TIM1_BRK_UP_TRG_COM_IRQHandler
256 | .thumb_set TIM1_BRK_UP_TRG_COM_IRQHandler,Default_Handler
257 |
258 | .weak TIM1_CC_IRQHandler
259 | .thumb_set TIM1_CC_IRQHandler,Default_Handler
260 |
261 | .weak TIM2_IRQHandler
262 | .thumb_set TIM2_IRQHandler,Default_Handler
263 |
264 | .weak TIM3_IRQHandler
265 | .thumb_set TIM3_IRQHandler,Default_Handler
266 |
267 | .weak TIM6_DAC_IRQHandler
268 | .thumb_set TIM6_DAC_IRQHandler,Default_Handler
269 |
270 | .weak TIM14_IRQHandler
271 | .thumb_set TIM14_IRQHandler,Default_Handler
272 |
273 | .weak TIM15_IRQHandler
274 | .thumb_set TIM15_IRQHandler,Default_Handler
275 |
276 | .weak TIM16_IRQHandler
277 | .thumb_set TIM16_IRQHandler,Default_Handler
278 |
279 | .weak TIM17_IRQHandler
280 | .thumb_set TIM17_IRQHandler,Default_Handler
281 |
282 | .weak I2C1_IRQHandler
283 | .thumb_set I2C1_IRQHandler,Default_Handler
284 |
285 | .weak I2C2_IRQHandler
286 | .thumb_set I2C2_IRQHandler,Default_Handler
287 |
288 | .weak SPI1_IRQHandler
289 | .thumb_set SPI1_IRQHandler,Default_Handler
290 |
291 | .weak SPI2_IRQHandler
292 | .thumb_set SPI2_IRQHandler,Default_Handler
293 |
294 | .weak USART1_IRQHandler
295 | .thumb_set USART1_IRQHandler,Default_Handler
296 |
297 | .weak USART2_IRQHandler
298 | .thumb_set USART2_IRQHandler,Default_Handler
299 |
300 | .weak CEC_IRQHandler
301 | .thumb_set CEC_IRQHandler,Default_Handler
302 |
303 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
304 |
305 |
--------------------------------------------------------------------------------
/cmsis_boot/stm32f0xx_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32F0xx_conf.h
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 23-March-2012
7 | * @brief Library configuration file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2012 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __STM32F0XX_CONF_H
30 | #define __STM32F0XX_CONF_H
31 |
32 | /* Includes ------------------------------------------------------------------*/
33 | /* Comment the line below to disable peripheral header file inclusion */
34 | /* #include "stm32f0xx_adc.h" */
35 | /*#include "stm32f0xx_cec.h"
36 | #include "stm32f0xx_crc.h"
37 | #include "stm32f0xx_comp.h"
38 | #include "stm32f0xx_dac.h"
39 | #include "stm32f0xx_dbgmcu.h"
40 | #include "stm32f0xx_dma.h"
41 | #include "stm32f0xx_exti.h"
42 | #include "stm32f0xx_flash.h"
43 | #include "stm32f0xx_gpio.h"
44 | #include "stm32f0xx_syscfg.h"
45 | #include "stm32f0xx_i2c.h"
46 | #include "stm32f0xx_iwdg.h"
47 | #include "stm32f0xx_pwr.h"
48 | #include "stm32f0xx_rcc.h"
49 | #include "stm32f0xx_rtc.h"
50 | #include "stm32f0xx_spi.h"
51 | #include "stm32f0xx_tim.h"
52 | #include "stm32f0xx_usart.h"
53 | #include "stm32f0xx_wwdg.h"
54 | #include "stm32f0xx_misc.h" *//* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
55 |
56 | /* Exported types ------------------------------------------------------------*/
57 | /* Exported constants --------------------------------------------------------*/
58 | /* Uncomment the line below to expanse the "assert_param" macro in the
59 | Standard Peripheral Library drivers code */
60 | /* #define USE_FULL_ASSERT 1 */
61 | /* Exported macro ------------------------------------------------------------*/
62 | #ifdef USE_FULL_ASSERT
63 |
64 | /**
65 | * @brief The assert_param macro is used for function's parameters check.
66 | * @param expr: If expr is false, it calls assert_failed function which reports
67 | * the name of the source file and the source line number of the call
68 | * that failed. If expr is true, it returns no value.
69 | * @retval None
70 | */
71 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
72 | /* Exported functions ------------------------------------------------------- */
73 | void assert_failed(uint8_t* file, uint32_t line);
74 | #else
75 | #define assert_param(expr) ((void)0)
76 | #endif /* USE_FULL_ASSERT */
77 |
78 | #endif /* __STM32F0XX_CONF_H */
79 |
80 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
81 |
--------------------------------------------------------------------------------
/cmsis_boot/system_stm32f0xx.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32f0xx.h
4 | * @author MCD Application Team
5 | * @version V1.2.0
6 | * @date 01-August-2013
7 | * @brief CMSIS Cortex-M0 Device Peripheral Access Layer System Header File.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2013 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /** @addtogroup CMSIS
29 | * @{
30 | */
31 |
32 | /** @addtogroup stm32f0xx_system
33 | * @{
34 | */
35 |
36 | /**
37 | * @brief Define to prevent recursive inclusion
38 | */
39 | #ifndef __SYSTEM_STM32F0XX_H
40 | #define __SYSTEM_STM32F0XX_H
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | /** @addtogroup STM32F0xx_System_Includes
47 | * @{
48 | */
49 |
50 | /**
51 | * @}
52 | */
53 |
54 |
55 | /** @addtogroup STM32F0xx_System_Exported_types
56 | * @{
57 | */
58 |
59 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
60 |
61 | /**
62 | * @}
63 | */
64 |
65 | /** @addtogroup STM32F0xx_System_Exported_Constants
66 | * @{
67 | */
68 |
69 | /**
70 | * @}
71 | */
72 |
73 | /** @addtogroup STM32F0xx_System_Exported_Macros
74 | * @{
75 | */
76 |
77 | /**
78 | * @}
79 | */
80 |
81 | /** @addtogroup STM32F0xx_System_Exported_Functions
82 | * @{
83 | */
84 |
85 | extern void SystemInit(void);
86 | extern void SystemCoreClockUpdate(void);
87 | /**
88 | * @}
89 | */
90 |
91 | #ifdef __cplusplus
92 | }
93 | #endif
94 |
95 | #endif /*__SYSTEM_STM32F0XX_H */
96 |
97 | /**
98 | * @}
99 | */
100 |
101 | /**
102 | * @}
103 | */
104 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
105 |
--------------------------------------------------------------------------------
/cmsis_boot/system_stm32f0xx_temp.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32f0xx.c
4 | * @author MCD Application Team
5 | * @version V1.2.0
6 | * @date 01-August-2013
7 | * @brief CMSIS Cortex-M0 Device Peripheral Access Layer System Source File.
8 | * This file contains the system clock configuration for STM32F0xx devices,
9 | * and is generated by the clock configuration tool
10 | * STM32F0xx_Clock_Configuration_V1.0.0.xls
11 | *
12 | * 1. This file provides two functions and one global variable to be called from
13 | * user application:
14 | * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
15 | * and Divider factors, AHB/APBx prescalers and Flash settings),
16 | * depending on the configuration made in the clock xls tool.
17 | * This function is called at startup just after reset and
18 | * before branch to main program. This call is made inside
19 | * the "startup_stm32f0xx.s" file.
20 | *
21 | * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
22 | * by the user application to setup the SysTick
23 | * timer or configure other parameters.
24 | *
25 | * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
26 | * be called whenever the core clock is changed
27 | * during program execution.
28 | *
29 | * 2. After each device reset the HSI (8 MHz Range) is used as system clock source.
30 | * Then SystemInit() function is called, in "startup_stm32f0xx.s" file, to
31 | * configure the system clock before to branch to main program.
32 | *
33 | * 3. If the system clock source selected by user fails to startup, the SystemInit()
34 | * function will do nothing and HSI still used as system clock source. User can
35 | * add some code to deal with this issue inside the SetSysClock() function.
36 | *
37 | * 4. The default value of HSE crystal is set to 8MHz, refer to "HSE_VALUE" define
38 | * in "stm32f0xx.h" file. When HSE is used as system clock source, directly or
39 | * through PLL, and you are using different crystal you have to adapt the HSE
40 | * value to your own configuration.
41 | *
42 | * 5. This file configures the system clock as follows:
43 | *=============================================================================
44 | * System Clock Configuration
45 | *=============================================================================
46 | * System Clock source | PLL(HSE)
47 | *-----------------------------------------------------------------------------
48 | * SYSCLK | 48000000 Hz
49 | *-----------------------------------------------------------------------------
50 | * HCLK | 48000000 Hz
51 | *-----------------------------------------------------------------------------
52 | * AHB Prescaler | 1
53 | *-----------------------------------------------------------------------------
54 | * APB1 Prescaler | 1
55 | *-----------------------------------------------------------------------------
56 | * APB2 Prescaler | 1
57 | *-----------------------------------------------------------------------------
58 | * HSE Frequency | 8000000 Hz
59 | *-----------------------------------------------------------------------------
60 | * PLL MUL | 6
61 | *-----------------------------------------------------------------------------
62 | * VDD | 3.3 V
63 | *-----------------------------------------------------------------------------
64 | * Flash Latency | 1 WS
65 | *-----------------------------------------------------------------------------
66 | *=============================================================================
67 | ******************************************************************************
68 | * @attention
69 | *
70 | * © COPYRIGHT 2013 STMicroelectronics
71 | *
72 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
73 | * You may not use this file except in compliance with the License.
74 | * You may obtain a copy of the License at:
75 | *
76 | * http://www.st.com/software_license_agreement_liberty_v2
77 | *
78 | * Unless required by applicable law or agreed to in writing, software
79 | * distributed under the License is distributed on an "AS IS" BASIS,
80 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
81 | * See the License for the specific language governing permissions and
82 | * limitations under the License.
83 | *
84 | ******************************************************************************
85 | */
86 |
87 | /** @addtogroup CMSIS
88 | * @{
89 | */
90 |
91 | /** @addtogroup stm32f0xx_system
92 | * @{
93 | */
94 |
95 | /** @addtogroup STM32F0xx_System_Private_Includes
96 | * @{
97 | */
98 |
99 | #include "stm32f0xx.h"
100 |
101 | #define WEAK __attribute__ ((weak))
102 |
103 | void WEAK SystemInit(void);
104 | void WEAK SystemCoreClockUpdate(void);
105 | void WEAK SetSysClock(void);
106 | //uint32_t WEAK SystemCoreClock;
107 | //__I uint8_t WEAK AHBPrescTable[16];
108 |
109 |
110 | /**
111 | * @}
112 | */
113 |
114 | /** @addtogroup STM32F0xx_System_Private_TypesDefinitions
115 | * @{
116 | */
117 |
118 | /**
119 | * @}
120 | */
121 |
122 | /** @addtogroup STM32F0xx_System_Private_Defines
123 | * @{
124 | */
125 | /**
126 | * @}
127 | */
128 |
129 | /** @addtogroup STM32F0xx_System_Private_Macros
130 | * @{
131 | */
132 |
133 | /**
134 | * @}
135 | */
136 |
137 | /** @addtogroup STM32F0xx_System_Private_Variables
138 | * @{
139 | */
140 | uint32_t WEAK SystemCoreClock = 48000000;
141 | __I uint8_t WEAK AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
142 |
143 | /**
144 | * @}
145 | */
146 |
147 | /** @addtogroup STM32F0xx_System_Private_FunctionPrototypes
148 | * @{
149 | */
150 |
151 | static void SetSysClock1(void);
152 |
153 | /**
154 | * @}
155 | */
156 |
157 | /** @addtogroup STM32F0xx_System_Private_Functions
158 | * @{
159 | */
160 |
161 | /**
162 | * @brief Setup the microcontroller system.
163 | * Initialize the Embedded Flash Interface, the PLL and update the
164 | * SystemCoreClock variable.
165 | * @param None
166 | * @retval None
167 | */
168 | void SystemInit1 (void)
169 | {
170 | /* Set HSION bit */
171 | RCC->CR |= (uint32_t)0x00000001;
172 |
173 | #if defined (STM32F0XX_MD) || defined (STM32F030X8)
174 | /* Reset SW[1:0], HPRE[3:0], PPRE[2:0], ADCPRE and MCOSEL[2:0] bits */
175 | RCC->CFGR &= (uint32_t)0xF8FFB80C;
176 | #else
177 | /* Reset SW[1:0], HPRE[3:0], PPRE[2:0], ADCPRE, MCOSEL[2:0], MCOPRE[2:0] and PLLNODIV bits */
178 | RCC->CFGR &= (uint32_t)0x08FFB80C;
179 | #endif /* STM32F0XX_MD or STM32F030X8 */
180 |
181 | /* Reset HSEON, CSSON and PLLON bits */
182 | RCC->CR &= (uint32_t)0xFEF6FFFF;
183 |
184 | /* Reset HSEBYP bit */
185 | RCC->CR &= (uint32_t)0xFFFBFFFF;
186 |
187 | /* Reset PLLSRC, PLLXTPRE and PLLMUL[3:0] bits */
188 | RCC->CFGR &= (uint32_t)0xFFC0FFFF;
189 |
190 | /* Reset PREDIV1[3:0] bits */
191 | RCC->CFGR2 &= (uint32_t)0xFFFFFFF0;
192 |
193 | /* Reset USARTSW[1:0], I2CSW, CECSW and ADCSW bits */
194 | RCC->CFGR3 &= (uint32_t)0xFFFFFEAC;
195 |
196 | /* Reset HSI14 bit */
197 | RCC->CR2 &= (uint32_t)0xFFFFFFFE;
198 |
199 | /* Disable all interrupts */
200 | RCC->CIR = 0x00000000;
201 |
202 | /* Configure the System clock frequency, AHB/APBx prescalers and Flash settings */
203 | SetSysClock();
204 | }
205 |
206 | /**
207 | * @brief Update SystemCoreClock according to Clock Register Values
208 | * The SystemCoreClock variable contains the core clock (HCLK), it can
209 | * be used by the user application to setup the SysTick timer or configure
210 | * other parameters.
211 | *
212 | * @note Each time the core clock (HCLK) changes, this function must be called
213 | * to update SystemCoreClock variable value. Otherwise, any configuration
214 | * based on this variable will be incorrect.
215 | *
216 | * @note - The system frequency computed by this function is not the real
217 | * frequency in the chip. It is calculated based on the predefined
218 | * constant and the selected clock source:
219 | *
220 | * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
221 | *
222 | * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
223 | *
224 | * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
225 | * or HSI_VALUE(*) multiplied/divided by the PLL factors.
226 | *
227 | * (*) HSI_VALUE is a constant defined in stm32f0xx.h file (default value
228 | * 8 MHz) but the real value may vary depending on the variations
229 | * in voltage and temperature.
230 | *
231 | * (**) HSE_VALUE is a constant defined in stm32f0xx.h file (default value
232 | * 8 MHz), user has to ensure that HSE_VALUE is same as the real
233 | * frequency of the crystal used. Otherwise, this function may
234 | * have wrong result.
235 | *
236 | * - The result of this function could be not correct when using fractional
237 | * value for HSE crystal.
238 | * @param None
239 | * @retval None
240 | */
241 | void SystemCoreClockUpdate1 (void)
242 | {
243 | uint32_t tmp = 0, pllmull = 0, pllsource = 0, prediv1factor = 0;
244 |
245 | /* Get SYSCLK source -------------------------------------------------------*/
246 | tmp = RCC->CFGR & RCC_CFGR_SWS;
247 |
248 | switch (tmp)
249 | {
250 | case 0x00: /* HSI used as system clock */
251 | SystemCoreClock = HSI_VALUE;
252 | break;
253 | case 0x04: /* HSE used as system clock */
254 | SystemCoreClock = HSE_VALUE;
255 | break;
256 | case 0x08: /* PLL used as system clock */
257 | /* Get PLL clock source and multiplication factor ----------------------*/
258 | pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
259 | pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
260 | pllmull = ( pllmull >> 18) + 2;
261 |
262 | if (pllsource == 0x00)
263 | {
264 | /* HSI oscillator clock divided by 2 selected as PLL clock entry */
265 | SystemCoreClock = (HSI_VALUE >> 1) * pllmull;
266 | }
267 | else
268 | {
269 | prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1;
270 | /* HSE oscillator clock selected as PREDIV1 clock entry */
271 | SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
272 | }
273 | break;
274 | default: /* HSI used as system clock */
275 | SystemCoreClock = HSI_VALUE;
276 | break;
277 | }
278 | /* Compute HCLK clock frequency ----------------*/
279 | /* Get HCLK prescaler */
280 | tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
281 | /* HCLK clock frequency */
282 | SystemCoreClock >>= tmp;
283 | }
284 |
285 | /**
286 | * @brief Configures the System clock frequency, AHB/APBx prescalers and Flash
287 | * settings.
288 | * @note This function should be called only once the RCC clock configuration
289 | * is reset to the default reset state (done in SystemInit() function).
290 | * @param None
291 | * @retval None
292 | */
293 | static void SetSysClock1(void)
294 | {
295 | __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
296 |
297 | /* SYSCLK, HCLK, PCLK configuration ----------------------------------------*/
298 | /* Enable HSE */
299 | RCC->CR |= ((uint32_t)RCC_CR_HSEON);
300 |
301 | /* Wait till HSE is ready and if Time out is reached exit */
302 | do
303 | {
304 | HSEStatus = RCC->CR & RCC_CR_HSERDY;
305 | StartUpCounter++;
306 | } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
307 |
308 | if ((RCC->CR & RCC_CR_HSERDY) != RESET)
309 | {
310 | HSEStatus = (uint32_t)0x01;
311 | }
312 | else
313 | {
314 | HSEStatus = (uint32_t)0x00;
315 | }
316 |
317 | if (HSEStatus == (uint32_t)0x01)
318 | {
319 | /* Enable Prefetch Buffer and set Flash Latency */
320 | FLASH->ACR = FLASH_ACR_PRFTBE | FLASH_ACR_LATENCY;
321 |
322 | /* HCLK = SYSCLK */
323 | RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
324 |
325 | /* PCLK = HCLK */
326 | RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE_DIV1;
327 |
328 | /* PLL configuration = HSE * 6 = 48 MHz */
329 | RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL));
330 | RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLMULL6);
331 |
332 | /* Enable PLL */
333 | RCC->CR |= RCC_CR_PLLON;
334 |
335 | /* Wait till PLL is ready */
336 | while((RCC->CR & RCC_CR_PLLRDY) == 0)
337 | {
338 | }
339 |
340 | /* Select PLL as system clock source */
341 | RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
342 | RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
343 |
344 | /* Wait till PLL is used as system clock source */
345 | while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)RCC_CFGR_SWS_PLL)
346 | {
347 | }
348 | }
349 | else
350 | { /* If HSE fails to start-up, the application will have wrong clock
351 | configuration. User can add here some code to deal with this error */
352 | }
353 | }
354 |
355 |
356 | #pragma weak SetSysClock = SetSysClock1
357 | #pragma weak SystemCoreClockUpdate = SystemCoreClockUpdate1
358 | #pragma weak SystemInit = SystemInit1
359 |
360 | //#pragma weak SystemCoreClock = SystemCoreClock1
361 | //#pragma weak AHBPrescTable = AHBPrescTable1
362 |
363 |
364 | /**
365 | * @}
366 | */
367 |
368 | /**
369 | * @}
370 | */
371 |
372 | /**
373 | * @}
374 | */
375 |
376 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
377 |
--------------------------------------------------------------------------------
/cmsis_core/core_cmFunc.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file core_cmFunc.h
3 | * @brief CMSIS Cortex-M Core Function Access Header File
4 | * @version V3.01
5 | * @date 06. March 2012
6 | *
7 | * @note
8 | * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
9 | *
10 | * @par
11 | * ARM Limited (ARM) is supplying this software for use with Cortex-M
12 | * processor based microcontrollers. This file can be freely distributed
13 | * within development tools that are supporting such ARM based processors.
14 | *
15 | * @par
16 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
17 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
19 | * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
20 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
21 | *
22 | ******************************************************************************/
23 |
24 | #ifndef __CORE_CMFUNC_H
25 | #define __CORE_CMFUNC_H
26 |
27 |
28 | /* ########################### Core Function Access ########################### */
29 | /** \ingroup CMSIS_Core_FunctionInterface
30 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
31 | @{
32 | */
33 |
34 | #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
35 | /* ARM armcc specific functions */
36 |
37 | #if (__ARMCC_VERSION < 400677)
38 | #error "Please use ARM Compiler Toolchain V4.0.677 or later!"
39 | #endif
40 |
41 | /* intrinsic void __enable_irq(); */
42 | /* intrinsic void __disable_irq(); */
43 |
44 | /** \brief Get Control Register
45 |
46 | This function returns the content of the Control Register.
47 |
48 | \return Control Register value
49 | */
50 | __STATIC_INLINE uint32_t __get_CONTROL(void)
51 | {
52 | register uint32_t __regControl __ASM("control");
53 | return(__regControl);
54 | }
55 |
56 |
57 | /** \brief Set Control Register
58 |
59 | This function writes the given value to the Control Register.
60 |
61 | \param [in] control Control Register value to set
62 | */
63 | __STATIC_INLINE void __set_CONTROL(uint32_t control)
64 | {
65 | register uint32_t __regControl __ASM("control");
66 | __regControl = control;
67 | }
68 |
69 |
70 | /** \brief Get IPSR Register
71 |
72 | This function returns the content of the IPSR Register.
73 |
74 | \return IPSR Register value
75 | */
76 | __STATIC_INLINE uint32_t __get_IPSR(void)
77 | {
78 | register uint32_t __regIPSR __ASM("ipsr");
79 | return(__regIPSR);
80 | }
81 |
82 |
83 | /** \brief Get APSR Register
84 |
85 | This function returns the content of the APSR Register.
86 |
87 | \return APSR Register value
88 | */
89 | __STATIC_INLINE uint32_t __get_APSR(void)
90 | {
91 | register uint32_t __regAPSR __ASM("apsr");
92 | return(__regAPSR);
93 | }
94 |
95 |
96 | /** \brief Get xPSR Register
97 |
98 | This function returns the content of the xPSR Register.
99 |
100 | \return xPSR Register value
101 | */
102 | __STATIC_INLINE uint32_t __get_xPSR(void)
103 | {
104 | register uint32_t __regXPSR __ASM("xpsr");
105 | return(__regXPSR);
106 | }
107 |
108 |
109 | /** \brief Get Process Stack Pointer
110 |
111 | This function returns the current value of the Process Stack Pointer (PSP).
112 |
113 | \return PSP Register value
114 | */
115 | __STATIC_INLINE uint32_t __get_PSP(void)
116 | {
117 | register uint32_t __regProcessStackPointer __ASM("psp");
118 | return(__regProcessStackPointer);
119 | }
120 |
121 |
122 | /** \brief Set Process Stack Pointer
123 |
124 | This function assigns the given value to the Process Stack Pointer (PSP).
125 |
126 | \param [in] topOfProcStack Process Stack Pointer value to set
127 | */
128 | __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
129 | {
130 | register uint32_t __regProcessStackPointer __ASM("psp");
131 | __regProcessStackPointer = topOfProcStack;
132 | }
133 |
134 |
135 | /** \brief Get Main Stack Pointer
136 |
137 | This function returns the current value of the Main Stack Pointer (MSP).
138 |
139 | \return MSP Register value
140 | */
141 | __STATIC_INLINE uint32_t __get_MSP(void)
142 | {
143 | register uint32_t __regMainStackPointer __ASM("msp");
144 | return(__regMainStackPointer);
145 | }
146 |
147 |
148 | /** \brief Set Main Stack Pointer
149 |
150 | This function assigns the given value to the Main Stack Pointer (MSP).
151 |
152 | \param [in] topOfMainStack Main Stack Pointer value to set
153 | */
154 | __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
155 | {
156 | register uint32_t __regMainStackPointer __ASM("msp");
157 | __regMainStackPointer = topOfMainStack;
158 | }
159 |
160 |
161 | /** \brief Get Priority Mask
162 |
163 | This function returns the current state of the priority mask bit from the Priority Mask Register.
164 |
165 | \return Priority Mask value
166 | */
167 | __STATIC_INLINE uint32_t __get_PRIMASK(void)
168 | {
169 | register uint32_t __regPriMask __ASM("primask");
170 | return(__regPriMask);
171 | }
172 |
173 |
174 | /** \brief Set Priority Mask
175 |
176 | This function assigns the given value to the Priority Mask Register.
177 |
178 | \param [in] priMask Priority Mask
179 | */
180 | __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
181 | {
182 | register uint32_t __regPriMask __ASM("primask");
183 | __regPriMask = (priMask);
184 | }
185 |
186 |
187 | #if (__CORTEX_M >= 0x03)
188 |
189 | /** \brief Enable FIQ
190 |
191 | This function enables FIQ interrupts by clearing the F-bit in the CPSR.
192 | Can only be executed in Privileged modes.
193 | */
194 | #define __enable_fault_irq __enable_fiq
195 |
196 |
197 | /** \brief Disable FIQ
198 |
199 | This function disables FIQ interrupts by setting the F-bit in the CPSR.
200 | Can only be executed in Privileged modes.
201 | */
202 | #define __disable_fault_irq __disable_fiq
203 |
204 |
205 | /** \brief Get Base Priority
206 |
207 | This function returns the current value of the Base Priority register.
208 |
209 | \return Base Priority register value
210 | */
211 | __STATIC_INLINE uint32_t __get_BASEPRI(void)
212 | {
213 | register uint32_t __regBasePri __ASM("basepri");
214 | return(__regBasePri);
215 | }
216 |
217 |
218 | /** \brief Set Base Priority
219 |
220 | This function assigns the given value to the Base Priority register.
221 |
222 | \param [in] basePri Base Priority value to set
223 | */
224 | __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
225 | {
226 | register uint32_t __regBasePri __ASM("basepri");
227 | __regBasePri = (basePri & 0xff);
228 | }
229 |
230 |
231 | /** \brief Get Fault Mask
232 |
233 | This function returns the current value of the Fault Mask register.
234 |
235 | \return Fault Mask register value
236 | */
237 | __STATIC_INLINE uint32_t __get_FAULTMASK(void)
238 | {
239 | register uint32_t __regFaultMask __ASM("faultmask");
240 | return(__regFaultMask);
241 | }
242 |
243 |
244 | /** \brief Set Fault Mask
245 |
246 | This function assigns the given value to the Fault Mask register.
247 |
248 | \param [in] faultMask Fault Mask value to set
249 | */
250 | __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
251 | {
252 | register uint32_t __regFaultMask __ASM("faultmask");
253 | __regFaultMask = (faultMask & (uint32_t)1);
254 | }
255 |
256 | #endif /* (__CORTEX_M >= 0x03) */
257 |
258 |
259 | #if (__CORTEX_M == 0x04)
260 |
261 | /** \brief Get FPSCR
262 |
263 | This function returns the current value of the Floating Point Status/Control register.
264 |
265 | \return Floating Point Status/Control register value
266 | */
267 | __STATIC_INLINE uint32_t __get_FPSCR(void)
268 | {
269 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
270 | register uint32_t __regfpscr __ASM("fpscr");
271 | return(__regfpscr);
272 | #else
273 | return(0);
274 | #endif
275 | }
276 |
277 |
278 | /** \brief Set FPSCR
279 |
280 | This function assigns the given value to the Floating Point Status/Control register.
281 |
282 | \param [in] fpscr Floating Point Status/Control value to set
283 | */
284 | __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
285 | {
286 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
287 | register uint32_t __regfpscr __ASM("fpscr");
288 | __regfpscr = (fpscr);
289 | #endif
290 | }
291 |
292 | #endif /* (__CORTEX_M == 0x04) */
293 |
294 |
295 | #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
296 | /* IAR iccarm specific functions */
297 |
298 | #include
299 |
300 |
301 | #elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
302 | /* TI CCS specific functions */
303 |
304 | #include
305 |
306 |
307 | #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
308 | /* GNU gcc specific functions */
309 |
310 | /** \brief Enable IRQ Interrupts
311 |
312 | This function enables IRQ interrupts by clearing the I-bit in the CPSR.
313 | Can only be executed in Privileged modes.
314 | */
315 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)
316 | {
317 | __ASM volatile ("cpsie i");
318 | }
319 |
320 |
321 | /** \brief Disable IRQ Interrupts
322 |
323 | This function disables IRQ interrupts by setting the I-bit in the CPSR.
324 | Can only be executed in Privileged modes.
325 | */
326 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
327 | {
328 | __ASM volatile ("cpsid i");
329 | }
330 |
331 |
332 | /** \brief Get Control Register
333 |
334 | This function returns the content of the Control Register.
335 |
336 | \return Control Register value
337 | */
338 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void)
339 | {
340 | uint32_t result;
341 |
342 | __ASM volatile ("MRS %0, control" : "=r" (result) );
343 | return(result);
344 | }
345 |
346 |
347 | /** \brief Set Control Register
348 |
349 | This function writes the given value to the Control Register.
350 |
351 | \param [in] control Control Register value to set
352 | */
353 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control)
354 | {
355 | __ASM volatile ("MSR control, %0" : : "r" (control) );
356 | }
357 |
358 |
359 | /** \brief Get IPSR Register
360 |
361 | This function returns the content of the IPSR Register.
362 |
363 | \return IPSR Register value
364 | */
365 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void)
366 | {
367 | uint32_t result;
368 |
369 | __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
370 | return(result);
371 | }
372 |
373 |
374 | /** \brief Get APSR Register
375 |
376 | This function returns the content of the APSR Register.
377 |
378 | \return APSR Register value
379 | */
380 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void)
381 | {
382 | uint32_t result;
383 |
384 | __ASM volatile ("MRS %0, apsr" : "=r" (result) );
385 | return(result);
386 | }
387 |
388 |
389 | /** \brief Get xPSR Register
390 |
391 | This function returns the content of the xPSR Register.
392 |
393 | \return xPSR Register value
394 | */
395 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void)
396 | {
397 | uint32_t result;
398 |
399 | __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
400 | return(result);
401 | }
402 |
403 |
404 | /** \brief Get Process Stack Pointer
405 |
406 | This function returns the current value of the Process Stack Pointer (PSP).
407 |
408 | \return PSP Register value
409 | */
410 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void)
411 | {
412 | register uint32_t result;
413 |
414 | __ASM volatile ("MRS %0, psp\n" : "=r" (result) );
415 | return(result);
416 | }
417 |
418 |
419 | /** \brief Set Process Stack Pointer
420 |
421 | This function assigns the given value to the Process Stack Pointer (PSP).
422 |
423 | \param [in] topOfProcStack Process Stack Pointer value to set
424 | */
425 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
426 | {
427 | __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) );
428 | }
429 |
430 |
431 | /** \brief Get Main Stack Pointer
432 |
433 | This function returns the current value of the Main Stack Pointer (MSP).
434 |
435 | \return MSP Register value
436 | */
437 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void)
438 | {
439 | register uint32_t result;
440 |
441 | __ASM volatile ("MRS %0, msp\n" : "=r" (result) );
442 | return(result);
443 | }
444 |
445 |
446 | /** \brief Set Main Stack Pointer
447 |
448 | This function assigns the given value to the Main Stack Pointer (MSP).
449 |
450 | \param [in] topOfMainStack Main Stack Pointer value to set
451 | */
452 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
453 | {
454 | __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) );
455 | }
456 |
457 |
458 | /** \brief Get Priority Mask
459 |
460 | This function returns the current state of the priority mask bit from the Priority Mask Register.
461 |
462 | \return Priority Mask value
463 | */
464 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void)
465 | {
466 | uint32_t result;
467 |
468 | __ASM volatile ("MRS %0, primask" : "=r" (result) );
469 | return(result);
470 | }
471 |
472 |
473 | /** \brief Set Priority Mask
474 |
475 | This function assigns the given value to the Priority Mask Register.
476 |
477 | \param [in] priMask Priority Mask
478 | */
479 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
480 | {
481 | __ASM volatile ("MSR primask, %0" : : "r" (priMask) );
482 | }
483 |
484 |
485 | #if (__CORTEX_M >= 0x03)
486 |
487 | /** \brief Enable FIQ
488 |
489 | This function enables FIQ interrupts by clearing the F-bit in the CPSR.
490 | Can only be executed in Privileged modes.
491 | */
492 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void)
493 | {
494 | __ASM volatile ("cpsie f");
495 | }
496 |
497 |
498 | /** \brief Disable FIQ
499 |
500 | This function disables FIQ interrupts by setting the F-bit in the CPSR.
501 | Can only be executed in Privileged modes.
502 | */
503 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void)
504 | {
505 | __ASM volatile ("cpsid f");
506 | }
507 |
508 |
509 | /** \brief Get Base Priority
510 |
511 | This function returns the current value of the Base Priority register.
512 |
513 | \return Base Priority register value
514 | */
515 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void)
516 | {
517 | uint32_t result;
518 |
519 | __ASM volatile ("MRS %0, basepri_max" : "=r" (result) );
520 | return(result);
521 | }
522 |
523 |
524 | /** \brief Set Base Priority
525 |
526 | This function assigns the given value to the Base Priority register.
527 |
528 | \param [in] basePri Base Priority value to set
529 | */
530 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value)
531 | {
532 | __ASM volatile ("MSR basepri, %0" : : "r" (value) );
533 | }
534 |
535 |
536 | /** \brief Get Fault Mask
537 |
538 | This function returns the current value of the Fault Mask register.
539 |
540 | \return Fault Mask register value
541 | */
542 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
543 | {
544 | uint32_t result;
545 |
546 | __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
547 | return(result);
548 | }
549 |
550 |
551 | /** \brief Set Fault Mask
552 |
553 | This function assigns the given value to the Fault Mask register.
554 |
555 | \param [in] faultMask Fault Mask value to set
556 | */
557 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
558 | {
559 | __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) );
560 | }
561 |
562 | #endif /* (__CORTEX_M >= 0x03) */
563 |
564 |
565 | #if (__CORTEX_M == 0x04)
566 |
567 | /** \brief Get FPSCR
568 |
569 | This function returns the current value of the Floating Point Status/Control register.
570 |
571 | \return Floating Point Status/Control register value
572 | */
573 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void)
574 | {
575 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
576 | uint32_t result;
577 |
578 | __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
579 | return(result);
580 | #else
581 | return(0);
582 | #endif
583 | }
584 |
585 |
586 | /** \brief Set FPSCR
587 |
588 | This function assigns the given value to the Floating Point Status/Control register.
589 |
590 | \param [in] fpscr Floating Point Status/Control value to set
591 | */
592 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
593 | {
594 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
595 | __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) );
596 | #endif
597 | }
598 |
599 | #endif /* (__CORTEX_M == 0x04) */
600 |
601 |
602 | #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
603 | /* TASKING carm specific functions */
604 |
605 | /*
606 | * The CMSIS functions have been implemented as intrinsics in the compiler.
607 | * Please use "carm -?i" to get an up to date list of all instrinsics,
608 | * Including the CMSIS ones.
609 | */
610 |
611 | #endif
612 |
613 | /*@} end of CMSIS_Core_RegAccFunctions */
614 |
615 |
616 | #endif /* __CORE_CMFUNC_H */
617 |
--------------------------------------------------------------------------------
/cmsis_core/core_cmInstr.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file core_cmInstr.h
3 | * @brief CMSIS Cortex-M Core Instruction Access Header File
4 | * @version V3.01
5 | * @date 06. March 2012
6 | *
7 | * @note
8 | * Copyright (C) 2009-2012 ARM Limited. All rights reserved.
9 | *
10 | * @par
11 | * ARM Limited (ARM) is supplying this software for use with Cortex-M
12 | * processor based microcontrollers. This file can be freely distributed
13 | * within development tools that are supporting such ARM based processors.
14 | *
15 | * @par
16 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
17 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
19 | * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
20 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
21 | *
22 | ******************************************************************************/
23 |
24 | #ifndef __CORE_CMINSTR_H
25 | #define __CORE_CMINSTR_H
26 |
27 |
28 | /* ########################## Core Instruction Access ######################### */
29 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
30 | Access to dedicated instructions
31 | @{
32 | */
33 |
34 | #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
35 | /* ARM armcc specific functions */
36 |
37 | #if (__ARMCC_VERSION < 400677)
38 | #error "Please use ARM Compiler Toolchain V4.0.677 or later!"
39 | #endif
40 |
41 |
42 | /** \brief No Operation
43 |
44 | No Operation does nothing. This instruction can be used for code alignment purposes.
45 | */
46 | #define __NOP __nop
47 |
48 |
49 | /** \brief Wait For Interrupt
50 |
51 | Wait For Interrupt is a hint instruction that suspends execution
52 | until one of a number of events occurs.
53 | */
54 | #define __WFI __wfi
55 |
56 |
57 | /** \brief Wait For Event
58 |
59 | Wait For Event is a hint instruction that permits the processor to enter
60 | a low-power state until one of a number of events occurs.
61 | */
62 | #define __WFE __wfe
63 |
64 |
65 | /** \brief Send Event
66 |
67 | Send Event is a hint instruction. It causes an event to be signaled to the CPU.
68 | */
69 | #define __SEV __sev
70 |
71 |
72 | /** \brief Instruction Synchronization Barrier
73 |
74 | Instruction Synchronization Barrier flushes the pipeline in the processor,
75 | so that all instructions following the ISB are fetched from cache or
76 | memory, after the instruction has been completed.
77 | */
78 | #define __ISB() __isb(0xF)
79 |
80 |
81 | /** \brief Data Synchronization Barrier
82 |
83 | This function acts as a special kind of Data Memory Barrier.
84 | It completes when all explicit memory accesses before this instruction complete.
85 | */
86 | #define __DSB() __dsb(0xF)
87 |
88 |
89 | /** \brief Data Memory Barrier
90 |
91 | This function ensures the apparent order of the explicit memory operations before
92 | and after the instruction, without ensuring their completion.
93 | */
94 | #define __DMB() __dmb(0xF)
95 |
96 |
97 | /** \brief Reverse byte order (32 bit)
98 |
99 | This function reverses the byte order in integer value.
100 |
101 | \param [in] value Value to reverse
102 | \return Reversed value
103 | */
104 | #define __REV __rev
105 |
106 |
107 | /** \brief Reverse byte order (16 bit)
108 |
109 | This function reverses the byte order in two unsigned short values.
110 |
111 | \param [in] value Value to reverse
112 | \return Reversed value
113 | */
114 | __attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
115 | {
116 | rev16 r0, r0
117 | bx lr
118 | }
119 |
120 |
121 | /** \brief Reverse byte order in signed short value
122 |
123 | This function reverses the byte order in a signed short value with sign extension to integer.
124 |
125 | \param [in] value Value to reverse
126 | \return Reversed value
127 | */
128 | __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value)
129 | {
130 | revsh r0, r0
131 | bx lr
132 | }
133 |
134 |
135 | /** \brief Rotate Right in unsigned value (32 bit)
136 |
137 | This function Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
138 |
139 | \param [in] value Value to rotate
140 | \param [in] value Number of Bits to rotate
141 | \return Rotated value
142 | */
143 | #define __ROR __ror
144 |
145 |
146 | #if (__CORTEX_M >= 0x03)
147 |
148 | /** \brief Reverse bit order of value
149 |
150 | This function reverses the bit order of the given value.
151 |
152 | \param [in] value Value to reverse
153 | \return Reversed value
154 | */
155 | #define __RBIT __rbit
156 |
157 |
158 | /** \brief LDR Exclusive (8 bit)
159 |
160 | This function performs a exclusive LDR command for 8 bit value.
161 |
162 | \param [in] ptr Pointer to data
163 | \return value of type uint8_t at (*ptr)
164 | */
165 | #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
166 |
167 |
168 | /** \brief LDR Exclusive (16 bit)
169 |
170 | This function performs a exclusive LDR command for 16 bit values.
171 |
172 | \param [in] ptr Pointer to data
173 | \return value of type uint16_t at (*ptr)
174 | */
175 | #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
176 |
177 |
178 | /** \brief LDR Exclusive (32 bit)
179 |
180 | This function performs a exclusive LDR command for 32 bit values.
181 |
182 | \param [in] ptr Pointer to data
183 | \return value of type uint32_t at (*ptr)
184 | */
185 | #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
186 |
187 |
188 | /** \brief STR Exclusive (8 bit)
189 |
190 | This function performs a exclusive STR command for 8 bit values.
191 |
192 | \param [in] value Value to store
193 | \param [in] ptr Pointer to location
194 | \return 0 Function succeeded
195 | \return 1 Function failed
196 | */
197 | #define __STREXB(value, ptr) __strex(value, ptr)
198 |
199 |
200 | /** \brief STR Exclusive (16 bit)
201 |
202 | This function performs a exclusive STR command for 16 bit values.
203 |
204 | \param [in] value Value to store
205 | \param [in] ptr Pointer to location
206 | \return 0 Function succeeded
207 | \return 1 Function failed
208 | */
209 | #define __STREXH(value, ptr) __strex(value, ptr)
210 |
211 |
212 | /** \brief STR Exclusive (32 bit)
213 |
214 | This function performs a exclusive STR command for 32 bit values.
215 |
216 | \param [in] value Value to store
217 | \param [in] ptr Pointer to location
218 | \return 0 Function succeeded
219 | \return 1 Function failed
220 | */
221 | #define __STREXW(value, ptr) __strex(value, ptr)
222 |
223 |
224 | /** \brief Remove the exclusive lock
225 |
226 | This function removes the exclusive lock which is created by LDREX.
227 |
228 | */
229 | #define __CLREX __clrex
230 |
231 |
232 | /** \brief Signed Saturate
233 |
234 | This function saturates a signed value.
235 |
236 | \param [in] value Value to be saturated
237 | \param [in] sat Bit position to saturate to (1..32)
238 | \return Saturated value
239 | */
240 | #define __SSAT __ssat
241 |
242 |
243 | /** \brief Unsigned Saturate
244 |
245 | This function saturates an unsigned value.
246 |
247 | \param [in] value Value to be saturated
248 | \param [in] sat Bit position to saturate to (0..31)
249 | \return Saturated value
250 | */
251 | #define __USAT __usat
252 |
253 |
254 | /** \brief Count leading zeros
255 |
256 | This function counts the number of leading zeros of a data value.
257 |
258 | \param [in] value Value to count the leading zeros
259 | \return number of leading zeros in value
260 | */
261 | #define __CLZ __clz
262 |
263 | #endif /* (__CORTEX_M >= 0x03) */
264 |
265 |
266 |
267 | #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
268 | /* IAR iccarm specific functions */
269 |
270 | #include
271 |
272 |
273 | #elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
274 | /* TI CCS specific functions */
275 |
276 | #include
277 |
278 |
279 | #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
280 | /* GNU gcc specific functions */
281 |
282 | /** \brief No Operation
283 |
284 | No Operation does nothing. This instruction can be used for code alignment purposes.
285 | */
286 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __NOP(void)
287 | {
288 | __ASM volatile ("nop");
289 | }
290 |
291 |
292 | /** \brief Wait For Interrupt
293 |
294 | Wait For Interrupt is a hint instruction that suspends execution
295 | until one of a number of events occurs.
296 | */
297 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __WFI(void)
298 | {
299 | __ASM volatile ("wfi");
300 | }
301 |
302 |
303 | /** \brief Wait For Event
304 |
305 | Wait For Event is a hint instruction that permits the processor to enter
306 | a low-power state until one of a number of events occurs.
307 | */
308 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __WFE(void)
309 | {
310 | __ASM volatile ("wfe");
311 | }
312 |
313 |
314 | /** \brief Send Event
315 |
316 | Send Event is a hint instruction. It causes an event to be signaled to the CPU.
317 | */
318 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __SEV(void)
319 | {
320 | __ASM volatile ("sev");
321 | }
322 |
323 |
324 | /** \brief Instruction Synchronization Barrier
325 |
326 | Instruction Synchronization Barrier flushes the pipeline in the processor,
327 | so that all instructions following the ISB are fetched from cache or
328 | memory, after the instruction has been completed.
329 | */
330 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __ISB(void)
331 | {
332 | __ASM volatile ("isb");
333 | }
334 |
335 |
336 | /** \brief Data Synchronization Barrier
337 |
338 | This function acts as a special kind of Data Memory Barrier.
339 | It completes when all explicit memory accesses before this instruction complete.
340 | */
341 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __DSB(void)
342 | {
343 | __ASM volatile ("dsb");
344 | }
345 |
346 |
347 | /** \brief Data Memory Barrier
348 |
349 | This function ensures the apparent order of the explicit memory operations before
350 | and after the instruction, without ensuring their completion.
351 | */
352 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __DMB(void)
353 | {
354 | __ASM volatile ("dmb");
355 | }
356 |
357 |
358 | /** \brief Reverse byte order (32 bit)
359 |
360 | This function reverses the byte order in integer value.
361 |
362 | \param [in] value Value to reverse
363 | \return Reversed value
364 | */
365 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV(uint32_t value)
366 | {
367 | uint32_t result;
368 |
369 | __ASM volatile ("rev %0, %1" : "=r" (result) : "r" (value) );
370 | return(result);
371 | }
372 |
373 |
374 | /** \brief Reverse byte order (16 bit)
375 |
376 | This function reverses the byte order in two unsigned short values.
377 |
378 | \param [in] value Value to reverse
379 | \return Reversed value
380 | */
381 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV16(uint32_t value)
382 | {
383 | uint32_t result;
384 |
385 | __ASM volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) );
386 | return(result);
387 | }
388 |
389 |
390 | /** \brief Reverse byte order in signed short value
391 |
392 | This function reverses the byte order in a signed short value with sign extension to integer.
393 |
394 | \param [in] value Value to reverse
395 | \return Reversed value
396 | */
397 | __attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __REVSH(int32_t value)
398 | {
399 | uint32_t result;
400 |
401 | __ASM volatile ("revsh %0, %1" : "=r" (result) : "r" (value) );
402 | return(result);
403 | }
404 |
405 |
406 | /** \brief Rotate Right in unsigned value (32 bit)
407 |
408 | This function Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
409 |
410 | \param [in] value Value to rotate
411 | \param [in] value Number of Bits to rotate
412 | \return Rotated value
413 | */
414 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
415 | {
416 |
417 | __ASM volatile ("ror %0, %0, %1" : "+r" (op1) : "r" (op2) );
418 | return(op1);
419 | }
420 |
421 |
422 | #if (__CORTEX_M >= 0x03)
423 |
424 | /** \brief Reverse bit order of value
425 |
426 | This function reverses the bit order of the given value.
427 |
428 | \param [in] value Value to reverse
429 | \return Reversed value
430 | */
431 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
432 | {
433 | uint32_t result;
434 |
435 | __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
436 | return(result);
437 | }
438 |
439 |
440 | /** \brief LDR Exclusive (8 bit)
441 |
442 | This function performs a exclusive LDR command for 8 bit value.
443 |
444 | \param [in] ptr Pointer to data
445 | \return value of type uint8_t at (*ptr)
446 | */
447 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
448 | {
449 | uint8_t result;
450 |
451 | __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) );
452 | return(result);
453 | }
454 |
455 |
456 | /** \brief LDR Exclusive (16 bit)
457 |
458 | This function performs a exclusive LDR command for 16 bit values.
459 |
460 | \param [in] ptr Pointer to data
461 | \return value of type uint16_t at (*ptr)
462 | */
463 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
464 | {
465 | uint16_t result;
466 |
467 | __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) );
468 | return(result);
469 | }
470 |
471 |
472 | /** \brief LDR Exclusive (32 bit)
473 |
474 | This function performs a exclusive LDR command for 32 bit values.
475 |
476 | \param [in] ptr Pointer to data
477 | \return value of type uint32_t at (*ptr)
478 | */
479 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
480 | {
481 | uint32_t result;
482 |
483 | __ASM volatile ("ldrex %0, [%1]" : "=r" (result) : "r" (addr) );
484 | return(result);
485 | }
486 |
487 |
488 | /** \brief STR Exclusive (8 bit)
489 |
490 | This function performs a exclusive STR command for 8 bit values.
491 |
492 | \param [in] value Value to store
493 | \param [in] ptr Pointer to location
494 | \return 0 Function succeeded
495 | \return 1 Function failed
496 | */
497 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
498 | {
499 | uint32_t result;
500 |
501 | __ASM volatile ("strexb %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
502 | return(result);
503 | }
504 |
505 |
506 | /** \brief STR Exclusive (16 bit)
507 |
508 | This function performs a exclusive STR command for 16 bit values.
509 |
510 | \param [in] value Value to store
511 | \param [in] ptr Pointer to location
512 | \return 0 Function succeeded
513 | \return 1 Function failed
514 | */
515 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
516 | {
517 | uint32_t result;
518 |
519 | __ASM volatile ("strexh %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
520 | return(result);
521 | }
522 |
523 |
524 | /** \brief STR Exclusive (32 bit)
525 |
526 | This function performs a exclusive STR command for 32 bit values.
527 |
528 | \param [in] value Value to store
529 | \param [in] ptr Pointer to location
530 | \return 0 Function succeeded
531 | \return 1 Function failed
532 | */
533 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
534 | {
535 | uint32_t result;
536 |
537 | __ASM volatile ("strex %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
538 | return(result);
539 | }
540 |
541 |
542 | /** \brief Remove the exclusive lock
543 |
544 | This function removes the exclusive lock which is created by LDREX.
545 |
546 | */
547 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __CLREX(void)
548 | {
549 | __ASM volatile ("clrex");
550 | }
551 |
552 |
553 | /** \brief Signed Saturate
554 |
555 | This function saturates a signed value.
556 |
557 | \param [in] value Value to be saturated
558 | \param [in] sat Bit position to saturate to (1..32)
559 | \return Saturated value
560 | */
561 | #define __SSAT(ARG1,ARG2) \
562 | ({ \
563 | uint32_t __RES, __ARG1 = (ARG1); \
564 | __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
565 | __RES; \
566 | })
567 |
568 |
569 | /** \brief Unsigned Saturate
570 |
571 | This function saturates an unsigned value.
572 |
573 | \param [in] value Value to be saturated
574 | \param [in] sat Bit position to saturate to (0..31)
575 | \return Saturated value
576 | */
577 | #define __USAT(ARG1,ARG2) \
578 | ({ \
579 | uint32_t __RES, __ARG1 = (ARG1); \
580 | __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
581 | __RES; \
582 | })
583 |
584 |
585 | /** \brief Count leading zeros
586 |
587 | This function counts the number of leading zeros of a data value.
588 |
589 | \param [in] value Value to count the leading zeros
590 | \return number of leading zeros in value
591 | */
592 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __CLZ(uint32_t value)
593 | {
594 | uint8_t result;
595 |
596 | __ASM volatile ("clz %0, %1" : "=r" (result) : "r" (value) );
597 | return(result);
598 | }
599 |
600 | #endif /* (__CORTEX_M >= 0x03) */
601 |
602 |
603 |
604 |
605 | #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
606 | /* TASKING carm specific functions */
607 |
608 | /*
609 | * The CMSIS functions have been implemented as intrinsics in the compiler.
610 | * Please use "carm -?i" to get an up to date list of all intrinsics,
611 | * Including the CMSIS ones.
612 | */
613 |
614 | #endif
615 |
616 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
617 |
618 | #endif /* __CORE_CMINSTR_H */
619 |
--------------------------------------------------------------------------------
/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | GPIO_InitTypeDef G;
8 | ADC_InitTypeDef A;
9 | TIM_TimeBaseInitTypeDef T;
10 | TIM_OCInitTypeDef TO;
11 | DMA_InitTypeDef D;
12 | RCC_ClocksTypeDef RC;
13 |
14 | /************ DEFINES **************/
15 | //Destination of ADC data
16 | #define BUF_SIZE 7500
17 | uint8_t data[BUF_SIZE] = {0};
18 |
19 | //Sample rate in Hz
20 | #define FS 1000000
21 | #define ADC_CHANNEL ADC_Channel_0
22 | #define ADC_PIN GPIO_Pin_0
23 | #define ADC_GPIO GPIOA
24 | /************************************/
25 |
26 |
27 | int main(void)
28 | {
29 | //Use clock provided by STLink on discovery board for less jitter
30 | RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);
31 | RCC_HSEConfig(RCC_HSE_Bypass);
32 | RCC_PREDIV1Config(RCC_PREDIV1_Div2);
33 | RCC_PLLCmd(DISABLE);
34 | RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_12);
35 | RCC_PLLCmd(ENABLE);
36 | while(!RCC_GetFlagStatus(RCC_FLAG_PLLRDY));
37 |
38 | //Use PLL as system clock (48MHz);
39 | RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
40 |
41 | //Enable required clocks
42 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
43 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
44 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
45 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM15, ENABLE);
46 |
47 | //Populate clock frequency struct
48 | RCC_GetClocksFreq(&RC);
49 |
50 | //Set ADC clock to PCLK/2
51 | RCC_ADCCLKConfig(RCC_ADCCLK_PCLK_Div2);
52 |
53 | //Initialize GPIO pin
54 | G.GPIO_Pin = ADC_PIN;
55 | G.GPIO_Mode = GPIO_Mode_AN;
56 | G.GPIO_OType = GPIO_OType_PP;
57 | G.GPIO_PuPd = GPIO_PuPd_UP;
58 | G.GPIO_Speed = GPIO_Speed_50MHz;
59 | GPIO_Init(ADC_GPIO, &G);
60 |
61 | //Setup the ADC for DMA transfers with T15 trigger output as the
62 | //conversion trigger
63 | A.ADC_ContinuousConvMode = DISABLE;
64 | A.ADC_DataAlign = ADC_DataAlign_Right;
65 | A.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T15_TRGO;
66 | A.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_Rising;
67 | A.ADC_Resolution = ADC_Resolution_8b;
68 | A.ADC_ScanDirection = ADC_ScanDirection_Upward;
69 | ADC_Init(ADC1, &A);
70 | ADC_GetCalibrationFactor(ADC1);
71 |
72 | //Enable ADC DMA
73 | ADC_DMACmd(ADC1, ENABLE);
74 | ADC_Cmd(ADC1, ENABLE);
75 |
76 | //Wait for ADC to be ready
77 | while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_ADRDY));
78 |
79 | //Set ADC conversion channel to fastest sample time
80 | ADC_ChannelConfig(ADC1, ADC_CHANNEL, ADC_SampleTime_1_5Cycles);
81 |
82 | //Configure TIM15 as the ADC trigger
83 | T.TIM_ClockDivision = TIM_CKD_DIV1;
84 | T.TIM_CounterMode = TIM_CounterMode_Up;
85 | T.TIM_Period = RC.PCLK_Frequency/FS -1;
86 | T.TIM_Prescaler = 0;
87 | T.TIM_RepetitionCounter = 0;
88 | TIM_TimeBaseInit(TIM15, &T);
89 | TIM_SelectOutputTrigger(TIM15, TIM_TRGOSource_Update);
90 |
91 | //Configure DMA for transfer
92 | //NOTE: Memory and peripheral sizes will need to be changed for
93 | //conversions larger than 8bits.
94 | D.DMA_BufferSize = BUF_SIZE;
95 | D.DMA_DIR = DMA_DIR_PeripheralSRC;
96 | D.DMA_M2M = DMA_M2M_Disable;
97 | D.DMA_MemoryBaseAddr = (uint32_t) &data;
98 | D.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
99 | D.DMA_MemoryInc = DMA_MemoryInc_Enable;
100 | D.DMA_Mode = DMA_Mode_Circular;
101 | D.DMA_PeripheralBaseAddr = (uint32_t) &(ADC1->DR);
102 | D.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
103 | D.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
104 | D.DMA_Priority = DMA_Priority_VeryHigh;
105 | DMA_Init(DMA1_Channel1, &D);
106 | DMA_Cmd(DMA1_Channel1, ENABLE);
107 |
108 | //Enable timer!
109 | TIM_Cmd(TIM15, ENABLE);
110 |
111 | uint32_t N = 0;
112 | while(1)
113 | {
114 | //Start conversions
115 | ADC_StartOfConversion(ADC1);
116 |
117 | //Wait for DMA to complete
118 | while(!DMA_GetFlagStatus(DMA1_FLAG_TC1));
119 |
120 | //Clear DMA flag
121 | DMA_ClearFlag(DMA1_FLAG_TC1);
122 |
123 | //Increment sample buffer complete counter
124 | N++;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/stm32_lib/inc/stm32f0xx_adc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_adc.h
4 | * @author MCD Application Team
5 | * @version V1.2.0
6 | * @date 01-August-2013
7 | * @brief This file contains all the functions prototypes for the ADC firmware
8 | * library
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2013 STMicroelectronics
13 | *
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 | * You may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at:
17 | *
18 | * http://www.st.com/software_license_agreement_liberty_v2
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | *
26 | ******************************************************************************
27 | */
28 |
29 | /* Define to prevent recursive inclusion -------------------------------------*/
30 | #ifndef __STM32F0XX_ADC_H
31 | #define __STM32F0XX_ADC_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f0xx.h"
39 |
40 | /** @addtogroup STM32F0xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup ADC
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 |
50 | /**
51 | * @brief ADC Init structure definition
52 | */
53 |
54 | typedef struct
55 | {
56 | uint32_t ADC_Resolution; /*!< Selects the resolution of the conversion.
57 | This parameter can be a value of @ref ADC_Resolution */
58 |
59 | FunctionalState ADC_ContinuousConvMode; /*!< Specifies whether the conversion is performed in
60 | Continuous or Single mode.
61 | This parameter can be set to ENABLE or DISABLE. */
62 |
63 | uint32_t ADC_ExternalTrigConvEdge; /*!< Selects the external trigger Edge and enables the
64 | trigger of a regular group. This parameter can be a value
65 | of @ref ADC_external_trigger_edge_conversion */
66 |
67 | uint32_t ADC_ExternalTrigConv; /*!< Defines the external trigger used to start the analog
68 | to digital conversion of regular channels. This parameter
69 | can be a value of @ref ADC_external_trigger_sources_for_channels_conversion */
70 |
71 | uint32_t ADC_DataAlign; /*!< Specifies whether the ADC data alignment is left or right.
72 | This parameter can be a value of @ref ADC_data_align */
73 |
74 | uint32_t ADC_ScanDirection; /*!< Specifies in which direction the channels will be scanned
75 | in the sequence.
76 | This parameter can be a value of @ref ADC_Scan_Direction */
77 | }ADC_InitTypeDef;
78 |
79 |
80 | /* Exported constants --------------------------------------------------------*/
81 |
82 | /** @defgroup ADC_Exported_Constants
83 | * @{
84 | */
85 | #define IS_ADC_ALL_PERIPH(PERIPH) ((PERIPH) == ADC1)
86 |
87 | /** @defgroup ADC_JitterOff
88 | * @{
89 | */
90 | #define ADC_JitterOff_PCLKDiv2 ADC_CFGR2_JITOFFDIV2
91 | #define ADC_JitterOff_PCLKDiv4 ADC_CFGR2_JITOFFDIV4
92 |
93 | #define IS_ADC_JITTEROFF(JITTEROFF) (((JITTEROFF) & 0x3FFFFFFF) == (uint32_t)RESET)
94 |
95 | /**
96 | * @}
97 | */
98 |
99 | /** @defgroup ADC_Resolution
100 | * @{
101 | */
102 | #define ADC_Resolution_12b ((uint32_t)0x00000000)
103 | #define ADC_Resolution_10b ADC_CFGR1_RES_0
104 | #define ADC_Resolution_8b ADC_CFGR1_RES_1
105 | #define ADC_Resolution_6b ADC_CFGR1_RES
106 |
107 | #define IS_ADC_RESOLUTION(RESOLUTION) (((RESOLUTION) == ADC_Resolution_12b) || \
108 | ((RESOLUTION) == ADC_Resolution_10b) || \
109 | ((RESOLUTION) == ADC_Resolution_8b) || \
110 | ((RESOLUTION) == ADC_Resolution_6b))
111 |
112 | /**
113 | * @}
114 | */
115 |
116 | /** @defgroup ADC_external_trigger_edge_conversion
117 | * @{
118 | */
119 | #define ADC_ExternalTrigConvEdge_None ((uint32_t)0x00000000)
120 | #define ADC_ExternalTrigConvEdge_Rising ADC_CFGR1_EXTEN_0
121 | #define ADC_ExternalTrigConvEdge_Falling ADC_CFGR1_EXTEN_1
122 | #define ADC_ExternalTrigConvEdge_RisingFalling ADC_CFGR1_EXTEN
123 |
124 | #define IS_ADC_EXT_TRIG_EDGE(EDGE) (((EDGE) == ADC_ExternalTrigConvEdge_None) || \
125 | ((EDGE) == ADC_ExternalTrigConvEdge_Rising) || \
126 | ((EDGE) == ADC_ExternalTrigConvEdge_Falling) || \
127 | ((EDGE) == ADC_ExternalTrigConvEdge_RisingFalling))
128 | /**
129 | * @}
130 | */
131 |
132 | /** @defgroup ADC_external_trigger_sources_for_channels_conversion
133 | * @{
134 | */
135 |
136 | /* TIM1 */
137 | #define ADC_ExternalTrigConv_T1_TRGO ((uint32_t)0x00000000)
138 | #define ADC_ExternalTrigConv_T1_CC4 ADC_CFGR1_EXTSEL_0
139 |
140 | /* TIM2 */
141 | #define ADC_ExternalTrigConv_T2_TRGO ADC_CFGR1_EXTSEL_1
142 |
143 | /* TIM3 */
144 | #define ADC_ExternalTrigConv_T3_TRGO ((uint32_t)(ADC_CFGR1_EXTSEL_0 | ADC_CFGR1_EXTSEL_1))
145 |
146 | /* TIM15 */
147 | #define ADC_ExternalTrigConv_T15_TRGO ADC_CFGR1_EXTSEL_2
148 |
149 | #define IS_ADC_EXTERNAL_TRIG_CONV(CONV) (((CONV) == ADC_ExternalTrigConv_T1_TRGO) || \
150 | ((CONV) == ADC_ExternalTrigConv_T1_CC4) || \
151 | ((CONV) == ADC_ExternalTrigConv_T2_TRGO) || \
152 | ((CONV) == ADC_ExternalTrigConv_T3_TRGO) || \
153 | ((CONV) == ADC_ExternalTrigConv_T15_TRGO))
154 | /**
155 | * @}
156 | */
157 |
158 | /** @defgroup ADC_data_align
159 | * @{
160 | */
161 |
162 | #define ADC_DataAlign_Right ((uint32_t)0x00000000)
163 | #define ADC_DataAlign_Left ADC_CFGR1_ALIGN
164 |
165 | #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DataAlign_Right) || \
166 | ((ALIGN) == ADC_DataAlign_Left))
167 | /**
168 | * @}
169 | */
170 |
171 | /** @defgroup ADC_Scan_Direction
172 | * @{
173 | */
174 |
175 | #define ADC_ScanDirection_Upward ((uint32_t)0x00000000)
176 | #define ADC_ScanDirection_Backward ADC_CFGR1_SCANDIR
177 |
178 | #define IS_ADC_SCAN_DIRECTION(DIRECTION) (((DIRECTION) == ADC_ScanDirection_Upward) || \
179 | ((DIRECTION) == ADC_ScanDirection_Backward))
180 | /**
181 | * @}
182 | */
183 |
184 | /** @defgroup ADC_DMA_Mode
185 | * @{
186 | */
187 |
188 | #define ADC_DMAMode_OneShot ((uint32_t)0x00000000)
189 | #define ADC_DMAMode_Circular ADC_CFGR1_DMACFG
190 |
191 | #define IS_ADC_DMA_MODE(MODE) (((MODE) == ADC_DMAMode_OneShot) || \
192 | ((MODE) == ADC_DMAMode_Circular))
193 | /**
194 | * @}
195 | */
196 |
197 | /** @defgroup ADC_analog_watchdog_selection
198 | * @{
199 | */
200 |
201 | #define ADC_AnalogWatchdog_Channel_0 ((uint32_t)0x00000000)
202 | #define ADC_AnalogWatchdog_Channel_1 ((uint32_t)0x04000000)
203 | #define ADC_AnalogWatchdog_Channel_2 ((uint32_t)0x08000000)
204 | #define ADC_AnalogWatchdog_Channel_3 ((uint32_t)0x0C000000)
205 | #define ADC_AnalogWatchdog_Channel_4 ((uint32_t)0x10000000)
206 | #define ADC_AnalogWatchdog_Channel_5 ((uint32_t)0x14000000)
207 | #define ADC_AnalogWatchdog_Channel_6 ((uint32_t)0x18000000)
208 | #define ADC_AnalogWatchdog_Channel_7 ((uint32_t)0x1C000000)
209 | #define ADC_AnalogWatchdog_Channel_8 ((uint32_t)0x20000000)
210 | #define ADC_AnalogWatchdog_Channel_9 ((uint32_t)0x24000000)
211 | #define ADC_AnalogWatchdog_Channel_10 ((uint32_t)0x28000000)
212 | #define ADC_AnalogWatchdog_Channel_11 ((uint32_t)0x2C000000)
213 | #define ADC_AnalogWatchdog_Channel_12 ((uint32_t)0x30000000)
214 | #define ADC_AnalogWatchdog_Channel_13 ((uint32_t)0x34000000)
215 | #define ADC_AnalogWatchdog_Channel_14 ((uint32_t)0x38000000)
216 | #define ADC_AnalogWatchdog_Channel_15 ((uint32_t)0x3C000000)
217 | #define ADC_AnalogWatchdog_Channel_16 ((uint32_t)0x40000000)
218 | #define ADC_AnalogWatchdog_Channel_17 ((uint32_t)0x44000000)
219 | #define ADC_AnalogWatchdog_Channel_18 ((uint32_t)0x48000000)
220 |
221 |
222 | #define IS_ADC_ANALOG_WATCHDOG_CHANNEL(CHANNEL) (((CHANNEL) == ADC_AnalogWatchdog_Channel_0) || \
223 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_1) || \
224 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_2) || \
225 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_3) || \
226 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_4) || \
227 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_5) || \
228 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_6) || \
229 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_7) || \
230 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_8) || \
231 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_9) || \
232 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_10) || \
233 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_11) || \
234 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_12) || \
235 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_13) || \
236 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_14) || \
237 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_15) || \
238 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_16) || \
239 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_17) || \
240 | ((CHANNEL) == ADC_AnalogWatchdog_Channel_18))
241 | /**
242 | * @}
243 | */
244 |
245 | /** @defgroup ADC_sampling_times
246 | * @{
247 | */
248 |
249 | #define ADC_SampleTime_1_5Cycles ((uint32_t)0x00000000)
250 | #define ADC_SampleTime_7_5Cycles ((uint32_t)0x00000001)
251 | #define ADC_SampleTime_13_5Cycles ((uint32_t)0x00000002)
252 | #define ADC_SampleTime_28_5Cycles ((uint32_t)0x00000003)
253 | #define ADC_SampleTime_41_5Cycles ((uint32_t)0x00000004)
254 | #define ADC_SampleTime_55_5Cycles ((uint32_t)0x00000005)
255 | #define ADC_SampleTime_71_5Cycles ((uint32_t)0x00000006)
256 | #define ADC_SampleTime_239_5Cycles ((uint32_t)0x00000007)
257 |
258 | #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SampleTime_1_5Cycles) || \
259 | ((TIME) == ADC_SampleTime_7_5Cycles) || \
260 | ((TIME) == ADC_SampleTime_13_5Cycles) || \
261 | ((TIME) == ADC_SampleTime_28_5Cycles) || \
262 | ((TIME) == ADC_SampleTime_41_5Cycles) || \
263 | ((TIME) == ADC_SampleTime_55_5Cycles) || \
264 | ((TIME) == ADC_SampleTime_71_5Cycles) || \
265 | ((TIME) == ADC_SampleTime_239_5Cycles))
266 | /**
267 | * @}
268 | */
269 |
270 | /** @defgroup ADC_thresholds
271 | * @{
272 | */
273 |
274 | #define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) <= 0xFFF)
275 |
276 | /**
277 | * @}
278 | */
279 |
280 | /** @defgroup ADC_channels
281 | * @{
282 | */
283 |
284 | #define ADC_Channel_0 ADC_CHSELR_CHSEL0
285 | #define ADC_Channel_1 ADC_CHSELR_CHSEL1
286 | #define ADC_Channel_2 ADC_CHSELR_CHSEL2
287 | #define ADC_Channel_3 ADC_CHSELR_CHSEL3
288 | #define ADC_Channel_4 ADC_CHSELR_CHSEL4
289 | #define ADC_Channel_5 ADC_CHSELR_CHSEL5
290 | #define ADC_Channel_6 ADC_CHSELR_CHSEL6
291 | #define ADC_Channel_7 ADC_CHSELR_CHSEL7
292 | #define ADC_Channel_8 ADC_CHSELR_CHSEL8
293 | #define ADC_Channel_9 ADC_CHSELR_CHSEL9
294 | #define ADC_Channel_10 ADC_CHSELR_CHSEL10
295 | #define ADC_Channel_11 ADC_CHSELR_CHSEL11
296 | #define ADC_Channel_12 ADC_CHSELR_CHSEL12
297 | #define ADC_Channel_13 ADC_CHSELR_CHSEL13
298 | #define ADC_Channel_14 ADC_CHSELR_CHSEL14
299 | #define ADC_Channel_15 ADC_CHSELR_CHSEL15
300 | #define ADC_Channel_16 ADC_CHSELR_CHSEL16
301 | #define ADC_Channel_17 ADC_CHSELR_CHSEL17
302 | #define ADC_Channel_18 ADC_CHSELR_CHSEL18
303 |
304 | #define ADC_Channel_TempSensor ((uint32_t)ADC_Channel_16)
305 | #define ADC_Channel_Vrefint ((uint32_t)ADC_Channel_17)
306 | #define ADC_Channel_Vbat ((uint32_t)ADC_Channel_18)
307 |
308 | #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) != (uint32_t)RESET) && (((CHANNEL) & 0xFFF80000) == (uint32_t)RESET))
309 |
310 | /**
311 | * @}
312 | */
313 |
314 | /** @defgroup ADC_interrupts_definition
315 | * @{
316 | */
317 |
318 | #define ADC_IT_ADRDY ADC_IER_ADRDYIE
319 | #define ADC_IT_EOSMP ADC_IER_EOSMPIE
320 | #define ADC_IT_EOC ADC_IER_EOCIE
321 | #define ADC_IT_EOSEQ ADC_IER_EOSEQIE
322 | #define ADC_IT_OVR ADC_IER_OVRIE
323 | #define ADC_IT_AWD ADC_IER_AWDIE
324 |
325 | #define IS_ADC_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFFFF60) == (uint32_t)RESET))
326 |
327 | #define IS_ADC_GET_IT(IT) (((IT) == ADC_IT_ADRDY) || ((IT) == ADC_IT_EOSMP) || \
328 | ((IT) == ADC_IT_EOC) || ((IT) == ADC_IT_EOSEQ) || \
329 | ((IT) == ADC_IT_OVR) || ((IT) == ADC_IT_AWD))
330 |
331 | #define IS_ADC_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFFFF60) == (uint32_t)RESET))
332 |
333 | /**
334 | * @}
335 | */
336 |
337 | /** @defgroup ADC_flags_definition
338 | * @{
339 | */
340 |
341 | #define ADC_FLAG_ADRDY ADC_ISR_ADRDY
342 | #define ADC_FLAG_EOSMP ADC_ISR_EOSMP
343 | #define ADC_FLAG_EOC ADC_ISR_EOC
344 | #define ADC_FLAG_EOSEQ ADC_ISR_EOSEQ
345 | #define ADC_FLAG_OVR ADC_ISR_OVR
346 | #define ADC_FLAG_AWD ADC_ISR_AWD
347 |
348 | #define ADC_FLAG_ADEN ((uint32_t)0x01000001)
349 | #define ADC_FLAG_ADDIS ((uint32_t)0x01000002)
350 | #define ADC_FLAG_ADSTART ((uint32_t)0x01000004)
351 | #define ADC_FLAG_ADSTP ((uint32_t)0x01000008)
352 | #define ADC_FLAG_ADCAL ((uint32_t)0x11000000)
353 |
354 | #define IS_ADC_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xEFFFFF60) == (uint32_t)RESET))
355 |
356 | #define IS_ADC_GET_FLAG(FLAG) (((FLAG) == ADC_FLAG_ADRDY) || ((FLAG) == ADC_FLAG_EOSMP) || \
357 | ((FLAG) == ADC_FLAG_EOC) || ((FLAG)== ADC_FLAG_EOSEQ) || \
358 | ((FLAG) == ADC_FLAG_AWD) || ((FLAG)== ADC_FLAG_OVR) || \
359 | ((FLAG) == ADC_FLAG_ADEN) || ((FLAG)== ADC_FLAG_ADDIS) || \
360 | ((FLAG) == ADC_FLAG_ADSTART) || ((FLAG)== ADC_FLAG_ADSTP) || \
361 | ((FLAG) == ADC_FLAG_ADCAL))
362 | /**
363 | * @}
364 | */
365 |
366 | /**
367 | * @}
368 | */
369 |
370 | /* Exported macro ------------------------------------------------------------*/
371 | /* Exported functions ------------------------------------------------------- */
372 |
373 | /* Function used to set the ADC configuration to the default reset state *****/
374 | void ADC_DeInit(ADC_TypeDef* ADCx);
375 |
376 | /* Initialization and Configuration functions *********************************/
377 | void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct);
378 | void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct);
379 | void ADC_JitterCmd(ADC_TypeDef* ADCx, uint32_t ADC_JitterOff, FunctionalState NewState);
380 | void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState);
381 |
382 | /* Power saving functions *****************************************************/
383 | void ADC_AutoPowerOffCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
384 | void ADC_WaitModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
385 |
386 | /* Analog Watchdog configuration functions ************************************/
387 | void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
388 | void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold,uint16_t LowThreshold);
389 | void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint32_t ADC_AnalogWatchdog_Channel);
390 | void ADC_AnalogWatchdogSingleChannelCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
391 |
392 | /* Temperature Sensor , Vrefint and Vbat management function ******************/
393 | void ADC_TempSensorCmd(FunctionalState NewState);
394 | void ADC_VrefintCmd(FunctionalState NewState);
395 | void ADC_VbatCmd(FunctionalState NewState);
396 |
397 | /* Channels Configuration functions *******************************************/
398 | void ADC_ChannelConfig(ADC_TypeDef* ADCx, uint32_t ADC_Channel, uint32_t ADC_SampleTime);
399 | void ADC_ContinuousModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
400 | void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
401 | void ADC_OverrunModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
402 | uint32_t ADC_GetCalibrationFactor(ADC_TypeDef* ADCx);
403 | void ADC_StopOfConversion(ADC_TypeDef* ADCx);
404 | void ADC_StartOfConversion(ADC_TypeDef* ADCx);
405 | uint16_t ADC_GetConversionValue(ADC_TypeDef* ADCx);
406 |
407 | /* Regular Channels DMA Configuration functions *******************************/
408 | void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState);
409 | void ADC_DMARequestModeConfig(ADC_TypeDef* ADCx, uint32_t ADC_DMARequestMode);
410 |
411 | /* Interrupts and flags management functions **********************************/
412 | void ADC_ITConfig(ADC_TypeDef* ADCx, uint32_t ADC_IT, FunctionalState NewState);
413 | FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint32_t ADC_FLAG);
414 | void ADC_ClearFlag(ADC_TypeDef* ADCx, uint32_t ADC_FLAG);
415 | ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, uint32_t ADC_IT);
416 | void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, uint32_t ADC_IT);
417 |
418 | #ifdef __cplusplus
419 | }
420 | #endif
421 |
422 | #endif /*__STM32F0XX_ADC_H */
423 |
424 | /**
425 | * @}
426 | */
427 |
428 | /**
429 | * @}
430 | */
431 |
432 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
433 |
--------------------------------------------------------------------------------
/stm32_lib/inc/stm32f0xx_dma.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_dma.h
4 | * @author MCD Application Team
5 | * @version V1.2.0
6 | * @date 01-August-2013
7 | * @brief This file contains all the functions prototypes for the DMA firmware
8 | * library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2013 STMicroelectronics
13 | *
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 | * You may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at:
17 | *
18 | * http://www.st.com/software_license_agreement_liberty_v2
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | *
26 | ******************************************************************************
27 | */
28 |
29 | /* Define to prevent recursive inclusion -------------------------------------*/
30 | #ifndef __STM32F0XX_DMA_H
31 | #define __STM32F0XX_DMA_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f0xx.h"
39 |
40 | /** @addtogroup STM32F0xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup DMA
45 | * @{
46 | */
47 | /* Exported types ------------------------------------------------------------*/
48 |
49 | /**
50 | * @brief DMA Init structures definition
51 | */
52 | typedef struct
53 | {
54 | uint32_t DMA_PeripheralBaseAddr; /*!< Specifies the peripheral base address for DMAy Channelx. */
55 |
56 | uint32_t DMA_MemoryBaseAddr; /*!< Specifies the memory base address for DMAy Channelx. */
57 |
58 | uint32_t DMA_DIR; /*!< Specifies if the peripheral is the source or destination.
59 | This parameter can be a value of @ref DMA_data_transfer_direction */
60 |
61 | uint32_t DMA_BufferSize; /*!< Specifies the buffer size, in data unit, of the specified Channel.
62 | The data unit is equal to the configuration set in DMA_PeripheralDataSize
63 | or DMA_MemoryDataSize members depending in the transfer direction */
64 |
65 | uint32_t DMA_PeripheralInc; /*!< Specifies whether the Peripheral address register is incremented or not.
66 | This parameter can be a value of @ref DMA_peripheral_incremented_mode */
67 |
68 | uint32_t DMA_MemoryInc; /*!< Specifies whether the memory address register is incremented or not.
69 | This parameter can be a value of @ref DMA_memory_incremented_mode */
70 |
71 | uint32_t DMA_PeripheralDataSize; /*!< Specifies the Peripheral data width.
72 | This parameter can be a value of @ref DMA_peripheral_data_size */
73 |
74 | uint32_t DMA_MemoryDataSize; /*!< Specifies the Memory data width.
75 | This parameter can be a value of @ref DMA_memory_data_size */
76 |
77 | uint32_t DMA_Mode; /*!< Specifies the operation mode of the DMAy Channelx.
78 | This parameter can be a value of @ref DMA_circular_normal_mode
79 | @note: The circular buffer mode cannot be used if the memory-to-memory
80 | data transfer is configured on the selected Channel */
81 |
82 | uint32_t DMA_Priority; /*!< Specifies the software priority for the DMAy Channelx.
83 | This parameter can be a value of @ref DMA_priority_level */
84 |
85 | uint32_t DMA_M2M; /*!< Specifies if the DMAy Channelx will be used in memory-to-memory transfer.
86 | This parameter can be a value of @ref DMA_memory_to_memory */
87 | }DMA_InitTypeDef;
88 |
89 | /* Exported constants --------------------------------------------------------*/
90 |
91 | /** @defgroup DMA_Exported_Constants
92 | * @{
93 | */
94 |
95 | #define IS_DMA_ALL_PERIPH(PERIPH) (((PERIPH) == DMA1_Channel1) || \
96 | ((PERIPH) == DMA1_Channel2) || \
97 | ((PERIPH) == DMA1_Channel3) || \
98 | ((PERIPH) == DMA1_Channel4) || \
99 | ((PERIPH) == DMA1_Channel5))
100 |
101 | /** @defgroup DMA_data_transfer_direction
102 | * @{
103 | */
104 |
105 | #define DMA_DIR_PeripheralSRC ((uint32_t)0x00000000)
106 | #define DMA_DIR_PeripheralDST DMA_CCR_DIR
107 |
108 | #define IS_DMA_DIR(DIR) (((DIR) == DMA_DIR_PeripheralSRC) || \
109 | ((DIR) == DMA_DIR_PeripheralDST))
110 | /**
111 | * @}
112 | */
113 |
114 | /** @defgroup DMA_peripheral_incremented_mode
115 | * @{
116 | */
117 |
118 | #define DMA_PeripheralInc_Disable ((uint32_t)0x00000000)
119 | #define DMA_PeripheralInc_Enable DMA_CCR_PINC
120 |
121 | #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PeripheralInc_Disable) || \
122 | ((STATE) == DMA_PeripheralInc_Enable))
123 | /**
124 | * @}
125 | */
126 |
127 | /** @defgroup DMA_memory_incremented_mode
128 | * @{
129 | */
130 |
131 | #define DMA_MemoryInc_Disable ((uint32_t)0x00000000)
132 | #define DMA_MemoryInc_Enable DMA_CCR_MINC
133 |
134 | #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MemoryInc_Disable) || \
135 | ((STATE) == DMA_MemoryInc_Enable))
136 | /**
137 | * @}
138 | */
139 |
140 | /** @defgroup DMA_peripheral_data_size
141 | * @{
142 | */
143 |
144 | #define DMA_PeripheralDataSize_Byte ((uint32_t)0x00000000)
145 | #define DMA_PeripheralDataSize_HalfWord DMA_CCR_PSIZE_0
146 | #define DMA_PeripheralDataSize_Word DMA_CCR_PSIZE_1
147 |
148 | #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PeripheralDataSize_Byte) || \
149 | ((SIZE) == DMA_PeripheralDataSize_HalfWord) || \
150 | ((SIZE) == DMA_PeripheralDataSize_Word))
151 | /**
152 | * @}
153 | */
154 |
155 | /** @defgroup DMA_memory_data_size
156 | * @{
157 | */
158 |
159 | #define DMA_MemoryDataSize_Byte ((uint32_t)0x00000000)
160 | #define DMA_MemoryDataSize_HalfWord DMA_CCR_MSIZE_0
161 | #define DMA_MemoryDataSize_Word DMA_CCR_MSIZE_1
162 |
163 | #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MemoryDataSize_Byte) || \
164 | ((SIZE) == DMA_MemoryDataSize_HalfWord) || \
165 | ((SIZE) == DMA_MemoryDataSize_Word))
166 | /**
167 | * @}
168 | */
169 |
170 | /** @defgroup DMA_circular_normal_mode
171 | * @{
172 | */
173 |
174 | #define DMA_Mode_Normal ((uint32_t)0x00000000)
175 | #define DMA_Mode_Circular DMA_CCR_CIRC
176 |
177 | #define IS_DMA_MODE(MODE) (((MODE) == DMA_Mode_Normal) || ((MODE) == DMA_Mode_Circular))
178 | /**
179 | * @}
180 | */
181 |
182 | /** @defgroup DMA_priority_level
183 | * @{
184 | */
185 |
186 | #define DMA_Priority_VeryHigh DMA_CCR_PL
187 | #define DMA_Priority_High DMA_CCR_PL_1
188 | #define DMA_Priority_Medium DMA_CCR_PL_0
189 | #define DMA_Priority_Low ((uint32_t)0x00000000)
190 |
191 | #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_Priority_VeryHigh) || \
192 | ((PRIORITY) == DMA_Priority_High) || \
193 | ((PRIORITY) == DMA_Priority_Medium) || \
194 | ((PRIORITY) == DMA_Priority_Low))
195 | /**
196 | * @}
197 | */
198 |
199 | /** @defgroup DMA_memory_to_memory
200 | * @{
201 | */
202 |
203 | #define DMA_M2M_Disable ((uint32_t)0x00000000)
204 | #define DMA_M2M_Enable DMA_CCR_MEM2MEM
205 |
206 | #define IS_DMA_M2M_STATE(STATE) (((STATE) == DMA_M2M_Disable) || ((STATE) == DMA_M2M_Enable))
207 |
208 | /**
209 | * @}
210 | */
211 |
212 | /** @defgroup DMA_interrupts_definition
213 | * @{
214 | */
215 |
216 | #define DMA_IT_TC DMA_CCR_TCIE
217 | #define DMA_IT_HT DMA_CCR_HTIE
218 | #define DMA_IT_TE DMA_CCR_TEIE
219 |
220 | #define IS_DMA_CONFIG_IT(IT) ((((IT) & 0xFFFFFFF1) == 0x00) && ((IT) != 0x00))
221 |
222 | #define DMA1_IT_GL1 DMA_ISR_GIF1
223 | #define DMA1_IT_TC1 DMA_ISR_TCIF1
224 | #define DMA1_IT_HT1 DMA_ISR_HTIF1
225 | #define DMA1_IT_TE1 DMA_ISR_TEIF1
226 | #define DMA1_IT_GL2 DMA_ISR_GIF2
227 | #define DMA1_IT_TC2 DMA_ISR_TCIF2
228 | #define DMA1_IT_HT2 DMA_ISR_HTIF2
229 | #define DMA1_IT_TE2 DMA_ISR_TEIF2
230 | #define DMA1_IT_GL3 DMA_ISR_GIF3
231 | #define DMA1_IT_TC3 DMA_ISR_TCIF3
232 | #define DMA1_IT_HT3 DMA_ISR_HTIF3
233 | #define DMA1_IT_TE3 DMA_ISR_TEIF3
234 | #define DMA1_IT_GL4 DMA_ISR_GIF4
235 | #define DMA1_IT_TC4 DMA_ISR_TCIF4
236 | #define DMA1_IT_HT4 DMA_ISR_HTIF4
237 | #define DMA1_IT_TE4 DMA_ISR_TEIF4
238 | #define DMA1_IT_GL5 DMA_ISR_GIF5
239 | #define DMA1_IT_TC5 DMA_ISR_TCIF5
240 | #define DMA1_IT_HT5 DMA_ISR_HTIF5
241 | #define DMA1_IT_TE5 DMA_ISR_TEIF5
242 |
243 | #define IS_DMA_CLEAR_IT(IT) ((((IT) & 0xFFF00000) == 0x00) && ((IT) != 0x00))
244 |
245 | #define IS_DMA_GET_IT(IT) (((IT) == DMA1_IT_GL1) || ((IT) == DMA1_IT_TC1) || \
246 | ((IT) == DMA1_IT_HT1) || ((IT) == DMA1_IT_TE1) || \
247 | ((IT) == DMA1_IT_GL2) || ((IT) == DMA1_IT_TC2) || \
248 | ((IT) == DMA1_IT_HT2) || ((IT) == DMA1_IT_TE2) || \
249 | ((IT) == DMA1_IT_GL3) || ((IT) == DMA1_IT_TC3) || \
250 | ((IT) == DMA1_IT_HT3) || ((IT) == DMA1_IT_TE3) || \
251 | ((IT) == DMA1_IT_GL4) || ((IT) == DMA1_IT_TC4) || \
252 | ((IT) == DMA1_IT_HT4) || ((IT) == DMA1_IT_TE4) || \
253 | ((IT) == DMA1_IT_GL5) || ((IT) == DMA1_IT_TC5) || \
254 | ((IT) == DMA1_IT_HT5) || ((IT) == DMA1_IT_TE5))
255 |
256 | /**
257 | * @}
258 | */
259 |
260 | /** @defgroup DMA_flags_definition
261 | * @{
262 | */
263 | #define DMA1_FLAG_GL1 DMA_ISR_GIF1
264 | #define DMA1_FLAG_TC1 DMA_ISR_TCIF1
265 | #define DMA1_FLAG_HT1 DMA_ISR_HTIF1
266 | #define DMA1_FLAG_TE1 DMA_ISR_TEIF1
267 | #define DMA1_FLAG_GL2 DMA_ISR_GIF2
268 | #define DMA1_FLAG_TC2 DMA_ISR_TCIF2
269 | #define DMA1_FLAG_HT2 DMA_ISR_HTIF2
270 | #define DMA1_FLAG_TE2 DMA_ISR_TEIF2
271 | #define DMA1_FLAG_GL3 DMA_ISR_GIF3
272 | #define DMA1_FLAG_TC3 DMA_ISR_TCIF3
273 | #define DMA1_FLAG_HT3 DMA_ISR_HTIF3
274 | #define DMA1_FLAG_TE3 DMA_ISR_TEIF3
275 | #define DMA1_FLAG_GL4 DMA_ISR_GIF4
276 | #define DMA1_FLAG_TC4 DMA_ISR_TCIF4
277 | #define DMA1_FLAG_HT4 DMA_ISR_HTIF4
278 | #define DMA1_FLAG_TE4 DMA_ISR_TEIF4
279 | #define DMA1_FLAG_GL5 DMA_ISR_GIF5
280 | #define DMA1_FLAG_TC5 DMA_ISR_TCIF5
281 | #define DMA1_FLAG_HT5 DMA_ISR_HTIF5
282 | #define DMA1_FLAG_TE5 DMA_ISR_TEIF5
283 |
284 | #define IS_DMA_CLEAR_FLAG(FLAG) ((((FLAG) & 0xFFF00000) == 0x00) && ((FLAG) != 0x00))
285 |
286 | #define IS_DMA_GET_FLAG(FLAG) (((FLAG) == DMA1_FLAG_GL1) || ((FLAG) == DMA1_FLAG_TC1) || \
287 | ((FLAG) == DMA1_FLAG_HT1) || ((FLAG) == DMA1_FLAG_TE1) || \
288 | ((FLAG) == DMA1_FLAG_GL2) || ((FLAG) == DMA1_FLAG_TC2) || \
289 | ((FLAG) == DMA1_FLAG_HT2) || ((FLAG) == DMA1_FLAG_TE2) || \
290 | ((FLAG) == DMA1_FLAG_GL3) || ((FLAG) == DMA1_FLAG_TC3) || \
291 | ((FLAG) == DMA1_FLAG_HT3) || ((FLAG) == DMA1_FLAG_TE3) || \
292 | ((FLAG) == DMA1_FLAG_GL4) || ((FLAG) == DMA1_FLAG_TC4) || \
293 | ((FLAG) == DMA1_FLAG_HT4) || ((FLAG) == DMA1_FLAG_TE4) || \
294 | ((FLAG) == DMA1_FLAG_GL5) || ((FLAG) == DMA1_FLAG_TC5) || \
295 | ((FLAG) == DMA1_FLAG_HT5) || ((FLAG) == DMA1_FLAG_TE5))
296 |
297 | /**
298 | * @}
299 | */
300 |
301 | /** @defgroup DMA_Buffer_Size
302 | * @{
303 | */
304 |
305 | #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1) && ((SIZE) < 0x10000))
306 |
307 | /**
308 | * @}
309 | */
310 |
311 | /**
312 | * @}
313 | */
314 |
315 | /* Exported macro ------------------------------------------------------------*/
316 | /* Exported functions ------------------------------------------------------- */
317 |
318 | /* Function used to set the DMA configuration to the default reset state ******/
319 | void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx);
320 |
321 | /* Initialization and Configuration functions *********************************/
322 | void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct);
323 | void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct);
324 | void DMA_Cmd(DMA_Channel_TypeDef* DMAy_Channelx, FunctionalState NewState);
325 |
326 | /* Data Counter functions******************************************************/
327 | void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t DataNumber);
328 | uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx);
329 |
330 | /* Interrupts and flags management functions **********************************/
331 | void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState);
332 | FlagStatus DMA_GetFlagStatus(uint32_t DMA_FLAG);
333 | void DMA_ClearFlag(uint32_t DMA_FLAG);
334 | ITStatus DMA_GetITStatus(uint32_t DMA_IT);
335 | void DMA_ClearITPendingBit(uint32_t DMA_IT);
336 |
337 | #ifdef __cplusplus
338 | }
339 | #endif
340 |
341 | #endif /*__STM32F0XX_DMA_H */
342 |
343 | /**
344 | * @}
345 | */
346 |
347 | /**
348 | * @}
349 | */
350 |
351 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
352 |
--------------------------------------------------------------------------------
/stm32_lib/inc/stm32f0xx_gpio.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_gpio.h
4 | * @author MCD Application Team
5 | * @version V1.2.0
6 | * @date 01-August-2013
7 | * @brief This file contains all the functions prototypes for the GPIO
8 | * firmware library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2013 STMicroelectronics
13 | *
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 | * You may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at:
17 | *
18 | * http://www.st.com/software_license_agreement_liberty_v2
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | *
26 | ******************************************************************************
27 | */
28 |
29 | /* Define to prevent recursive inclusion -------------------------------------*/
30 | #ifndef __STM32F0XX_GPIO_H
31 | #define __STM32F0XX_GPIO_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f0xx.h"
39 |
40 | /** @addtogroup STM32F0xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup GPIO
45 | * @{
46 | */
47 | /* Exported types ------------------------------------------------------------*/
48 |
49 | #define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \
50 | ((PERIPH) == GPIOB) || \
51 | ((PERIPH) == GPIOC) || \
52 | ((PERIPH) == GPIOD) || \
53 | ((PERIPH) == GPIOF))
54 |
55 | #define IS_GPIO_LIST_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \
56 | ((PERIPH) == GPIOB))
57 |
58 | /** @defgroup Configuration_Mode_enumeration
59 | * @{
60 | */
61 | typedef enum
62 | {
63 | GPIO_Mode_IN = 0x00, /*!< GPIO Input Mode */
64 | GPIO_Mode_OUT = 0x01, /*!< GPIO Output Mode */
65 | GPIO_Mode_AF = 0x02, /*!< GPIO Alternate function Mode */
66 | GPIO_Mode_AN = 0x03 /*!< GPIO Analog In/Out Mode */
67 | }GPIOMode_TypeDef;
68 |
69 | #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_IN)|| ((MODE) == GPIO_Mode_OUT) || \
70 | ((MODE) == GPIO_Mode_AF)|| ((MODE) == GPIO_Mode_AN))
71 | /**
72 | * @}
73 | */
74 |
75 | /** @defgroup Output_type_enumeration
76 | * @{
77 | */
78 | typedef enum
79 | {
80 | GPIO_OType_PP = 0x00,
81 | GPIO_OType_OD = 0x01
82 | }GPIOOType_TypeDef;
83 |
84 | #define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD))
85 |
86 | /**
87 | * @}
88 | */
89 |
90 | /** @defgroup Output_Maximum_frequency_enumeration
91 | * @{
92 | */
93 | typedef enum
94 | {
95 | GPIO_Speed_Level_1 = 0x00, /*!< I/O output speed: Low 2 MHz */
96 | GPIO_Speed_Level_2 = 0x01, /*!< I/O output speed: Medium 10 MHz */
97 | GPIO_Speed_Level_3 = 0x03 /*!< I/O output speed: High 50 MHz */
98 | }GPIOSpeed_TypeDef;
99 |
100 | #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_Level_1) || ((SPEED) == GPIO_Speed_Level_2) || \
101 | ((SPEED) == GPIO_Speed_Level_3))
102 | /**
103 | * @}
104 | */
105 |
106 | /** @defgroup Configuration_Pull-Up_Pull-Down_enumeration
107 | * @{
108 | */
109 | typedef enum
110 | {
111 | GPIO_PuPd_NOPULL = 0x00,
112 | GPIO_PuPd_UP = 0x01,
113 | GPIO_PuPd_DOWN = 0x02
114 | }GPIOPuPd_TypeDef;
115 |
116 | #define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_NOPULL) || ((PUPD) == GPIO_PuPd_UP) || \
117 | ((PUPD) == GPIO_PuPd_DOWN))
118 | /**
119 | * @}
120 | */
121 |
122 | /** @defgroup Bit_SET_and_Bit_RESET_enumeration
123 | * @{
124 | */
125 | typedef enum
126 | {
127 | Bit_RESET = 0,
128 | Bit_SET
129 | }BitAction;
130 |
131 | #define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET))
132 | /**
133 | * @}
134 | */
135 |
136 | /**
137 | * @brief GPIO Init structure definition
138 | */
139 | typedef struct
140 | {
141 | uint32_t GPIO_Pin; /*!< Specifies the GPIO pins to be configured.
142 | This parameter can be any value of @ref GPIO_pins_define */
143 |
144 | GPIOMode_TypeDef GPIO_Mode; /*!< Specifies the operating mode for the selected pins.
145 | This parameter can be a value of @ref GPIOMode_TypeDef */
146 |
147 | GPIOSpeed_TypeDef GPIO_Speed; /*!< Specifies the speed for the selected pins.
148 | This parameter can be a value of @ref GPIOSpeed_TypeDef */
149 |
150 | GPIOOType_TypeDef GPIO_OType; /*!< Specifies the operating output type for the selected pins.
151 | This parameter can be a value of @ref GPIOOType_TypeDef */
152 |
153 | GPIOPuPd_TypeDef GPIO_PuPd; /*!< Specifies the operating Pull-up/Pull down for the selected pins.
154 | This parameter can be a value of @ref GPIOPuPd_TypeDef */
155 | }GPIO_InitTypeDef;
156 |
157 | /* Exported constants --------------------------------------------------------*/
158 |
159 | /** @defgroup GPIO_Exported_Constants
160 | * @{
161 | */
162 |
163 | /** @defgroup GPIO_pins_define
164 | * @{
165 | */
166 | #define GPIO_Pin_0 ((uint16_t)0x0001) /*!< Pin 0 selected */
167 | #define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */
168 | #define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */
169 | #define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */
170 | #define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */
171 | #define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */
172 | #define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */
173 | #define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */
174 | #define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */
175 | #define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */
176 | #define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */
177 | #define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */
178 | #define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */
179 | #define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */
180 | #define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */
181 | #define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */
182 | #define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */
183 |
184 | #define IS_GPIO_PIN(PIN) ((PIN) != (uint16_t)0x00)
185 |
186 | #define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \
187 | ((PIN) == GPIO_Pin_1) || \
188 | ((PIN) == GPIO_Pin_2) || \
189 | ((PIN) == GPIO_Pin_3) || \
190 | ((PIN) == GPIO_Pin_4) || \
191 | ((PIN) == GPIO_Pin_5) || \
192 | ((PIN) == GPIO_Pin_6) || \
193 | ((PIN) == GPIO_Pin_7) || \
194 | ((PIN) == GPIO_Pin_8) || \
195 | ((PIN) == GPIO_Pin_9) || \
196 | ((PIN) == GPIO_Pin_10) || \
197 | ((PIN) == GPIO_Pin_11) || \
198 | ((PIN) == GPIO_Pin_12) || \
199 | ((PIN) == GPIO_Pin_13) || \
200 | ((PIN) == GPIO_Pin_14) || \
201 | ((PIN) == GPIO_Pin_15))
202 |
203 | /**
204 | * @}
205 | */
206 |
207 | /** @defgroup GPIO_Pin_sources
208 | * @{
209 | */
210 | #define GPIO_PinSource0 ((uint8_t)0x00)
211 | #define GPIO_PinSource1 ((uint8_t)0x01)
212 | #define GPIO_PinSource2 ((uint8_t)0x02)
213 | #define GPIO_PinSource3 ((uint8_t)0x03)
214 | #define GPIO_PinSource4 ((uint8_t)0x04)
215 | #define GPIO_PinSource5 ((uint8_t)0x05)
216 | #define GPIO_PinSource6 ((uint8_t)0x06)
217 | #define GPIO_PinSource7 ((uint8_t)0x07)
218 | #define GPIO_PinSource8 ((uint8_t)0x08)
219 | #define GPIO_PinSource9 ((uint8_t)0x09)
220 | #define GPIO_PinSource10 ((uint8_t)0x0A)
221 | #define GPIO_PinSource11 ((uint8_t)0x0B)
222 | #define GPIO_PinSource12 ((uint8_t)0x0C)
223 | #define GPIO_PinSource13 ((uint8_t)0x0D)
224 | #define GPIO_PinSource14 ((uint8_t)0x0E)
225 | #define GPIO_PinSource15 ((uint8_t)0x0F)
226 |
227 | #define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \
228 | ((PINSOURCE) == GPIO_PinSource1) || \
229 | ((PINSOURCE) == GPIO_PinSource2) || \
230 | ((PINSOURCE) == GPIO_PinSource3) || \
231 | ((PINSOURCE) == GPIO_PinSource4) || \
232 | ((PINSOURCE) == GPIO_PinSource5) || \
233 | ((PINSOURCE) == GPIO_PinSource6) || \
234 | ((PINSOURCE) == GPIO_PinSource7) || \
235 | ((PINSOURCE) == GPIO_PinSource8) || \
236 | ((PINSOURCE) == GPIO_PinSource9) || \
237 | ((PINSOURCE) == GPIO_PinSource10) || \
238 | ((PINSOURCE) == GPIO_PinSource11) || \
239 | ((PINSOURCE) == GPIO_PinSource12) || \
240 | ((PINSOURCE) == GPIO_PinSource13) || \
241 | ((PINSOURCE) == GPIO_PinSource14) || \
242 | ((PINSOURCE) == GPIO_PinSource15))
243 | /**
244 | * @}
245 | */
246 |
247 | /** @defgroup GPIO_Alternate_function_selection_define
248 | * @{
249 | */
250 |
251 | /**
252 | * @brief AF 0 selection
253 | */
254 | #define GPIO_AF_0 ((uint8_t)0x00) /* WKUP, EVENTOUT, TIM15, SPI1, TIM17,
255 | MCO, SWDAT, SWCLK, TIM14, USART1,
256 | CEC, IR_OUT, SPI2 */
257 | /**
258 | * @brief AF 1 selection
259 | */
260 | #define GPIO_AF_1 ((uint8_t)0x01) /* USART2, CEC, TIM3, USART1, IR_OUT,
261 | EVENTOUT, I2C1, I2C2, TIM15 */
262 | /**
263 | * @brief AF 2 selection
264 | */
265 | #define GPIO_AF_2 ((uint8_t)0x02) /* TIM2, TIM1, EVENTOUT, TIM16, TIM17 */
266 | /**
267 | * @brief AF 3 selection
268 | */
269 | #define GPIO_AF_3 ((uint8_t)0x03) /* TS, I2C1, TIM15, EVENTOUT */
270 |
271 | /**
272 | * @brief AF 4 selection
273 | */
274 | #define GPIO_AF_4 ((uint8_t)0x04) /* TIM14, I2C1 (only for STM32F0XX_LD and STM32F030X6 devices) */
275 | /**
276 | * @brief AF 5 selection
277 | */
278 | #define GPIO_AF_5 ((uint8_t)0x05) /* TIM16, TIM17 */
279 |
280 | /**
281 | * @brief AF 6 selection
282 | */
283 | #define GPIO_AF_6 ((uint8_t)0x06) /* EVENTOUT */
284 | /**
285 | * @brief AF 7 selection
286 | */
287 | #define GPIO_AF_7 ((uint8_t)0x07) /* COMP1 OUT and COMP2 OUT */
288 |
289 | #define IS_GPIO_AF(AF) (((AF) == GPIO_AF_0) || ((AF) == GPIO_AF_1) || \
290 | ((AF) == GPIO_AF_2) || ((AF) == GPIO_AF_3) || \
291 | ((AF) == GPIO_AF_4) || ((AF) == GPIO_AF_5) || \
292 | ((AF) == GPIO_AF_6) || ((AF) == GPIO_AF_7))
293 |
294 | /**
295 | * @}
296 | */
297 |
298 | /** @defgroup GPIO_Speed_Legacy
299 | * @{
300 | */
301 |
302 | #define GPIO_Speed_2MHz GPIO_Speed_Level_1 /*!< I/O output speed: Low 2 MHz */
303 | #define GPIO_Speed_10MHz GPIO_Speed_Level_2 /*!< I/O output speed: Medium 10 MHz */
304 | #define GPIO_Speed_50MHz GPIO_Speed_Level_3 /*!< I/O output speed: High 50 MHz */
305 |
306 | /**
307 | * @}
308 | */
309 |
310 | /**
311 | * @}
312 | */
313 |
314 | /* Exported macro ------------------------------------------------------------*/
315 | /* Exported functions ------------------------------------------------------- */
316 | /* Function used to set the GPIO configuration to the default reset state *****/
317 | void GPIO_DeInit(GPIO_TypeDef* GPIOx);
318 |
319 | /* Initialization and Configuration functions *********************************/
320 | void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
321 | void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);
322 | void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
323 |
324 | /* GPIO Read and Write functions **********************************************/
325 | uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
326 | uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
327 | uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
328 | uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
329 | void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
330 | void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
331 | void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);
332 | void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);
333 |
334 | /* GPIO Alternate functions configuration functions ***************************/
335 | void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF);
336 |
337 | #ifdef __cplusplus
338 | }
339 | #endif
340 |
341 | #endif /* __STM32F0XX_GPIO_H */
342 | /**
343 | * @}
344 | */
345 |
346 | /**
347 | * @}
348 | */
349 |
350 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
351 |
--------------------------------------------------------------------------------
/stm32_lib/inc/stm32f0xx_misc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_misc.h
4 | * @author MCD Application Team
5 | * @version V1.2.0
6 | * @date 01-August-2013
7 | * @brief This file contains all the functions prototypes for the miscellaneous
8 | * firmware library functions (add-on to CMSIS functions).
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2013 STMicroelectronics
13 | *
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 | * You may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at:
17 | *
18 | * http://www.st.com/software_license_agreement_liberty_v2
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | *
26 | ******************************************************************************
27 | */
28 |
29 | /* Define to prevent recursive inclusion -------------------------------------*/
30 | #ifndef __STM32F0XX_MISC_H
31 | #define __STM32F0XX_MISC_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f0xx.h"
39 |
40 | /** @addtogroup STM32F0xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup MISC
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 |
50 | /**
51 | * @brief NVIC Init Structure definition
52 | */
53 |
54 | typedef struct
55 | {
56 | uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled.
57 | This parameter can be a value of @ref IRQn_Type
58 | (For the complete STM32 Devices IRQ Channels list,
59 | please refer to stm32f0xx.h file) */
60 |
61 | uint8_t NVIC_IRQChannelPriority; /*!< Specifies the priority level for the IRQ channel specified
62 | in NVIC_IRQChannel. This parameter can be a value
63 | between 0 and 3. */
64 |
65 | FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel
66 | will be enabled or disabled.
67 | This parameter can be set either to ENABLE or DISABLE */
68 | } NVIC_InitTypeDef;
69 |
70 | /**
71 | *
72 | @verbatim
73 |
74 | @endverbatim
75 | */
76 |
77 | /* Exported constants --------------------------------------------------------*/
78 |
79 | /** @defgroup MISC_Exported_Constants
80 | * @{
81 | */
82 |
83 | /** @defgroup MISC_System_Low_Power
84 | * @{
85 | */
86 |
87 | #define NVIC_LP_SEVONPEND ((uint8_t)0x10)
88 | #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04)
89 | #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02)
90 | #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \
91 | ((LP) == NVIC_LP_SLEEPDEEP) || \
92 | ((LP) == NVIC_LP_SLEEPONEXIT))
93 | /**
94 | * @}
95 | */
96 |
97 | /** @defgroup MISC_Preemption_Priority_Group
98 | * @{
99 | */
100 | #define IS_NVIC_PRIORITY(PRIORITY) ((PRIORITY) < 0x04)
101 |
102 | /**
103 | * @}
104 | */
105 |
106 | /** @defgroup MISC_SysTick_clock_source
107 | * @{
108 | */
109 |
110 | #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB)
111 | #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004)
112 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
113 | ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
114 | /**
115 | * @}
116 | */
117 |
118 | /**
119 | * @}
120 | */
121 |
122 | /* Exported macro ------------------------------------------------------------*/
123 | /* Exported functions ------------------------------------------------------- */
124 |
125 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
126 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState);
127 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource);
128 |
129 | #ifdef __cplusplus
130 | }
131 | #endif
132 |
133 | #endif /* __STM32F0XX_MISC_H */
134 |
135 | /**
136 | * @}
137 | */
138 |
139 | /**
140 | * @}
141 | */
142 |
143 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
144 |
--------------------------------------------------------------------------------
/stm32_lib/inc/stm32f0xx_syscfg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_syscfg.h
4 | * @author MCD Application Team
5 | * @version V1.2.0
6 | * @date 01-August-2013
7 | * @brief This file contains all the functions prototypes for the SYSCFG firmware
8 | * library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2013 STMicroelectronics
13 | *
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 | * You may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at:
17 | *
18 | * http://www.st.com/software_license_agreement_liberty_v2
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | *
26 | ******************************************************************************
27 | */
28 |
29 | /*!< Define to prevent recursive inclusion -------------------------------------*/
30 | #ifndef __STM32F0XX_SYSCFG_H
31 | #define __STM32F0XX_SYSCFG_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /*!< Includes ------------------------------------------------------------------*/
38 | #include "stm32f0xx.h"
39 |
40 | /** @addtogroup STM32F0xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup SYSCFG
45 | * @{
46 | */
47 | /* Exported types ------------------------------------------------------------*/
48 | /* Exported constants --------------------------------------------------------*/
49 |
50 | /** @defgroup SYSCFG_Exported_Constants
51 | * @{
52 | */
53 |
54 | /** @defgroup SYSCFG_EXTI_Port_Sources
55 | * @{
56 | */
57 | #define EXTI_PortSourceGPIOA ((uint8_t)0x00)
58 | #define EXTI_PortSourceGPIOB ((uint8_t)0x01)
59 | #define EXTI_PortSourceGPIOC ((uint8_t)0x02)
60 | #define EXTI_PortSourceGPIOD ((uint8_t)0x03)
61 | #define EXTI_PortSourceGPIOF ((uint8_t)0x05)
62 |
63 | #define IS_EXTI_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == EXTI_PortSourceGPIOA) || \
64 | ((PORTSOURCE) == EXTI_PortSourceGPIOB) || \
65 | ((PORTSOURCE) == EXTI_PortSourceGPIOC) || \
66 | ((PORTSOURCE) == EXTI_PortSourceGPIOD) || \
67 | ((PORTSOURCE) == EXTI_PortSourceGPIOF))
68 | /**
69 | * @}
70 | */
71 |
72 | /** @defgroup SYSCFG_EXTI_Pin_sources
73 | * @{
74 | */
75 | #define EXTI_PinSource0 ((uint8_t)0x00)
76 | #define EXTI_PinSource1 ((uint8_t)0x01)
77 | #define EXTI_PinSource2 ((uint8_t)0x02)
78 | #define EXTI_PinSource3 ((uint8_t)0x03)
79 | #define EXTI_PinSource4 ((uint8_t)0x04)
80 | #define EXTI_PinSource5 ((uint8_t)0x05)
81 | #define EXTI_PinSource6 ((uint8_t)0x06)
82 | #define EXTI_PinSource7 ((uint8_t)0x07)
83 | #define EXTI_PinSource8 ((uint8_t)0x08)
84 | #define EXTI_PinSource9 ((uint8_t)0x09)
85 | #define EXTI_PinSource10 ((uint8_t)0x0A)
86 | #define EXTI_PinSource11 ((uint8_t)0x0B)
87 | #define EXTI_PinSource12 ((uint8_t)0x0C)
88 | #define EXTI_PinSource13 ((uint8_t)0x0D)
89 | #define EXTI_PinSource14 ((uint8_t)0x0E)
90 | #define EXTI_PinSource15 ((uint8_t)0x0F)
91 |
92 | #define IS_EXTI_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == EXTI_PinSource0) || \
93 | ((PINSOURCE) == EXTI_PinSource1) || \
94 | ((PINSOURCE) == EXTI_PinSource2) || \
95 | ((PINSOURCE) == EXTI_PinSource3) || \
96 | ((PINSOURCE) == EXTI_PinSource4) || \
97 | ((PINSOURCE) == EXTI_PinSource5) || \
98 | ((PINSOURCE) == EXTI_PinSource6) || \
99 | ((PINSOURCE) == EXTI_PinSource7) || \
100 | ((PINSOURCE) == EXTI_PinSource8) || \
101 | ((PINSOURCE) == EXTI_PinSource9) || \
102 | ((PINSOURCE) == EXTI_PinSource10) || \
103 | ((PINSOURCE) == EXTI_PinSource11) || \
104 | ((PINSOURCE) == EXTI_PinSource12) || \
105 | ((PINSOURCE) == EXTI_PinSource13) || \
106 | ((PINSOURCE) == EXTI_PinSource14) || \
107 | ((PINSOURCE) == EXTI_PinSource15))
108 | /**
109 | * @}
110 | */
111 |
112 | /** @defgroup SYSCFG_Memory_Remap_Config
113 | * @{
114 | */
115 | #define SYSCFG_MemoryRemap_Flash ((uint8_t)0x00)
116 | #define SYSCFG_MemoryRemap_SystemMemory ((uint8_t)0x01)
117 | #define SYSCFG_MemoryRemap_SRAM ((uint8_t)0x03)
118 |
119 |
120 | #define IS_SYSCFG_MEMORY_REMAP(REMAP) (((REMAP) == SYSCFG_MemoryRemap_Flash) || \
121 | ((REMAP) == SYSCFG_MemoryRemap_SystemMemory) || \
122 | ((REMAP) == SYSCFG_MemoryRemap_SRAM))
123 |
124 | /**
125 | * @}
126 | */
127 |
128 | /** @defgroup SYSCFG_DMA_Remap_Config
129 | * @{
130 | */
131 | #define SYSCFG_DMARemap_TIM17 SYSCFG_CFGR1_TIM17_DMA_RMP /* Remap TIM17 DMA requests from channel1 to channel2 */
132 | #define SYSCFG_DMARemap_TIM16 SYSCFG_CFGR1_TIM16_DMA_RMP /* Remap TIM16 DMA requests from channel3 to channel4 */
133 | #define SYSCFG_DMARemap_USART1Rx SYSCFG_CFGR1_USART1RX_DMA_RMP /* Remap USART1 Rx DMA requests from channel3 to channel5 */
134 | #define SYSCFG_DMARemap_USART1Tx SYSCFG_CFGR1_USART1TX_DMA_RMP /* Remap USART1 Tx DMA requests from channel2 to channel4 */
135 | #define SYSCFG_DMARemap_ADC1 SYSCFG_CFGR1_ADC_DMA_RMP /* Remap ADC1 DMA requests from channel1 to channel2 */
136 |
137 | #define IS_SYSCFG_DMA_REMAP(REMAP) (((REMAP) == SYSCFG_DMARemap_TIM17) || \
138 | ((REMAP) == SYSCFG_DMARemap_TIM16) || \
139 | ((REMAP) == SYSCFG_DMARemap_USART1Rx) || \
140 | ((REMAP) == SYSCFG_DMARemap_USART1Tx) || \
141 | ((REMAP) == SYSCFG_DMARemap_ADC1))
142 |
143 | /**
144 | * @}
145 | */
146 |
147 | /** @defgroup SYSCFG_I2C_FastModePlus_Config
148 | * @{
149 | */
150 | #define SYSCFG_I2CFastModePlus_PB6 SYSCFG_CFGR1_I2C_FMP_PB6 /* Enable Fast Mode Plus on PB6 */
151 | #define SYSCFG_I2CFastModePlus_PB7 SYSCFG_CFGR1_I2C_FMP_PB7 /* Enable Fast Mode Plus on PB7 */
152 | #define SYSCFG_I2CFastModePlus_PB8 SYSCFG_CFGR1_I2C_FMP_PB8 /* Enable Fast Mode Plus on PB8 */
153 | #define SYSCFG_I2CFastModePlus_PB9 SYSCFG_CFGR1_I2C_FMP_PB9 /* Enable Fast Mode Plus on PB9 */
154 | #define SYSCFG_I2CFastModePlus_PA9 SYSCFG_CFGR1_I2C_FMP_PA9 /* Enable Fast Mode Plus on PA9 (only for STM32F0XX_LD and STM32F030X6 devices) */
155 | #define SYSCFG_I2CFastModePlus_PA10 SYSCFG_CFGR1_I2C_FMP_PA10/* Enable Fast Mode Plus on PA10(only for STM32F0XX_LD and STM32F030X6 devices) */
156 | #define SYSCFG_I2CFastModePlus_I2C1 SYSCFG_CFGR1_I2C_FMP_I2C1/* Enable Fast Mode Plus on PB10, PB11, PF6 and PF7(only for STM32F0XX_LD and STM32F030X6 devices) */
157 |
158 | #define IS_SYSCFG_I2C_FMP(PIN) (((PIN) == SYSCFG_I2CFastModePlus_PB6) || \
159 | ((PIN) == SYSCFG_I2CFastModePlus_PB7) || \
160 | ((PIN) == SYSCFG_I2CFastModePlus_PB8) || \
161 | ((PIN) == SYSCFG_I2CFastModePlus_PB9) || \
162 | ((PIN) == SYSCFG_I2CFastModePlus_PA9) || \
163 | ((PIN) == SYSCFG_I2CFastModePlus_PA10)|| \
164 | ((PIN) == SYSCFG_I2CFastModePlus_I2C1))
165 |
166 | /**
167 | * @}
168 | */
169 |
170 | /** @defgroup SYSCFG_Lock_Config
171 | * @{
172 | */
173 | #define SYSCFG_Break_PVD SYSCFG_CFGR2_PVD_LOCK /*!< Connects the PVD event to the Break Input of TIM1 */
174 | #define SYSCFG_Break_SRAMParity SYSCFG_CFGR2_SRAM_PARITY_LOCK /*!< Connects the SRAM_PARITY error signal to the Break Input of TIM1 */
175 | #define SYSCFG_Break_Lockup SYSCFG_CFGR2_LOCKUP_LOCK /*!< Connects Lockup output of CortexM0 to the break input of TIM1 */
176 |
177 | #define IS_SYSCFG_LOCK_CONFIG(CONFIG) (((CONFIG) == SYSCFG_Break_PVD) || \
178 | ((CONFIG) == SYSCFG_Break_SRAMParity) || \
179 | ((CONFIG) == SYSCFG_Break_Lockup))
180 |
181 | /**
182 | * @}
183 | */
184 |
185 | /** @defgroup SYSCFG_flags_definition
186 | * @{
187 | */
188 |
189 | #define SYSCFG_FLAG_PE SYSCFG_CFGR2_SRAM_PE
190 |
191 | #define IS_SYSCFG_FLAG(FLAG) (((FLAG) == SYSCFG_FLAG_PE))
192 |
193 | /**
194 | * @}
195 | */
196 |
197 | /**
198 | * @}
199 | */
200 |
201 | /* Exported macro ------------------------------------------------------------*/
202 | /* Exported functions ------------------------------------------------------- */
203 |
204 | /* Function used to set the SYSCFG configuration to the default reset state **/
205 | void SYSCFG_DeInit(void);
206 |
207 | /* SYSCFG configuration functions *********************************************/
208 | void SYSCFG_MemoryRemapConfig(uint32_t SYSCFG_MemoryRemap);
209 | void SYSCFG_DMAChannelRemapConfig(uint32_t SYSCFG_DMARemap, FunctionalState NewState);
210 | void SYSCFG_I2CFastModePlusConfig(uint32_t SYSCFG_I2CFastModePlus, FunctionalState NewState);
211 | void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex);
212 | void SYSCFG_BreakConfig(uint32_t SYSCFG_Break);
213 | FlagStatus SYSCFG_GetFlagStatus(uint32_t SYSCFG_Flag);
214 | void SYSCFG_ClearFlag(uint32_t SYSCFG_Flag);
215 |
216 | #ifdef __cplusplus
217 | }
218 | #endif
219 |
220 | #endif /*__STM32F0XX_SYSCFG_H */
221 |
222 | /**
223 | * @}
224 | */
225 |
226 | /**
227 | * @}
228 | */
229 |
230 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
231 |
--------------------------------------------------------------------------------
/stm32_lib/src/stm32f0xx_gpio.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_gpio.c
4 | * @author MCD Application Team
5 | * @version V1.2.0
6 | * @date 01-August-2013
7 | * @brief This file provides firmware functions to manage the following
8 | * functionalities of the GPIO peripheral:
9 | * + Initialization and Configuration functions
10 | * + GPIO Read and Write functions
11 | * + GPIO Alternate functions configuration functions
12 | *
13 | * @verbatim
14 | *
15 | *
16 | ===========================================================================
17 | ##### How to use this driver #####
18 | ===========================================================================
19 | [..]
20 | (#) Enable the GPIO AHB clock using RCC_AHBPeriphClockCmd()
21 | (#) Configure the GPIO pin(s) using GPIO_Init()
22 | Four possible configuration are available for each pin:
23 | (++) Input: Floating, Pull-up, Pull-down.
24 | (++) Output: Push-Pull (Pull-up, Pull-down or no Pull)
25 | Open Drain (Pull-up, Pull-down or no Pull).
26 | In output mode, the speed is configurable: Low, Medium, Fast or High.
27 | (++) Alternate Function: Push-Pull (Pull-up, Pull-down or no Pull)
28 | Open Drain (Pull-up, Pull-down or no Pull).
29 | (++) Analog: required mode when a pin is to be used as ADC channel,
30 | DAC output or comparator input.
31 | (#) Peripherals alternate function:
32 | (++) For ADC, DAC and comparators, configure the desired pin in analog
33 | mode using GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AN
34 | (++) For other peripherals (TIM, USART...):
35 | (+++) Connect the pin to the desired peripherals' Alternate
36 | Function (AF) using GPIO_PinAFConfig() function. For PortC,
37 | PortD and PortF, no configuration is needed.
38 | (+++) Configure the desired pin in alternate function mode using
39 | GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
40 | (+++) Select the type, pull-up/pull-down and output speed via
41 | GPIO_PuPd, GPIO_OType and GPIO_Speed members
42 | (+++) Call GPIO_Init() function
43 | (#) To get the level of a pin configured in input mode use GPIO_ReadInputDataBit()
44 | (#) To set/reset the level of a pin configured in output mode use
45 | GPIO_SetBits()/GPIO_ResetBits()
46 | (#) During and just after reset, the alternate functions are not active and
47 | the GPIO pins are configured in input floating mode (except JTAG pins).
48 | (#) The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as
49 | general-purpose (PC14 and PC15, respectively) when the LSE oscillator
50 | is off. The LSE has priority over the GPIO function.
51 | (#) The HSE oscillator pins OSC_IN/OSC_OUT can be used as general-purpose
52 | PD0 and PD1, respectively, when the HSE oscillator is off. The HSE has
53 | priority over the GPIO function.
54 | @endverbatim
55 | ******************************************************************************
56 | * @attention
57 | *
58 | * © COPYRIGHT 2013 STMicroelectronics
59 | *
60 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
61 | * You may not use this file except in compliance with the License.
62 | * You may obtain a copy of the License at:
63 | *
64 | * http://www.st.com/software_license_agreement_liberty_v2
65 | *
66 | * Unless required by applicable law or agreed to in writing, software
67 | * distributed under the License is distributed on an "AS IS" BASIS,
68 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
69 | * See the License for the specific language governing permissions and
70 | * limitations under the License.
71 | *
72 | ******************************************************************************
73 | */
74 |
75 | /* Includes ------------------------------------------------------------------*/
76 | #include "stm32f0xx_gpio.h"
77 | #include "stm32f0xx_rcc.h"
78 |
79 | /** @addtogroup STM32F0xx_StdPeriph_Driver
80 | * @{
81 | */
82 |
83 | /** @defgroup GPIO
84 | * @brief GPIO driver modules
85 | * @{
86 | */
87 |
88 | /* Private typedef -----------------------------------------------------------*/
89 | /* Private define ------------------------------------------------------------*/
90 | /* Private macro -------------------------------------------------------------*/
91 | /* Private variables ---------------------------------------------------------*/
92 | /* Private function prototypes -----------------------------------------------*/
93 | /* Private functions ---------------------------------------------------------*/
94 |
95 | /** @defgroup GPIO_Private_Functions
96 | * @{
97 | */
98 |
99 | /** @defgroup GPIO_Group1 Initialization and Configuration
100 | * @brief Initialization and Configuration
101 | *
102 | @verbatim
103 | ===============================================================================
104 | ##### Initialization and Configuration #####
105 | ===============================================================================
106 |
107 | @endverbatim
108 | * @{
109 | */
110 |
111 | /**
112 | * @brief Deinitializes the GPIOx peripheral registers to their default reset
113 | * values.
114 | * @param GPIOx: where x can be (A, B, C, D or F) to select the GPIO peripheral.
115 | * @retval None
116 | */
117 | void GPIO_DeInit(GPIO_TypeDef* GPIOx)
118 | {
119 | /* Check the parameters */
120 | assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
121 |
122 | if(GPIOx == GPIOA)
123 | {
124 | RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOA, ENABLE);
125 | RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOA, DISABLE);
126 | }
127 | else if(GPIOx == GPIOB)
128 | {
129 | RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOB, ENABLE);
130 | RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOB, DISABLE);
131 | }
132 | else if(GPIOx == GPIOC)
133 | {
134 | RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOC, ENABLE);
135 | RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOC, DISABLE);
136 | }
137 | else if(GPIOx == GPIOD)
138 | {
139 | RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOD, ENABLE);
140 | RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOD, DISABLE);
141 | }
142 | else
143 | {
144 | if(GPIOx == GPIOF)
145 | {
146 | RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOF, ENABLE);
147 | RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOF, DISABLE);
148 | }
149 | }
150 | }
151 |
152 | /**
153 | * @brief Initializes the GPIOx peripheral according to the specified
154 | * parameters in the GPIO_InitStruct.
155 | * @param GPIOx: where x can be (A, B, C, D or F) to select the GPIO peripheral.
156 | * @param GPIO_InitStruct: pointer to a GPIO_InitTypeDef structure that contains
157 | * the configuration information for the specified GPIO peripheral.
158 | * @note The configured pins can be: GPIO_Pin_0 to GPIO_Pin_15 for GPIOA, GPIOB and GPIOC,
159 | * GPIO_Pin_0 to GPIO_Pin_2 for GPIOD, GPIO_Pin_0 to GPIO_Pin_3 for GPIOF.
160 | * @retval None
161 | */
162 | void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
163 | {
164 | uint32_t pinpos = 0x00, pos = 0x00 , currentpin = 0x00;
165 |
166 | /* Check the parameters */
167 | assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
168 | assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));
169 | assert_param(IS_GPIO_MODE(GPIO_InitStruct->GPIO_Mode));
170 | assert_param(IS_GPIO_PUPD(GPIO_InitStruct->GPIO_PuPd));
171 |
172 | /*-------------------------- Configure the port pins -----------------------*/
173 | /*-- GPIO Mode Configuration --*/
174 | for (pinpos = 0x00; pinpos < 0x10; pinpos++)
175 | {
176 | pos = ((uint32_t)0x01) << pinpos;
177 |
178 | /* Get the port pins position */
179 | currentpin = (GPIO_InitStruct->GPIO_Pin) & pos;
180 |
181 | if (currentpin == pos)
182 | {
183 | if ((GPIO_InitStruct->GPIO_Mode == GPIO_Mode_OUT) || (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_AF))
184 | {
185 | /* Check Speed mode parameters */
186 | assert_param(IS_GPIO_SPEED(GPIO_InitStruct->GPIO_Speed));
187 |
188 | /* Speed mode configuration */
189 | GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (pinpos * 2));
190 | GPIOx->OSPEEDR |= ((uint32_t)(GPIO_InitStruct->GPIO_Speed) << (pinpos * 2));
191 |
192 | /* Check Output mode parameters */
193 | assert_param(IS_GPIO_OTYPE(GPIO_InitStruct->GPIO_OType));
194 |
195 | /* Output mode configuration */
196 | GPIOx->OTYPER &= ~((GPIO_OTYPER_OT_0) << ((uint16_t)pinpos));
197 | GPIOx->OTYPER |= (uint16_t)(((uint16_t)GPIO_InitStruct->GPIO_OType) << ((uint16_t)pinpos));
198 | }
199 |
200 | GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (pinpos * 2));
201 |
202 | GPIOx->MODER |= (((uint32_t)GPIO_InitStruct->GPIO_Mode) << (pinpos * 2));
203 |
204 | /* Pull-up Pull down resistor configuration */
205 | GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)pinpos * 2));
206 | GPIOx->PUPDR |= (((uint32_t)GPIO_InitStruct->GPIO_PuPd) << (pinpos * 2));
207 | }
208 | }
209 | }
210 |
211 | /**
212 | * @brief Fills each GPIO_InitStruct member with its default value.
213 | * @param GPIO_InitStruct: pointer to a GPIO_InitTypeDef structure which will
214 | * be initialized.
215 | * @retval None
216 | */
217 | void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct)
218 | {
219 | /* Reset GPIO init structure parameters values */
220 | GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All;
221 | GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN;
222 | GPIO_InitStruct->GPIO_Speed = GPIO_Speed_Level_2;
223 | GPIO_InitStruct->GPIO_OType = GPIO_OType_PP;
224 | GPIO_InitStruct->GPIO_PuPd = GPIO_PuPd_NOPULL;
225 | }
226 |
227 | /**
228 | * @brief Locks GPIO Pins configuration registers.
229 | * @note The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR,
230 | * GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
231 | * @note The configuration of the locked GPIO pins can no longer be modified
232 | * until the next device reset.
233 | * @param GPIOx: where x can be (A or B) to select the GPIO peripheral.
234 | * @param GPIO_Pin: specifies the port bit to be written.
235 | * This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
236 | * @retval None
237 | */
238 | void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
239 | {
240 | __IO uint32_t tmp = 0x00010000;
241 |
242 | /* Check the parameters */
243 | assert_param(IS_GPIO_LIST_PERIPH(GPIOx));
244 | assert_param(IS_GPIO_PIN(GPIO_Pin));
245 |
246 | tmp |= GPIO_Pin;
247 | /* Set LCKK bit */
248 | GPIOx->LCKR = tmp;
249 | /* Reset LCKK bit */
250 | GPIOx->LCKR = GPIO_Pin;
251 | /* Set LCKK bit */
252 | GPIOx->LCKR = tmp;
253 | /* Read LCKK bit */
254 | tmp = GPIOx->LCKR;
255 | /* Read LCKK bit */
256 | tmp = GPIOx->LCKR;
257 | }
258 |
259 | /**
260 | * @}
261 | */
262 |
263 | /** @defgroup GPIO_Group2 GPIO Read and Write
264 | * @brief GPIO Read and Write
265 | *
266 | @verbatim
267 | ===============================================================================
268 | ##### GPIO Read and Write #####
269 | ===============================================================================
270 |
271 | @endverbatim
272 | * @{
273 | */
274 |
275 | /**
276 | * @brief Reads the specified input port pin.
277 | * @param GPIOx: where x can be (A, B, C, D or F) to select the GPIO peripheral.
278 | * @param GPIO_Pin: specifies the port bit to read.
279 | * @note This parameter can be GPIO_Pin_x where x can be:(0..15) for GPIOA,
280 | * GPIOB or GPIOC,(0..2) for GPIOD and(0..3) for GPIOF.
281 | * @retval The input port pin value.
282 | */
283 | uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
284 | {
285 | uint8_t bitstatus = 0x00;
286 |
287 | /* Check the parameters */
288 | assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
289 | assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
290 |
291 | if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)Bit_RESET)
292 | {
293 | bitstatus = (uint8_t)Bit_SET;
294 | }
295 | else
296 | {
297 | bitstatus = (uint8_t)Bit_RESET;
298 | }
299 | return bitstatus;
300 | }
301 |
302 | /**
303 | * @brief Reads the specified input port pin.
304 | * @param GPIOx: where x can be (A, B, C, D or F) to select the GPIO peripheral.
305 | * @retval The input port pin value.
306 | */
307 | uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx)
308 | {
309 | /* Check the parameters */
310 | assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
311 |
312 | return ((uint16_t)GPIOx->IDR);
313 | }
314 |
315 | /**
316 | * @brief Reads the specified output data port bit.
317 | * @param GPIOx: where x can be (A, B, C, D or F) to select the GPIO peripheral.
318 | * @param GPIO_Pin: Specifies the port bit to read.
319 | * @note This parameter can be GPIO_Pin_x where x can be:(0..15) for GPIOA,
320 | * GPIOB or GPIOC,(0..2) for GPIOD and(0..3) for GPIOF.
321 | * @retval The output port pin value.
322 | */
323 | uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
324 | {
325 | uint8_t bitstatus = 0x00;
326 |
327 | /* Check the parameters */
328 | assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
329 | assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
330 |
331 | if ((GPIOx->ODR & GPIO_Pin) != (uint32_t)Bit_RESET)
332 | {
333 | bitstatus = (uint8_t)Bit_SET;
334 | }
335 | else
336 | {
337 | bitstatus = (uint8_t)Bit_RESET;
338 | }
339 | return bitstatus;
340 | }
341 |
342 | /**
343 | * @brief Reads the specified GPIO output data port.
344 | * @param GPIOx: where x can be (A, B, C, D or F) to select the GPIO peripheral.
345 | * @retval GPIO output data port value.
346 | */
347 | uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)
348 | {
349 | /* Check the parameters */
350 | assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
351 |
352 | return ((uint16_t)GPIOx->ODR);
353 | }
354 |
355 | /**
356 | * @brief Sets the selected data port bits.
357 | * @param GPIOx: where x can be (A, B, C, D or F) to select the GPIO peripheral.
358 | * @param GPIO_Pin: specifies the port bits to be written.
359 | * @note This parameter can be GPIO_Pin_x where x can be:(0..15) for GPIOA,
360 | * GPIOB or GPIOC,(0..2) for GPIOD and(0..3) for GPIOF.
361 | * @retval None
362 | */
363 | void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
364 | {
365 | /* Check the parameters */
366 | assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
367 | assert_param(IS_GPIO_PIN(GPIO_Pin));
368 |
369 | GPIOx->BSRR = GPIO_Pin;
370 | }
371 |
372 | /**
373 | * @brief Clears the selected data port bits.
374 | * @param GPIOx: where x can be (A, B, C, D or F) to select the GPIO peripheral.
375 | * @param GPIO_Pin: specifies the port bits to be written.
376 | * @note This parameter can be GPIO_Pin_x where x can be: (0..15) for GPIOA,
377 | * GPIOB or GPIOC,(0..2) for GPIOD and(0..3) for GPIOF.
378 | * @retval None
379 | */
380 | void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
381 | {
382 | /* Check the parameters */
383 | assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
384 | assert_param(IS_GPIO_PIN(GPIO_Pin));
385 |
386 | GPIOx->BRR = GPIO_Pin;
387 | }
388 |
389 | /**
390 | * @brief Sets or clears the selected data port bit.
391 | * @param GPIOx: where x can be (A, B, C, D or F) to select the GPIO peripheral.
392 | * @param GPIO_Pin: specifies the port bit to be written.
393 | * @param BitVal: specifies the value to be written to the selected bit.
394 | * This parameter can be one of the BitAction enumeration values:
395 | * @arg Bit_RESET: to clear the port pin
396 | * @arg Bit_SET: to set the port pin
397 | * @note The GPIO_Pin parameter can be GPIO_Pin_x where x can be: (0..15) for GPIOA,
398 | * GPIOB or GPIOC,(0..2) for GPIOD and(0..3) for GPIOF.
399 | * @retval None
400 | */
401 | void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
402 | {
403 | /* Check the parameters */
404 | assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
405 | assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
406 | assert_param(IS_GPIO_BIT_ACTION(BitVal));
407 |
408 | if (BitVal != Bit_RESET)
409 | {
410 | GPIOx->BSRR = GPIO_Pin;
411 | }
412 | else
413 | {
414 | GPIOx->BRR = GPIO_Pin ;
415 | }
416 | }
417 |
418 | /**
419 | * @brief Writes data to the specified GPIO data port.
420 | * @param GPIOx: where x can be (A, B, C, D or F) to select the GPIO peripheral.
421 | * @param PortVal: specifies the value to be written to the port output data register.
422 | * @retval None
423 | */
424 | void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal)
425 | {
426 | /* Check the parameters */
427 | assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
428 |
429 | GPIOx->ODR = PortVal;
430 | }
431 |
432 | /**
433 | * @}
434 | */
435 |
436 | /** @defgroup GPIO_Group3 GPIO Alternate functions configuration functions
437 | * @brief GPIO Alternate functions configuration functions
438 | *
439 | @verbatim
440 | ===============================================================================
441 | ##### GPIO Alternate functions configuration functions #####
442 | ===============================================================================
443 |
444 | @endverbatim
445 | * @{
446 | */
447 |
448 | /**
449 | * @brief Writes data to the specified GPIO data port.
450 | * @param GPIOx: where x can be (A or B) to select the GPIO peripheral.
451 | * @param GPIO_PinSource: specifies the pin for the Alternate function.
452 | * This parameter can be GPIO_PinSourcex where x can be (0..15).
453 | * @param GPIO_AF: selects the pin to used as Alternate function.
454 | * This parameter can be one of the following value:
455 | * @arg GPIO_AF_0: WKUP, EVENTOUT, TIM15, SPI1, TIM17,MCO, SWDAT, SWCLK, TIM14,
456 | * USART1, CEC, IR_OUT, SPI2
457 | * @arg GPIO_AF_1: USART2, CEC, Tim3, USART1, IR_OUT,EVENTOUT, I2C1, I2C2, TIM15
458 | * @arg GPIO_AF_2: TIM2, TIM1, EVENTOUT, TIM16, TIM17
459 | * @arg GPIO_AF_3: TS, I2C1, TIM15, EVENTOUT
460 | * @arg GPIO_AF_4: TIM14, I2C1 (only for STM32F0XX_LD and STM32F030X6 devices)
461 | * @arg GPIO_AF_5: TIM16, TIM17
462 | * @arg GPIO_AF_6: EVENTOUT
463 | * @arg GPIO_AF_7: COMP1 OUT, COMP2 OUT
464 | * @note The pin should already been configured in Alternate Function mode(AF)
465 | * using GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
466 | * @note Refer to the Alternate function mapping table in the device datasheet
467 | * for the detailed mapping of the system and peripherals'alternate
468 | * function I/O pins.
469 | * @retval None
470 | */
471 | void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
472 | {
473 | uint32_t temp = 0x00;
474 | uint32_t temp_2 = 0x00;
475 |
476 | /* Check the parameters */
477 | assert_param(IS_GPIO_LIST_PERIPH(GPIOx));
478 | assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
479 | assert_param(IS_GPIO_AF(GPIO_AF));
480 |
481 | temp = ((uint32_t)(GPIO_AF) << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
482 | GPIOx->AFR[GPIO_PinSource >> 0x03] &= ~((uint32_t)0xF << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
483 | temp_2 = GPIOx->AFR[GPIO_PinSource >> 0x03] | temp;
484 | GPIOx->AFR[GPIO_PinSource >> 0x03] = temp_2;
485 | }
486 |
487 | /**
488 | * @}
489 | */
490 |
491 | /**
492 | * @}
493 | */
494 |
495 | /**
496 | * @}
497 | */
498 |
499 | /**
500 | * @}
501 | */
502 |
503 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
504 |
--------------------------------------------------------------------------------
/stm32_lib/src/stm32f0xx_misc.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_misc.c
4 | * @author MCD Application Team
5 | * @version V1.2.0
6 | * @date 01-August-2013
7 | * @brief This file provides all the miscellaneous firmware functions (add-on
8 | * to CMSIS functions).
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2013 STMicroelectronics
13 | *
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 | * You may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at:
17 | *
18 | * http://www.st.com/software_license_agreement_liberty_v2
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | *
26 | ******************************************************************************
27 | */
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include "stm32f0xx_misc.h"
31 |
32 | /** @addtogroup STM32F0xx_StdPeriph_Driver
33 | * @{
34 | */
35 |
36 | /** @defgroup MISC
37 | * @brief MISC driver modules
38 | * @{
39 | */
40 |
41 | /* Private typedef -----------------------------------------------------------*/
42 | /* Private define ------------------------------------------------------------*/
43 | /* Private macro -------------------------------------------------------------*/
44 | /* Private variables ---------------------------------------------------------*/
45 | /* Private function prototypes -----------------------------------------------*/
46 | /* Private functions ---------------------------------------------------------*/
47 |
48 | /** @defgroup MISC_Private_Functions
49 | * @{
50 | */
51 | /**
52 | *
53 | @verbatim
54 | *******************************************************************************
55 | ##### Interrupts configuration functions #####
56 | *******************************************************************************
57 | [..] This section provide functions allowing to configure the NVIC interrupts
58 | (IRQ). The Cortex-M0 exceptions are managed by CMSIS functions.
59 | (#) Enable and Configure the priority of the selected IRQ Channels.
60 | The priority can be 0..3.
61 |
62 | -@- Lower priority values gives higher priority.
63 | -@- Priority Order:
64 | (#@) Lowest priority.
65 | (#@) Lowest hardware priority (IRQn position).
66 |
67 | @endverbatim
68 | */
69 |
70 | /**
71 | * @brief Initializes the NVIC peripheral according to the specified
72 | * parameters in the NVIC_InitStruct.
73 | * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains
74 | * the configuration information for the specified NVIC peripheral.
75 | * @retval None
76 | */
77 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)
78 | {
79 | uint32_t tmppriority = 0x00;
80 |
81 | /* Check the parameters */
82 | assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd));
83 | assert_param(IS_NVIC_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPriority));
84 |
85 | if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE)
86 | {
87 | /* Compute the Corresponding IRQ Priority --------------------------------*/
88 | tmppriority = NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel >> 0x02];
89 | tmppriority &= (uint32_t)(~(((uint32_t)0xFF) << ((NVIC_InitStruct->NVIC_IRQChannel & 0x03) * 8)));
90 | tmppriority |= (uint32_t)((((uint32_t)NVIC_InitStruct->NVIC_IRQChannelPriority << 6) & 0xFF) << ((NVIC_InitStruct->NVIC_IRQChannel & 0x03) * 8));
91 |
92 | NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel >> 0x02] = tmppriority;
93 |
94 | /* Enable the Selected IRQ Channels --------------------------------------*/
95 | NVIC->ISER[0] = (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
96 | }
97 | else
98 | {
99 | /* Disable the Selected IRQ Channels -------------------------------------*/
100 | NVIC->ICER[0] = (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
101 | }
102 | }
103 |
104 | /**
105 | * @brief Selects the condition for the system to enter low power mode.
106 | * @param LowPowerMode: Specifies the new mode for the system to enter low power mode.
107 | * This parameter can be one of the following values:
108 | * @arg NVIC_LP_SEVONPEND: Low Power SEV on Pend.
109 | * @arg NVIC_LP_SLEEPDEEP: Low Power DEEPSLEEP request.
110 | * @arg NVIC_LP_SLEEPONEXIT: Low Power Sleep on Exit.
111 | * @param NewState: new state of LP condition.
112 | * This parameter can be: ENABLE or DISABLE.
113 | * @retval None
114 | */
115 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
116 | {
117 | /* Check the parameters */
118 | assert_param(IS_NVIC_LP(LowPowerMode));
119 |
120 | assert_param(IS_FUNCTIONAL_STATE(NewState));
121 |
122 | if (NewState != DISABLE)
123 | {
124 | SCB->SCR |= LowPowerMode;
125 | }
126 | else
127 | {
128 | SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode);
129 | }
130 | }
131 |
132 | /**
133 | * @brief Configures the SysTick clock source.
134 | * @param SysTick_CLKSource: specifies the SysTick clock source.
135 | * This parameter can be one of the following values:
136 | * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source.
137 | * @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source.
138 | * @retval None
139 | */
140 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
141 | {
142 | /* Check the parameters */
143 | assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource));
144 |
145 | if (SysTick_CLKSource == SysTick_CLKSource_HCLK)
146 | {
147 | SysTick->CTRL |= SysTick_CLKSource_HCLK;
148 | }
149 | else
150 | {
151 | SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8;
152 | }
153 | }
154 |
155 | /**
156 | * @}
157 | */
158 |
159 | /**
160 | * @}
161 | */
162 |
163 | /**
164 | * @}
165 | */
166 |
167 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
168 |
--------------------------------------------------------------------------------
/stm32_lib/src/stm32f0xx_syscfg.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_syscfg.c
4 | * @author MCD Application Team
5 | * @version V1.2.0
6 | * @date 01-August-2013
7 | * @brief This file provides firmware functions to manage the following
8 | * functionalities of the SYSCFG peripheral:
9 | * + Remapping the memory mapped at 0x00000000
10 | * + Remapping the DMA channels
11 | * + Enabling I2C fast mode plus driving capability for I2C pins
12 | * + Configuring the EXTI lines connection to the GPIO port
13 | * + Configuring the CFGR2 features (Connecting some internal signal
14 | * to the break input of TIM1)
15 | *
16 | * @verbatim
17 | ===============================================================================
18 | ##### How to use this driver #####
19 | ===============================================================================
20 | [..]
21 | The SYSCFG registers can be accessed only when the SYSCFG
22 | interface APB clock is enabled.
23 | To enable SYSCFG APB clock use:
24 | RCC_APBPeriphClockCmd(RCC_APBPeriph_SYSCFG, ENABLE).
25 | * @endverbatim
26 | *
27 | ******************************************************************************
28 | * @attention
29 | *
30 | * © COPYRIGHT 2013 STMicroelectronics
31 | *
32 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
33 | * You may not use this file except in compliance with the License.
34 | * You may obtain a copy of the License at:
35 | *
36 | * http://www.st.com/software_license_agreement_liberty_v2
37 | *
38 | * Unless required by applicable law or agreed to in writing, software
39 | * distributed under the License is distributed on an "AS IS" BASIS,
40 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41 | * See the License for the specific language governing permissions and
42 | * limitations under the License.
43 | *
44 | ******************************************************************************
45 | */
46 |
47 | /* Includes ------------------------------------------------------------------*/
48 | #include "stm32f0xx_syscfg.h"
49 |
50 | /** @addtogroup STM32F0xx_StdPeriph_Driver
51 | * @{
52 | */
53 |
54 | /** @defgroup SYSCFG
55 | * @brief SYSCFG driver modules
56 | * @{
57 | */
58 |
59 | /* Private typedef -----------------------------------------------------------*/
60 | /* Private define ------------------------------------------------------------*/
61 | /* Private macro -------------------------------------------------------------*/
62 | /* Private variables ---------------------------------------------------------*/
63 | /* Private function prototypes -----------------------------------------------*/
64 | /* Private functions ---------------------------------------------------------*/
65 |
66 | /** @defgroup SYSCFG_Private_Functions
67 | * @{
68 | */
69 |
70 | /** @defgroup SYSCFG_Group1 SYSCFG Initialization and Configuration functions
71 | * @brief SYSCFG Initialization and Configuration functions
72 | *
73 | @verbatim
74 | ===============================================================================
75 | ##### SYSCFG Initialization and Configuration functions #####
76 | ===============================================================================
77 |
78 | @endverbatim
79 | * @{
80 | */
81 |
82 | /**
83 | * @brief Deinitializes the SYSCFG registers to their default reset values.
84 | * @param None
85 | * @retval None
86 | * @note MEM_MODE bits are not affected by APB reset.
87 | * @note MEM_MODE bits took the value from the user option bytes.
88 | * @note CFGR2 register is not affected by APB reset.
89 | * @note CLABBB configuration bits are locked when set.
90 | * @note To unlock the configuration, perform a system reset.
91 | */
92 | void SYSCFG_DeInit(void)
93 | {
94 | /* Set SYSCFG_CFGR1 register to reset value without affecting MEM_MODE bits */
95 | SYSCFG->CFGR1 &= SYSCFG_CFGR1_MEM_MODE;
96 | /* Set EXTICRx registers to reset value */
97 | SYSCFG->EXTICR[0] = 0;
98 | SYSCFG->EXTICR[1] = 0;
99 | SYSCFG->EXTICR[2] = 0;
100 | SYSCFG->EXTICR[3] = 0;
101 | /* Set CFGR2 register to reset value: clear SRAM parity error flag */
102 | SYSCFG->CFGR2 |= (uint32_t) SYSCFG_CFGR2_SRAM_PE;
103 | }
104 |
105 | /**
106 | * @brief Configures the memory mapping at address 0x00000000.
107 | * @param SYSCFG_MemoryRemap: selects the memory remapping.
108 | * This parameter can be one of the following values:
109 | * @arg SYSCFG_MemoryRemap_Flash: Main Flash memory mapped at 0x00000000
110 | * @arg SYSCFG_MemoryRemap_SystemMemory: System Flash memory mapped at 0x00000000
111 | * @arg SYSCFG_MemoryRemap_SRAM: Embedded SRAM mapped at 0x00000000
112 | * @retval None
113 | */
114 | void SYSCFG_MemoryRemapConfig(uint32_t SYSCFG_MemoryRemap)
115 | {
116 | uint32_t tmpctrl = 0;
117 |
118 | /* Check the parameter */
119 | assert_param(IS_SYSCFG_MEMORY_REMAP(SYSCFG_MemoryRemap));
120 |
121 | /* Get CFGR1 register value */
122 | tmpctrl = SYSCFG->CFGR1;
123 |
124 | /* Clear MEM_MODE bits */
125 | tmpctrl &= (uint32_t) (~SYSCFG_CFGR1_MEM_MODE);
126 |
127 | /* Set the new MEM_MODE bits value */
128 | tmpctrl |= (uint32_t) SYSCFG_MemoryRemap;
129 |
130 | /* Set CFGR1 register with the new memory remap configuration */
131 | SYSCFG->CFGR1 = tmpctrl;
132 | }
133 |
134 | /**
135 | * @brief Configure the DMA channels remapping.
136 | * @param SYSCFG_DMARemap: selects the DMA channels remap.
137 | * This parameter can be one of the following values:
138 | * @arg SYSCFG_DMARemap_TIM17: Remap TIM17 DMA requests from channel1 to channel2
139 | * @arg SYSCFG_DMARemap_TIM16: Remap TIM16 DMA requests from channel3 to channel4
140 | * @arg SYSCFG_DMARemap_USART1Rx: Remap USART1 Rx DMA requests from channel3 to channel5
141 | * @arg SYSCFG_DMARemap_USART1Tx: Remap USART1 Tx DMA requests from channel2 to channel4
142 | * @arg SYSCFG_DMARemap_ADC1: Remap ADC1 DMA requests from channel1 to channel2
143 | * @param NewState: new state of the DMA channel remapping.
144 | * This parameter can be: ENABLE or DISABLE.
145 | * @note When enabled, DMA channel of the selected peripheral is remapped
146 | * @note When disabled, Default DMA channel is mapped to the selected peripheral
147 | * @note By default TIM17 DMA requests is mapped to channel 1,
148 | * use SYSCFG_DMAChannelRemapConfig(SYSCFG_DMARemap_TIM17, Enable) to remap
149 | * TIM17 DMA requests to channel 2 and use
150 | * SYSCFG_DMAChannelRemapConfig(SYSCFG_DMARemap_TIM17, Disable) to map
151 | * TIM17 DMA requests to channel 1 (default mapping)
152 | * @retval None
153 | */
154 | void SYSCFG_DMAChannelRemapConfig(uint32_t SYSCFG_DMARemap, FunctionalState NewState)
155 | {
156 | /* Check the parameters */
157 | assert_param(IS_SYSCFG_DMA_REMAP(SYSCFG_DMARemap));
158 | assert_param(IS_FUNCTIONAL_STATE(NewState));
159 |
160 | if (NewState != DISABLE)
161 | {
162 | /* Remap the DMA channel */
163 | SYSCFG->CFGR1 |= (uint32_t)SYSCFG_DMARemap;
164 | }
165 | else
166 | {
167 | /* use the default DMA channel mapping */
168 | SYSCFG->CFGR1 &= (uint32_t)(~SYSCFG_DMARemap);
169 | }
170 | }
171 |
172 | /**
173 | * @brief Configure the I2C fast mode plus driving capability.
174 | * @param SYSCFG_I2CFastModePlus: selects the pin.
175 | * This parameter can be one of the following values:
176 | * @arg SYSCFG_I2CFastModePlus_PB6: Configure fast mode plus driving capability for PB6
177 | * @arg SYSCFG_I2CFastModePlus_PB7: Configure fast mode plus driving capability for PB7
178 | * @arg SYSCFG_I2CFastModePlus_PB8: Configure fast mode plus driving capability for PB8
179 | * @arg SYSCFG_I2CFastModePlus_PB9: Configure fast mode plus driving capability for PB9
180 | * @arg SYSCFG_I2CFastModePlus_PA9: Configure fast mode plus driving capability for PA9 (only for STM32F0XX_LD and STM32F030X6 devices)
181 | * @arg SYSCFG_I2CFastModePlus_PA10: Configure fast mode plus driving capability for PA10 (only for STM32F0XX_LD and STM32F030X6 devices)
182 | * @arg SYSCFG_I2CFastModePlus_I2C1: Configure fast mode plus driving capability for PB10, PB11, PF6 and PF7(only for STM32F0XX_LD and STM32F030X6 devices)
183 | * @param NewState: new state of the DMA channel remapping.
184 | * This parameter can be: ENABLE or DISABLE.
185 | * @note ENABLE: Enable fast mode plus driving capability for selected pin
186 | * @note DISABLE: Disable fast mode plus driving capability for selected pin
187 | * @retval None
188 | */
189 | void SYSCFG_I2CFastModePlusConfig(uint32_t SYSCFG_I2CFastModePlus, FunctionalState NewState)
190 | {
191 | /* Check the parameters */
192 | assert_param(IS_SYSCFG_I2C_FMP(SYSCFG_I2CFastModePlus));
193 | assert_param(IS_FUNCTIONAL_STATE(NewState));
194 |
195 | if (NewState != DISABLE)
196 | {
197 | /* Enable fast mode plus driving capability for selected pin */
198 | SYSCFG->CFGR1 |= (uint32_t)SYSCFG_I2CFastModePlus;
199 | }
200 | else
201 | {
202 | /* Disable fast mode plus driving capability for selected pin */
203 | SYSCFG->CFGR1 &= (uint32_t)(~SYSCFG_I2CFastModePlus);
204 | }
205 | }
206 |
207 | /**
208 | * @brief Selects the GPIO pin used as EXTI Line.
209 | * @param EXTI_PortSourceGPIOx: selects the GPIO port to be used as source
210 | * for EXTI lines where x can be (A, B, C, D or F).
211 | * @param EXTI_PinSourcex: specifies the EXTI line to be configured.
212 | * This parameter can be EXTI_PinSourcex where x can be (0..15)
213 | * @retval None
214 | */
215 | void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex)
216 | {
217 | uint32_t tmp = 0x00;
218 |
219 | /* Check the parameters */
220 | assert_param(IS_EXTI_PORT_SOURCE(EXTI_PortSourceGPIOx));
221 | assert_param(IS_EXTI_PIN_SOURCE(EXTI_PinSourcex));
222 |
223 | tmp = ((uint32_t)0x0F) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03));
224 | SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] &= ~tmp;
225 | SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] |= (((uint32_t)EXTI_PortSourceGPIOx) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03)));
226 | }
227 |
228 | /**
229 | * @brief Connect the selected parameter to the break input of TIM1.
230 | * @note The selected configuration is locked and can be unlocked by system reset
231 | * @param SYSCFG_Break: selects the configuration to be connected to break
232 | * input of TIM1
233 | * This parameter can be any combination of the following values:
234 | * @arg SYSCFG_Break_PVD: Connects the PVD event to the Break Input of TIM1.
235 | * @arg SYSCFG_Break_SRAMParity: Connects the SRAM_PARITY error signal to the Break Input of TIM1 .
236 | * @arg SYSCFG_Break_Lockup: Connects Lockup output of CortexM0 to the break input of TIM1.
237 | * @retval None
238 | */
239 | void SYSCFG_BreakConfig(uint32_t SYSCFG_Break)
240 | {
241 | /* Check the parameter */
242 | assert_param(IS_SYSCFG_LOCK_CONFIG(SYSCFG_Break));
243 |
244 | SYSCFG->CFGR2 |= (uint32_t) SYSCFG_Break;
245 | }
246 |
247 | /**
248 | * @brief Checks whether the specified SYSCFG flag is set or not.
249 | * @param SYSCFG_Flag: specifies the SYSCFG flag to check.
250 | * This parameter can be one of the following values:
251 | * @arg SYSCFG_FLAG_PE: SRAM parity error flag.
252 | * @retval The new state of SYSCFG_Flag (SET or RESET).
253 | */
254 | FlagStatus SYSCFG_GetFlagStatus(uint32_t SYSCFG_Flag)
255 | {
256 | FlagStatus bitstatus = RESET;
257 |
258 | /* Check the parameter */
259 | assert_param(IS_SYSCFG_FLAG(SYSCFG_Flag));
260 |
261 | /* Check the status of the specified SPI flag */
262 | if ((SYSCFG->CFGR2 & SYSCFG_CFGR2_SRAM_PE) != (uint32_t)RESET)
263 | {
264 | /* SYSCFG_Flag is set */
265 | bitstatus = SET;
266 | }
267 | else
268 | {
269 | /* SYSCFG_Flag is reset */
270 | bitstatus = RESET;
271 | }
272 | /* Return the SYSCFG_Flag status */
273 | return bitstatus;
274 | }
275 |
276 | /**
277 | * @brief Clear the selected SYSCFG flag.
278 | * @param SYSCFG_Flag: selects the flag to be cleared.
279 | * This parameter can be any combination of the following values:
280 | * @arg SYSCFG_FLAG_PE: SRAM parity error flag.
281 | * @retval None
282 | */
283 | void SYSCFG_ClearFlag(uint32_t SYSCFG_Flag)
284 | {
285 | /* Check the parameter */
286 | assert_param(IS_SYSCFG_FLAG(SYSCFG_Flag));
287 |
288 | SYSCFG->CFGR2 |= (uint32_t) SYSCFG_Flag;
289 | }
290 |
291 | /**
292 | * @}
293 | */
294 |
295 | /**
296 | * @}
297 | */
298 |
299 | /**
300 | * @}
301 | */
302 |
303 | /**
304 | * @}
305 | */
306 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
307 |
--------------------------------------------------------------------------------